akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) { cout << ", "; first = false; }
    cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n);
  for (lli i=0; i<n; ++i) cin >> v[i];
}

int main() {
  lli h, w;
  cin >> h >> w;
  vector<string> v;
  read_n(v, h);
  auto e = remove_if(begin(v), end(v), [](auto& s) {
      return all_of(begin(s), end(s), [](auto c) { return c == '.'; });
  });
  h -= end(v) - e;
  vector<bool> b(w, true);
  for (lli j=0; j<h; ++j) {
    for (lli i=0; i<w; ++i) {
      if (v[j][i] != '.') b[i] = false;
    }
  }
  for (lli j=0; j<h; ++j) {
    lli i = 0;
    auto ee = remove_if(begin(v[j]), end(v[j]), [&](auto c) {
      return b[i++];
    });
    v[j].erase(ee, end(v[j]));
  }
  for (auto it=begin(v); it<e; ++it) cout << *it << endl;
  return 0;
}


Measured memory_bytes: 256
#include<string>
#include<iomanip>
#include<cmath>
#include <iostream>
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    int ats = 0;
    while(n>0)
    {
        n /=k;
        ats ++;
    }
    cout << ats;





}




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

using namespace std;
typedef long long ll;
typedef long double ld;
#define endl "\n"
#define all(v) v.begin(),v.end()
#define sz(v)  v.size()


void fast() {

    cin.tie(0);
    cin.sync_with_stdio(0);
}



int main() {
    fast();
    int n;cin>>n;
    int ans=0;
    for (int i = 1; i <=n ; ++i) {
        int nd=log10(i)+1;
        if((nd)%2==1)ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 512
///----> bismillahir rahmanir rahim <---- -- { ^ _ ^ }
///     { ^_^ }   { ^ _ ^ }



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


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi; ///VECTOR<VECTOR<INT>NAME>NAME 2
typedef vector<vl> vvl;///LONG LONG
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;///VECTOR WITH PAIR
typedef vector<pll> vll;
typedef double dl;

#define endl "\n"
#define PB push_back
#define F first
#define S second
#define as(a) (a).begin(),(a).end()
#define ras(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define over return 0;

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }


///--------> YOUR JOURNEY STARTS HERE <-------



int main(){

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

ll c=0;
for (int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                if(a[i]!=a[j] && a[j]!=a[k] && a[k]!=a[i]){
                    if((a[i]+a[j])>a[k] && ((a[k]+a[i])>a[j]) && ((a[j]+a[k])>a[i])){
                        c++;
                    }
                }
            }

    }
}
cout<<c<<endl;

over
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<typeinfo>
#include<complex>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a;i < b; i++)

ll exp(ll);

