akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long ll;

template <typename T> inline bool chkmin(T &x,T y) { return y < x ? x = y,1 : 0; }
template <typename T> inline bool chkmax(T &x,T y) { return x < y ? x = y,1 : 0; }

const int INF = 0x3f3f3f3f;
const int N = 3e3 + 10,mod = 998244353;

int fac[N],inv[N];

inline int read() {
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-')ch = getchar();
	if(ch == '-')flag = -1,ch = getchar();
	while(isdigit(ch))x = (x << 3) + (x << 1) + (ch - '0'),ch = getchar();
	return x * flag;
}

inline int fpm(int a,int b) {
	int res = 1;
	while(b) {
		if(b & 1) res = 1ll * res * a % mod;
		a = 1ll * a * a % mod,b /= 2;
	}
	return res;
}

inline void init(int n) {
	fac[0] = 1;
	For(i,1,n) fac[i] = 1ll * fac[i - 1] * i % mod;
	inv[n] = fpm(fac[n],mod - 2);
	Fordown(i,n,1) inv[i - 1] = 1ll * inv[i] * i % mod;
}

inline int C(int n,int m) {
	if(n < 0 || m < 0 || n < m) return 0;
	return 1ll * fac[n] * inv[m] % mod * inv[n - m] % mod;
}

int main() {

	int n = read(),v = read();
	init(n);
	if(v & 1) {
		int ans = fpm(2,n);
		For(i,0,n) {
			int sum = 0;
			For(j,i,min(i + i,v - 1)) if(j & 1) sum = (sum + C(i,j - i)) % mod;
			For(j,i,i + i - 1) if(!(j & 1)) {
				int cnt = max(0,(j - v + 2) / 2);
				sum = (sum + C(i - cnt * 2,j - i - cnt * 2)) % mod;
			}
			ans = (ans + 1ll * C(n,i) * sum) % mod;
		}
		printf("%d\n",ans);
	} else {
		int ans = 0;
		For(i,0,n) {
			int sum = 0;
			For(j,i,min(i + i,v - 1)) if(!(j & 1)) sum = (sum + C(i,j - i)) % mod;
			For(j,i,i + i - 1) if(j & 1) {
				int cnt = max(0,(j - v + 1) / 2);
				sum = (sum + C(i - cnt * 2,j - i - cnt * 2)) % mod;
			}
			ans = (ans + 1ll * C(n,i) * sum) % mod;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int a[100005],cnt[100005];
int main(int argc, char** argv) {
	int n;
	cin >> n;
	for(int i=1;i<=n;i++)
		cin >> a[i];
	int ans=0,mx=0,mmx=0,w=0;
	for(int i=1;i<=n;i+=2)
		++cnt[a[i]];
	for(int i=1;i<=100000;i++)
	{
		if(cnt[i]>mx) mmx=mx,mx=cnt[i],w=i;
		else if(cnt[i]>mmx) mmx=cnt[i];
	}
	memset(cnt,0,sizeof cnt);
	for(int i=2;i<=n;i+=2)
		++cnt[a[i]];
	for(int i=1;i<=100000;i++)
	{
		if(i!=w) ans=max(ans,cnt[i]+mx);
		else ans=max(ans,cnt[i]+mmx);
	}
	cout << n-ans;
	return 0;
}

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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef struct data{
	int place;
	int cost;

	bool operator<(const data &ri) const{
		return cost < ri.cost;
	}
	bool operator>(const data &ri) const{
		return cost > ri.cost;
	}
}data;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};

llong int gcd(llong int a, llong int b){
	if(a < b) swap(a, b);
	while(b){
		a %= b;
		swap(a, b);
	}

	return a;
}

llong int lcm(llong int a, llong int b){
	return a / gcd(a, b) * b;
}
int main(){
	int q,w;
	string s, t;
	cin >> q >> w;
	cin >> s >> t;
	if(q<w){
		swap(s,t);
		swap(q,w);
	}
	llong int l = lcm(q,w);
	llong int g = gcd(q,w);
	llong int sg = q/g, tg = w/g;
	llong int si = 0, ti = 0;
	for(int i = 0; i < g; i++){
		// cout << si << s[si] << ti << t[ti] << endl;
		if(s[si] != t[ti]){
			cout << -1 << endl;
			return 0;
		}
		si += sg, ti += tg;
	}
	cout << l << endl;

	return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
using namespace std;

int main(void){

    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        a[i] = x;
    }

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

    if(a[n/2-1] == a[n/2]){
        cout<<"0"<<endl;
        return 0;
    }else{
        cout<<a[n/2]-a[n/2-1]<<endl;
    }
    return 0;

}

Measured memory_bytes: 640
import java.util.*;

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

        String Sa = sc.next();
        int la = Sa.length();
        int a = 0;
        String Sb = sc.next();
        int lb = Sb.length();
        int b = 0;
        String Sc = sc.next();
        int c = 0;
        int lc = Sc.length();
        String x = "A";
        String y = "abc";

        for(int i=0; i<la+lb+lc+3; i++){
            if(x.equals("A")){
                if(a<la){
                    if(Sa.charAt(a)==y.charAt(0)){
                        x = "A";
                    }
                    else if(Sa.charAt(a)==y.charAt(1)){
                        x = "B";
                    }
                    else if(Sa.charAt(a)==y.charAt(2)){
                        x = "C";
                    }
                }
                a += 1;
                if(a==la+1){
                    x = "";
                }
            }
            else if(x.equals("B")){
                if(b<lb){
                    if(Sb.charAt(b)==y.charAt(0)){
                        x = "A";
                    }
                    else if(Sb.charAt(b)==y.charAt(1)){
                        x = "B";
                    }
                    else if(Sb.charAt(b)==y.charAt(2)){
                        x = "C";
                    }
                }
                b += 1;
                if(b==lb+1){
                    x = "";
                }
            }
            else if(x.equals("C")){
                if(c<lc){
                    if(Sc.charAt(c)==y.charAt(0)){
                        x = "A";
                    }
                    else if(Sc.charAt(c)==y.charAt(1)){
                        x = "B";
                    }
                    else if(Sc.charAt(c)==y.charAt(2)){
                        x = "C";
                    }
                }
                c += 1;
                if(c==lc+1){
                    x ="";
                }
            }

            if(a==la+1){
                System.out.println("A");
                break;
            }
            else if(b==lb+1){
                System.out.println("B");
                break;
            }
            else if(c==lc+1){
                System.out.println("C");
                break;
            }
        }
    }
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int x[n];
    for(int i=0;i<n;i++){
        cin >> x[i];
    }
    int ans=10000000;
    for(int i=1;i<=100;i++){
        int sum=0;
        for(int j=0;j<n;j++){
            sum+=(x[j]-i)*(x[j]-i);
        }
        ans=min(sum,ans);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int n; cin >> n;
  double v[n],c;
  for (int i=0;i<n;i++)cin >> v[i];
  sort(v,v+n);
  c = v[0];
  for (int i=1;i<n;i++)c = (c + v[i])/2.0;
  cout << c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define pb push_back
#define eb emplace_back
#define rep(i,a,b) for(auto i=(a);i!=(b);++i)
#define all(v) (v).begin(), (v).end()
#define rs resize
#define x first
#define y second
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
 
const ll INF = 2147483647;
const ll LLINF = 9223372036854775807LL;
 
// lambda-expression: [] (args) -> retType { body }
 
ll pow10(ll n)
{
	ll r = 1;
	while (n--) r *= 10;
	return r;
}
 
void run()
{
	ll a, b;
	cin >> a >> b;
	stringstream ss;
	ss << b;
	ll N = ss.str().length();
 
	ll SUM = a * pow10(N) + b;
	double s = SUM;
	double sq = sqrt(s);
 
	ll sss = (ll) (sq + 0.5);
	cout << ((sss * sss == SUM) ? "Yes" : "No") << endl;
}
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	(cout << fixed).precision(10);
	run();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<climits>
#include<cstring>

using namespace std;

int main() {
	int h, w; cin >> h >> w;
	char a[h+1][w+1];
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> a[i][j];
		}
	}
	long long int dp[h+1][w+1];
	memset(dp, 0, sizeof(dp));
	dp[1][1] = 1;

	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (a[i][j] == '.') {
				dp[i][j] = (dp[i - 1][j] + dp[i][j - 1] + dp[i][j])%1000000007;
			}
		}
	}
	cout << dp[h][w] << endl;
}

