akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
//long long a[505],b[505];
int s[505][505];//,f[505][505];
int n,m,l,x,y;
int main()
{
    //freopen("express.in","r",stdin);
   // freopen("express.out","w",stdout);
    scanf("%d%d%d",&n,&m,&l);
    for(register int i=1;i<=m;i++)
    {
        scanf("%d%d",&x,&y);
        //a[x]++;
        //b[y]++;
        s[x][y]++;
        //f[y][x]++;
    }
    //for(register int i=500;i>=1;i--)
    //    a[i]=a[i]+a[i+1];
    //for(register int i=1;i<=500;i++)
    //    b[i]=b[i]+b[i-1];
    for(register int i=1;i<=500;i++)
        for(register int j=i+1;j<=500;j++)
            s[i][j]+=s[i][j-1];
    //for(register int i=1;i<=500;i++)
    //    for(register int j=i;j>=1;j--)
    //        f[i][j]+=f[i][j+1];
    for(register int i=1;i<=500;i++)
        for(register int j=i-1;j>=1;j--)
            s[j][i]+=s[j+1][i];
    for(register int i=1;i<=l;i++)
    {
        scanf("%d%d",&x,&y);
        printf("%d\n",s[x][y]);
    }
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N,L;
  cin>>N>>L;
  string S[N];
  REP(i,N)cin>>S[i];
  sort(S,S+N);
  REP(i,N)cout<<S[i];
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,i,j;
  scanf("%d",&n);
  int c[n+1],s[n+1],f[n+1];
  for(i=1;i<n;i++)
    scanf("%d%d%d",&c[i],&s[i],&f[i]);
  int time[n+1];
  time[n]=0;
  for(i=n-1;i>=1;i--){
    for(j=i;j<n-1;j++){
      while(c[j]+s[j]>s[j+1])
        s[j+1]+=f[j+1];
    }
    time[i]=s[n-1]+c[n-1];
  }
  for(i=1;i<=n;i++)
    printf("%d\n",time[i]);
  return 0;
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  string s;
  cin >> s;
  
  bool ok = true;
  int n = s.size();
  REP(i,n){
    if(s[i] != s[n-i-1]) ok = false;
  }
  
  int m = n/2;
  REP(i,m){
    if(s[i] != s[m-i-1]) ok = false;
  }
  
  
  if(ok) cout << "Yes" << endl;
  else  cout << "No" << endl;
  
}

Measured memory_bytes: 3596
local mab = math.abs
local mmi, mma = math.min, math.max
local h, w = io.read("*n", "*n", "*l")
local t = {}
for i = 1, w do
  t[i] = {}
end
for i = 1, h do
  local s = io.read()
  for j = 1, w do
    t[j][i] = s:byte(j)
  end
end

local inf = 1000000007
local function solve(a, b)
  local cost = {}
  for i = 0, 2 * h + 1 do
    cost[i + 1] = {}
    for j = 0, h + 1 do
      cost[i + 1][j + 1] = 0
    end
  end
  for a_used = 0, h - 1 do
    for b_used = 0, h - 1 do
      if a[h - a_used] == b[h - b_used] then
        local sum_used = a_used + b_used
        cost[sum_used + 1][a_used + 1] = cost[sum_used + 1][a_used + 1] + 1
      end
    end
  end
  for sum_used = 2 * h, 2, -1 do
    for a_used = h, 1, -1 do
      local b_used = sum_used - a_used
      if 1 <= b_used and b_used <= h then
        cost[sum_used - 2 + 1][a_used - 1 + 1]
        = cost[sum_used - 2 + 1][a_used - 1 + 1] + cost[sum_used + 1][a_used + 1]
      end
    end
  end
  local dp1, dp2 = {}, {}
  for i = 1, h + 1 do
    dp1[i] = inf
  end
  dp1[1] = 0
  for i = 0, h * 2 - 1 do
    local a_used_min = mma(0, i - h)
    local a_used_max = mmi(h, i)
    local src = i % 2 == 0 and dp1 or dp2
    local dst = i % 2 == 0 and dp2 or dp1
    for j = 1, h + 1 do
      dst[j] = inf
    end
    for a_used = a_used_min, a_used_max do
      local b_used = i - a_used
      if a_used < h then
        dst[a_used + 2] = mmi(dst[a_used + 2], src[a_used + 1] + cost[i + 1][a_used + 1])
      end
      if b_used < h then
        dst[a_used + 1] = mmi(dst[a_used + 1], src[a_used + 1] + cost[i + 1][a_used + 1])
      end
    end
  end
  return dp1[h + 1]
end

local ret = 0
for i = 1, w - 1 do
  ret = ret + solve(t[i], t[i + 1])
end
print(ret)


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