int main() {

	int a, p;
	cin >> a >> p;

	a *= 3;
	a += p;
	a /= 2;

	cout << a << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	final double EPS = 1e-8;
	Scanner sc;
	int a,p,q;
	void run() {
		sc = new Scanner(System.in);
		while (true) {
			p = sc.nextInt();
			q = sc.nextInt();
			a = sc.nextInt();
			int n = sc.nextInt();
			if ( (p|q|a|n) == 0 ) break;
			
			System.out.println(solve(n,1,1,0));
		}	
	}

	int solve(int n, int d,int prod, int sum) {
		int cnt = 0;
		for (int i=d;prod*i<=a;i++) {
			int lhs = p*(prod*i);
			int rhs = sum*i + prod;
			if(lhs < rhs*q) continue;
			if(lhs == rhs*q) {cnt++;continue;}
			if(n==1) continue;
			cnt += solve(n-1,i,prod*i,rhs);
			
		}
		return cnt;
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long ll;

const int N=1e6+5,Mo=998244353;

int pwr(int x,int y) {
	int z=1;
	for(;y;y>>=1,x=(ll)x*x%Mo)
		if (y&1) z=(ll)z*x%Mo;
	return z;
}

int n,m,fact[N],inv[N];

int C(int m,int n) {return (ll)fact[m]*inv[n]%Mo*inv[m-n]%Mo;}

int main() {
	scanf("%d%d",&n,&m);
	if (n<m) swap(n,m);
	int ans=0,inv2=pwr(2,Mo-2);
	fact[0]=1;fo(i,1,n+m) fact[i]=(ll)fact[i-1]*i%Mo;
	inv[n+m]=pwr(fact[n+m],Mo-2);fd(i,n+m-1,0) inv[i]=(ll)inv[i+1]*(i+1)%Mo;
	fo(i,1,m) (ans+=(ll)C(2*i,i)*C(n+m-2*i,n-i)%Mo*inv2%Mo)%=Mo;
	ans=(ll)ans*pwr(C(n+m,n),Mo-2)%Mo;
	(ans+=n)%=Mo; 
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 7936
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e17;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
const int N=1000005;

void solve()
{
    
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int p=0;
    for(int i=0;i<n;i++)
        p+=a[i];
    p=p/n;
    int ans=0;
    for(int i=0;i<n;i++)
        ans=ans+(p-a[i])*(p-a[i]);
    int ans1=0;
    for(int i=0;i<n;i++)
        ans1=ans1+(p+1-a[i])*(p+1-a[i]);
    cout<<min(ans,ans1)<<endl;
    
}

int32_t main()
{
    IOS;
    
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c,d,e,kioku,x;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	for(x=0; x<5; x++)
	{
		if(a<b)
		{
			kioku=a;
			a=b;
			b=kioku;
		}
		if(b<c)
		{
			kioku=b;
			b=c;
			c=kioku;
		}if(c<d)
		{
			kioku=c;
			c=d;
			d=kioku;
		}if(d<e)
		{
			kioku=d;
			d=e;
			e=kioku;
		}
	}
	printf("%d %d %d %d %d\n",a,b,c,d,e);
	return 0;
}

Measured memory_bytes: 596
//HovalHaq!
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1 << 17;

struct node {
	vector<int> N;
	int dlt = 0, dsn = 0;
} G[maxN];

void DFS_lt(int v, int u, int d) {
	G[v].dlt = d;
	for(int w : G[v].N) 
		if(w != u)
			DFS_lt(w, v, d + 1);
}

void DFS_sn(int v, int u, int d) {
	G[v].dsn = d;
	for(int w : G[v].N) 
		if(w != u)
			DFS_sn(w, v, d + 1);
}

int main() {
	int n, lt, sn; cin >> n >> lt >> sn;
	for(int i = 1; i < n; i++) {
		int u, v; cin >> u >> v;
		G[v].N.push_back(u);
		G[u].N.push_back(v);
	}
	DFS_lt(lt, -1, 0);
	DFS_sn(sn, -1, 0);
	int r = 0;
	for(int i = 1; i <= n; i++)
		if(G[i].N.size() == 1 && G[i].dlt < G[i].dsn)
			r = max(r, G[G[i].N[0]].dsn);
	cout << r;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];
int32_t main(){_

   map<int, int> M;
   for (int i = 1; i <= 9; ++i)
   {
      for (int j = 1; j <= 9; ++j)
      {
         M[i*j] = 1;
      }
   }
   
   cin >> n;
   if(M[n]){
      cout<<"Yes";
   }
   else{
      cout<<"No";
   }
   

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int N = 1e3 + 5;
#define int long long int

bool fun(int a, int b, int c) {
    if(a + b <= c) return false ;
    else if(a + c <= b) return false ;
    else if(b + c <= a) return false ;
    else return true ;
}

int32_t main() {
    IOS ;
    // int t ; cin >> t ; while(t--) {}
    int n ; cin >> n ; int arr[n] ;
    for(int i=0; i<n; i++) cin >> arr[i] ;
    
    int cnt = 0 ;
    for(int i=0; i<n-2; i++) {
        for(int j=i+1; j<n-1; j++) {
            for(int k=j+1; k<n; k++) {
                if((arr[i] != arr[j]) and 
                (arr[j] != arr[k]) and (arr[i] != arr[k])) {
                    if(fun(arr[i], arr[j], arr[k])) cnt++ ;
                }
                
            }
        }
    }
    
    cout << cnt ;
    return 0 ;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

int main() {
	int n; cin >> n;
	vector<long long> a(n), imos(n + 1);
	long long sum = 0;
	for (int i = 0; i < n; ++i) cin >> a[i], sum += a[i];
	for (int i = 1; i < n; ++i)
		imos[i] = imos[i - 1] + a[i - 1];
	long long ans = 1e18;
	for (int i = 0; i <= n; ++i) {
		ans = min(ans, abs(imos[i] - (sum - imos[i])));
		//cout << imos[i] << " " << sum - imos[i] << endl;
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 3328
H,W,N=map(int,input().split())
d={}
for i in range(N):
    a,b=map(int,input().split())
    d[(a-1,b-1)]=1
#print(d)
X=[-1,0,1,-1,0,1,-1,0,1]
Y=[-1,-1,-1,0,0,0,1,1,1]
C=[0 for i in range(10)]
D={}
#print(d)
for i in d.keys():
    #print(i[0])
    for j in range(9):
        D[(i[0]+X[j],i[1]+Y[j])]=1
#print(D)
for i in D.keys():
    cnt=0
    for j in range(9):
        if (i[0]+X[j])<0 or (H-1)<(i[0]+X[j]) or (i[1]+Y[j])<0 or (W-1)<(i[1]+Y[j]):
            cnt=0
            break
        elif (i[0]+X[j],i[1]+Y[j]) in d:
            cnt+=1
    #print(i,cnt)
    C[cnt]+=1
C[0]=(H-2)*(W-2)-sum(C[1:])
#print(C)
for i in range(10):
    print(C[i])

Measured memory_bytes: 150260
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>

using namespace std;

using lli = long long;

#define debug(var) cout << (#var) << ": " << (var) << endl;

template<class T>
void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) cout << ", ";
    cout << x;
    first = false;
  }
  cout << endl;
}

#define dump_array(a) cout << (#a) << ": "; dump_array_impl(a)

lli mod = 1000000007;
int h, w, k;
vector<int> line_cnts, ptns;

int main() {
  cin >> h >> w >> k;
  
  for (int p=0; p<(1<<(w-1)); ++p) {
    bool ok = true;
    for (int q=p; q!=0; q>>=1) {
      if (q&1 && q&2) {
	ok = false;
	break;
      }
    }
    if (ok) ptns.push_back(p);
  }

  line_cnts = vector<int>(w-1, 0);

  for (auto p : ptns) {
    for (int i=0, mask=1; i<w-1; ++i, mask<<=1) {
      if (p&mask) ++line_cnts[i];
    }
  }

  vector<lli> pos_from(w, 0), pos_to(w, 0);
  pos_from[0] = 1;
  for (int j=0; j<h; ++j) {
    fill(begin(pos_to), end(pos_to), 0);
    for (int i=0; i<w; ++i) {
      lli pass = ptns.size();
      if (i>0) {
	pos_to[i-1] += pos_from[i] * line_cnts[i-1];
	pos_to[i-1] %= mod;
	pass -= line_cnts[i-1];
      }
      if (i<w-1) {
	pos_to[i+1] += pos_from[i] * line_cnts[i];
	pos_to[i+1] %= mod;
	pass -= line_cnts[i];
      }
      pos_to[i] += pos_from[i] * pass;
      pos_to[i] %= mod;
    }
    copy(begin(pos_to), end(pos_to), begin(pos_from));
  }

  cout << pos_to[k-1] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define max 1000000
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define lli long long int
#define endl '\n'
#define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define InputArray(a,n) for(int i=0;i<n;i++) cin >> a[i];
#define CopyArray(a,temp,n) for(int i=0;i<n;i++) temp[i]=a[i];
#define PrintArray(a,n) for(int i=0;i<n;i++) cout << a[i] << " "; cout << endl;
using namespace std;


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

	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	if(a == 0) {
		cout << 1 << endl;
	} else if(b == 0) {
		cout << 2 << endl;
	} else if(c == 0) {
		cout << 3 << endl;
	} else if(d == 0) {
		cout << 4 << endl;
	} else {
		cout << 5 << endl;
	}

	cerr << "time = " << (clock() / CLOCKS_PER_SEC) << " sec" << '\n';
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin>>a>>b;
	cout<<(a-1)*(b-1)<<'\n';
	return 0;
}


Measured memory_bytes: 892
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int count = 0;
    int ans = 0;
    for(int i=1;i<=N;i++){
      for(int j=1;j<=N;j++){
        if(i % 2 == 1 && i % j == 0){
          count++;
        }
      }
      if(count==8){
        ans++;
      }
      count = 0;
    }
    System.out.println(ans);
  }
}


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

int main()
{
	int n,x;
  	cin>>n>>x;
  	int d=0,l;
  	int ans=1;
  	for(int i=0 ; i<n ; ++i)
    {
    	cin>>l;
      	d+=l;
      	ans+=(d<=x);
      	if(d>x)
        break;
    }
  	cout<<ans<<endl;
  	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main()
{
    ft
    long long t,i,j,n,m,l=0,r,c[10][10];
    string s;
    cin>>n;
    memset(c,0,sizeof(c));
    for(i=1;i<=n;i++)
    {
        s=to_string(i);
        if((i%10)!=0)
        {
            c[s[0]-48][i%10]++;
        }
    }
    for(i=1;i<=9;i++)
    {
        for(j=1;j<=9;j++)
        {
            l+=(c[i][j]*c[j][i]);
        }
    }
    cout<<l<<"\n";
    return 0;
}

Measured memory_bytes: 3720
import java.util.Scanner;
public class Main {

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

		int n = sc.nextInt(); //??¶?????°
		int m = sc.nextInt(); //?§?????????°
		int i;
		int max=0;
		int mmax=0;
		int kyoginm=0;
		int result=0;

		int[] kyogi = new int[n];
		int[] hu = new int[m];
		int[] score = new int[n];

		for(i = 0; i < n; i++){
			kyogi[i] = sc.nextInt();
			score[i] = 0;//?????¨
		}

		for(i = 0; i < m; i++){
			hu[i] = sc.nextInt(); //??????
		}


		for(i = 0; i < m; i++){
			for(int j = 0; j < n; j++){
				if(hu[i] >= kyogi[j]){
					score[j] = score[j]+1;
					break;
				}
			}
		}

		for(i = 0; i < n; i++){
			if(max < score[i]){
				max = score[i];
				result = i+1;
			}
		}

		System.out.println(result);

	}
}

Measured memory_bytes: 33288
import numpy as np
import math as m

def main(**kwargs):
    r = "No"

    if (A[0][0] in B) and (A[0][1] in B) and (A[0][2] in B):
        r = "Yes"
    
    if (A[1][0] in B) and (A[1][1] in B) and (A[1][2] in B):
        r = "Yes"
    
    if (A[2][0] in B) and (A[2][1] in B) and (A[2][2] in B):
        r = "Yes"
    
    if (A[0][0] in B) and (A[1][0] in B) and (A[2][0] in B):
        r = "Yes"
    
    if (A[0][1] in B) and (A[1][1] in B) and (A[2][1] in B):
        r = "Yes"
    
    if (A[0][2] in B) and (A[1][2] in B) and (A[2][2] in B):
        r = "Yes"
    
    if (A[0][0] in B) and (A[1][1] in B) and (A[2][2] in B):
        r = "Yes"
    
    if (A[0][2] in B) and (A[1][1] in B) and (A[2][0] in B):
        r = "Yes"
    
    return r

if __name__ == "__main__":
    A = np.zeros((3, 3), dtype="int")
    cin = np.array(input().split(" ")).astype("int")
    A[0][0], A[0][1], A[0][2] = cin
    cin = np.array(input().split(" ")).astype("int")
    A[1][0], A[1][1], A[1][2] = cin
    cin = np.array(input().split(" ")).astype("int")
    A[2][0], A[2][1], A[2][2] = cin

    cin = np.array(input().split(" ")).astype("int")
    n, *_ = cin

    B = np.zeros(n, dtype="int")

    for i in range(n):
        cin = np.array(input().split(" ")).astype("int")
        B[i], *_ = cin
    
    cout = main(A=A, n=n, B=B)
    print(cout)

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll W, H, x, y, r;
	cin>>W>>H>>x>>y>>r;
	if (0<=x-r && x+r<=W && 0<=y-r && y+r<=H){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}
	return 0;
}


Measured memory_bytes: 3120
#include<iostream>
#include<cmath>
using namespace std;
int  main()
{
   int n;
   cin>>n;
   int a[n+1];
   for(int i=1;i<=n;i++)
   	 cin>>a[i];
   	long long mmin=0x3f3f3f3f;
   	for(int i=1;i<=100;i++)
   	{
   		long long sum=0;
   		for(int h=1;h<=n;h++)
   		  sum+=(a[h]-i)*(a[h]-i);
   		mmin=min(sum,mmin);  
	   }
   cout<<mmin;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;

template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return minimum(head, tail...); }

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

int main()
{
  ll N;
  std::cin >> N;
  std::vector<ll> vd(N, 0LL);
  for (auto& x : vd) std::cin >> x;

  std::sort(vd.begin(), vd.end(), std::less<>());
  ll ans = vd[N/2] - vd[N/2-1];
  print(ans);

  return 0;
}


Measured memory_bytes: 1024
#include<vector>
#include<iostream>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<deque>
#define ll long long
using namespace std;
#define BUF_SIZE 1048576
char _buf[BUF_SIZE],*_is=_buf,*_it=_buf;
inline char rdc(){
	if (_is==_it) _it=(_is=_buf)+fread(_buf,1,BUF_SIZE,stdin);
	return *_is++;
}
inline void rdi(int &x){
	int f=0;
	register char ch=rdc();
	while ((ch<'0' or ch>'9') and (ch^'-')) ch=rdc();
	if (ch=='-') f=1,ch=rdc();
	while (ch>='0' and ch<='9') x=(x<<3)+(x<<1)+(ch^'0'),ch=rdc();
	if(f) x=-x;
}
inline void rdi(ll &x){
	ll f=0;
	register char ch=rdc();
	while ((ch<'0' or ch>'9') and (ch^'-')) ch=rdc();
	if (ch=='-') f=1,ch=rdc();
	while (ch>='0' and ch<='9') x=(x<<3)+(x<<1)+(ch^'0'),ch=rdc();
	if(f) x=-x;
}
inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline void _write(int x){
	write(x);
	putchar(' ');
}
inline void print(int x){
	write(x);
	putchar('\n');
}
inline void write(ll x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline void _write(ll x){
	write(x);
	putchar(' ');
}
inline void print(ll x){
	write(x);
	putchar('\n');
}
#define int ll
int res,n,d;
int a[200005];
int dpl[200005],dpr[200005]; 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	rdi(n),rdi(d);
	int i,j;
	for(i=0;i<n;++i) rdi(a[i]),res+=a[i];
	res+=(n-1)*d;
	dpr[0]=a[0];
	for(i=1;i<n;++i) dpr[i]=min(a[i],dpr[i-1]+d);
	dpl[n-1]=a[n-1];
	for(i=n-2;~i;--i) dpl[i]=min(a[i],dpl[i+1]+d);
	for(i=1;i<n-1;++i) res+=min(dpl[i],dpr[i]);
	print(res);
	return 0;
}

Measured memory_bytes: 6016
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

//つねに10億7などの剰余をとる構造体
//参考: https://www.youtube.com/watch?v=L8grWxBlIZ4&t=9858
//参考: https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#4-%E7%B4%AF%E4%B9%97-an
int mod  = MODA;
struct modint {
	ll x;
	modint (ll x):x(x%mod){}
	modint& operator+=(const modint a){
		(x += a.x ) %= mod;
		return *this;
	}
	modint& operator-=(const modint a){
		(x -= a.x ) %= mod;
		if (x < 0) x += mod;
		return *this;
	}
	modint& operator*=(const modint a){
		(x *= a.x ) %= mod;
		return *this;
	}
	modint& operator/=(modint a){
		ll exp = mod - 2;
		while(exp > 0){
			if(exp & 1) *this *= a.x;
			a *= a.x;
			exp >>= 1;
		}
		return *this;
	}
	modint operator+(const modint a) const{
		modint res(*this);
		return res+=a;
	}
	modint operator-(const modint a) const{
		modint res(*this);
		return res-=a;
	}
	modint operator*(const modint a) const{
		modint res(*this);
		return res*=a;
	}
	modint operator/(const modint a) const{
		modint res(*this);
		return res/=a;
	}
};
modint modpow(modint x, ll n){
	modint res=1;
	while(n > 0){
		if(n & 1) res = res * x.x;
		x = x * x;
		n >>= 1;
	}
	return res;
}

int main() {
	modint ans = 1;
	int tmp;
	int n;
	cin >> n;
	vector< pair<int, ll>> lo(200001);
	REP(i, 200001) lo[i] = make_pair(-1, (ll) 0);
	int prec = 0, c;
	REP(i, n){
		cin >> c;
		if(lo[c].first != i-1 && lo[c].first != -1) ans += lo[c].second;
		lo[c] = make_pair(i, ans.x); 
	}
	cout << ans.x << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
using ll=long long;
using namespace std;
ll a[110000];
map <ll,ll> b;
int main(){
  ll n,c=0,d=0;
  cin>>n;
  rep(i,0,n){cin>>a[i];b[a[i]]++;}
  rep(i,0,b.size()){
    if(b[i]>0)c++;
    if(b[i]>1)d+=b[i]-1;
  }
  cout<<c-d%2;
}


Measured memory_bytes: 7296
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[550][550];

int main(){
  vi vec;
  cin >> n;
  rep(i,0,n){
    cin >> m;
    vec.pb(m);
  }
  sort(all(vec),greater<ll>());
  l = 1;
  m = vec[0];
  rep(i,1,vec.sz){
    if(vec[i] < m){
      l++;
      m = vec[i];
    }
  }
  print(l);
  return 0;
}

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


int main() {
    int n, k; cin >> n >> k;
    int i=0;
    while(n){
        n /= k;
        i++;
    }
    cout << i;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

  int n,a[105],sum,min,max,i,j,k;
  int ave;
    for(j=0;j<21;j++){
    scanf("%d",&n);
    if(n==0)
      break;
    else{
      sum = 0;
      min = 1000;
      max = 0;
      for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        sum += a[i];
      }
      for(k=0;k<n;k++){
        if(min>a[k])min=a[k];
        if(max<a[k])max=a[k];
      }
      ave = (sum - min -max)/(n-2);
      printf("%d\n",ave);
    }
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}
int main (){
    int n;
    int ans=0;
    cin >> n;
    vector<int>a(100000,0);
    rep(i,n){
        int b;
        cin >> b;
        a[b]++;
    }
    for(int i=1;i<=99998;i++){
        int sum=a[i-1]+a[i]+a[i+1];
        ans=max(ans,sum);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 640
use std::io;

pub trait ExRead {
    fn read_line(&mut self) -> io::Result<String>;
    fn read_to_string(&mut self) -> io::Result<String>;
}

impl ExRead for io::StdinLock<'_> {
    fn read_line(&mut self) -> io::Result<String> {
        let mut buf = String::new();
        io::BufRead::read_line(self, &mut buf).map(|_| buf)
    }

    fn read_to_string(&mut self) -> io::Result<String> {
        self.read_line().map(|s| s.trim().to_string())
    }
}

pub trait SplitAndParse<T: std::str::FromStr> {
    type Result;
    fn split_and_parse(self) -> Self::Result;
}

impl<'a, T: std::str::FromStr> SplitAndParse<T> for &'a str {
    type Result = Result<Vec<T>, <T as std::str::FromStr>::Err>;
    fn split_and_parse(self) -> Self::Result {
        self.split_whitespace()
            .map(|e| e.parse())
            .fold(Ok(Vec::new()),
                |acc, e| acc.and_then(|mut v| e.map(|parsed| {v.push(parsed); v})))
    }
}

extern crate num;

pub fn abs_diff<T: num::Num + Copy + Ord>(n1: T, n2: T) -> T {
    std::cmp::max(n1, n2) - std::cmp::min(n1, n2)
}

fn main() {
    let n: usize;
    let mut a: Vec<(usize, usize)>;

    {
        let stdin = std::io::stdin();
        let mut lkin = stdin.lock();
        let mut input = lkin.read_line().unwrap().split_and_parse().unwrap().into_iter();
        n = input.next().unwrap();
        a = (1..=n).zip(lkin.read_line().unwrap().split_and_parse().unwrap()).collect();
    }

    a.sort_by_key(|&(_, a)| a);
    let mut dp = Vec::new();
    dp.resize(n+1, Vec::new());
    dp.iter_mut().enumerate().for_each(|(i, v)| v.resize(n-i+1, 0));
    for i in 1..=n {
        dp[i][0] = dp[i-1][0] + a[n-i].1 * abs_diff(a[n-i].0, i);
        dp[0][i] = dp[0][i-1] + a[n-i].1 * abs_diff(a[n-i].0, n-i+1);
    }

    for pick in 2..=n {
        for r_align in 1..pick {
            dp[pick - r_align][r_align] = std::cmp::max(
                dp[pick - r_align - 1][r_align] + a[n-pick].1 * abs_diff(a[n-pick].0, pick - r_align),
                dp[pick - r_align][r_align - 1] + a[n-pick].1 * abs_diff(a[n-pick].0, n - r_align + 1)
            );
        }
    }
  
    println!("{}", dp.iter().max_by_key(|v| v.last().unwrap()).unwrap().last().unwrap());
}


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

#define P pair<int,int>
#define vv vector<vector<int>>
#define v vector<int>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;

int main()
{
  int x,n;
  cin >>x>>n;
  int a[n];
  rep(i,n)
  {
    int tmp;
    cin >>tmp;
    a[i]=tmp;
  }

  int ans=10000000;
  int num=0;
  for(int i=0;i<=200;i++)
  {
    int tmo=0;
    rep(c,n)
    {
      if(a[c]==i)
      {
        tmo=1;

      }

    }
    if(tmo==1)continue;
    int sa=abs(i-x);
    if(sa<ans)
    {
      ans=sa;
      num=i;
    }
  }

  printf("%d",num);
  return 0;


}


Measured memory_bytes: 3764
#include <stdio.h>
int main(void) {
    int a,b,result;
    scanf("%d %d",&a,&b);
    if(a <= 5) {
        result = 0;
    } else if(a <= 12) {
        result = b /2;
    } else {
        result = b;
    }
    printf("%d\n",result);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int arr[100005];

int main(){

    int n,k,i,x,y,ans=INT_MAX,temp;
    cin>>n>>k;
    for(i=1; i<=n; i++)cin>>arr[i];
    for(i=k; i<=n; i++){
        if(arr[i-k+1]>0){
            temp=arr[i];
            ans=min(ans,temp);
        }
        else if(arr[i]<0){
            temp=abs(arr[i-k+1]);
            ans=min(ans,temp);
        }
        else{
            x=abs(arr[i-k+1]);
            y=arr[i];
            temp=max(x,y)+min(x,y)*2;
            ans=min(ans,temp);
        }
        ///cout<<i<<' '<<ans<<endl;
    }
    cout<<ans<<endl;

    return 0;
}


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

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    if(s[0] == '0' || s[n - 1] == '1'){
        cout << -1 << endl;
        return 0;
    }
    for(int i = 0; i < n - 1; i++){
        if(s[i] != s[n - 2 - i]){
            cout << -1 << endl;
            return 0;
        }
    }
    int k = 1;
    int l = n;
    for(int i = 0; i < n - 1; i++){
        if(s[i] == '1'){
            cout << k << " " << k + 1 << endl;
            k++;
        }
        else{
            cout << k << " " << l << endl;
            l--;
        }
    }
}


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

int main() {
    int n, c=0;
    int a[100];
    cin>>n;
    for (int i = 1; i <= n; i++)
    {
        cin>>a[i-1];
        if(a[i-1]%2!=0 && i%2!=0)
            c++;
    }
    cout<<c<<endl;
    return 0;
}

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

#define mod 1000000007

// dp[i][j][l] はiまで, 奇妙さj, 未定がl個の場合の数
ll dp[51][2501][51];

int main() {
    int n, k;
    cin >> n >> k;
    
    dp[1][0][0] = 1;
    dp[1][0][1] = 1;
    for (int i = 1; i < n; ++i) {
        for (int j = 0; j <= i*i; ++j) {
            for (int l = 0; l <= i; ++l) {
                dp[i][j][l] %= mod;
                if(l != 0) dp[i+1][j+l*2][l-1] += dp[i][j][l] * (l*l);
                dp[i+1][j+l*2][l] += dp[i][j][l] * (2*l+1);
                dp[i+1][j+l*2][l+1] += dp[i][j][l];
            }
        }
    }
    dp[n][k][0] %= mod;
    cout << dp[n][k][0];
    return 0;
}

Measured memory_bytes: 49024
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
//using
using namespace std;
/*using vi = vector <int>;
using vs = vector <string>;
using vc = vector <char>;*/
//vector<vector<int> > hyou(N, vector<int>(N));
//define
#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
//グローバル変数宣言
int a=0,b=0,c=0,e=0,n=0,k=0;


signed main(){
   cin>>n;
   vector<int>d(n);
   rep(i,n)cin>>d[i];
   a=n/2;
   sort(d.begin(),d.end());
   b=d[a-1];
   c=d[a];
   print(c-b);
}


Measured memory_bytes: 4048
S = input()

tf_list = []

for i in range(len(S)):
    if i % 2 == 0:
       if S[i]  == 'R' or S[i] == 'U' or S[i] == 'D':
           tf_list.append(1)
       else:
            tf_list.append(0)
    else:
        if S[i] == 'L' or S[i] == 'U' or S[i] == 'D':
            tf_list.append(1)
        else:
            tf_list.append(0)

if sum(tf_list) == 1 * len(S):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
S = list(input())
T = list(input())
LS = len(S)
LT = len(T)
a = ""
for i in reversed(range(LS - LT + 1)):
    for j in range(LT):
        if S[i + j] != T[j] and S[i + j] != "?":
            break
        if j == LT - 1:
            for k in range(LT):
                S[i + k] = T[k]
            #print("".join(S))
            s = str("".join(S)).replace("?", "a")
            print(s)
            exit()
# S = S.replace("?", "a")
print("UNRESTORABLE")


Measured memory_bytes: 3064
import itertools
N = input()
ans = 0

def dfs(s):
  if s != '':
    if int(s) > int(N) :
      return 0
  
  ret = 1 if all(s.count(c) for c in '357') > 0 else 0
  
  for x in '357':
    ret += dfs(s + x)
  
  return ret

print(dfs(''))

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int dp[12][110] = {0};

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

    int N;
    cin >> N;
    vector<int> s(N);
    for(int i = 0; i < N; i++){
        cin >> s[i];
    }

    for(int i = 0; i < 10; i++){
        for(int j = 0; j <= N; j++){
            dp[i][j] = -1;
        }
    }

    dp[0][0] = 0;

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

    for(int j = 0; j < N; j++){
        for(int i  = 0; i < 10; i++){
            if(dp[i][j] >= 0){
                // 使わない場合
                chmax(dp[i][j+1], dp[i][j]);
                chmax(dp[((i+s[j])%10)][j+1], dp[i][j] + s[j]);
            }
        }
    }

    int ans = 0;
    for(int j = 1; j < 10; j++){
        chmax(ans, dp[j][N]);
    }

    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a,b,c,ex;
	scanf("%d %d %d",&a,&b,&c);
	if (a>b){
		ex=a;
		a=b;
		b=ex;
		}
	if (b>c){
		ex=b;
		b=c;
		c=ex;
		}
	if (a>b){
		ex=a;
		a=b;
		b=ex;
		}
	
	printf ("%d %d %d\n",a,b,c);
	return 0;
}

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

using namespace std;

int main()
{
  int n, m;
  cin >> n >> m;
  int ca = 0, p = 0;
  vector<int> s(n, 0);
  for(int i = 0; i < m; ++i)
  {
    int x;
    string r;
    cin >> x >> r;
    --x;
    if(s[x] >= 0)
    {
      if(r == "AC")
      {
        ++ca;
        p += s[x];
        s[x] = -1;
      }
      else// r == "WA"
      {
        ++s[x];
      }
    }
  }
  cout << ca << " " << p << endl;
  return 0;
}


Measured memory_bytes: 640
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def Partition(aa,p,r):
    x=aa[r]
    i=p-1
    for j in range(p,r):
        if aa[j]<=x:
            i+=1
            aa[i],aa[j]=aa[j],aa[i]
    aa[i+1],aa[r]=aa[r],aa[i+1]
    return i+1

def main():
    n=int(input())
    aa=list(map(int, input().split()))
    idx=Partition(aa,0,n-1)
    aa[idx]="["+str(aa[idx])+"]"
    print(*aa)
main()



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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> P(N);
  for (int i = 0; i < N; i++) cin >> P.at(i);

  vector<long> V(N + 1);
  for (long i = 0, sum = 0; i < N; i++) V.at(i + 1) = sum += P.at(i);
  
  long mx = 0;
  for (int i = 0; i + K < N + 1; i++) mx = max(mx, V.at(i + K) - V.at(i));

  cout << fixed << setprecision(6) << (mx + K) / 2.0 << "\n";
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
 
int main() {
	long long int  x,y;
	cin>>x>>y;
	
	vector <long long int >vec;
	for(int i=0;pow(2,i)<=1e18;i++)
	  {
	  	vec.push_back(pow(2,i));
	  }
	  //cout<<y/x;
	 int ans=lower_bound(vec.begin(),vec.end(),y/x)-vec.begin();
	 //cout<<ans<<"\n";
	 
	if(binary_search(vec.begin(),vec.end(),y/x)==true)
	  {
	  	ans=ans+1;
	  	//return 0;
	  	
	  }
	else{	
	  	
	  	//cout<<ans<<"\n";
	  }
	
	 
	   cout<<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
using namespace std;
template <class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b<a) {a = b; return 1;} return 0;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

double temp(int t, int h) {
    double s = t-h*0.006;
    return s;
}

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) {
        cin >> a[i];
    }
    sort(all(a));
    cout << abs(a[0]-a[a.size()-1]) << "\n";
}


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

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

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

