akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;
using Graph = vector<vector<ll>>;

int main()
{
    ll n;
    cin >> n;
    for (int a = 1; a <= 3500; a++)
    {
        for (int b = 1; b <= 3500; b++)
        {
            if (4 * a * b - n * b - n * a == 0)
                continue;
            int c = (n * a * b) / (4 * a * b - n * b - n * a);
            if ((n * a * b) % (4 * a * b - n * b - n * a) == 0 && c > 0&&c<=3500)
            {
                cout << a << " " << b << " " << c << endl;
                return 0;
            }
        }
    }
}

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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 55, M = 1010;

int n, m;
int a[N];
LL f[N][N][N * N];

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i ++ ) cin >> a[i];
	
	for (int i = 0; i <= n; i ++ ) f[i][0][0] = 1;
	
	for (int i = 1; i <= n; i ++ )
		for (int j = 1; j <= i; j ++ )
			for (int k = 0; k < N * N; k ++ )
			{
				f[i][j][k] += f[i - 1][j][k];
				if (k >= a[i]) f[i][j][k] += f[i - 1][j - 1][k - a[i]];
			}
	
	// cout << f[2][0][0] << endl;
	
	LL res = 0;
	for (int i = 1; i <= n; i ++ ) res += f[n][i][i * m];
	cout << res << endl;	
	return 0;
}

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