int main(){
  int n,k; cin>>n>>k;

  int m=(n-2)*(n-1)/2;
  if(k>m)cout<<-1<<endl;
  else{
    cout<<n-1+m-k<<endl;
    for(int i=2; i<=n; ++i){
      cout<<1<<" "<<i<<endl;
    }
    int cnt=0;
    for(int i=2; i<=n-1; ++i){
      for(int j=i+1; j<=n; ++j){
        if(cnt==m-k)goto end;
        cout<<i<<" "<<j<<endl;
        ++cnt;
      }
    }
    end:;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<string>v;
string s;
int main()
{
	int k;
	cin>>s;
	cin>>k;
	for(int i=0;i<s.length();i++)
	{
		for(int j=i;j<s.length()&&j<i+k;j++)
			v.push_back(s.substr(i,j-i+1));
	}
	sort(v.begin(),v.end());
	k--;
	v.erase(unique(v.begin(),v.end()),v.end());
	printf("%s\n",v[k].c_str());
	return 0;
}

Measured memory_bytes: 1660
#include<iostream>
using namespace std;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL);
#define f(i,p,q) for(int i=p;i<q;i++)

int main()
{  sync;
int  n;cin>>n;
     int a=n/2;
     int b=n-a;
     cout<<a*b;

}


Measured memory_bytes: 256
n=int(input())
if n==1:
  print('ACL')
if n==2:
  print('ACLACL')
if n==3:
  print('ACLACLACL')
if n==4:
  print('ACLACLACLACL')
if n==5:
  print('ACLACLACLACLACL')
  

Measured memory_bytes: 9092
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll N;
  cin >> N;
  ll C[N], S[N], F[N];
  REP(i, N - 1) { cin >> C[i] >> S[i] >> F[i]; }

  REP(i, N - 1) {
    ll sum = S[i] + C[i];
    FOR(j, i + 1, N - 1) {
      if (sum < S[j]) {
        sum = S[j] + C[j];
      } else {
        if (sum % F[j] == 0) {
          sum += C[j];
        } else {
          sum += F[j] - sum % F[j] + C[j];
        }
      }
    }
    cout << sum << endl;
  }
  cout << 0;
  return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) (a.begin(), a.end())

int main(){
    while(1){
        int n,x,cnt = 0;
        cin >> n >> x;
        if(!n && !x)return 0;
        REP(i,1,n+1)REP(j,i+1,n+1)REP(k,j+1,n+1)
            if(i + j + k == x)cnt++;

        cout << cnt << endl;
    }

    return 0;
}



Measured memory_bytes: 3080
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		int num = Integer.parseInt(line);

		StringBuilder ans = new StringBuilder();
		int x = 3;
		for (int i = 3; i <= num; i++) {

			if (i % 3 == 0  || i % 10 == 3) {
				ans.append(" " + i);

			} else{
				while ( x >= 1 ) {
					if (x %10 == 3) {
						ans.append(" " + i);
						break;
					}
					x/=10;
				}

			}
			x = i;
			x ++;
		}

		String d = ans.toString();
		System.out.println(d);
	}

//330番台がかぶっているのでそれをなんとかする
}



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

using namespace std;

long f(long p, long k, vector<int> *W)
{
    long i = 0;
    long t = 0;
    long sum = 0;

    while (i < W->size() && t < k)
    {
        if (sum + W->at(i) <= p)
        {
            sum += W->at(i);
            i++;
        }
        else
        {
            sum = 0;
            t++;
        }
    }

    return i;
}

int main()
{
    long n, k;
    cin >> n >> k;
    vector<int> W(n);
    for (long i = 0; i < n; i++)
    {
        cin >> W.at(i);
    }

    long l = 0;
    long r = 100000 * 10000; // k_max * w_max
    long mid;
    while (r - l > 1)
    {
        mid = (l + r) / 2;
        long v = f(mid, k, &W);
        if (v >= n)
        {
            r = mid;
        }
        else
        {
            l = mid;
        }
    }
    cout << r << endl;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
bool matris[22][22];
long long int dp[2197152][22];
const long long int md=1000000007;
long long int yeet;
int n;
long long int dpf(int mask,int last)
{
	// cout << mask << "\n";
	if(dp[mask][last]!=-1)
		return dp[mask][last];
	if(last==n+1)
	{
		return 1;
	}
	long long int muz=0;
	for(int i=0;i<n;i++)
	{
		if(((mask&(1<<i))==0)&&(matris[i][last-1]==1))
		{
			// cout << "uak ";
			muz+=dpf((mask|(1<<i)),last+1)%md;
			muz%=md;
		}
	}
	// cout << "\n";
	dp[mask][last]=muz;
	return muz;
}
int main()
{
	
	memset(dp,-1,sizeof(dp));
	ios_base::sync_with_stdio(false);
	cin >> n;
	yeet=(1<<n)-1;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin >> matris[i][j];
		}
	}
	cout << dpf(0,1);
}

Measured memory_bytes: 377984
mod, min_value = 2019, 2019
l, r = map(int, input().split())
length = r - l
for i in range(mod):
  for j in range(mod):
    if length - j - i <= 0 or min_value == 0:
      break
    min_value = min(min_value, (l + i) * (r - j) % mod)