#define NIL NULL

Node find(Node, int);
void insert(int);
void inorder(Node);
void preorder(Node);
void Delete(Node);
Node Minimum(Node);
Node Successor(Node);

Node root;

int main()
{
  int n, i, x;
  char com[20];
  Node t;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%s", com);

    if( com[0] == 'f' ){
      scanf("%d", &x);
      t = find(root, x);

      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    
    else if( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    
    else if( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    
    else if ( com[0] == 'd' ){
      scanf("%d", &x);
      Delete(find(root, x));
    }
  }
  
  return 0;
}

Node Minimum(Node x)
{

  while(x->left != NIL) x = x->left;
  return x;

}

/* ????´¢ */
Node find(Node root, int x)
{

  if(root == NIL || x == root->key) return root;
  if(x < root->key) return find(root->left, x);
  else return find(root->right, x);

}

Node Successor(Node x)
{

  Node y;

  if(x->right != NIL) return Minimum(x->right);

  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }

  return y;

}

/* ?????? */
void Delete(Node z)
{
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z-> right == NIL) y = z;
  else y = Successor(z);

  if(y->left != NIL) x = y->left;
  else x = y->right;

  if(x != NIL) x->parent = y->parent;

  if(y->parent == NIL) root = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;

  if(y != z) z->key = y->key;

}