int main(){
    string S;
    cin >> S;
    int N = S.size();

    for(int bit=0; bit<(1<<(N-1)); bit++){
        int temp = S[0]-'0';

        for(int i=0; i<(N-1); i++){
            if(bit & (1<<i)) temp += S[i+1]-'0';
            else temp -= S[i+1]-'0';
        }
        if(temp == 7){
            cout << S[0];
            for(int j=0; j<N-1; j++){
                if(bit%2==0) cout << '-';
                else cout << '+';
                cout << S[j+1];
                bit /= 2;
            }
            cout << "=7" << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<deque>
#include<stack>
using namespace std;

int n,m,big,cnt;
int price[100005],mx[100005];

int main(){
	cin>>n>>m;
	m/=2;
	for(int i=0;i<n;i++) cin>>price[i];
	for(int i=n-2;i>=0;i--) mx[i]=max(mx[i+1],price[i+1]);
	//for(int i=0;i<n;i++) cout<<mx[i]<<" "<<price[i]<<endl;
	for(int i=0;i<n;i++) if(mx[i]>price[i]){
		//cout<<mx[i]<<endl;
		if(mx[i]-price[i]==big) cnt++;
		if(mx[i]-price[i]>big){
			big=mx[i]-price[i];
			cnt=1;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){

	int n;
	int money[6] = {500,100,50,10,5,1};
	while(cin >> n, n){
		
		int change = 0;
		n = 1000 - n;
		rep(i,6){
			
			change += n / money[i];
			n = n % money[i];
		}
		cout << change << endl;
	}

	return 0;
}

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

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

	if(a < b){
		cout << "a < b" << endl;
	}else if(a > b){
		cout << "a > b" << endl;
	}else{
		cout << "a == b" << endl;
	}

	return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdlib>
using namespace std;

int main() {
	int y, m, d;
	scanf("%d/%d/%d", &y, &m, &d);
	//cout << y << m << d;
	if (y < 2019) {
		printf("Heisei\n");
	}
	else if (y == 2019) {
		if (m < 4) {
			printf("Heisei\n");
		}
		else if (m == 4) {
			if (d <= 30) {
				printf("Heisei\n");
			}
			else {
		//		cout << 99;
				printf("TBD\n");
			}
		}
		else {
			//cout << 88;
			printf("TBD\n");
		}
	}
	else {
	//	cout << 77;
		printf("TBD\n");
	}
	
return		(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define I64 "%I64d"
#define RAN(v)v.begin(),v.end()
#define pb push_back
#define lb lower_bound
#define ub upper_bound
using namespace std;
typedef long long ll;
template<class T>
inline void upd1(T&a,T b){a>b?a=b:0;}
template<class T>
inline void upd2(T&a,T b){a<b?a=b:0;}
struct ano{
	operator ll(){
		ll x=0,y=0,c=getchar();
		while(c<48)
			y=c==45,c=getchar();
		while(c>47)
			x=x*10+c-48,c=getchar();
		return y?-x:x;
	}
}buf;
const int N=5e5+5;
char a[N];
int c[N],f[N][3];
int sol(int l,int r){
	int k=0,m=0;
	for(int i=l;i<=r;++i)
		if(a[i]=='1'){
			++k;
			if(i==r||a[i+1]=='0')
				c[++m]=k,k=0;
		}
	f[0][1]=-1e9;
	for(int i=1;i<=m;++i){
		f[i][0]=max(f[i-1][2]+c[i],f[i-1][0]+c[i]-1);
		f[i][1]=max(f[i-1][2],f[i-1][1]+c[i]-1);
		f[i][2]=max(f[i-1][2],max(f[i-1][0],f[i-1][1]+c[i]));
		if(c[i]!=1)
			upd2(f[i][1],f[i-1][0]);
	}
	return f[m][2];
}
int main(){
	~buf;
	scanf("%s",a);
	int l=0,s=0;
	for(int i=2;a[i];++i)
		if(a[i]=='1'){
			if(a[i-1]!='1'&&a[i-2]!='1')l=i;
			if(a[i+1]!='1'&&a[i+2]!='1')s+=sol(l,i);
		}
	printf("%d\n",s);
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DBG(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define DBG(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define CIN(type, ...) \
  type __VA_ARGS__;    \
  read_from_cin(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int p[200000];

double exp(int i) {
  return p[i] * (p[i] + 1) / 2 / (double)(p[i]);
}

int main() {
  CIN(int, N, K);
  REP(i, N) cin >> p[i];
  DBG(p[0]);

  DBG(exp(0));

  double sum = 0;
  REP(i, K) sum += exp(i);
  double ans = sum;
  for (int i = K; i < N; ++i) {
    sum -= exp(i - K);
    sum += exp(i);
    ans = max(ans, sum);
  }
  cout << setprecision(20) << ans << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main(){
  int n,q,l,r;
  scanf("%d %d",&n,&q);
  char s[n + 1];
  scanf("%s",&s);
  int f[n];
  f[1] = 0;
  for(int i = 2;i <= n;i++){
    f[i] = f[i - 1];
    if(s[i - 2] == 'A' && s[i - 1] == 'C'){
      f[i]++;
    }
  }
  for(int i = 0;i < q;i++){
    scanf("%d %d",&l,&r);
    printf("%d\n",f[r] - f[l]);
  }
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
#define endl '\n'
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll k, n;
  cin >> k >> n;
  vll a(n);
  for (ll i = 0; i < n; i++) cin >> a[i];
  ll ans = 0;
  for (ll i = 0; i < n - 1; i++) ans = max(ans, a[i + 1] - a[i]);
  ans = max(ans, a[0] + k - a[n - 1]);
  cout << k - ans << endl;
}

Measured memory_bytes: 1920
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<vector>
#include<numeric>
#include<random>
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int ans;
	int x;

	cin >> x;
	ans = x * x*x;

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


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

int main(void) {
    int n, m;
    cin >> n >> m;
    vector<int> cnt(n + 1);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        cnt.at(a)++;
        cnt.at(b)++;
    }
    for (int i = 1; i <= n; i++) {
        cout << cnt.at(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 3604
from bisect import *
import sys
n = int(input())
ss = []
color = {}
cnt = 0
for _ in range(n):
    a, b, *c = map(int,sys.stdin.readline().split())
    if a == 0:
        if b not in color:
            insort_left(ss,b)
            color[b]=1
            cnt += 1
        elif color[b] == 0:
            color[b] = 1
            cnt += 1
        print(cnt)
    elif a == 1:
        print(color[b] if b in color else 0)
    elif a == 2:
        if b in color:
            cnt -=color[b]
            color[b] = 0
    else:
        L = bisect_left(ss,b)
        R = bisect(ss,c[0])
        for i in range(L,R):
            if color[ss[i]] == 1:
                print(ss[i])


Measured memory_bytes: 28292
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>

using namespace std;

const int N=2e5+5;

typedef long long LL;

int n,a[N],b[N],tot,h[N],e[N],nxt[N],m;

map <int,int> Id,sa,sb;

bool vis[N];

void Add(int x,int y)
{
	e[++tot]=y; nxt[tot]=h[x]; h[x]=tot;
}

void Link(int x,int y)
{
	if (!Id[x]) Id[x]=++m;
	if (!Id[y]) Id[y]=++m;
	Add(Id[x],Id[y]); Add(Id[y],Id[x]);
}

void dfs(int x)
{
	vis[x]=1;
	for (int i=h[x];i;i=nxt[i]) if (!vis[e[i]]) dfs(e[i]);
}

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=n;i++) scanf("%d",&b[i]);
	for (int i=1;i<=n;i++) a[0]^=a[i],b[0]^=b[i];
	for (int i=0;i<=n;i++)
	{
		sa[a[i]]++; sb[b[i]]++;
	}
	for (int i=0;i<=n;i++) if (sa[a[i]]!=sb[a[i]])
	{
		printf("-1\n"); return 0;
	}
	for (int i=1;i<=n;i++) if (a[i]!=b[i]) Link(a[i],b[i]);
	if (!tot)
	{
		printf("0\n"); return 0;
	}
	Link(a[0],b[0]);
	//tot--;
	tot=(tot>>1)-2;
	for (int i=1;i<=m;i++) if (!vis[i])
	{
		tot++; dfs(i);
	}
	printf("%d\n",tot);
	return 0;
}

Measured memory_bytes: 19840
#include<cstdio>
#include<cstring>
const int MAXN = 100000;
const int MAXK = 1000;
int x[MAXN + 5], y[MAXN + 5], c[MAXN + 5];
int y1[10 * MAXK + 5];
int main() {
    int N, K, Max = 0, cnt = 0;
    scanf("%d%d",&N,&K);
    for(int i=1;i<=N;i++) {
        char ch;
        scanf("%d%d %c",&x[i],&y[i],&ch);
        x[i] = x[i] % (2*K);//降维 
        y[i] = y[i] % (2*K);
        if( ch == 'W' ) c[i] = 1;
        else c[i] = 0;
    }
    for(int i=0;i<=K;i++) 
    {
        cnt = 0;
        memset(y1,0,sizeof(y1));
        for(int j=1;j<=N;j++) 
        {
            int p = ( i<=x[j] && x[j] < i+K );
            int q = ( 0 <=y[j] && y[j] < K );
            //printf("%d %d",p,q); 
            if( p ^ q == c[j] )//通过位与来实现
            {
                cnt++;
                y1[y[j]] ++;
            }
            else 
            {
                y1[y[j]] --;
            }
        }
        for(int j=0;j<=K;j++) 
        {
            if( cnt > Max ) Max = cnt;
            if( N - cnt > Max ) Max = N - cnt;
            if( j != K )
                cnt = cnt - y1[j] - y1[K+j];
        }
    }
    printf("%d\n",Max);
}

Measured memory_bytes: 1408
#include <algorithm>
#include <iostream>
#include <utility>

using namespace std;

constexpr static int MAXN = 3e5;

int64_t n, k;
int64_t a[MAXN], s[MAXN];
pair <int64_t, int> b[MAXN];
int cnt[MAXN];

void update(int i, int by) {
    while (i <= n) {
        cnt[i] += by;
        i |= (i + 1);
    }
}

int query(int i) {
    int res = 0;
    while (i >= 0) {
        res += cnt[i];
        i = (i & (i + 1)) - 1;
    }
    return res;
}

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] -= k;
        s[i + 1] = s[i] + a[i];
    }

    for (int i = 0; i <= n; i++)
        b[i] = {s[i], i};
    sort(b, b + n + 1);

    int64_t total = 0;
    for (int i = 0; i <= n; i++)
        update(i, 1);
    for (int i = 0; i <= n; i++) {
        int j = b[i].second;
        total += n + 1 - i - query(j);
        update(j, -1);
    }
    cout << total << endl;
}


Measured memory_bytes: 10112
N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]

def dfs(i, a_len, b_len, c_len):
  if i == N:
    if a_len == 0 or b_len == 0 or c_len == 0:
      return float('inf')
    else:
      return abs(a_len - A) + abs(b_len - B) + abs(c_len - C) - 30
  
  br1 = dfs(i + 1, a_len + L[i], b_len, c_len) + 10
  br2 = dfs(i + 1, a_len, b_len + L[i], c_len) + 10
  br3 = dfs(i + 1, a_len, b_len, c_len + L[i]) + 10
  br4 = dfs(i + 1, a_len, b_len, c_len)
  
  return min(br1, br2, br3, br4)

print(dfs(0,0,0,0))


Measured memory_bytes: 3064
import java.util.StringTokenizer;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author wijebandara
 */
public class Main {
     public static void main(String[] args) {
        java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
        {
            try {
                String s =in.readLine();
                StringTokenizer st;
                while(s!=null)
                {
                    st = new StringTokenizer(s);
                    int p =Integer.parseInt(st.nextToken()) + Integer.parseInt(st.nextToken()) ;
                    
                    System.out.println((int)Math.log10(p)+1);
                    s =in.readLine();
                }
            } catch (Exception ex) {
                System.exit(0);
            }
            
            
        }
     }
}

Measured memory_bytes: 16896
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BLucasNumber {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n;
	    in >> n;
	    ll l[110];
	    l[0] = 2;
	    l[1] = 1;
	    for(int i=2; i<=100; i++){
	        l[i] = l[i-1] + l[i-2];
	    }

	    out << l[n] << endl;
	}
};


int main() {
	BLucasNumber solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define PII pair<int,int>
#define ls x<<1
#define rs x<<1|1
#define fi first
#define se second
#define pb push_back
#define cwk freopen("D:\\c++\\in.txt","r",stdin),freopen("D:\\c++\\out.txt","w",stdout)
using namespace std;
const int N=2e3+10;
ll dp[N][N];
struct node{
	ll a,b;
	bool operator < (const node &phx) const {
		return a<phx.a;
	}
}e[N];
int n;
int main()
{
	//cwk;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		int a;
		scanf("%d",&a);
		e[i]=(node){a,i};
	}
	sort(e+1,e+1+n);
	for(int i=1;i<=n;i++) dp[i][i]=e[1].a*abs(e[1].b-i);
	for(int len=2;len<=n;len++) {
		for(int l=1;l<=n;l++) {
			int r=len+l-1;
			if(r>n) break;
			dp[l][r]=max(dp[l+1][r]+e[len].a*abs(e[len].b-l),dp[l][r-1]+e[len].a*abs(e[len].b-r));
		}
	}
	printf("%lld\n",dp[1][n]);
	return 0;
}

Measured memory_bytes: 26512
#define _[2<<17]
n,i;A _,B _,T _,F _;long M,D _,P _,R _;s(u,i,p,I){R[i]=i?s(u,T[i],p,0),(I=B[i])-p?s(I,F[I],u,0),D[u]=D[u]*-~D[I]%M:D[u]:++D[u];return 0;}S(u,x,p,i,I){for(i=F[u];I=B[i];I-p?S(I,R[i]*x%M+1,u,0,0),x=x*-~D[I]%M:0)i=T[i];P[u]=x%M;}main(u,v){for(;~scanf("%d%d",&u,&v);)i++?A[i-1]=B[i]=u,B[i-1]=A[i++]=v:(n=u,M=v);for(;--i;F[A[i]]=i)T[i]=F[A[i]];s(1,F[1],0,0);for(S(1,1,0,0,0);i++<n;)printf("%d ",P[i]);}

Measured memory_bytes: 14592
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  ll a, n;
  map<ll, ll> map;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    map[a] += 1;
  }

  ll cnt = 0;
  for (auto& x : map) {
    if (x.first < x.second) cnt += x.second - x.first;
    if (x.first > x.second) cnt += x.second;
  }
  cout << cnt << endl;
}


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

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define f1(i, n) for(int i=1;i<=n;i++)
#define f0(i, n) for(int i=0;i<n;i++)
#define ldb ldouble
#define inf 9999999999999999
#define mod 998244353
//#define mod 1000000007
#define int ll

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

//**Start here**//

///declaration///

//library structure//
int a[100005],b[15][15],cnt[100005];
vector <int> g[15];

//variables//
int n,m,X,Y,ans=0;

//data structure//

///function///
//preset//

//input//
void input()
{
    cin >> n;
    for (int i=1;i<=n;++i)
    {
        cin >> a[i];
        ans+=a[i]-1;
    }
    cout << ans;
    return;
}

//algorithm//

//solve//
void solve()
{

    return;
}

//output//
void output()
{

    return;
}

///main///
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	//freopen("test.INP","r",stdin);
    //freopen("test.OUT","w",stdout);
    /*int test;
    cin >> test;
    for (int k=1;k<=test;++k)*/
    {
        input();
        solve();
        output();
    }
    return 0;
}

/**code-by-@datr1bs**/


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>

using namespace std;

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

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi atan(1.0)*4
#define pb(x) push_back(x)
#define in(x) insert(x)
#define fl(x,y) for(ll i=x;i<y;i++)
#define all(cont) cont.begin(),cont.end()
#define sz size()
bool isprm(ll a){for(ll i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
int main()
{
    ll a,b,t,n,k,p,q,r,sum,ct=0,flag=0;
    string s,s1,s2,s3;
    set<ll>st;
    map<ll,ll>mp;
      vector<ll>v,vv;

        n=5; ct=0;
        fl(0,n)
         {cin>>r; ct++; if(r==0) p=ct;}
      cout<<p<<endl;
}







Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    vector<ll> a, b;
    rep(i, n){
        ll x, y;
        cin >> x >> y;
        a.push_back(x);
        b.push_back(y);
    }
    ll res=0;
    rep(i, n){
        if((res+a[n-1-i])%b[n-1-i]){
          res += b[n - 1 - i] - ((res + a[n - 1 - i]) % b[n - 1 - i]);
        }
    }
    cout << res << endl;
    return 0;
}

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

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> l(N);
  for (auto & _l : l)
    cin >> _l;
  sort(l.rbegin(), l.rend());
  cout << accumulate(l.begin(), l.begin() + K, 0);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,c,d,maxx;
	cin>>a>>b>>c>>d;
	maxx=max(a*c,a*d);
	maxx=max(maxx,max(b*c,b*d));
	cout<<maxx;
	return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

typedef struct List {
	struct List *next;
	int v;
} list;

list *adj[1001] = {};

int DFS(int r, int flag[], int prev[])
{
	int tmp;
	list *p;
	flag[r] = -1;
	for (p = adj[r]; p != NULL; p = p->next) {
		if (flag[p->v] == 0) {
			prev[p->v] = r;
			tmp = DFS(p->v, flag, prev);
			if (tmp > 0) return tmp;
		} else if (flag[p->v] == -1) {
			prev[p->v] = r;
			return r;
		}
	}
	flag[r] = 1;
	return 0;
}

int main()
{
	int i, N, M, u, w;
	list e[2001];
	scanf("%d %d", &N, &M);
	for (i = 1; i <= M; i++) {
		scanf("%d %d", &u, &w);
		e[i].v = w;
		e[i].next = adj[u];
		adj[u] = &(e[i]);
	}
	
	int r, flag[1001] = {}, prev[1001] = {};
	list *p;
	for (i = 1; i <= N; i++) {
		if (flag[i] != 0) continue;
		r = DFS(i, flag, prev);
		if (r > 0) break;
	}
	if (i > N) {
		printf("-1\n");
		fflush(stdout);
		return 0;
	}
	
	for (i = 1; i <= N; i++) flag[i] = 0;
	for (u = r; flag[u] == 0; u = prev[u]) flag[u] = 1;
	while (1) {
		for (p = adj[r]; p != NULL; p = p->next) if (flag[p->v] == 1 && prev[p->v] != r) break;
		if (p != NULL) {
			for (w = prev[p->v]; w != r; w = prev[w]) flag[w] = 0;
			prev[p->v] = r;
			continue;
		}
		for (u = prev[r]; u != r; u = prev[u]) {
			for (p = adj[u]; p != NULL; p = p->next) if (flag[p->v] == 1 && prev[p->v] != u) break;
			if (p != NULL) {
				for (w = prev[p->v]; w != u; w = prev[w]) flag[w] = 0;
				prev[p->v] = u;
				break;
			}
		}
		if (u == r) break;
		else r = u;
	}
	
	int sum = 0;
	for (i = 1; i <= N; i++) sum += flag[i];
	printf("%d\n", sum);
	for (u = prev[r]; u != r; u = prev[u]) printf("%d\n", u);
	printf("%d\n", r);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
int vis[maxn];
int main()
{
    int n,m;
    int maxx=maxn;
    int minn=0;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int l,r;
        scanf("%d%d",&l,&r);
        minn=max(minn,l);
        maxx=min(maxx,r);
    }
    int x=maxx-minn+1;
    if(x<0)
        x=0;
    printf("%d\n",x);
    return 0;
}


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

void intervals(int max, vector<int>& G) {
    int g = 1;
    while (g <= max) {
        G.push_back(g);
        g = 3 * g + 1;
    }
}

int insertionSort(int N, int A[], int g) {
    int n_swapped = 0;
    for (int i = g; i < N; i++) {
        int v = A[i];
        int iBef = i - g;
        while (0 <= iBef && v < A[iBef]) {
            A[iBef + g] = A[iBef];
            iBef -= g;
            n_swapped++;
        }
        A[iBef + g] = v;
    }
    return n_swapped;
}

int shellSort(int N, int A[], vector<int>& G) {
    int n_swapped = 0;
    for (int i = G.size() - 1; i >= 0; i--) {
        n_swapped += insertionSort(N, A, G[i]);
    }
    return n_swapped;
}

/* ALDS1_2_D: Shell Sort */
int main() {
    int N;
    cin >> N;

    int A[N];
    for (int i = 0; i < N; i++)
        scanf("%d\n", &A[i]);

    vector<int> G;
    intervals(N, G);

    int n_swapped = shellSort(N, A, G);

    cout << G.size() << endl << G.back();
    for (int i = G.size() - 2; i >= 0; i--)
        printf(" %d", G[i]);
    cout << endl;

    cout << n_swapped << endl;
    for (int i = 0; i < N; i++)
        printf("%d\n", A[i]);

    return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

// 1-indexed
class BIT{
  private:
    int n;
    vector<int> bit;
  public:
    BIT(){};
    BIT(int _n) : bit(_n + 1, 0), n(_n){}
    int sum(int i){
      int s= 0;
      while(i > 0){
        s += bit[i];
        i -= i & -i;
      }
      return s;
    }
    int sum(int i, int j){
      return sum(j) - sum(i - 1);
    }
    void add(int i,int x){
      while(i <= n){
        bit[i] += x;
        i += i & -i;
      }
    }

    int query(int i){
      return bit[i] - bit[i-1];
    }
};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  BIT bit(n);
  int ans = 0;
  rep(i, n){
    int k;
    cin >> k;
    bit.add(k, 1);
    int x = bit.sum(k - 1);
    if(x == 0){
      ++ans;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)

using ull = unsigned long long;
const ull b = 1000000007;

ull f(string s) {
  ull h = 0;
  rep(i, s.size()) h = b * h + s[i];
  return h;
}

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

  string s;
  cin >> s;
  int n = s.size();
  int q;
  cin >> q;
  vector<unordered_set<ull>> hashs(n + 1);
  rep(i, q) {
    string t;
    cin >> t;
    int m = t.size();
    if (m > n) continue;
    hashs[m].insert(f(t));
  }

  vector<int> l(n, -1);
  ull bb = 1;
  for (int len = 1; len <= n; len++) {
    bb *= b;
    if (hashs[len].empty()) continue;
    ull h = f(s.substr(0, len));
    int r = len - 1;
    while (true) {
      if (hashs[len].count(h) && l[r] == -1) {
        l[r] = r - len + 1;
      }
      r++;
      if (r >= n) break;
      h = b * h - bb * s[r - len] + s[r];
    }
  }

  int cnt = 0;
  int r = -1;
  rep(i, n) {
    if (r < l[i]) {
      cnt++;
      r = i;
    }
  }

  cout << cnt << endl;
}



Measured memory_bytes: 9580
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false); 
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}	
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}		    
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}	    	  	
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}		
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}	
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}	    	
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}	    	
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}				
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        
        int T = 1;//in.nextInt();
        for(int t = 1; t <= T; t++)
        {
            int n = in.nextInt();
            int m = in.nextInt();
            int p = in.nextInt();
            
            if(n+m+p>=22) out.write("bust\n");
            else out.write("win\n");
            
            
        }
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 21332
// finish date: 2018/2/05

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>>
        vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    int n;
    cin >> n;
    string s0;
    cin >> s0;

    int tempVal = 0;
    bool exVal = false;
    vi val_s0;
    rep(i, s0.length()) {
        if (s0[i] < 'A') {
            tempVal *= 10;
            tempVal += s0[i] - '0';
            exVal = true;
        }
        if (exVal && (s0[i] >= 'A' || i == s0.length() - 1)) {
            val_s0.push_back(-1000000000 + tempVal);
            tempVal = 0;
            exVal = false;
        }
        if (s0[i] >= 'A') {
            val_s0.push_back(s0[i]);
        }
    }


    rep(k, n) {
        string s;
        cin >> s;
        vi val_s;
        rep(i, s.length()) {
            if (s[i] < 'A') {
                tempVal *= 10;
                tempVal += s[i] - '0';
                exVal = true;
            }
            if (exVal && (s[i] >= 'A' || i == s.length() - 1)) {
                val_s.push_back(-1000000000 + tempVal);
                tempVal = 0;
                exVal = false;
            }
            if (s[i] >= 'A') {
                val_s.push_back(s[i]);
            }
        }
        rep(i, min(val_s0.size(), val_s.size())) {
            if (val_s0[i] > val_s[i]) {
                cout << "-" << endl;
                break;
            } else if (val_s0[i] < val_s[i]) {
                cout << "+" << endl;
                break;
            }
            if (i == min(val_s0.size(), val_s.size())-1) {
                if (val_s0.size() <= val_s.size()) {
                    cout << "+" << endl;
                } else {
                    cout << "-" << endl;
                }
            }
        }
    }


    return 0;
}