print(min_value)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <ctime>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <queue>
#include <utility>
#include <cmath>
#include <functional>
#include <map>
#include <set>
using namespace std;
const int INF = 1000000009;

char a, b;
int main(){
	scanf("%c%*c%c", &a, &b);
	if((int)a < (int)b){
		printf("<\n");
	}else if((int)a > (int)b){
		printf(">\n");
	}else{
		printf("=\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string convertToTitle(long long int n) {
        string out="";
  
  
        while(n){
          //gdjfnvjdfnv
            n--;
            out = char((n%26)+'a') + out;
            n/=26;
          //new line
        }
        return out;
    }
int main(){
	int t=1;
	//cin >> t;
	while(t--){
		long long int n,k,z,i=0,count=0;
      	cin >> n ;
      	string s = convertToTitle(n);
      cout << s << endl;
	}
}

Measured memory_bytes: 3628
// #define _GLIBCXX_DEBUG
// #pragma GCC optimize("Ofast")
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, n) for (i64 i = 0; i < (i64)(n); ++i)
#define reps(i, s, n) for (i64 i = s; i < (i64)(n); ++i)

void solve() {
    int r;
    cin >> r;
    cout << 3 * r * r << "\n";
}
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    solve();
}

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

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

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

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

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


int main() {
  int N, K, S; cin >> N >> K >> S;
  if (S>=pow(10,8)) {
    rep(i,K) cout << S << " ";
    repr(i,K,N) cout << 1 << " ";
  }
  else {
    rep(i,K) cout << S << " ";
    repr(i,K,N) cout << S+1 << " ";
  }
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define pii pair<ll,ll>
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
  FAST/**/
   
   ll n;
   cin>>n;
   
   ll arr[n];
   rep(n)
        cin>>arr[i];
   ll arr1[n];
   rep(n)
        cin>>arr1[i];
        
   ll fr[n+1], fr1[n+1];
   memset(fr,0,sizeof(fr));
   memset(fr1,0,sizeof(fr1));
   
   rep(n)
        fr[arr[i]]++, fr1[arr1[i]]++;
   
   bool pos = 1;
   
   rep(n+1)
        if(fr[i] + fr1[i]>n)
            pos = 0;
   
   if(!pos)
   {
       cout<<"No\n";
       return 0;
   }
   
   reverse(arr1,arr1+n);
   ll l = n, r = -1;
   for(ll i=0;i<n;i++)
   {
       if(arr1[i] == arr[i])
            l = min(l,i), r = max(r,i);
   }
   
   if(l<=r)
   {
       //cout<<l<<" "<<r<<"\n";
       ll ptr = 0;
       for(ll i=l;i<=r;i++)
       {
           while(ptr<n &&(arr[ptr] == arr[l] || arr1[ptr] == arr[l]))
                ptr++;
           if(ptr == n)
           {
               pos = 0;
               break;
           }
           swap(arr1[i],arr1[ptr]);
           ptr++;
       }
   }
   
    if(!pos)
   {
       cout<<"No\n";
       return 0;
   }
   
   cout<<"Yes\n";
   rep(n)
        cout<<arr1[i]<<" ";
   
   return 0;        
}  

  
          
   

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