/* ?????\ */
void insert(int k)
{

  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }

  z->parent = y;

  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;

}

/* ??????????????? */
void inorder(Node root)
{

  if(root != NIL){
    inorder(root->left);
    printf(" %d", root->key);
    inorder(root->right);
  }

}

/* ??????????????? */
void preorder(Node root)
{

  if(root != NIL){
    printf(" %d", root->key);
    preorder(root->left);
    preorder(root->right);
  }

}

Measured memory_bytes: 19364
array = []
while true
	#array = []
	#while true
		line = gets
		#exit if line.nil?
		break if line.nil?
		a,b = line.chomp.split(' ').map(&:to_i)
		array[a] = array[a] ? array[a] + 1 : 1
		array[b] = array[b] ? array[b] + 1 : 1
		if a==0 && b==0
			i = 3
			status = array[1]%2==1 && array[2]%2==1 ? 'OK' : 'NG'
			#status = array[1]%2==0 ||  array[2]%2==0 ? 'NG' :'OK'
			#p "now #{status}, #{array[1]} #{array[2]}"
			while array[i]
				if array[i]%2!=0
					status = 'NG'
					break
				end
				i = i+1
			end
			puts status
			array = []
		end
	#end
end

Measured memory_bytes: 8720
// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let ha: Vec<i64> = read_vec();
    let mut h = ha[0];
    let a     = ha[1];

    let mut count = 1;
    loop {
        h -= a;
        if h <= 0 { break; }
        count += 1;
    }

    println!("{}", count);
}


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

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << " " << max(a + b - n, 0l) << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 256
# 三井住友信託銀行プログラミングコンテスト2019: B – Tax Rate
N = int(input())