Measured memory_bytes: 9088
#include <stdio.h>
#include <string.h>

void swap( int , int , int , int , int* );
void check( int* );
int comp( int* , int* );
int is_same( int* , int* );

int main(void){
    int dice1[100][6] = {};
    int dice2[6] = {};
    int *p1 , *p2;
    int i,j,z,loop;
    p1 = dice1[0];
    p2 = dice2;
    
    int ary_cnt = 0;
    int different = 1;
    
    scanf( "%d" , &loop );
    for( z = 0 ; z < 6 ; z++ ){ scanf( "%d" , p1 + z ); }
    
    
    for( i = 0 ; i < loop - 1 ; i++ ){//大枠
        for( z = 0 ; z < 6 ; z++ ){ scanf( "%d" , p2 + z ); }
        
        for( j = 0 ; j < ary_cnt + 1 ; j++ ){
            if( is_same( dice1[j] , dice2 ) ){
                different = 0;
                break;
            }else if( j == ary_cnt ){
                for( z = 0 ; z < 6 ; z++ ){ dice1[j+1][z] = dice2[z]; }
                ary_cnt++;
                break;
            }
        }
    }
    
    if( different ){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
}


int is_same( int *dice1 , int *dice2 ){
    int *p1 , *p2;
    int i,j;
    p1 = dice1;
    p2 = dice2;
    int ok = 0;
    
            for( i = 0 ; i < 4 ; i++ ){
                if( comp( p1 , p2 ) ){ ok = 1; break; }
                for( j = 0 ; j < 4 ; j++ ){
                    swap( 1 , 2 , 4, 3 , p1 );//スピン
                    if( comp( p1 , p2 ) ){ ok = 1; break; }
                }
                swap( 0 , 1 , 5 , 4 , p1 );//N
            } 

            for( i = 0 ; i < 4 ; i++ ){
                if( comp( p1 , p2 ) ){ ok = 1; break; }
                for( j = 0 ; j < 4 ; j++ ){
                    swap( 1 , 2 , 4, 3 , p1 );//スピン
                    if( comp( p1 , p2 ) ){ ok = 1; break; }
                }
                swap( 0 , 2 , 5 , 3 , p1 );//W
            }

        if( ok ){
            return 1;
        }else{
            return 0;
        }
}


int comp( int *dice1 , int *dice2 ){
    for( int i = 0; i < 6; i++ ){
        if( dice1[i] != dice2[i] ){
            return 0;
        }
    }
    return 1;
}


void swap( int x1, int x2 , int x3 , int x4 , int *dice ){
    int tmp;
    tmp = *( dice + x1 );
    *( dice + x1 ) = *( dice + x2 );
    *( dice + x2 ) = *( dice + x3 );
    *( dice + x3 ) = *( dice + x4 );
    *( dice + x4 ) = tmp;
    return;
};

void check(int *dice){
    for( int i = 0 ; i < 6 ; i++ ){
        printf( "%d " , dice[i] );
    }
    printf("\n");
}



Measured memory_bytes: 2112
#pragma GCC optimize(2,3,"Ofast","unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define in inline
namespace fast_io
{
	char buf[1<<12],*p1=buf,*p2=buf,sr[1<<23],z[23],nc;int CC=-1,Z=0,Bi=0,ny;
	in char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
	in ll read()
	{
		ll x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;Bi=1;if(nc<0)return nc;
		x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48),Bi++;return x*ny;
	}
	in db gf() {int a=read(),y=ny,b=(nc!='.')?0:read();return (b?a+(db)b/pow(10,Bi)*y:a);}
	in int gs(char *s) {char c,*t=s;while(c=gc(),c<=32);*s++=c;while(c=gc(),c>32)*s++=c;return s-t;}
}
using namespace fast_io;
#define pb push_back
const int N=1e6+5,p=1e9+7;
ll n,a[N],re,all,ans;
int main()
{
	n=read();
	for(ll i=1;i<=n;i++)a[i]=read();
	for(ll i=3;i<=n;i++)re^=a[i];
	all=a[1]+a[2];all-=re;if(all<0)return puts("-1"),0;
	for(ll i=42;i>=0;i--)
	{
		if(2*(1ll<<i)<=all)
		{
			if((re>>i&1))return puts("-1"),0;
			ans+=(1ll<<i);all-=2*(1ll<<i);
		}
	}
	if(all)return puts("-1"),0;
	if(ans>a[1])return puts("-1"),0;
	for(ll i=42;i>=0;i--) if((re>>i&1)&&(ans+(1ll<<i))<=a[1])ans+=(1ll<<i);
	if(ans==0)return puts("-1"),0;
	return cout<<a[1]-ans,0;
}
//Author: disangan233

Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;