int main(){
    int N;
    long sum = 0;
    cin >> N;
    vector<int> height(N);
    rep(i, N){
        cin >> height.at(i);
    }
    for(int i = 1; i < N; i++){
        if(height.at(i-1) > height.at(i)){
            sum += height.at(i-1) - height.at(i);
            height.at(i) = height.at(i-1);
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 4044
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define N 200010
#define mod 924844033
#define g 5
using namespace std;

struct edge{int x, y, next;}A[N*2];
int n, l, p[N], jc[N], inv[N], size[N], x, y, a[N*4], b[N*4], R[N*4], n1, L, INV, ans[N];

inline int pow(int y, int x){
	int s=1, t=y;
	while(x){if(x&1)s=(ll)s*t%mod; t=(ll)t*t%mod; x>>=1;}
	return s;
}

inline void add(int x, int y){A[++l].x=x; A[l].y=y; A[l].next=p[x]; p[x]=l;}
inline void dfs(int x, int fa){
	size[x]=1;
	for(int i=p[x]; i; i=A[i].next)if(fa!=A[i].y){dfs(A[i].y, x); size[x]+=size[A[i].y];}
}

inline int C(int n, int m){return (ll)jc[n]*inv[m]%mod*inv[n-m]%mod;}

inline void NTT(int *a, int f){
	for(int i=0; i<n1; i++)if(i<R[i])swap(a[i], a[R[i]]);
	for(int i=1; i<n1; i<<=1){
		int wn=pow(g, (mod-1)/(i*2)); if(f==-1)wn=pow(wn, mod-2);
		for(int j=0; j<n1; j+=i*2){
			int w=1;
			for(int k=0; k<i; k++){
				int x=a[j+k], y=(ll)w*a[j+k+i]%mod;
				a[j+k]=x+y; a[j+k+i]=x-y;
				if(a[j+k]>=mod)a[j+k]-=mod; if(a[j+k+i]<0)a[j+k+i]+=mod;
				w=(ll)w*wn%mod;
			}
		}
	}
	if(f==-1)for(int i=0; i<n1; i++)a[i]=(ll)a[i]*INV%mod;
}
inline void solve(){
	memset(a, 0, sizeof(a)); memset(b, 0, sizeof(b));
	for(int i=1; i<=n; i++)a[size[i]]++;
	for(int i=0; i<=n; i++)a[i]=(ll)a[i]*jc[i]%mod;
	for(int i=0; i<=n; i++)b[i]=inv[n-i];
	n1=n+1;
	L=1; while((1<<L)<n1*2)L++; n1=1<<L;
	for(int i=0; i<n1; i++)R[i]=(R[i/2]/2)|((i&1)<<(L-1));
	
	INV=pow(n1, mod-2);
	NTT(a, 1); NTT(b, 1);
	for(int i=0; i<n1; i++)a[i]=(ll)a[i]*b[i]%mod;
	NTT(a, -1);
	
	for(int i=1; i<=n; i++)ans[i]=(ans[i]-(ll)a[n+i]*inv[i]%mod+mod)%mod;
}

int main(){
	scanf("%d", &n);
	l=0; memset(p, 0, sizeof(p));
	for(int i=1; i<=n-1; i++){scanf("%d%d", &x, &y); add(x, y); add(y, x);}
	dfs(1, 0);
	jc[0]=1; for(int i=1; i<=n; i++)jc[i]=(ll)jc[i-1]*i%mod;
	inv[0]=inv[1]=1; for(int i=2; i<=n; i++)inv[i]=(ll)(mod-mod/i)*inv[mod%i]%mod;
	for(int i=1; i<=n; i++)inv[i]=(ll)inv[i-1]*inv[i]%mod;
	for(int i=1; i<=n; i++)ans[i]=(ll)(n+1)*C(n, i)%mod;
	solve();
	for(int i=1; i<=n; i++)size[i]=n-size[i];
	solve();
	for(int i=1; i<=n; i++)printf("%d\n", ans[i]);
	return 0;
}

Measured memory_bytes: 24192
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define FORD(i,a,b) for(int i = (a); i >= (b); i--)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C& _a4, C _b4) { _a4 = min(_a4, _b4); }
template<class C> void maxi(C& _a4, C _b4) { _a4 = max(_a4, _b4); }

template<class TH> void _dbg(const char *sdbg, TH h) { cerr << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
	while (*sdbg != ',')cerr << *sdbg++; cerr << '=' << h << ','; _dbg(sdbg + 1, a...);
}

template<class T> ostream& operator<<(ostream& os, vector<T> V) {
	os << "["; for (auto& vv : V) os << vv << ","; os << "]";
	return os;
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) {
	return os << "(" << P.st << "," << P.nd << ")";
}


#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#endif

int32_t main(int32_t argc, char ** argv) {
	ios_base::sync_with_stdio(0);
	int n, m, k;
	cin >> n >> m >> k;
	REP(i, n + 1) {
		REP(j, m + 1) {
			if (j * (n - i) + i * (m - j) == k) {
				cout << "Yes";
				return 0;
			}
		}
	}
	cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int d[210][210];

int main()
{
    string s;
    cin >> s;
    cout << (s[0] == '9' || s[1] == '9' ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N, H, W, cnt = 0; cin >> N >> H >> W;
    for (int i = 0; i < N; ++i) {
        int a, b; cin >> a >> b;
        if (a >= H && b >= W) cnt++;
    }
    printf("%d\n", cnt);
}


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

int main() {
  int N, Y;
  cin >> N >> Y;
  rep(i, N + 1){
    rep(j, N + 1 - i){
      if(10000 * i + 5000 * j + 1000 * (N - i - j) == Y){
        cout << i << " " << j << " " << N - i - j << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <iterator>
#include <algorithm>
#include <map>
using namespace std;

int main(void){
    // Your code here!
    int a = 0;
    string s;
    cin >> s;
    for(int i = 0; i < 4; i++)
    if(s[i] == '-'){
        a--;
    }else{
        a++;
    }
    cout << a << endl;
}


Measured memory_bytes: 256
$j=$n=1e9
def f d,l,m,c,w
c<$n&&(l[0]?l.map{|i|f d+[i],l-[i],m,c+(d[-1][1]-i[1]).abs*(7+w*2),w-i[2]}:($n=c;$j=d))end
w=0
m=(1..gets.to_i).map{i=gets.split.map &:to_i;w+=i[2];i}
m.map{|i|f [i],m-[i],m,0,w-i[2]}
puts$j.map{|i|i[0]}.reverse*" "

Measured memory_bytes: 15760
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll n;
  cin >> n;

  ll sum = 0;
  vector<ll> v;
  for (int i = 1; i <= n; i++) {
    sum += i;
    v.push_back(i);
    if (sum >= n) {
      break;
    }
  }

  ll rem = sum - n;
  for (int i = 0; i < v.size(); i++) {
    if (v[i] == rem) continue;
    cout << v[i] << ln;
  }

  return 0;
}

Measured memory_bytes: 384
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
U = 2*10**5
MOD = 10**9+7
fact = [1]*(U+1)
fact_inv = [1]*(U+1)
for i in range(1,U+1):
  fact[i] = (fact[i-1]*i)%MOD
fact_inv[U] = pow(fact[U],MOD-2,MOD)
for i in range(U,0,-1):
	fact_inv[i-1] = (fact_inv[i]*i)%MOD
def comb(n,k):
  if k < 0 or k > n:
    return 0
  x = fact[n]
  x *= fact_inv[k]
  x %= MOD
  x *= fact_inv[n-k]
  x %= MOD
  return x

mod=10**9+7
p=a[:n-k+1][::-1]
q=a[k-1:]
ans=0
for i in range(1,len(p)+1):
    ans+=(q[i-1]-p[i-1])*comb(k-2+i,k-1)
    ans%=mod
print(ans)

Measured memory_bytes: 23888
#include <stdio.h>

int main(void) {
	int arr[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};
	int n;
	scanf("%d", &n);
	printf("%d", arr[n-1]);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

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

int h, w;
int sx, sy;
int gx, gy;
vector<string> s;

int bfs(){
    if(s[sy][sx]=='#') return 0;
    vector< vector<int> > steps(h, vector<int>(w));

    queue<pint> q;
    q.push(make_pair(sx, sy));

    while(!q.empty()){
        int x, y;
        tie(x, y) = q.front(); q.pop();
        for(int k = 0; k < 4; k++){
            int nx = x + dx[k];
            int ny = y + dy[k];
            if(nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
            if(s[ny][nx]=='#') continue;
            if(ny == sy && nx == sx) continue;
            if(steps[ny][nx] != 0) continue;
            steps[ny][nx] = steps[y][x] + 1;
            q.emplace(nx, ny);
        }
    }
    int ret = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            ret = max(ret, steps[i][j]);
        }
    }
    return ret;
}

void solve() {
    cin >> h >> w;
    s.resize(h);
    for(int i = 0; i < h; ++i){
        cin >> s[i];
    }
    int ans = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            sy = i;
            sx = j;
            int tmp = bfs();
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            :oyhhhhhhyo:    
#define next         .sdNNNmNNNNNNNmds. 
#define y0          -hNNNNy`yNNNNNN`/Nh-
#define y1          mNNNNNd+dNNNNNN+sNNm
#define yn          mNNNNNNNNy--:smNNNms
#define tm          .+oooooosyysooooo+- 
#define read               :yhy/        
#define rank              :mNmo         
#define index              ... 
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int N = 111111;
int a[N];
int n;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    map<int, int> mp;
    cin >> n;
    int cnt = 0;
    rep(i, 1, n) {
        cin >> a[i];
        if(mp[a[i]] == 0) {
            cnt++;
        }
        mp[a[i]]++;
    }
    if(cnt > 3) {
        cout << "No" << endl;
    } else if(cnt == 3) {
        vector<int> all;
        rall(p, mp) {
            all.pb(p.fi);
            if(p.se * 3 != n) {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << (((all[0] ^ all[1]) == all[2]) ? "Yes" : "No") << endl;
    } else if(cnt == 2) {
        int n0 = 0, n1 = 0;
        rall(p, mp) {
            if(p.fi) {
                n1 = p.se;
            } else {
                n0 = p.se;
            }
        }
        if(!n0) {
            cout << "No" << endl;
        } else {
            cout << (3 * n1 == 2 * n && 3 * n0 == n ? "Yes" : "No") << endl;
        }
    } else {
        cout << (a[1] ? "No" : "Yes") << endl;
    }
    return 0;
}


Measured memory_bytes: 4224
#include<iostream>
#include<set>
using namespace std;
int main()
{
  int V,d,N=1001,ans;
  while(cin>>V>>d){
    set<int> s;
    set<int>::iterator it;
    int f,g,t;
    f=g=1;
    for(int i=0;i<V;i++){
      t=f;
      f=(f+g)%N;
      g=t;
      s.insert(f);
    }
    ans=1;
    t=2;
    for(it=s.begin();it!=s.end();it++){
      if(*it - t >= d)ans++;
      t=*it;
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 0
#include <stdio.h>
#include <math.h>
#include <string.h>
int abs(int n){
    if(n > 0){
        return n;
    } else {
        return -n;
    }
}

int min(int a, int b){
    if(a > b){
        return b;
    } else {
        return a;
    }
}


int main(){
  int n;
  scanf("%d", &n);
  double sum = 0;
  for(int i= 0; i < n; i++){
      double x;
      scanf("%lf", &x);
      char u[3];
      scanf("%s", u);
     // printf("%d\n",x);
      if(strcmp(u, "JPY")==0){
          sum += x;
      } else {
          sum += x*380000;
      }
  }
  printf("%f", sum);
  return 0;
}




Measured memory_bytes: 128
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define For(i, a, b) for (i = a; i <= b; i++)
using namespace std;
const int N = 3e5 + 5, M = 11, PYZ = 1e9 + 7;
char s[N]; int n, to[M][2], f[N][M];
int main() {
	to[1][0] = 2; to[1][1] = 3; to[2][0] = 4; to[2][1] = 5; to[3][0] = 6; to[3][1] = 7;
	to[4][0] = to[4][1] = 2; to[5][0] = 2; to[5][1] = 3; to[6][0] = 8; to[6][1] = 3;
	to[7][0] = to[7][1] = 7; to[8][0] = to[8][1] = 6; f[0][1] = 1;
	int i, j; scanf("%s", s + 1); n = strlen(s + 1); For (i, 1, n) For (j, 1, 8) {
		if (s[i] != '1') f[i][to[j][0]] = (f[i][to[j][0]] + f[i - 1][j]) % PYZ;
		if (s[i] != '0') f[i][to[j][1]] = (f[i][to[j][1]] + f[i - 1][j]) % PYZ;
	}
	cout << (f[n][3] + f[n][7]) % PYZ << endl; return 0;
}

Measured memory_bytes: 13440
import java.util.Scanner;
 
 
public class Main{
     
    public static void main(String[] args){
    	
    	final Scanner sc = new Scanner(System.in);
    	
    	while(true){
    		final int N = sc.nextInt();
    		
    		if(N == 0){
    			break;
    		}
    		
    		final int[][] knows = new int[N][];
    		
    		for(int i = 0; i < N; i++){
    			final int M = sc.nextInt();
    			
    			knows[i] = new int[M];
    			
    			for(int j = 0; j < M; j++){
    				knows[i][j] = sc.nextInt();
    			}
    			
    		}
    		
    		final int K = sc.nextInt();
    		final int[] data = new int[K];
    		
    		for(int i = 0; i < K; i++){
    			data[i] = sc.nextInt();
    		}
    		
    		int conf = -1;
    		for(int i = 0; i < N; i++){
    			boolean flag = true;
    			
    			for(int d : data){
    				boolean in_flag = false;
    				
    				for(int m : knows[i]){
    					if(d == m){
    						in_flag = true;
    						break;
    					}
    				}
    				
    				if(!in_flag){
    					flag = false;
    					break;
    				}
    			}
    			
    			if(flag){
    				if(conf == -1){
    					conf = i + 1;
    				}else{
    					conf = -1;
    					break;
    				}
    			}
    		}
    		
    		System.out.println(conf);
    		
    	}
    	
    }
     
}

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

int main() {
  int a;
  cin >> a;
  
  cout << a + pow(a, 2) + pow(a, 3) << endl;
  return 0;
}


Measured memory_bytes: 4072
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <utility>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto&e:c)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif
template<class T> ostream& operator<<(ostream& os, vector<T> const& v){
    rep(i,v.size()) os << v[i] << (i+1==v.size()?"":" ");
    return os;
}

int main(){
    int n; cin >> n;
    while(n--){
        int cnt[66] = {0};
        int sum = 0;
        rep(i,8){
            int x;
            scanf("%x",&x);
            rep(j,32) if(x>>j & 1) cnt[j]++;
            sum += x;
        }
        int s; scanf("%x", &s);
        dump(vi(cnt,cnt+32));

        int K = 0;
        rep(i,32){
            if((sum>>i&1) != (s>>i&1)){
                K |= 1<<i;
                sum = sum - (1<<i)*cnt[i] + (1<<i)*(8-cnt[i]);
                cnt[i] = 8-cnt[i];
            }
        }
        printf("%x\n",K);
    }
}

Measured memory_bytes: 1220
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.NoSuchElementException;

public class Main {
	long N;
	ArrayList<Long> all,sub;
	HashMap<Long,Integer>[] map;
	public void createGoodNumber(){
		all = new ArrayList<Long>();
		ArrayDeque<Long> q = new ArrayDeque<Long>();
		q.add(2L);
		q.add(8L);
		while(q.size() > 0){
			long L = q.poll();
			all.add(L);
			if(L >= (long)1e17)continue;
			q.add(L * 10 + 2);
			q.add(L * 10 + 8);
		}
		Collections.sort(all);
	}

	public int dfs(int i,long n){
		if(n == 1){
			return 0;
		}

		if(map[i].containsKey(n)){
			return map[i].get(n);
		}

		int ret = -1;

		for(int j = i;j < sub.size();j++){
			if(n % sub.get(j) == 0){
				int tmp = dfs(j,n / sub.get(j));
				if(tmp+1 > 0){
					map[i].put(n, tmp+1);
					return tmp+1;
				}
			}
		}

		map[i].put(n,ret);
		return ret;
	}


	@SuppressWarnings("unchecked")
	public void solve() {
		N = nextLong();
		createGoodNumber();
		sub = new ArrayList<Long>();

		for(int i = 0;i < all.size();i++){
			if(N % all.get(i) == 0)sub.add(all.get(i));
		}

		if(N == 1){
			out.println(-1);
			return;
		}

		map = new HashMap[sub.size()];
		for(int i = 0;i < sub.size();i++){
			map[i] = new HashMap<Long,Integer>();
		}

		if(sub.size() == 0){
			out.println(-1);
		}else{
			out.println(dfs(0,N));
		}
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 72320
#!/usr/bin/env python3

import heapq

n, k = list(map(int, input().split()))
v = list(map(int, input().split()))

max_try = min(n, k)
ans = 0

for a in range(0, max_try+1):
    for b in range(0, max_try+1-a):
        c = k-(a+b)
        # print(a, b, c, "", end="")
        # print(a, b, c)
        ans_tmp = 0
        garbage = []
        heapq.heapify(garbage)
        for i in range(a):
            num = v[i]
            ans_tmp += num

            if num < 0:
                heapq.heappush(garbage, num)

        for i in range(b):
            num = v[-1-i]
            ans_tmp += num

            if num < 0:
                heapq.heappush(garbage, num)

        # print(garbage)
        for i in range(c):
            # print(garbage)
            if len(garbage) == 0:
                break
            num = -heapq.heappop(garbage)
            # print(num)
            ans_tmp += num
        # print()
        # print(ans_tmp)
        ans = max(ans, ans_tmp)

print(ans)


Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define All(v) (v).begin(),(v).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> p(n), c(m);
    rep(i, n) cin >> p[i].first >> p[i].second;
    rep(i, m) cin >> c[i].first >> c[i].second;
    rep(i,n){
        int d = mod;
        int res = 0;
        rep(j,m){
            int di = abs(p[i].first - c[j].first) + abs(p[i].second - c[j].second);
            if(di<d){
                d = di;
                res = j + 1;
            }
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9+7;
#define REP(i,j,n) for(int i=j;i<n;i++)
#define rep(i,n) REP(i,0,n)


// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans = -INF;
    ans = max(ans, a*c);
    ans = max(ans, a*d);
    ans = max(ans, b*c);
    ans = max(ans, b*d);
    cout << ans << endl;
}


Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

void solve(){
    int n;
    cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    vector<ll>v(100005);
    ll ans=1;
    rep(i,n){
        if(a[i])ans*=v[a[i]-1]-v[a[i]];
        else ans*=(3LL-v[0]);
        ans%=mod;
        v[a[i]]++;
    }
    cout<<ans<<"\n";
}
 
int main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 1792
extern crate proconio;
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut a = a.iter().zip(1..=(n as i64)).collect::<Vec<_>>();
    a.sort_by(|x, y| y.0.cmp(&x.0));
    let mut dp = vec![vec![0; n + 1]; n + 1];
    for i in 0..n {
        for j in 0..n {
            if i + j < n {
                let v = a[i + j].0;
                let k = a[i + j].1;
                // k -> i + 1
                dp[i + 1][j] =
                    std::cmp::max(dp[i + 1][j], dp[i][j] + v * (k - (i + 1) as i64).abs());
                // k -> n - j
                dp[i][j + 1] =
                    std::cmp::max(dp[i][j + 1], dp[i][j] + v * (k - (n - j) as i64).abs());
            }
        }
    }
    let mut ans = 0;
    for i in 0..=n {
        ans = std::cmp::max(ans, dp[i][n - i]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 33408
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 18
#define MAXM 150
#define MASK (1<<15)
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n,m;
P a[MAXM];
int dp[MASK];
int pos[MAXN];
int p2[300];
vector<int> v[MAXN];
void add(int &a,int b) {a+=b; if(a>=MOD) a-=MOD;}
void dec(int &a,int b) {a-=b; if(a<0) a+=MOD;}
int solve(int mask)
{
    if(__builtin_popcount(mask)==1) return 1;
    if(dp[mask]!=-1) return dp[mask];
    int &ans=dp[mask];
    ans=1;
    int sub=mask;
    do
    {
        sub=(sub-1)&mask;
        int sup=mask^sub;
        if(sub==0) break;
        int rem=(sub&3);
        if(rem==1||rem==2) continue;
        int res=1;
        for(int j=0;j<n;j++)
        {
            if(sub&(1<<j))
            {
                int cnt=__builtin_popcount(pos[j]&sup);
                if(!cnt)
                {
                    res=0;
                    break;
                }
                else res=1LL*res*(p2[cnt]-1)%MOD;
            }
            else if(sup&(1<<j))
            {
                int cnt=__builtin_popcount(pos[j]&sub);
                res=1LL*res*p2[cnt]%MOD;
            }
        }
        add(ans,1LL*res*solve(sub)%MOD);
    }while(sub!=mask);
    return ans;
}
int main()
{
    p2[0]=1;
    for(int i=1;i<=250;i++) p2[i]=2LL*p2[i-1]%MOD;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)
    {
        scanf("%d%d",&a[i].F,&a[i].S);
        a[i].F--;a[i].S--;
        pos[a[i].F]|=(1<<a[i].S);
    }
    memset(dp,-1,sizeof(dp));
    int ans=p2[m];
    dec(ans,solve((1<<n)-1));
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
double a,b,x,v,dv,ans;
double pi=4*atan(1.0);
void solve(){
  v=a*a*b;
  dv=v-x;

if (dv==0) {
  cout<<"0"<<endl;
}else if(dv/v<=0.5){
    ans=(dv*2)/(a*a);
    ans=atan(ans/a)/pi*180;
    printf("%lf\n",ans );
  }else{
    ans=(x*2)/(b*a);
    ans=atan(b/ans)/pi*180;
    printf("%lf\n",ans );
  }

}



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

  solve();
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
typedef long long ll;
inline ll max(ll a,ll b){
	return a>b?a:b;
}
inline ll min(ll a,ll b){
	return a<b?a:b;
}
ll m,n;
main(){
	scanf("%lld%lld",&n,&m);
	printf("%lld",min(n,m>>1)+(max(m-(n<<1),0ll)>>2));
}

Measured memory_bytes: 128
s = list(input())
n = len(s)
for j in range(n):
  s[j] = int(s[j])
a = 0
b = 0

for i in range(n):
  if i%2 == 0 and s[i] == 0:
    a += 1
  elif i%2 == 0 and s[i] == 1:
    b += 1
  elif i%2 == 1 and s[i] == 0:
    b += 1
  else:
    a += 1
print(min(a,b))


Measured memory_bytes: 81796
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <fstream>
#include <iterator>
using namespace std;

// Debug Vector
template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v)
{
    if (!v.empty())
    {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p)
{
    out << "[" << p.first << ", " << p.second << "]";
    return out;
}

typedef long long ll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    vector<int> diff(m - 1);

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

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

    // cout << x << endl;

    for (int i = 0; i < m - 1; i++)
    {
        diff[i] = x[i + 1] - x[i];
    }
    // cout << diff << endl;

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

    int sum = 0;
    for (int i = 0; i < m - n; i++)
    {
        sum += diff[i];
    }

    cout << sum << endl;
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(V),v.end()));
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

typedef long long ll;
using namespace std;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	string ans = "";
	cin >> s;
	REP(i, s.size()) {
		if (s[i] == 'B'&&ans != "")ans.erase(ans.end() - 1);
		else if(isdigit(s[i]))ans += s[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'


void solve(){
  int n;
  cin >> n;
  vector<int>a(n);
  forn(i,n)cin>>a[i];
  sort(all(a));
  debug() << imie(a);
  int m = n / 2;
  int ans = 0;
  if (n % 2 == 0){
    ans = a[m] - a[m-1];
  }
  cout << ans;
}

int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

1
322123


n - 1
0 ... (n-1) [res ... res] S - (n-1) ... S


 */

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

int main(){
    string s;
    cin >> s;
    int ans;
    int len;
    s.pop_back();
    while(s.size() > 0){
        if(s.size() % 2 != 0){
            s.pop_back();
        }else{
            if(s.substr(0,s.size()/2) == s.substr(s.size()/2)){
                ans = s.size();
                break;
            }else{
                s.pop_back();
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =998244353;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
    


  int main(){
     lint a,v,b,w,t;
     cin>>a>>v>>b>>w>>t;
     lint dis=abs(a-b);
     if((v-w)*t>=dis)cout<<"YES";
     else cout<<"NO";

  }
 
  
      
      
    
 
  
          
  

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

int const N=3e3+5, M=1e5+5, OO = 0x3f3f3f3f;

int n1,n2;
string s1,s2;

int mem[N][N];
int solve(int i, int j)
{
    if(i==n1 || j==n2)
        return 0;
    if(mem[i][j]!=-1)
        return mem[i][j];
    if(s1[i]==s2[j])
        return mem[i][j]=1+solve(i+1,j+1);
    int op1=solve(i+1,j);
    int op2=solve(i,j+1);
    return mem[i][j]=max(op1,op2);
}




void printTrack(int i, int j)
{
    if(i==n1 || j==n2)
        return;
    if(s1[i]==s2[j])
    {
        printf("%c",s1[i]);
        printTrack(i+1,j+1);
        return;
    }
    int optimal=solve(i,j);
    int op1=solve(i+1,j);
    int op2=solve(i,j+1);
    if(optimal==op1)
        printTrack(i+1,j);
    else
        printTrack(i,j+1);
}


int main()
{
//    freopen("input.txt","rt",stdin);
//    freopen("output.txt","wt",stdout);
    cin>>s1>>s2;
    n1=s1.size();
    n2=s2.size();
    memset(mem, -1, sizeof mem);
    solve(0,0);
    printTrack(0,0);
    puts("");
    return 0;
}


Measured memory_bytes: 35840