X = int(N / 1.08)
X_min = int(X * 1.08)
X_max = int((X + 1) * 1.08)

if X_min == N:
    print(X)
elif X_max == N:
    print(X + 1)
else:
    print(':(')

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

int main() {
  int N;
  scanf("%d", &N);
  char W[105][15];
  for (int i = 0; i < N; i++) {
    scanf("%s", W[i]);
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j) continue;
      if (strcmp(W[i], W[j]) == 0) {
        puts("No");
        return 0;
      }
    }
  }
  for (int i = 0; i < N - 1; i++) {
    int len = strlen(W[i]);
    if (W[i][len - 1] != W[i + 1][0]) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}


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


char S[5];
int main(){
	string s ;
	scanf("%s",S);
	s = S ;

	if(s.size() == 2 ) cout << s << endl ;
	else {
		for(int i = 0 ; i < s.size() ; i++ ){
			cout << s[s.size() - 1 - i ];
		}
		cout << endl ;
	}

	return 0 ;
}

Measured memory_bytes: 256
#include <iostream>

#define rep(i, N) for (LL i = 0; i < N; ++i)
typedef long long int LL;

using namespace std;

int main() {
    LL A, B;
    LL limit = 2;
    cin >> A >> B;
    LL ans = 0;
    rep(i, limit) ans += (A > B) ? A-- : B--;

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


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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];