Measured memory_bytes: 3212
import java.util.*;
import java.math.*;
import java.lang.*;
import java.io.*;
 
public class Main{
  public static void main(String args[]) throws IOException{
    Scanner s=new Scanner(System.in);
   
    int n=s.nextInt();
   int k=s.nextInt();
    
    String ss=s.next();
    
    System.out.println(ss.substring(0,k-1)+(char)(ss.charAt(k-1)+32)+ss.substring(k));
  }
}

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

using namespace std;

int p[25];

int main(){
	int n;
	scanf("%d", &n);
	
	for(int i = 0; i < n; i ++){
		scanf("%d", &p[i]);
	}
	
	int ans = 0;
	for(int i = 1; i < n-1; i ++){
		if(p[i] > p[i-1] && p[i] < p[i+1]){
			ans ++;
		}else if(p[i] < p[i-1] && p[i] > p[i+1]){
			ans ++;
		}
	}
	printf("%d", ans);
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cstdlib>
#include<algorithm>

using namespace std;

int N;

int A, B;
bool flipped;

vector<int> ans;

void no(){
	printf("-1\n");
	exit(0);
}

int vals[300300];

void solve(){
	if(A + B > N + 1) no();
	if((long long)A * B < N) no();
	for(int i = 0; i < A; ++i){
		vals[i] = 1;
	}
	vals[0] = B;
	int tmp = A + B - 1;
	tmp = N - tmp;
	for(int i = 1; i < A; ++i){
		int cur = min(tmp, B - 1);
		vals[i] += cur;
		tmp -= cur;
	}
	int m = 0;
	for(int i = 0; i < A; ++i){
		int cur = vals[i];
		for(int x = m + cur; x > m; --x){
			ans.push_back(x);
		}
		m += cur;
	}
}

int main(){
	scanf("%d%d%d", &N, &A, &B);
	solve();
	for(int i = 0; i < N; ++i){
		printf("%d%c", ans[i], i == N - 1 ? '\n' : ' ');
	}
	return 0;
}


Measured memory_bytes: 4208
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
typedef long long lint;
const int N=131080;
int n;
class pair{
	public:
		lint x,y;
		friend bool operator < (const pair &a,const pair &b);
};

bool operator < (const pair &a,const pair &b){
	return a.x==b.x?a.y<b.y:a.x<b.x;
}

inline int nxi(){
	int x=0;
	char c;
	while((c=getchar())>'9'||c<'0');
	while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
	return x;
}

inline int x_bound(std::vector <pair> &vt,const lint _lim){
	int l=0,r=vt.size()-1,mid;
	while(l!=r){
		mid=(l+r+1)>>1;
		if(vt[mid].x>_lim) r=mid-1;
		else l=mid;
	}
	return l;
}

inline int y_bound(std::vector <pair> &vt,const lint _lim){
	int l=0,r=vt.size()-1,mid;
	while(l!=r){
		mid=(l+r)>>1;
		if(vt[mid].y>_lim) l=mid+1;
		else r=mid;
	}
	return l;
}

inline void sanitize_seq(std::vector <pair> &vt){
	const int sz=vt.size();
	int p1=1,p2=1;
	for(; p1<sz; ++p1){
		if(vt[p1].x!=vt[p2-1].x) vt[p2++]=vt[p1];
	}
	while((int)vt.size()>p2) vt.pop_back();
}

namespace G{
	int cnt,nxt[N][2],wt[N][2];
	lint lim_w;
	std::vector <pair> vt[N];

	inline void add(const int a,const int b,const int v){
		bool f=nxt[a][0]>0;
		nxt[a][f]=b,wt[a][f]=v;
	}

	void dfs(const int x){
		if(!nxt[x][0]){
			vt[x].push_back((pair){0,0});
			return;
		}
		dfs(nxt[x][0]);
		dfs(nxt[x][1]);
		if(vt[nxt[x][0]].size()>vt[nxt[x][1]].size()){
			std::swap(nxt[x][0],nxt[x][1]);
			std::swap(wt[x][0],wt[x][1]);
		}

		const int c0=nxt[x][0],c1=nxt[x][1];
		const lint v0=wt[x][0],v1=wt[x][1];
		const int lim_l=vt[c0].size();

		for(int i=0,j,lst_j=-1; i<lim_l; ++i){
			const lint _lim=lim_w-vt[c0][i].y-v0-v1;
			j=x_bound(vt[c1],_lim);
			if(vt[c1][j].x>_lim) continue;
			if(j!=lst_j){
				lst_j=j;
				vt[x].push_back((pair){vt[c0][i].x+v0,vt[c1][j].y+v1});
			}
		}
		for(int i=lim_l-1,j,lst_j=-1; i>=0; --i){
			const lint _lim=lim_w-vt[c0][i].x-v0-v1;
			j=y_bound(vt[c1],_lim);
			if(vt[c1][j].y>_lim) continue;
			if(j!=lst_j){
				lst_j=j;
				vt[x].push_back((pair){vt[c1][j].x+v1,vt[c0][i].y+v0});
			}
		}
		std::sort(vt[x].begin(),vt[x].end());
		sanitize_seq(vt[x]);
	}

	bool jdg(const lint tgt){
		lim_w=tgt;
		for(int i=1; i<=n; ++i){
			vt[i].clear();
		}
		dfs(1);
		return !vt[1].empty();
	}
}

inline lint solve(){
	lint l=0,r=2e10,mid;
	while(l!=r){
		mid=(l+r)>>1;
		if(G::jdg(mid)) r=mid;
		else l=mid+1;
	}
	return l;
}

int main(){
	n=nxi();
	for(int i=2; i<=n; ++i){
		int fr=nxi();
		G::add(fr,i,nxi());
	}
	printf("%lld\n",solve());
	return 0;
}

Measured memory_bytes: 27892
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(ll)>
using namespace std;
#define All(v) (v).begin(),(v).end()
typedef long long ll;
const ll mod = 1000000007;
const ll inf = mod*mod;
const ll d5 = 114514;
const double EPS = 1e-10;
const double INF = 1e+10;
const double PI = acos(-1.0);
int main(){
    ll n;
    cin>>n;
    vector<pair<ll,ll>> r(n),b(n);
    for(ll i=0;i<n;i++){
        cin>>r[i].second>>r[i].first;
    }
    for(ll i=0;i<n;i++){
        cin>>b[i].first>>b[i].second;
    }
    sort(All(r));
    reverse(All(r));
    sort(All(b));
    ll res = 0;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<n;j++){
            if(b[i].first>r[j].second&&b[i].second>r[j].first){
                //cout<<b[i].first<<' '<<r[j].first<<endl;
                res++;
                r[j].first=inf;
                r[j].second=inf;
                break;
            }
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
/*
 * author :Sadik Hassan(_sad_)
 *
*/
#include "bits/stdc++.h"
using namespace std;
using   ll =          long long;
using   ld =          long double;
#define nl            "\n"
#define pb            push_back
#define fi            first
#define se            second
#define MP            make_pair
#define PI            (acos(-1.0))
#define rep1(i,n)     for(int i=1;i<=n;i++)
#define rep(i,n)      for(int i=0;i<n;i++)
#define SZ(s)         (int)s.size()
#define all(x)        (x).begin(), (x).end()
#define rall(x)       (x).rbegin(), (x).rend()
#define w(t)          int t;cin>>t;while(t--)
#define TSU(s)        transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSL(s)        transform(s.begin(),s.end(),s.begin(),::tolower);
#define _SAD()     	  ios::sync_with_stdio(0),cin.tie(0),cout.tie(0),cout<<fixed<<setprecision(15);

typedef vector<int> vi;
typedef vector<ll> vii;
typedef set<int> si;
typedef set<ll> sii;
/*---------------------------------------------------------------------*/

const int N = (int)1e6+1;
const int MOD =(int)1e9+7;
const ll INF = (ll)1e18+5;

int main()
{
    _SAD();
    ll n,m,k;
    cin>>n>>m>>k;
    vii a(n+1,0),b(m+1,0);
    for(int i=0;i<n;i++)
    {
        int ax;
     cin>>ax;
     a[i+1]=a[i]+ax;
    }
    for(int i=0;i<m;i++)
    {
        int bx;
        cin>>bx;
        b[i+1]=b[i]+bx;
    }
  ll cnt=0,ans=0,gu=m;
  for(ll i=0;i<=n;i++)
  {
  	for(ll j=gu;j>=0;j--)
  	{
  		if(a[i]+b[j]<=k)
  		{
  			cnt=max(cnt,i+j);
  			gu=j;
  			break;
  		}
  	}
  }
   cout <<cnt<<nl;
    return 0;
}


Measured memory_bytes: 6348
#include <bits/stdc++.h>
#define maxn 100005
using namespace std;
priority_queue<int>que;
int a[maxn];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        que.push(a[i]);
    }
    if(n==1){
        while(m){
            a[1]/=2;
            m--;
            if(a[1]==0) break;
        }
        cout<<a[1]<<endl;
        return 0;
    }
    while(m){
        int val=que.top();
        que.pop();
        while(m&&que.top()<=val){
            val/=2;
            m--;
        }
        que.push(val);
    }
    long long res=0;
    while(!que.empty()){
        res+=que.top();
        que.pop();
    }
    printf("%lld\n",res);
    return 0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

string s;

int main(void) {
  // Here your code !
  cin >> s;

  int ans;

  if (s == "SUN") ans = 7;
  else if (s == "MON") ans = 6;
  else if (s == "TUE") ans = 5;
  else if (s == "WED") ans = 4;
  else if (s == "THU") ans = 3;
  else if (s == "FRI") ans = 2;
  else if (s == "SAT") ans = 1;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int k, s,ans=0,i,j;
	scanf("%d%d", &k, &s);
	for (i = 0; i <= k; i++) {
		for (j = 0; j <= k; j++) {
			if ((s - i - j >= 0) &&( s - i - j <= k)) {
				ans++;
			}
		}
	}
	printf("%d", ans);
	
	return 0;
}

Measured memory_bytes: 128
N, M = [int(i) for i in input().split()]
masks = [0] * M

for i in range(M):
    inp = [int(j) for j in input().split()]
    k = inp[0]
    s = inp[1:]
    b = [0] * N
    for j in range(N):
        b[j] = "1" if j+1 in s else "0"
    masks[i] = int("".join(reversed(b)), 2)
    # print(list(reversed(b)))

ps = [int(p) for p in input().split()]
s = 0

for t in range(2**N):
    for i in range(M):
        v = masks[i] & t
        # print("i:", i)
        # print("t: {}\nm: {}\nv: {}\n\n".format(format(t, "b"), format(masks[i], "b"), format(v, "b")))
        if format(v, "b").count("1") % 2 != ps[i]:
            break
    else:
        # print("count")
        s += 1

print(s)

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

int main()
{
    int a, ac = 0, wa = 0, tle = 0, re = 0;
    scanf("%d", &a);
    for(int i = 0; i < a; i++){
        string su;
        cin >> su;
        if(su == "AC"){
            ac++;
        }else if(su == "WA"){
            wa++;
        }else if(su == "TLE"){
            tle++;
        }else if(su == "RE"){
            re++;
        }
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits.h>
#include <climits>
#include <map>
#include <unordered_map>
#include <cmath>
#include <set>
#include <unordered_set>
#include <iterator>
#include <deque>
#include <assert.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
ull min(ull x, ull y){ if (x<y) return x; return y;}
ull max(ull x, ull y){ if (x<y) return y; return x;}
ll min(ll x, ll y){ if (x<y) return x; return y;}
ll max(ll x, ll y){ if (x<y) return y; return x;}
double min(double x, double y){ if (x<y) return x; return y;}
double max(double x, double y){ if (x<y) return y; return x;}
ull gcd(ull x, ull y){
    if (!x) return y;
    if (!y) return x;
    if (x>y) swap(x,y);
    return gcd(x, y%x);
}
ull inv(ull a, ull c){ // a,c are coprime and a<c
    if (a==1){
        return 1;
    }
    return ((c-(c/a))*inv(c%a,c))%c;
}

int M = 2019, cnt[2019] = {0}, n, m = 0;
ll ans = 0;
string s;
int mod10(int x){
    if (!x) return 1;
    int z = mod10(x/2);
    z = (z*z)%M;
    if (x&1) z = (z*10)%M;
    return z;
}


int main(){
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    cin>>s;
    n = s.size();
    cnt[0]++;
    for (int i = n-1; i >= 0; i--){
        int d = s[i]-'0';
        m = (m + d*mod10(n-1-i))%2019;
        ans += cnt[m];
        cnt[m]++;
    }
    cout<<ans<<"\n";
    return 0;
}





Measured memory_bytes: 3468
#include <iostream>
#include <queue>
#include <climits>
using namespace std;
typedef unsigned long long int ll;
#define INFI LLONG_MAX
int main(){
	ll t=1;
	//cin>>t; 

	while(t--){
int n;
int h;
cin>>n;
cin>>h;
if(n%h==0)
cout<<n/h;
else
cout<<(n/h)+1;
}
}






   
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

// abc119d
int main() {
  int A,B,Q; cin >> A >> B >> Q;
  vector<ll> s(A+2), t(B+2);
  rep(i,A) cin >> s[i+1];
  rep(i,B) cin >> t[i+1];
  s[0] = t[0] = -LINF;
  s[A+1] = t[B+1] = LINF;

  rep(_,Q) {
    ll ans = LINF;
    ll x; cin >> x;
    rep(i,2) {
      if (i==1) swap(s,t);
      rep(j,2) {
        int idx = lower_bound(s.begin(), s.end(), x) - s.begin() -1 + j;
        ll sx = s[idx];
        rep(k,2) {
          int tIdx = lower_bound(t.begin(), t.end(), sx) - t.begin() -1 + k; 
          ll tx = t[tIdx];
          ll num = abs(sx - x);
          num += abs(sx - tx);
          chmin(ans, num);
        }
      }
    }
    swap(s,t);
    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 4832
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int main(){
  int W, N, cs=0;
  int cost[1001], weight[1001];
  int dp[1001];
  
  while(cin >> W, W){
    cin >> N;
    for(int i = 0 ; i < N ; i++){
      scanf("%d,%d", &cost[i], &weight[i]);
    }
    fill(dp, dp+1001, -1);
    dp[0] = 0;

    for(int i = 0 ; i < N ; i++){
      for(int j = W-weight[i] ; j >= 0 ; j--){
	if(dp[j] >= 0) dp[j+weight[i]] = max(dp[j+weight[i]], dp[j]+cost[i]);
      }
    }

    int Cost = 0, Weight = 0;
    
    for(int i = 0 ; i <= W ; i++){
      if(dp[i] > Cost){
	Cost = dp[i];
	Weight = i;
      }
    }
    printf("Case %d:\n%d\n%d\n", ++cs, Cost, Weight);
  }
  return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pairA
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    int n,k;
    cin>>n>>k;
    if(n%k==0)cout<<0<<endl;
    else cout<<1<<endl;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
H = list(map(int,input().split()))
r = [[] for i in range(N)]
for i in range(M):
    A,B = map(int,input().split())
    r[A-1].append(B-1)
    r[B-1].append(A-1)

ans = 0

for i in range(N):
    a = r[i]
    p = 0
    for j in range(len(a)):
        if H[i] > H[a[j]]:
            p += 1
    if p == len(a):
        ans += 1

print(ans)

Measured memory_bytes: 29396
H, W = map(int, input().split())

g = ["." + input() + "." for _ in range(H)]
g = ["." * (W + 2)] + g + ["." * (W + 2)]

for i in range(1, H + 1):
    for j in range(1, W + 1):
        if g[i][j] == "#" and g[i - 1][j] == "." and g[i][j + 1] == "." and g[i + 1][j] == "." and g[i][j - 1] == ".":
            print("No")
            exit()
print("Yes")

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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int y = (a % d == 0 ? a / d : a / d + 1);
    int x = (c % b == 0 ? c / b : c / b + 1);
    if (x == 1) cout << "Yes";
    else {
        if (x < y + 1) cout << "Yes";
        else cout << "No";
    }


    return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main(void){
    double num;
    for(;scanf("%lf",&num) != EOF;){
        if(num <= 48.00)
            printf("light fly\n");
        else if(num <= 51.00)
            printf("fly\n");
        else if(num <= 54.00)
            printf("bantam\n");
        else if(num <= 57.00)
            printf("feather\n");
        else if(num <= 60.00)
            printf("light\n");
        else if(num <= 64.00)
            printf("light welter\n");
        else if(num <= 69.00)
            printf("welter\n");
        else if(num <= 75.00)
            printf("light middle\n");
        else if(num <= 81.00)
            printf("middle\n");
        else if(num <= 91.00)
            printf("light heavy\n");
        else
            printf("heavy\n");
    }
    return 0;
}

Measured memory_bytes: 608
import sys


def solve(inp):
    (A, B) = map(int, inp.readline().strip().split(' '))

    if A >= 10 or B >= 10:
        return "-1"
    else:
        return str(A * B)


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

typedef long long ll;

int main() {
  ll x; cin >> x;
  ll ans = 0;

  ans += x / 11 * 2;
  if (x % 11 != 0) {
    ans += (x % 11 > 6) ? 2 : 1;
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    int x, a, b;
    cin >> x >> a >> b;
    if (b <= a) {
        cout << "delicious" << endl;
    } else {
        if (b - a <= x) {
            cout << "safe" << endl;
        } else {
            cout << "dangerous" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256