int main(){
  int h,w;
  cin >> h >> w;
  char c[h][w];
  ll d[h][w];
      rep(i,h){
       rep(j,w){
        cin >> c[i][j];
         d[i][j]=inf;
       }
      }
  ll ans=-1;
  for(int sx=0;sx<h;sx++){
    for(int sy=0;sy<w;sy++){
      for(int gx=0;gx<h;gx++){
        for(int gy=0;gy<w;gy++){
          if(sx==gx && sy==gy)continue;
          if(c[sx][sy]=='#' || c[gx][gy]=='#')continue;
          rep(i,h){
       rep(j,w){
         d[i][j]=inf;
       }
      }
          
          
          
      queue<pint> que;
      int direct[5]={0,1,0,-1,0};
      d[sx][sy]=0;
      que.push({sx,sy});
      while(que.size()){
        int x=que.front().first;
        int y=que.front().second;
        que.pop();
        rep(i,4){
          int nx=x+direct[i];
          int ny=y+direct[i+1];
         if(0<=nx && nx<h && 0<=ny && ny<w && c[nx][ny]=='.' && d[nx][ny]==inf){
          d[nx][ny]=d[x][y]+1;
           que.push({nx,ny});
         }
        }
      }
//      cout << d[gx][gy] << endl;
      ans=max(ans,d[gx][gy]);
        }
      }
    }
  }
  cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int a[10];
  int i;
  int j;
  int temp = 0;
 
  for(i=0; i<10; i++){
    scanf("\n%d", &a[i]);
  }

/*********** sorting ***********/

  for(i=0; i<10; i++){
    for(j=10-1; j>i; j--){
      if(a[j]<a[j-1]){
	temp=a[j];
	a[j]=a[j-1];
	a[j-1]=temp;
      }
    }
  }

/*********** output ***********/

  printf("%d\n%d\n%d\n", a[9], a[8], a[7]);

  return 0;

}

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