// template starts
typedef long long int ll;

// template ends here

void solve(){
	// code starts from here
	int N;
	cin >> N;
	vector<ll> vec(N);
	input(vec,N);
	
	sort(all(vec));
	reverse(all(vec));
	ll sum = vec[0];
	
	for(int i = 2; i < N; i++){
		sum += vec[i/2];
	}
	cout << sum << endl;
}

int main(){
 	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	int T;
	T = 1;
	while(T--){
		solve();
	}

	return 0;
}


Measured memory_bytes: 4780
n, k = map(int, input().split())
mod = pow(10, 9) + 7
ans = 0
for i in range(k, n+2):
    #小さい方からi個選ぶ
    mini = i*(i-1)//2
    maxa = (2*n-i+1)*i//2
    ans = (ans + (maxa - mini + 1)% mod)% mod
print(ans)


Measured memory_bytes: 9028
# https://atcoder.jp/contests/abc142/tasks/abc142_b
# -*- coding: utf-8 -*-

get_str = list(map(int, input().strip().split()))
friend_cnt = get_str[0]
toll_thr = get_str[1]
atoll_val = list(map(int, input().strip().split()))

ok_cnt = 0
for i in range(friend_cnt):
    if atoll_val[i] >= toll_thr:
        ok_cnt += 1

print(ok_cnt)

Measured memory_bytes: 11916
n=int(input())
a=[0]*n
a=list(map(int,input().split()))
a=sorted(a)
maxnum=a[-1]
check=[True]*(maxnum+1)
before=0

for x in a:
    if (before==x):
        check[x]=False
        continue
    num=2
    while num*x<=maxnum:
        check[x*num]=False
        num+=1
    before=x

ans=0
for i in a:
    ans+=check[i]
    
print(ans)

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

int main() {
  int min_x = 0, max_x, min_y = 0, max_y, N;
  int x, y, a;
  cin >> max_x >> max_y >> N;

  for(int i = 0; i < N; i++) {
    cin >> x >> y >> a;
    if(a == 1 && x > min_x) min_x = max(min_x, x);
    else if(a == 2) max_x = min(max_x, x);
    else if(a == 3) min_y = max(min_y, y);
    else if(a == 4) max_y = min(max_y, y);
  }
  if(max_x-min_x <= 0 || max_y-min_y <= 0) cout << 0 << endl;
  else cout << (max_x-min_x) * (max_y-min_y)<< endl;
}



Measured memory_bytes: 3636
N = int(input())
L = list(map(int, input().split()))

L.sort(reverse=True)

count = 0
for i in range(N):
  for j in range(i + 1, N):
    for k in range(j + 1, N):
      if L[i] != L[j] and L[j] != L[k] and L[i] < L[j] + L[k]:
        count += 1

print(count)

Measured memory_bytes: 9192