int main() {
    int C1, C2, C3;
    while (cin >> C1 >> C2 >> C3) {
        int cnt = 0;
        for (int i=1; i<=9; ++i) {
            if (i == C1 || i == C2 || i == C3) continue;
            if (C1 + C2 + i <= 20) cnt ++;
        }
        if (7 < 2 * cnt) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> sunuke(N,0);

    rep(i, K) {
        int d;
        cin >> d;
        rep(j, d) {
            int a;
            cin >> a;
            sunuke[a-1]++;
        }
    }

    int ans = 0;
    rep(i, N) {
        if (sunuke[i] == 0) {
            ans++;
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3556
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt();
		int ans = 0;
		for (int i = 1; i <= n; i++) {
			String s = "" + i;
			int sum = 0;
			for (int j = 0; j < s.length(); j++) {
				sum += Integer.parseInt("" + s.charAt(j));
			}
			if (a <= sum && sum <= b) {
				ans += i;
			}
		}
		System.out.println(ans);
		sc.close();
	}

}


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

// #define mod (int) 998244353
// #define MOD (int) 1e9+7
// // Big two primes
// #define X 1001100011100001111ll
// #define all(a) a.begin(),a.end()
// #define for0(i, n) for (int i = 0; i < n; i++)
// #define for1(i, n) for (int i = 1; i <= n; i++)
// #define loop(i,a,b) for (int i = a; i < b; i++)
// #define bloop(i,a,b) for (int i = a ; i>=b;i--)
// #define tc(t) int t; cin >> t; while (t--)
// //#define int long long
// #define ll long long
// #define pb emplace_back
// #define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
// #define in(x) scanf("%d", &x)
// #define rr return 0
// #define prec(n) fixed<<setprecision(n)
// #define maxpq priority_queue<int>
// #define minpq priority_queue<int, vector<int>, greater<int> >
// #define inf (int)(1e18)
// #define ini(a, i) memset(a, i, sizeof(a))
// #define vi vector<int>
// #define fi first
// #define se second
// #define endl "\n"
// #define ii pair<int, int>
// #define vii vector<ii>
// #define sz(s) s.size()


char a[1000][1000];


int main(){
    cout<<setprecision(15);
    int n,i,j;
    cin>>n;
    double p[n];
    for(i=0;i<n;i++){
        cin>>p[i];
    }
    double dp[n+1][n+1];
    for(i=0;i<n+1;i++){
        for(j=0;j<n+1;j++)
            dp[i][j]=0;
    }
    dp[0][0]=1.0;
    dp[1][1]=p[0];
    dp[1][0]=1.0-p[0];
    for(i=2;i<n+1;i++){
        dp[i][i]=dp[i-1][i-1]*p[i-1];
        dp[i][0]=dp[i-1][0]*(1.0-p[i-1]);
    }
    for(i=2;i<n+1;i++){
        for(j=1;j<i;j++){
            dp[i][j]=(dp[i-1][j]*(1.0-p[i-1])+dp[i-1][j-1]*p[i-1]);
        }
    }
    double ans=0.0;
    for(i=n/2+1;i<=n;i++){
        ans+=(dp[n][i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 70528
def main():
    donut_num, material = map(int, input().split(" "))
    min_material = float("inf")
    sum_material = 0
    answer = 0
    for _ in range(donut_num):
        mass = int(input())
        min_material = min(min_material, mass)
        sum_material += mass
    material -= sum_material
    answer += donut_num
    answer += material // min_material
    print(answer)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> l(n);
    for(int i = 0; i < n; i++) cin >> l[i];
    sort(l.begin(), l.end());
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        for(int j = i+1; j < n; j++)
        {
            auto itr = lower_bound(l.begin(), l.end(), l[i]+l[j]);
            int dis = distance(l.begin(), itr) - j-1;
            ans += dis;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

s1 = s2 = 0
b = 0
left = []
for i in range(n):
    s2 += a[i]
    while s1 + a[b] < s2 - a[b]:
        s1 += a[b]
        s2 -= a[b]
        b += 1
    left.append(((s1, s2), (s1 + a[b], s2 - a[b])))
s1 = s2 = 0
b = n
right = []
for i in range(n-1, -1, -1):
    s1 += a[i]
    while s2 + a[b-1] < s1 - a[b-1]:
        s2 += a[b-1]
        s1 -= a[b-1]
        b -= 1
    right.append(((s1, s2), (s1 - a[b-1], s2 + a[b-1])))
right.reverse()
ans = 1001001001001001001
for p1, p2 in zip(left, right[1:]):
    for s1, s2 in p1:
        for t1, t2 in p2:
            ans = min(ans, max(s1, s2, t1, t2) - min(s1, s2, t1, t2))
print(ans)

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

int main() {
	int n, k;
	cin >> n >> k;
	
	int ans = 0;
	while (n > 1) {
		n -= k;
		ans++;
		n++;
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define DEBUG(x)           cout << '>' << #x << ':' << x << endl;
#define forn(i,n)          for(int i=0;i<(int)n;++i)
#define for1(i,n)          for(int i=1;i<=(int)n;++i)
#define forr(i,n)          for(int i=(int)n-1;i>=0;--i)
#define forre(i,a,b)       for(int i=(int)b;i>=(int)a;--i)
#define fore(i,a,b)        for(int i=(int)a;i<=(int)b;++i)
#define input(arr,n)       for(int i=0;i<n;i++)cin>>arr[i]
#define output(arr,n)      for(int i=0;i<n;i++)cout<<arr[i]<<" "
#define for_each(arr)      for(auto& it:arr)cout<<it<<" "
#define ff                 first
#define ss                 second
#define PI                 acos(-1.0)
#define all(a)             a.begin(),a.end()
#define rall(a)            a.rbegin(),a.rend()
#define Unique(a)          sort(all(a)),a.erase(unique(all(a)),a.end())
#define pb(x)              push_back(x)
#define eb(x)              emplace_back(x)
#define ppb(x)             pop_back(x)
#define pf(x)              push_front(x)
#define ppf(x)             pop_front(x)
#define in(x,y)            insert({x,y})
#define Sort(a)            sort(a.begin(),a.end())
#define mem(arr,a)         memset(arr,a,sizeof arr)
#define ins(a)             insert(a)
#define max2(a,b)          max(a,b)
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max3(b,c,d))
#define min2(a,b)          min(a,b)
#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min3(b,c,d))
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<char> vc;
typedef vector<double> vd;
/*inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void Set(int & n, int b) { n |= two(b); }
inline void Reset(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }*/
/*int fx1[]={+1,-1,+0,+0};
int fy1[]={+0,+0,+1,-1};
int fx2={+0,+0,+1,-1,-1,+1,-1,+1};
int fy2={-1,+1,+0,+0,+1,+1,-1,-1};
*/

ll a,b,c,n,ans,cn1,cn2,cn3,t;
string s,s1,s2;


int main()
{
    FIO;
    //#ifndef ONLINE_JUDGE
   // freopen("input.txt","r",stdin);
   // freopen("output.txt","w",stdout);
  //  #endif
    cin>>a>>b;
    vector<int>v(b);
    for(int i=0;i<b;i++)cin>>v[i];
    for(int i=0;i<b;i++)ans+=v[i];
    if(ans>=a)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;



    #ifdef ONLINE_JUDGE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    #endif
   return 0;
}




Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    string s, t;
    cin >> s >> t;
    int i = 0;
    if(s == t){
        cout << "Yes" << endl;
    }
    else{
        while(i<s.size()){
            s = s.back() + s.substr(0, s.size()-1);
            if(s == t){
                cout << "Yes" << endl;
                break;
            }
            i++;
        }
    }
    if(i == s.size()){
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//============================================================================
// 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

//============================================================================
#define succ(x) ((x)+1)
#define pred(x) ((x)-1)
//============================================================================
void enter()
{
    int i,x,y;

    for (i=0;; i++){
        scanf("%d", &x);
        scanf("%d", &y);
        if (!x && !y)
            break;
        printf("%d %d\n", (x<y)?x:y, (x<y)?y:x);
    }
}
//============================================================================
int main(void)
{
    enter();
    return 0;
}
//============================================================================

Measured memory_bytes: 596
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define N 200010
using namespace std;
int n, a[N];
int sgn(int x) {
	return x < 0 ? -1 : x > 0;
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	if (n == 1) {
		puts("1");
		return 0;
	}
	
	int flag;
	if (a[1] == a[2]) flag = 0;
	else flag = (a[1] < a[2] ? -1 : 1);
	int ans = 1;
	for (int i = 3; i <= n; ++i) {
		if (!flag || sgn(a[i - 1] - a[i]) == 0 || sgn(a[i - 1] - a[i]) == flag) {
			if (sgn(a[i - 1] - a[i])) flag = sgn(a[i - 1] - a[i]);
		}
		else {
			flag = 0;
			++ans;
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>

int main(void)
{
	int i,len,a_c=0,b_c=0;
	char s[100001],a[100001],b[100001];
	scanf("%s",s);
	len=strlen(s);
	for(i=0;i<len;i++){
		if(i%2==0){
			a[i]='0';
			b[i]='1';
			}
		else{
			a[i]='1';
			b[i]='0';
			}
	}
	for(i=0;i<len;i++){
		if(s[i]!=a[i])
			a_c++;
		if(s[i]!=b[i])
			b_c++;
	}
	
	if(a_c>=b_c)
		printf("%d",b_c);
	else
		printf("%d",a_c);
	return 0;
}
			

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;
int main()
{

  ll x;
  cin>>x;
  ll tmp=1;
  ll ans=0,cnt=0;

  while(1){
    cnt+=tmp;
    tmp++;
    ans++;
    if(cnt>=x){
      cout<<ans<<endl;
      return 0;
    }
  }



  return 0;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    for (int i = 0; i < n; ++i) {
        cout << s[i] << t[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - Sum of Divisors
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  ll sum = 0;
  for (int i = 1; i <= n; i++) {
    int m = n / i;
    sum += (ll)i * m * (m + 1) / 2;
  }

  printf("%lld\n", sum);
  return 0;
}


Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
 
#define int long long int
 
const int mod = 1e9 + 7;
// const long double pi_2 = acos(0);
 
template <typename Type>
istream &operator>>(istream &in, vector<Type> &vec) {
    int n = vec.size();
    for (int i = 0; i < n; i++)
        in >> vec[i];
    return in;
}
template <typename Type>
ostream &operator<<(ostream &out, vector<Type> &vec) {
    for (auto val : vec)
        out << val << " ";
    return out;
}


#undef int
int main()
{
#define int long long int
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int r, c, n;
    cin>>r>>c>>n;
    vector<int> done(n);
    vector< pair<int, int> > tv, bv, lv, rv;

    for(int i = 0;i<n;i++)
    {
    	int x1, y1, x2, y2;
    	cin>>x1>>y1>>x2>>y2;
    	if((x1 == 0 || x1 == r || y1 == 0 || y1 == c) && (x2 == 0 || x2 == r || y2 == 0 || y2 == c))
    	{
    		if(x1 == 0)
    			tv.push_back({y1, i});
    		else if(x1 == r)
    			bv.push_back({y1, i});
    		else if(y1 == 0)
    			lv.push_back({x1, i});
    		else rv.push_back({x1, i});
			
			if(x2 == 0)
    			tv.push_back({y2, i});
    		else if(x2 == r)
    			bv.push_back({y2, i});
    		else if(y2 == 0)
    			lv.push_back({x2, i});
    		else rv.push_back({x2, i});
    	}
    }

    vector<int> stack;

    sort(tv.begin(), tv.end());
    sort(bv.begin(), bv.end(), greater< pair<int, int> >());
    sort(rv.begin(), rv.end());
    sort(lv.begin(), lv.end(), greater< pair<int, int> >());


    for(auto p: tv)
    {
    	if(done[p.second])
    	{
    		if(!stack.empty() && stack.back() == p.second)
    			stack.pop_back();
    		else
    		{
    			cout<<"NO"<<endl;
    			return 0;
    		}
    	}
    	else
    		stack.push_back(p.second), done[p.second] = 1;
    }
    for(auto p: rv)
    {
    	if(done[p.second])
    	{
    		if(!stack.empty() && stack.back() == p.second)
    			stack.pop_back();
    		else
    		{
    			cout<<"NO"<<endl;
    			return 0;
    		}
    	}
    	else
    		stack.push_back(p.second), done[p.second] = 1;
    }
    for(auto p: bv)
    {
    	if(done[p.second])
    	{
    		if(!stack.empty() && stack.back() == p.second)
    			stack.pop_back();
    		else
    		{
    			cout<<"NO"<<endl;
    			return 0;
    		}
    	}
    	else
    		stack.push_back(p.second), done[p.second] = 1;
    }
    for(auto p: lv)
    {
    	if(done[p.second])
    	{
    		if(!stack.empty() && stack.back() == p.second)
    			stack.pop_back();
    		else
    		{
    			cout<<"NO"<<endl;
    			return 0;
    		}
    	}
    	else
    		stack.push_back(p.second), done[p.second] = 1;
    }
    if(stack.empty())
    	cout<<"YES"<<endl;
    else
    	cout<<"NO"<<endl;

 
    return 0;
}

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

using namespace std;

const int MX = 100000;

int b[MX], l[MX], u[MX], c[MX];

int main() {
	int n, x;
	ignore = scanf("%d %d", &n, &x);
	for (int i = 0; i < n; i++) ignore = scanf("%d %d %d", b + i, l + i, u + i);
	
	vector<pair<long long, int>> vec;
	for (int i = 0; i < n; i++) {
		vec.emplace_back((x - b[i]) * 1ll * u[i] + b[i] * 1ll * l[i], i);
	}
	
	sort(vec.begin(), vec.end());
	reverse(vec.begin(), vec.end());
	
	long long ans = -1;
	for (long long p = (1LL << 40); p > 0; p /= 2) {
		long long full = (ans + p) / x;
		int leftover = (ans + p) % x;
		
		if (full >= n) continue;
		
		fill(c, c + n, -1);
		
		long long sum = 0;
		for (int i = 0; i < full; i++) {
			int j = vec[i].second;
			c[j] = u[j];
			sum += u[j] * 1ll * (x - b[j]);
		}
		
		for (int i = 0; i < n; i++) {
			if (c[i] != -1) continue;
			sum -= l[i] * 1ll * b[i];
		}
		
		if (leftover == 0) {
			if (sum < 0) ans += p;
			continue;
		}
		
		bool win = false;
		for (int i = 0; i < n; i++) {
			long long cur = 0;
			if (c[i] != -1) {
				int j = vec[full].second;
				
				cur -= c[i] * 1ll * (x - b[i]);
				cur += l[j] * 1ll * b[j];
				cur += u[j] * 1ll * (x - b[j]);
			}
			else {
				cur += l[i] * 1ll * b[i];
			}
			
			c[i] = leftover > b[i] ? u[i] : l[i];
			cur += c[i] * 1ll * (leftover - b[i]);
			if (sum + cur >= 0) win = true;
		}
		
		if (win == false) ans += p;
	}
	
	printf("%lld\n", ans + 1);
	
	return 0;
}


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

int main() {
	vector<string> w = { "Sunny", "Cloudy", "Rainy" };

	string S; cin >> S;

	if (S == w[0]) cout << w[1] << endl;
	else if (S == w[1]) cout << w[2] << endl;
	else if (S == w[2]) cout << w[0] << endl;
}


Measured memory_bytes: 256
import copy
s = input()
n = len(s)
l = []
c = [0]*26

for i in s:
    l.append(ord(i)-ord("a"))
    c[l[-1]] += 1

ans = 10**10

for i in range(26):
    if c[i]:
        count = 0
        l2 = copy.deepcopy(l)
        while (n-count)*i != sum(l2):
            count += 1
            nl = []
            for j in range(n-count):
                if l2[j] == i or l2[j+1] == i:
                    nl.append(i)
                else:
                    nl.append(1000)
            l2 = nl
        ans = min(ans,count)
print(ans)


Measured memory_bytes: 9232
#pragma region

#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;
typedef long long ll;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "vec[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

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

  ll N;
  cin >> N;
  vector<ll> P(N), Q(N), R(N);
  cin >> P >> Q;
  rep(i, N) R[i] = N - i;

  ll p = 0, q = 0;
  while (P != R) {
    next_permutation(all(P));
    p++;
  }
  while (Q != R) {
    next_permutation(all(Q));
    q++;
  }
  out(abs(p - q));
}


Measured memory_bytes: 256
n, t = map(int, raw_input().split())
T = map(int, raw_input().split())

rest = 0
ans = 0
prev = 0
for i in xrange(n):
    ti = T[i]
    if rest > 0:
        ans += min(rest, ti - prev)
        rest = max(0, rest - (ti - prev))
    rest = t
    prev = T[i]
print ans + rest


Measured memory_bytes: 20036
using System;

namespace TestSpace
{
    class Test
    {
        static void Main(string[] args)
        {
            double r, S, L;

            r = double.Parse(Console.ReadLine());
            S = Math.Pow(r, 2) * Math.PI;
            L = 2 * r * Math.PI;

            Console.WriteLine("{0} {1}", S, L);
        }
    }
}



Measured memory_bytes: 15956
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;


int main(void){
  int n,m;
  cin >> n >> m;
  priority_queue<int> que;
  
  rep(i,n){
	int work;
	cin >> work;
	que.push(work);
  }

  rep(i,m){
	que.push(que.top()/2);
	que.pop();
  }
  ll ans = 0;
  rep(i,n){
	ans += que.top();
	que.pop();
  }
  
  cout << ans << endl;

  return 0;
}


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

int n, m, x;

int a[5123][5123];
int b[5123][5123];
int c[5123][5123];
int d[5123][5123];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m >> x;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            char s;
            cin >> s;
            a[i][j] = s - '0';
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            b[i][j] = b[i - 1][j] + b[i][j - 1] - b[i - 1][j - 1] + (a[i][j] == 1 && a[i][j - 1] == 1);
            c[i][j] = c[i - 1][j] + c[i][j - 1] - c[i - 1][j - 1] + (a[i][j] == 1 && a[i - 1][j] == 1);
            d[i][j] = d[i - 1][j] + d[i][j - 1] - d[i - 1][j - 1] + a[i][j];
        }
    }
    while(x--){
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        int ve = b[x2][y2] - b[x2][y1] - b[x1 - 1][y2] + b[x1 - 1][y1];
        int ho = c[x2][y2] - c[x2][y1 - 1] - c[x1][y2] + c[x1][y1 - 1];
        cout<<d[x2][y2] - d[x2][y1 - 1] - d[x1 - 1][y2] + d[x1 - 1][y1 - 1] - ve - ho<<"\n";
    }
	return 0;
}


Measured memory_bytes: 164864
while True:
    (n, x) = [int(i) for i in input().split()]
    if n == x == 0: break
    count = 0
    for i in range(1,n - 1):
        for j in range(i + 1 ,n):
            for k in range(j + 1 ,n + 1):
                if i + j + k == x: 
                    count += 1
                    break 
    print(count)

Measured memory_bytes: 6724
import java.util.Scanner;

public class Main {

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

		while (true) {

			int x = sc.nextInt();
			int y = sc.nextInt();
			int s = sc.nextInt();

			int max = 0;

			if (x == 0 && y == 0 && s == 0) {
				break;
			}

			for (int i = 1; i < s; i++) {
				for (int j = 1; j < s; j++) {

					int a = i * (100 + x) / 100;
					int b = j * (100 + x) / 100;

					if (a + b == s) {
						int c = i * (100 + y) / 100;
						int d = j * (100 + y) / 100;

						int sum = c + d;

						if (sum > max) {
							max = sum;
						}
					}
				}
			}

			System.out.println(max);
		}
	}
}

Measured memory_bytes: 21028
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

int main() {
	string s;
	int q, rev = 0;
	vector<vector<char> > add(2);

	cin >> s;
	cin >> q;

	for (int i = 0; i < q; ++i) {
		int t, f;
		char ch;
		cin >> t;

		if (t == 1) {
			rev = 1 - rev;
		}
		else {
			cin >> f >> ch;

			if (f == 1) {
				add[rev].push_back(ch);
			}
			else {
				add[1 - rev].push_back(ch);
			}
		}
	}

	string final;

	for (int i = 0; i < (int) add[0].size(); ++i) {
		final += add[0][(int) add[0].size() - 1 - i];
	}

	final += s;

	for (int i = 0; i < (int) add[1].size(); ++i) {
		final += add[1][i];
	}

	if (rev) {
		reverse(final.begin(), final.end());
		cout << final << endl;
	}
	else {
		cout << final << endl;
	}

	return 0;
}

Measured memory_bytes: 1368
using System;

namespace AtCoder
{
    static class Solver
    {
        static IO io = new IO();

        public static void Solve()
        {
            io.Read();
            string S = io.String();

            io.WriteLine(Ans(S));

        }

        public static string Ans(string S)
        {
            bool[] is_used = new bool[26];
            for (int i = 0; i < S.Length; ++i)
            {
                int s = (int)S[i] - 97;
                if (is_used[s])
                {
                    return "no";
                }
                else
                {
                    is_used[s] = true;
                }
            }
            return "yes";
        }

    }
}
namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            Solver.Solve();
        }
    }
    class IO
    {
        private string[] _Inputs;
        private int _Index;
        public void Read()
        {
            _Inputs = new string[1];
            _Inputs[0] = Console.ReadLine();
            _Index = 0;
        }
        public void ReadSplit()
        {
            _Inputs = Console.ReadLine().Split(' ');
            _Index = 0;
        }
        public string String()
        {
            return _Inputs[_Index++];
        }
        public string[] String(int xCount)
        {
            string[] rv = new string[xCount];
            Array.Copy(_Inputs, _Index, rv, 0, xCount);
            _Index += xCount;
            return rv;
        }
        public int Int()
        {
            return int.Parse(_Inputs[_Index++]);
        }
        public int[] Int(int xCount)
        {
            int[] rv = new int[xCount];
            for (int i = 0; i < xCount; ++i)
            {
                rv[i] = int.Parse(_Inputs[_Index++]);
            }
            return rv;
        }
        public long Long()
        {
            return long.Parse(_Inputs[_Index++]);
        }
        public long[] Long(int xCount)
        {
            long[] rv = new long[xCount];
            for (int i = 0; i < xCount; ++i)
            {
                rv[i] = long.Parse(_Inputs[_Index++]);
            }
            return rv;
        }
        public void Write(string xStr)
        {
            Console.Write(xStr);
        }
        public void WriteLine(string xStr)
        {
            Console.WriteLine(xStr);
        }
    }
}

Measured memory_bytes: 11092
#include <cstdio>
typedef long long ll;

const int N = 1001000, p = 1e9+7;
inline int qm(const int x) {return x < p ? x : x - p;}
int n, a, b, c, d;

int main() {
	scanf("%d",&n);
	if(n == 1) return puts("1"), 0;
	if(n == 2) return puts("4"), 0;
	c = n, b = (ll)n * n%p;
	int sm = 0;
	for(int i=n-2;i;--i) {
		sm = qm(sm + d);
		a = (sm + b + (ll)(n-1)*(n-1) + i+1)%p;
		d = c, c = b, b = a;
	}
	printf("%d\n", b);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
	int x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	priority_queue<pair<int,int> >h;
	while(a--)
	{
		int w;
		cin>>w;
		h.push(make_pair(w,1));
	}
	while(b--)
	{
		int w;
		cin>>w;
		h.push(make_pair(w,2));
	}
	while(c--)
	{
		int w;
		cin>>w;
		h.push(make_pair(w,3));
	}
	int z=x+y;
	int ans=0;
	while(z)
	{
		pair<int,int> f=h.top();
		h.pop();
		if(f.second==3)
		{
			ans+=f.first;
			--z;
		}
		else if(f.second==1&&x)
		{
			ans+=f.first;
			--x;
			--z;
		}
		else if(f.second==2&&y)
		{
			ans+=f.first;
			--y;
			--z;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10348
#include<stdio.h>
#define N 250

int main(){
  int size,i,key[N];

  for(i=0 ; i<N ; i++){
    key[i] = NULL;
  }
  scanf("%d",&size);
  for(i=1 ; i<size+1 ; i++){
    scanf("%d",&key[i]);
  }
  for(i=1 ; i<size+1 ; i++){
    printf("node %d: ",i);
    printf("key = %d, ",key[i]);
      if(i/2>0)printf("parent key = %d, ",key[i/2]);
      if(2*i <= size) printf("left key = %d, ",key[2*i]);
      if(2*i+1 <= size) printf("right key = %d, ",key[2*i+1]);
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2104
package main

import (
	"fmt"
	"math"
)

func isInt(n float64) bool {
	return math.Floor(n) == n
}

func main() {
	var n float64
	fmt.Scan(&n)

	for i := n; 0 < i; i-- {
		n := math.Sqrt(i)
		if isInt(n) {
			fmt.Println(int(i))
			break
		}
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef vector<bool> vb;
 
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()
 
ll n;
string s;
 
void solve(){
  cin >> n >> s;
  
  vll r,g,b;
  rep(i,0,n){
   if(s[i]=='R') r.emplace_back(i+1);
   else if(s[i]=='G') g.emplace_back(i+1);
   else b.emplace_back(i+1); 
  }
  ll res=r.size()*g.size()*b.size();
  
 
  
  rep(i,0,g.size()){
   rep(j,0,b.size()){
    if((g[i]+b[j])%2) continue;
     res-=upper_bound(all(r),(g[i]+b[j])/2)-lower_bound(all(r),(g[i]+b[j])/2);
   }
  }
  
  rep(i,0,r.size()){
   rep(j,0,b.size()){
    if((r[i]+b[j])%2) continue;
     res-=upper_bound(all(g),(r[i]+b[j])/2)-lower_bound(all(g),(r[i]+b[j])/2);
   }
  }
   rep(i,0,r.size()){
   rep(j,0,g.size()){
    if((r[i]+g[j])%2) continue;
     res-=upper_bound(all(b),(r[i]+g[j])/2)-lower_bound(all(b),(r[i]+g[j])/2);
   }
  }
  
  cout << res << endl;
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}  

Measured memory_bytes: 3696
import numpy as np
import sys
readline = sys.stdin.buffer.readline
#K,S=map(int, readline().split())
#S=list(readline())
S=input()

#print(S)
i=S.index('A')
#print(i)

S1 = S[::-1]

j=(S1.index('Z'))
j=len(S)-j
#print(S1)
#print(j)
#print(len(S)-j)
print(j-i)

Measured memory_bytes: 13000
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
   int K;
   cin >> K;
   int sum = 0;
   for(int i=1; i<=K; i++){
      for(int j=0; j<= K; j++){
         if((i % 2 == 0)and(j % 2 != 0)){
            sum++;
         }
      }
   }
   cout << sum << endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define INF (1e18)
const ll SIZE = 200010;
struct BIT {
	ll bit[SIZE];
	void init(){
		memset(bit,0,sizeof(bit));
	}
	void add(ll k, ll x){
		k++;
		while(k < SIZE){
			bit[k] += x;
			k += k&-k;
		}
	}
	ll get(ll k){
		k++;
		ll ret = 0;
		while(k > 0){
			ret += bit[k];
			k -= k&-k;
		}
		return ret;
	}
	ll get(ll s, ll t){ return get(t) - get(s-1); }

	ll pos(ll k){
		ll l = 0,r = SIZE;
		while(r - l > 1){
			ll m = (l + r) / 2;
			if(get(m) < k) l = m;
			else r = m;
		}
		return r;
	}
};

int main(){   
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    BIT bit;
    ll A[200010];
    rep(i,0,N) cin >> A[i];
    rep(i,0,N) A[i] -= K;
    ll sum[200010] = {};
    rep(i,0,N) sum[i+1] = sum[i] + A[i];
    vector<ll> v;
    rep(i,0,N+1) v.push_back(sum[i]);
    sort(v.begin(), v.end());
    unique(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());

    ll ans = 0;
    rep(i,0,N+1){
        ll pos = lower_bound(v.begin(), v.end(), sum[i]) - v.begin();
        ans += bit.get(pos);
        bit.add(pos, 1);
    }
    print(ans);
}


Measured memory_bytes: 7028
S = input()

A = int(S[:2])
B = int(S[2:])

if 1 <= A <= 12:
	if 1 <= B <= 12:
		print('AMBIGUOUS')
	else:
		print('MMYY')
else:
	if 1 <= B <= 12:
		print('YYMM')
	else:
		print('NA')




Measured memory_bytes: 2940
import heapq
# import collections
# from heapq import heapify
H, W, M = map(int, input().split())
hw = set([tuple(map(int, input().split())) for i in range(M)])
D1 = [0]*H
D2 = [0]*W

for x, y in hw:
    x -= 1
    y -= 1
    D1[x] += 1
    D2[y] += 1

X = max(D1)
Y = max(D2)

h = [x for x in range(H) if D1[x] == X]
w = [x for x in range(W) if D2[x] == Y]
ans = X+Y-1
for x in h:
    for y in w:
        if (x+1, y+1) not in hw:
            ans += 1
            print(ans)
            exit(0)
print(ans)


Measured memory_bytes: 169688
#include <bits/stdc++.h>
#define REP(i, n, s) for (int i = (s); i < (n); i++)
#define PI 3.141592653589793
#define EPS 1e-15
#define SIZE 200001
using namespace std;
typedef long long int LL;
typedef long double LD;

int N;
LL K;
double s[SIZE];

// Count number of triangles whose area is less than X
// Another point comes right to others.
// i : position of the point
// X : target area size
int count(int i, double X) {
	int all = (N - i) / 2;
	int l = 0, r = all + 1;
	while(r - l > 1) {
		int m = (l + r) / 2;
		double area = (s[i] + s[m] + s[N - i - m]) / 2.0;
//		if (area > X + EPS) r = m;
		if (area > X) r = m;
		else l = m;
	}
	if (r == all + 1) return N - i - 1;
	return l * 2;
}

bool check(double X) {
	LL sum = 0;
	REP(i, N - 1, 1) {
		sum += count(i, X);
	}
	return sum * N >= 3 * K;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N >> K;
	REP(i, N+1, 0) {
		s[i] = sin(2.0*PI*(double)i/(double)N);
	}
	double l = 0.0, r = 2.0 * PI;
	// (1/2)^50 = 8.881784197001252e-16
	REP(i, 50, 0) {
		double m = (l + r) / 2;
		if (check(m)) r = m;
		else l = m;
	}
	cout << fixed << setprecision(20) << r << endl;
	return 0;
}

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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const int INF = 100001;

int n;
int t;

int main()
{
    int a, b;
    cin >> n >> t;
    int ans = INF;
    REP(i, n)
    {
        cin >> a >> b;
        if (b <= t)
        {
            ans = min(ans, a);
        }
    }
    if (ans == INF)
    {
        cout << "TLE" << endl;
        return 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384