akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
int c(const void *val1,const void *val2){
    return *(int *)val2-*(int *)val1;
}
int main(void){
    int num,dp,dt,dc,i,t[100]={0},sum,sum1;
    scanf("%d\n%d %d\n%d",&num,&dp,&dt,&dc);
    for(i=0;scanf("%d",&t[i++]),i!=num;);
    qsort(t,num,4,c);
    sum=dc/dp;
    for(i=0,dc+=t[i],dp+=dt,sum1=dc/dp;sum<=sum1;){
        sum=sum1;
        dc+=t[++i];
        dp+=dt;
        sum1=dc/dp;
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<algorithm>

#define pb push_back
#define clr clear()
#define sz size()
#define FOR(i,a) for(int i=0;i<(int)(a);i++)

using namespace std;

typedef vector<int> vi;

struct BigInt{
  vi v;
  int s;

  BigInt(void){v.clr;s=0;}
  
  BigInt(int x){
    v.clr; s = 1;
    if(!x)s = 0;
    else if(x<0){
      s = -1;
      x *= -1;
    }
    while(x){
      v.pb(x%10);
      x/=10;
    }
  }

  BigInt(string &x){
    int a = 0;
    v.clr; s = 1;
    if(x[0]=='-'){
      s = -1;
      a = 1;
    }else if(x[0]=='0')s = 0;
    for(int i=x.sz-1;i>=a;i--)v.pb(x[i]-'0');
  }

  BigInt nega(void){
    BigInt t = *this;
    t.s *= -1;
    return t;
  }

  BigInt abs(void){
    if(s<0)return this->nega();
    return *this;
  }

  string bitos(void){
    if(!s)return "0";
    string res;
    FOR(i,v.sz)res += v[i]+'0';
    reverse(res.begin(),res.end());
    return (s<0)?('-'+res):res;
  }

  BigInt operator+(BigInt a){
    if(!s)return a;
    if(!a.s)return *this;
    if(s==a.s){
      if(a.v.sz < v.sz)return a+(*this);
      FOR(i,v.sz)a.v[i] += v[i];
      FOR(i,a.v.sz-1)
	if(a.v[i]>9){
	  a.v[i] -= 10;
	  a.v[i+1]++;
	}

      if(a.v[a.v.sz-1]>9){
	a.v[a.v.sz-1] -= 10;
	a.v.pb(1);
      }
      return a;
    }else{
      if(s<0)return a-(*this).nega();
      else return (*this)-a.nega();
    }
  }
  
  BigInt operator-(BigInt a){
    if(!s)return a.nega();
    if(!a.s)return *this;   
    if(s==a.s){
      if(a.abs() > this->abs())return (a-(*this)).nega();
      BigInt b = *this;
      FOR(i,a.v.sz)b.v[i] -= a.v[i];
      FOR(i,b.v.sz-1)
	if(b.v[i]<0){
	  b.v[i] += 10;
	  b.v[i+1]--;
	}

      while(b.v.sz && !b.v.back())b.v.pop_back();
      if(b.v.empty())b.s=0;
      return b;
    }else return (*this)+a.nega();
  }

  BigInt operator*(BigInt a){
    if(!s)return *this;
    if(!a.s)return a;

    BigInt b(0),tmp;    
    FOR(i,a.v.sz){
      tmp = *this;
      FOR(j,tmp.v.sz)tmp.v[j] *= a.v[i];
   
      FOR(j,tmp.v.sz){
	if(i+j<b.v.sz)b.v[i+j] += tmp.v[j];
	else b.v.pb(tmp.v[j]);
      }
    }

    FOR(i,b.v.sz){
      if(b.v[i]>9){
	if(i+1<b.v.sz)b.v[i+1] += b.v[i]/10;
	else b.v.pb(b.v[i]/10);
	b.v[i] %= 10;
      }
    }
    b.s = s*a.s;
    return b;
  }

  void operator=(BigInt a){v = a.v;s = a.s;}

  bool operator==(BigInt a){
    if(s!=a.s)return false;
    if(!s)return true;
    if(v.sz!=a.v.sz)return false;
    FOR(i,v.sz)if(v[i]!=a.v[i])return false;
    return true;
  }

  bool operator<(BigInt a){
    if(s!=a.s)return s<a.s;
    if(!s)return false;
    int d = v.sz - a.v.sz;
    if(d)return 0>d*s;
    for(int i=v.sz-1;i>=0;i--){
      d = v[i] - a.v[i];
      if(d)return 0>d*s;
    }
    return false;
  }

  bool operator<=(BigInt a){return (*this==a)||(*this<a);}
  bool operator>(BigInt a){return !(*this<=a);}
  bool operator>=(BigInt a){return !(*this<a);}
};

int main(){
  int n;
  BigInt ans(1);

  for(int i=2;i<=1501;i++)ans = ans * BigInt(i);
  ans = ans + BigInt(2);

  cin >> n;
  cout << ans.bitos() << endl;
  for(int i=0;i<n;i++)cout << i+2 << endl;
}

Measured memory_bytes: 1344
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define loopinc(i, a, b, inc) for(int i = a; i < (b); i += inc)
#define loop(i, a, b) for(int i = a; i < (b); i++)
#define rep(i, n) loop(i, 0, n)
#define rrep(i, n) for (int i = n-1; i >= 0; i--)
#define endl "\n"
#define all(c) (c).begin(),(c).end()
#define lloopinc(i, a, b, inc) for(ll i = a; i < (b); i += inc)
#define lloop(i, a, b) for(ll i = a; i < (b); i++)
#define lrep(i, n) lloop(i, 0, n)
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tuple<int, int, int> tiii;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

constexpr ll mod = 1000000007;
ll nc2(ll n) { return n*(n-1)/2; }
signed main() {
	// freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;
	ll acc = 0;
	loop(i, k, n+2) {
		acc += nc2(n+1)-nc2(n+1-i)-nc2(i)+1;
		acc %= mod;
	}
	cout << acc % mod << endl;
}


Measured memory_bytes: 3656
n, m, l = map(int, input().split())
mat_a = []
mat_b = []

for i in range(n):
    mat_a.append(list(map(int, input().split())))
    
for j in range(m):
    mat_b.append(list(map(int, input().split())))
    
for p in range(n):
    mat_c = []
    for q in range(l):
        sum = 0
        for r in range(m):
            sum += mat_a[p][r] * mat_b[r][q]
        mat_c.append(sum)
    print(' '.join(map(str, mat_c)))





Measured memory_bytes: 6312
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric> 
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll h, w;
    cin >> h >> w;
    ll ans = INF;
    ll a, b, c, d;
    bool flag = false;
    if(h % 2 != 0) flag = true;
    ll area1, area2, area3;
    for(int i = 1; i < w; i++)
    {
        ll x = w - i;
        area1 = h * i;
        //横
        if(flag) a = h / 2, b = h / 2 + 1;
        else a = b = h / 2;
        area2 = x * a;
        area3 = x * b;
        ll tmp = max({area1, area2, area3}) - min({area1, area2, area3});
        ans = min(tmp, ans);
        //縦に分ける
        if(x % 2 != 0) c = x / 2, d = x / 2 + 1;
        else c = d = x / 2;
        area2 = c * h;
        area3 = d * h;
        tmp = max({area1, area2, area3}) - min({area1, area2, area3});
        ans = min(tmp, ans);
    }
    swap(h, w);
    if(h % 2 != 0) flag = true;
    else flag = false;
    for(int i = 1; i < w; i++)
    {
        ll x = w - i;
        area1 = h * i;
        //横
        if(flag) a = h / 2, b = h / 2 + 1;
        else a = b = h / 2;
        area2 = x * a;
        area3 = x * b;
        ll tmp = max({area1, area2, area3}) - min({area1, area2, area3});
        ans = min(tmp, ans);
        //縦に分ける
        if(x % 2 != 0) c = x / 2, d = x / 2 + 1;
        else c = d = x / 2;
        area2 = c * h;
        area3 = d * h;
        tmp = max({area1, area2, area3}) - min({area1, area2, area3});
        ans = min(tmp, ans);
    }
    cout << ans << endl;
	return 0;	
}



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

using namespace std;

using ll = long long;

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

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

    ll cnt = n;
    ll l = 0, r = 0, bit = 0;
    while (l <= r && l + 1 < n) {
        while (r < n && ((a[r] == 0) || (bit & a[r]) == 0))
            bit ^= a[r++];

        cnt += (r - l - 1);
        bit ^= a[l++];
    }

    cout << cnt << endl;

    return 0;
}


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

int main(){

    int N;
    cin >> N;

    vector<double> v(N);
    for (size_t i = 0; i < N; i++)
    {
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    double ans = v[0]; 
    for(int i=1;i<N;i++){
        ans= (ans+v[i])/2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pob pop_back
#define vi vector<ll>
#define mp make_pair
#define sz size()
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define maxx 100005
#define se second
#define fi first
#define be begin()
#define en end()
#define sortv(v) sort(v.begin(),v.end());
#define w() ll _;cin>>_;while(_--)
#define edge pair<ll,ll>
#define pq priority_queue<ll>
#define mod 1000000007
#define Endl "\n"
#define cy cout<<"YES"<<endl;
#define cn cout<<"NO"<<endl;
using namespace std;




int main()
{
		
	fast;
	
	char c;
	cin>>c;
	if(c>='A' && c<='Z')
	{
		cout<<"A"<<endl;
	}
	else
	{
		cout<<"a"<<endl;
	}
	
	

	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=2e5+10;
const int maxt=(1<<20)+10;
int mx[maxt],tag[maxt];
int X[maxn],H[maxn],p[maxn];
int n,d,a;
vector<int> lsh;
inline void modify(int x,int l,int r,int p,int v)
{
	if(l==r)
	{
		mx[x]=v;
		return;
	}
	int mid=(l+r)>>1;
	if(p<=mid)modify(x*2,l,mid,p,v);
	else modify(x*2+1,mid+1,r,p,v);
	mx[x]=max(mx[x*2],mx[x*2+1]);
}
inline void pushdown(int x,int l,int r)
{
	if(!tag[x])return;
	mx[x*2]-=tag[x];
	if(mx[x*2]<0)mx[x*2]=0;
	tag[x*2]+=tag[x];
	if(tag[x*2]>inf)tag[x*2]=inf;
	mx[x*2+1]-=tag[x];
	if(mx[x*2+1]<0)mx[x*2+1]=0;
	tag[x*2+1]+=tag[x];
	if(tag[x*2+1]>inf)tag[x*2+1]=inf;
	tag[x]=0;
}
inline pii getlft(int x,int l,int r,int tl,int tr)
{
	if(l>tr||r<tl)return make_pair(inf,inf);
	if(mx[x]<=0)return make_pair(inf,inf);
	if(l==r)return make_pair(l,mx[x]);
	pushdown(x,l,r);
	int mid=(l+r)>>1;
	if(mx[x*2]>0)return getlft(x*2,l,mid,tl,tr);
	return getlft(x*2+1,mid+1,r,tl,tr);
}
inline void add(int x,int l,int r,int tl,int tr,int v)
{
	if(l>tr||r<tl)return;
	if(tl<=l&&r<=tr)
	{
		mx[x]-=v;
		if(mx[x]<0)mx[x]=0;
		tag[x]+=v;
		if(tag[x]>inf)tag[x]=inf;
		return;
	}
	pushdown(x,l,r);
	int mid=(l+r)>>1;
	add(x*2,l,mid,tl,tr,v);
	add(x*2+1,mid+1,r,tl,tr,v);
	mx[x]=max(mx[x*2],mx[x*2+1]);
}
int rid[maxn];
int main()
{
	scanf("%d%d%d",&n,&d,&a);
//	n=200000;
//	d=20;
//	a=1;
	for(int i=0;i<n;i++)
	{
		scanf("%d%d",&X[i],&H[i]);
	//	X[i]=i*20;
	//	H[i]=i*20;
		lsh.push_back(X[i]);
	}
	sort(lsh.begin(),lsh.end());
	lsh.erase(unique(lsh.begin(),lsh.end()),lsh.end());
	int m=lsh.size();
	for(int i=0;i<n;i++)
	{
		p[i]=lower_bound(lsh.begin(),lsh.end(),X[i])-lsh.begin();
		rid[p[i]]=i;
		modify(1,0,m-1,p[i],H[i]);
	}
	ll ans=0;
	int p=-1;
	while(true)
	{
		pii res=getlft(1,0,m-1,p+1,m-1);
		if(res.first>=inf)break;
		int x=res.first,v=res.second;
		p=res.first;
		x=rid[x];
		int torht=(int)min(1ll*lsh.back()+1,1ll*X[x]+2ll*d+1ll);
		int y=lower_bound(lsh.begin(),lsh.end(),torht)-lsh.begin()-1;
		ll cnt=(v*1ll+a*1ll-1ll)/(a*1ll);
		ans+=cnt;
		add(1,0,m-1,res.first,y,min(cnt*a,inf*1ll));
		if(p==m-1)break;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 11508
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <bitset>
#include <map>
#include <math.h>

using namespace std;

int main(){

    long long A, B, r, GCD;
    cin >> A >> B;

    // 最大公約数を求める
    if (A < B) swap(A, B);
    r = A % B;
    while(r != 0){
        A = B;
        B = r;
        r = A % B;
    }
    GCD = B;

    // 素因数分解
    vector<pair<long long, int>> prime_factor;
    if (GCD % 2 == 0) prime_factor.emplace_back(2, 0);
    while (GCD % 2 == 0){
        GCD = GCD / 2;
        prime_factor.back().second++;
    }
    for (long long i = 3; i*i <= GCD; i += 2){
        if (GCD % i != 0) continue;
        prime_factor.emplace_back(i, 0);
        while (GCD % i == 0){
            GCD = GCD / i;
            prime_factor.back().second++; // .back() は [prime_factor.size()-1] と同じ
        }
    }
    if (GCD != 1) prime_factor.emplace_back(GCD, 1);

    // 確認
    cout << prime_factor.size() + 1 << endl;



    return 0;
}


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

int main(void){

    long long int X;
    long long int i=0;
    long long int money=100;
    scanf("%ld",&X);
    
    while(money<X){
        money=(long long int)(money*1.01);
        i++;
    }

    printf("%ld",i);
    return 0;
}

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

const int mod = 1000000007;
struct mod_int
{
    long long x;
    mod_int(long long x = 0) : x((x % mod + mod) % mod) {}
    mod_int operator-() const { return mod_int(-x); }
    mod_int &operator+=(const mod_int a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mod_int &operator-=(const mod_int a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mod_int &operator*=(const mod_int a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mod_int operator+(const mod_int a) const
    {
        mod_int res(*this);
        return res += a;
    }
    mod_int operator-(const mod_int a) const
    {
        mod_int res(*this);
        return res -= a;
    }
    mod_int operator*(const mod_int a) const
    {
        mod_int res(*this);
        return res *= a;
    }
    mod_int pow(long long t) const
    {
        if (!t)
            return 1;
        mod_int a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mod_int inv() const
    {
        return pow(mod - 2);
    }
    mod_int &operator/=(const mod_int a)
    {
        return (*this) *= a.inv();
    }
    mod_int operator/(const mod_int a) const
    {
        mod_int res(*this);
        return res /= a;
    }
};

int main()
{
    int n, k;
    std::cin >> n >> k;
    std::vector<mod_int> stairSum(n + 1);
    stairSum[0] = 0;
    for (int i = 1; i <= n; ++i)
    {
        stairSum[i] = stairSum[i - 1] + i;
    }
    mod_int sum = 0;
    for (int i = k; i <= n; ++i)
    {
        sum += stairSum[n] - stairSum[n - i] - stairSum[i - 1] + 1;
    }
    sum += 1;
    std::cout << sum.x << std::endl;
    return 0;
}

Measured memory_bytes: 4836
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int town = sc.nextInt();
        int road = sc.nextInt();
        int[] num = new int[road*2];
        int townNum = 1;
        int[] ans = new int[town+1];

        for(int i=0; i<road*2; i++){
            num[i] = sc.nextInt();
        }

        for(int i=0; i<road*2; i++){
            for(int y=0; y<town+1; y++){
                if(y==num[i]){
                    ans[y]++;
                }
            }
        }

        for(int i=1; i<town+1; i++){
            System.out.println(ans[i]);
        }
    }
}

Measured memory_bytes: 27188
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
int const INF = INT_MAX;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int N, Q;

struct SegmentTree {
	private:
		int n;
		vector<int> node;
	
	public:
		SegmentTree(vector<int> v) {
			int sz = v.size();
			n = 1; while (n < sz)n *= 2;
			node.resize(2 * n - 1, INF);

			for (int i = 0; i < sz; i++)node[i + n - 1] = v[i];
			for (int i = n - 2; i >= 0; i--)node[i] = min(node[2 * i + 1], node[2 * i + 2]);
		}

		void update(int x, int val) {
			x += (n - 1);
			node[x] = val;
			while (x > 0) {
				x = (x - 1) / 2;
				node[x] = min(node[2 * x + 1], node[2 * x + 2]);
			}
		}

		int getmin(int a, int b, int k = 0, int l = 0, int r = -1) {
			if (r < 0)r = n;
			if (r <= a || b <= l)return INF;
			if (a <= l && r <= b)return node[k];

			int vl = getmin(a, b, 2 * k + 1, l, (l + r) / 2);
			int vr = getmin(a, b, 2 * k + 2, (l + r) / 2, r);
			return min(vl, vr);
		}

};

int main() {
	cin >> N >> Q;
	SegmentTree seg(vector<int>(N, INF));

	for (int i = 0; i < Q; i++) {
		int c, x, y; cin >> c >> x >> y;
		if (c == 0)seg.update(x, y);
		else cout << seg.getmin(x, y + 1) << endl;
	}
	return 0;
}


Measured memory_bytes: 4092
#include <iostream>

using namespace std;

int main(){
    long long N, M;
    cin >> N >> M;
    long long ans = 0;
    
    ans += min(N, M/2);
    N -= ans;
    M -= 2*ans;
    ans += M/4;

    cout << ans << endl;


    return 0;
}

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

x = a[0]
y = a[1]


def total(x,y,n):
    total = 4 * n + 2 * (x - n)
    return total

for var in range(0,x + 1):
    ans = total(x,y,var)
    if (ans == y):
        print("Yes")
        break
    else:
        if (var == x):
            print("No")
            break
        else:
            continue


Measured memory_bytes: 9188
#include <iostream>
#include <algorithm>
#include <vector>
#include <fstream>
#include <list>
#include <string>
using namespace std;

int main()
{
	ifstream fin("input.txt");
	long long n, m, counter = 0;
	cin >> n >> m;
	if (n < m)
	{
		counter += n;
		m -= 2 * n;
		n = 0;
		n = m / 4;
		m -= m / 2;
		counter += n;
		cout << counter << endl;
		return 0;
	}
	else

	{
		counter += (m/2);
	}
	cout << counter << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
/////////////////////////////////
int main(){
    int n;
    cin >> n;
    vector<double> v(n);
    rep(i, n) cin >> v[i];
    sort(v.begin(), v.end());
    int ans=0;
    for (int i = 1; i < n ;i++)
        v[i] = (v[i - 1] + v[i]) / 2;
    cout<<v[n-1]<<endl;
}

Measured memory_bytes: 3844
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
	"unsafe"
)

func main() {
	K, N := sc.nextInt(), sc.nextInt()
	An := sc.nextInts()

	ansArr := make([]int, N)
	ansArr[0] = K - An[len(An)-1] + An[0]
	prev := An[0]
	total := K - An[len(An)-1] + An[0]
	for i := 1; i < N; i++ {
		ansArr[i] = An[i] - prev
		prev = An[i]
		total += ansArr[i]
	}
	minDis := K
	for i := 0; i < N; i++ {
		tmp := total - ansArr[i]
		if minDis > tmp {
			minDis = tmp
		}
	}
	fmt.Println(minDis)
}

var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}

// Pair a
type Pair struct {
	first  int
	second int
}

// Queue a
type Queue struct {
	v []Pair
}

// Push for queue
func (q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func (q *Queue) Pop() Pair {
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func (q Queue) Front() Pair {
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool {
	return len(q.v) == 0
}


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

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;


signed main() {
	int n, m; cin >> n >> m;
	vector<int> v(n);
	rep(i, n) v[i] = i + 1;
	rep(i, m) {
		string s; cin >> s;
		string s1, s2;
		bool flag = true;
		for (auto a : s) {
			if (a == ',') flag = !flag;
			else if (flag) {
				s1 = s1 + a;
			}
			else {
				s2 = s2 + a;
			}
		}
		int a, b;
		a = stoi(s1);
		b = stoi(s2);
		swap(v[a - 1], v[b - 1]);
	}
	for (auto a : v) {
		cout << a << endl;
	}
}


Measured memory_bytes: 3060
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}
ll n,m;

vector<int> v[100001];
vector<ll> h;
bool dfs(int ik){
    ll tk = h[ik];
    rep(i,v[ik].size()){
        if(tk<=h[v[ik][i]])return false;
    }

    return true;
}
int main(){

    cin>>n>>m;
    rep(i,n){
        ll hn;
        cin>>hn;
        h.push_back(hn);
    }
    h.resize(n,0);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    ll ans = 0;
    rep(i,n){
        bool f = dfs(i);
        if(f){ans++;}
    }
    cout<<ans<<endl;



    
return 0;
}


Measured memory_bytes: 9220
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(hoge) (hoge).begin(),(hoge).end()
using namespace std;
int main(){
  ll n,k;
  cin>>n>>k;
  vector<int>num(200010);
  for(int i=0;i<n;i++){int a;cin>>a;num[a]++;}
  sort(ALL(num));
  int ans=0;
  for(int i=0;i<200010-k;i++){
    ans+=num[i];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def factorial(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
n = inp[0]
a = inp
xor = 0
sum = 0
mae = 0
usiro = 0
c = 0
f = 0
ans = 0
a.size.times do |i|
  f = 0
  if(i!=0)
    xor = xor ^ a[i-1]
    sum -= a[i-1]
    c -= 1
  end
  while(sum == xor and usiro < n)
    xor = xor ^ a[usiro]
    sum += a[usiro]
    usiro += 1
    c += 1
  end
  f = 1 if(sum != xor)
  ans += c - f
end
p ans

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

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> v(n);
    rep(i,m){
        int k;
        cin >> k;
        rep(j,k){
            int s;
            cin>>s;
            s--;
            v[s] |= (1<<i);
        }
    }
    int p=0;
    rep(i,m){
        int x;
        cin >> x;
        p|= (x<<i);
    }
    int ans = 0;
    for(int bit=0; bit<(1<<n);bit++){
        int t=0;
        rep(i,n){
            if((bit>>i)&1){
                t^= v[i];
            }
        }
        if(t==p) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)(n);++i)
#define rep1(i, n) for (int i=1;i<=(int)(n);++i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=r-1;i>=(int)(l);--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

vi S[1010];

signed main()
{
	int N; cin >> N;
 
	int a = -1;
	for (int i = 1; i <= 1000; ++i) {
		if (i * (i - 1) / 2 == N) {
			a = i;
			break;
		}
	}

	if (a == -1) {
		puts("No");
		return 0;
	}

	puts("Yes");
	printf("%lld\n", a);
 
	int id = 1;
	for (int i = 0; i < a; ++i) {
		for (int j = i + 1; j < a; ++j) {
			S[i].push_back(id);
			S[j].push_back(id);

			id++;
		}
	}

	for (int i = 0; i < a; ++i) {
		printf("%lld", (int)S[i].size());
		for (int j : S[i]) printf(" %lld", j);
		puts("");
	}
}



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

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define eof !cin.eof()
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define ull unsigned long long
#define ll long long
#define ld long double
#define sz(a) a.size()
#define all(s) s.begin(), s.end()
#define rall(s, n) s, s + n
#define x first
#define y second
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ii pair <int, int>
#define iii pair <int, ii>
#define vi vector <int>
#define vit vector <int> :: iterator
#define vlt vector <ll> :: iterator
#define vl vector <ll> 
#define vii vector <ii>
#define viii vector <iii>
#define vd vector <double>
#define vull vector <ull>
#define vc vector <char>
#define vs vector <string>
#define vb vector <bool>
#define vvi vector <vector <int>>
#define vvl vector <vector <ll>>
#define EPS 1e-10
#define INF 1000000000
#define mod 1000000007
#define reset(a, nilai) memset(a, nilai, sizeof(a))
#define minof min_element
#define maxof max_element
using namespace std;

int n, k;
int main () {
	IOS;
	
	scanf("%d%d", &n, &k);
	vi a(n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	vb dp(k + 1);
	for (int stone = 0; stone <= k; stone++) {
		for (int i = 0; i < n; i++) {
			if (stone >= a[i] && !dp[stone - a[i]]) {
				dp[stone] = true;
			}
		}
	}
	printf((dp[k] ? "First\n" : "Second\n"));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    long long n;
    vector<long long> y3;
    for (long long y = 0; y < 1234; y++) {
	y3.push_back(y * y * y);
    }
    while (cin >> n, n) {
	long long ans = 1LL << 60;
	for (long long x = 1; x < n; x++) {
	    long long y = upper_bound(y3.begin(), y3.end(), n*n*n-x*x*x) - y3.begin();
	    if (y == 0 || y > n) continue;
	    y--;
	    ans = min(ans, n*n*n-x*x*x-y*y*y);
	}
	cout << ans << endl;
    }
    
    return 0;
}




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

int main() {
    int N; cin >> N;
    int A[N], costAll = 0; 
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (i == 0) costAll += abs(A[i]);
        else if (i == N - 1) costAll += abs(A[i] - A[i - 1]) + abs(A[i]);
        else costAll += abs(A[i] - A[i - 1]);
    }

    for (int i = 0; i < N; i++) {
        int prev_loc, cur_loc = A[i], next_loc;
        if (i == 0) {
            prev_loc = 0; next_loc = A[i + 1];
        } else if (i == N - 1) {
            prev_loc = A[i - 1]; next_loc = 0;
        } else {
            prev_loc = A[i - 1]; next_loc = A[i + 1];
        }

        int save;
        if ((prev_loc <= cur_loc && cur_loc <= next_loc) ||
            (prev_loc >= cur_loc && cur_loc >= next_loc)) {
            save = 0;
        } else if (abs(cur_loc - next_loc) < abs(cur_loc - prev_loc)) {
            save = abs(next_loc - cur_loc) * 2;
        } else {
            save = abs(prev_loc - cur_loc) * 2;
        }

        cout << costAll - save << endl;
    }
}

Measured memory_bytes: 1664
#include <stdio.h>
int main()
{
	float n500,n1000;
	while(scanf("%f %f",&n500,&n1000)!=EOF){
		if(n500<35.5&&n1000<71)
			printf("AAA\n");
		else if(n500<37.5&&n1000<77)
			printf("AA\n");
		else if(n500<40&&n1000<83)
			printf("A\n");
		else if(n500<43&&n1000<89)
			printf("B\n");
		else if(n500<50&&n1000<105)
			printf("C\n");
		else if(n500<55&&n1000<116)
			printf("D\n");
		else if(n500<70&&n1000<148)
			printf("E\n");
		else
			printf("NA\n");
	}
}

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

using namespace std;
typedef long long ll;


int main(){
    ios::sync_with_stdio(false);
    #ifdef DBG
        freopen("in", "r", stdin);
    #endif

    ll a, b;
    cin>>a>>b;
    ll g = __gcd(a, b);
    if(g == b) cout<<"-1";
    else if(a == 1) cout<<b+1; 
    else{
        cout<<a*(b-1);
    }

    return 0;
}


//

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
// now

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0) : d(n,-1){}
    int Find (int x){//根の番号を探す
        if(d[x] < 0) return x;
        return d[x] = Find(d[x]);
    }
    bool unite (int x, int y){
        x = Find(x); y = Find(y);
        if(x == y ) return false;
        if(d[x] < d[y]){
            swap(x,y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    } 

    bool same(int x, int y){
        return Find(x) == Find(y);
    }
    int size(int x) {
        return (-d[Find(x)]);
    }
};


ll nCr (ll n, ll r){
    ll ans = 1;
    for(ll i = n ; i > n-r ; i --){
        ans *= i;
    }
    for(ll i = 1 ; i<= r; i ++){
        ans /= i;
    }
    return ans ;
}

int nPr (int n,int r){
    int ans = 1;
    for(int i = n ; i > n-r ; i --){
        ans *= i;
    }
    return ans ;
}
 ll modd = 1e9+ 7;
ll wa (ll n,ll mi, ll ma){
    ll ans  = n * (mi+ma) /2;
    return ans;
}
ll kw(ll k,ll n){
    
    ll ans  =0;
    ll mi,ma;
    mi= wa(k,0,k-1);
    
    ma = wa(k,n-k+1,n);
    
    return (ma-mi +1)%modd;
}

int main(){
    int n;
    cin >> n;
    vector<int> vec(n);

    REP(i,n){
        cin >> vec[i];
    }

    ll sum = 0;
    int now;
    now = vec[0]; 

    FOR(i,1,n){
        if(now > vec[i]){
            sum += now - vec[i];
        }else{
            now = vec[i];
        }
    }
    cout << sum <<endl;
}





Measured memory_bytes: 4044
#include <iostream>
#include <cstdio>
#define X 4001
#define V 1000000
using namespace std;

int main(){
	int n;
	while(1){
		cin >> n;
		if(n==0) break;
		long a[X];
		int f[X];
		for(int i=0;i<X;i++) a[i] = 0;
		for(int i=0;i<X;i++) f[i] = 0;
		int b;
		long c,d;
		int s = 0;
		for(int i=0;i<n;i++){
			cin >> b >> c >> d;
			if(a[b]<V) a[b] += c*d;
			if(f[b]==0){
				s++;
				f[b] = s;
			}
		}
		bool e = true;
		for(int i=1;i<X;i++){
			for(int j=0;j<X;j++){
				if(f[j]!=i) continue;
				if(a[j]>=V){
					e = false;
					cout << j << endl;
				}
				break;
			}
		}
		if(e) cout << "NA" << endl;
	}
}

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

int main() {
  int n;
  cin >> n;
  vector<pair<int, int> > pairs(n);
  int time = 0;
  bool possible = true;
  
  for (int i = 0; i < n; i++) {
    cin >> pairs[i].second >> pairs[i].first;
  }

  // firstが小さい順、secondが小さい順にソート
  sort(pairs.begin(), pairs.end());

  for (int i = 0; i < n; i++) {
    time += pairs[i].second;
    if(time > pairs[i].first){
      possible = false;
    }
  }

  if(possible){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1792
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647 -> 10桁
// MAX ll 9,223,372,036,854,775,807 -> 19桁
// MAX O(n) 10^18 -> 18回
// double pi = M_PI or acos(-1)

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s.at(i);
    set<string> t;

    rep(i, n) {
        t.insert(s.at(i));
    }

    cout << t.size() << endl;
    
    return 0;
}


Measured memory_bytes: 24996
#include <iostream>
#include <bitset>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int A[5];

bool checkThreeName(int x) {
	int num = 0;
	while (true) {
		if (x % 2 == 1) {
			num++;
		}
		x /= 2;
		if (x == 0) {
			break;
		}
	}
	return num == 3;
}

bool checkExistName(int x) {
	int digit = 0;
	while (true) {
		if (x % 2 == 1) {
			if (A[digit] == 0) {
				return false;
			};
		}
		x /= 2;
		if (x == 0) {
			break;
		}
		digit++;
	}
	return true;
}
ll countName(int x) {
	if (!checkThreeName(x))return 0;
	if (!checkExistName(x))return 0;
	//cout << bitset<5>(x) << endl;

	ll num = 1;
	int digit = 0;
	while (true) {
		if (x % 2 == 1) {
			num *= A[digit];
		}
		x /= 2;
		if (x == 0) {
			break;
		}
		digit++;
	}
	return num;
}

int main() {
	int N; cin >> N;

	rep(i, 0, 5) {
		A[i] = 0;
	}

	rep(i, 0, N) {
		char c[11];
		cin >> c;
		if (c[0] == 'M') A[0]++;
		if (c[0] == 'A') A[1]++;
		if (c[0] == 'R') A[2]++;
		if (c[0] == 'C') A[3]++;
		if (c[0] == 'H') A[4]++;
	}

	ll count = 0;
	for (int i = 0; i < 1 << 5; i++) {
		count += countName(i);
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
val = input().split()
a = int(val[0])
b = int(val[1])

str_a = str(a) * b
str_b = str(b) * a

min_length = a if a <= b else b
for i in range(min_length):
    if str_a[i] <= str_b[i]:
        answer = str_a
        break
    elif str_b[i] < str_a[i]:
        answer = str_b

print(answer)

Measured memory_bytes: 3064
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Next Alphabet
 */

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

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  char s[4];
  scanf("%s", s);

  putchar(s[0] + 1);
  putchar('\n');
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#include<set>
#include<complex>
#include<complex>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define INF 200000000

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;

enum
{
	BOTTOM,
	LEFT,
	RIGHT,
	TOP
};

struct P
{
	double x, y;
	P(double x,double y) :x(x), y(y) {}
	P() :P(0, 0) {}
	P operator+(const P& v)const
	{
		return P(x + v.x, y + v.y);
	}
	P operator-(const P& v)const
	{
		return P(x - v.x, y - v.y);
	}
	P operator*(const double v)const
	{
		return P(x*v, y*v);
	}
	bool operator==(const P& v)const
	{
		return abs(x - v.x) <= 0.0000000000001&&abs(y - v.y) <= 0.00000000000001;
	}
	bool operator!=(const P& v)const
	{
		return abs(x - v.x) > 0.0000000000001 || abs(y - v.y) > 0.00000000000001;
	}

	double dot(const P& v)const
	{
		return x*v.x + y*v.y;
	}
	double cross(const P& v)const
	{
		return x*v.y - y*v.x;
	}
	double length()const
	{
		return sqrt(x*x + y*y);
	}
	double length2()const
	{
		return (x*x + y*y);
	}

	P unit()const
	{
		return P(x / length(), y / length());
	}
	
	bool operator<(const P& v)const
	{
		return x<v.x || (x == v.x) && y < v.y;
	}
	bool operator>(const P& v)const
	{
		return x>v.x || (x == v.x) && y > v.y;
	}
};

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

	double cx, cy, cr;
	cin >> cx >> cy >> cr;
	P c(cx, cy);

	int q;
	cin >> q;

	for (int i = 0; i < q; i++)
	{
		double x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		P p1(x1, y1), p2(x2, y2);

		P p1c = c - p1, p12 = (p2 - p1).unit();
		P pp = p1 + p12*(p1c.x*p12.x + p1c.y*p12.y);

		double h = (c - pp).length();

		if (h == cr)
		{
			printf("%.10lf %.10lf %.10lf %.10lf\n", pp.x, pp.y, pp.x, pp.y);
		}
		else
		{
			P cp1 = pp + p12*sqrt(cr*cr - h*h), cp2 = pp - p12*sqrt(cr*cr - h*h);
			if (cp1 > cp2)
			{
				swap(cp1, cp2);
			}
			printf("%.10lf %.10lf %.10lf %.10lf\n", cp1.x, cp1.y, cp2.x, cp2.y);
		}
	}

	return 0;
}


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

int main(){
    int N,A,B,Q;
    cin >> N >> A >> B >> Q;
    vector<int> X(A+1),Y(B+1),H(B+1);
    vector<char> C(A+1);
    for(int i=1;i<=A;i++) cin >> X[i] >> C[i];
    for(int j=1;j<=B;j++) cin >> Y[j] >> H[j];
    
    auto f = [&](int x,int id){
        int k = (x-Y[id])/(Y[id]-H[id])+1;
        return x+k*(H[id]-Y[id]);
    };

    auto most_left = [&](int x){
        while(true){
            vector<int>::iterator it = upper_bound(Y.begin(),Y.end(),x);
            it--;
            int id = it-Y.begin();
            if(!H[id]) return x;
            x = f(x,id);
        }
        return -1; 
    };

    map<int,char> m;
    for(int i=1;i<=A;i++) m[most_left(X[i])] = C[i];
    for(int i=0;i<Q;i++){
        int z;
        cin >> z;
        int l = most_left(z);
        cout << (m.count(l)? m[l]:'?');
    }
    cout << endl;
}


Measured memory_bytes: 3140
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
typedef long long ll;

using namespace std;
int A, B, C = 0;
vector<int > a;



int main(){

    cin >> A >> B >> C;

    if(A > B){
        cout << "0" << endl;
    }else{
        if(B / A > C){
            cout << C << endl;
        }else{
            cout << B/A << endl;
        }
        
    }
    
    


}

Measured memory_bytes: 256
//Keep Working Hard
  // I__Like__Food
  #include<bits/stdc++.h>
  #include <ext/pb_ds/assoc_container.hpp> 
  #include <ext/pb_ds/tree_policy.hpp>
  #pragma comment(linker, "/stack:200000000")
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast") 
  #pragma GCC optimize("unroll-loops")
  using namespace std;
  using namespace __gnu_pbds;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 998244353
  #define N 305
  #define INF 1e16
  const double PI = acos(-1);

int32_t main()
{




    string s;
    cin >> s;

    int n = s.length();


    string s2 = s;
    reverse(all(s2));



    string ss = s.substr(0,(n-1)/2);
    string ss2 = ss;
    reverse(all(ss2));


    string sss = s.substr((n+3)/2 - 1,100);

    string sss2 = sss;
    reverse(all(sss2));

    bool ok = bool(s2 == s) and bool(sss == sss2) and bool(ss == ss2);

    
    if(ok)
    {
      cout << "Yes";
    }
    else
    {
      cout << "No";
    }
  return 0;
} 

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

int main(){
        int h,w,k,i,j,kk,cnt=0,ans=0;
        char tmp;
        cin >> h >> w >> kk;
        vector<vector<char>> c(h, vector<char>(w));
        for(i=0;i<h;++i){
                for(j=0;j<w;++j){
                        cin >> tmp;
                        c.at(i).at(j) = tmp;
                        if(tmp=='#') ++cnt;
                }
        }
        for(i=0;i<(1<<h+w);++i){
                vector<vector<char>> cc(h, vector<char>(w));
                copy(c.begin(),c.end(),cc.begin());
                int cnt_t = cnt;
                for(j=0;j<h+w;++j){
                        if((i>>j)&1){
                                if(j<h){
                                        for(k=0;k<w;++k){
                                                if(cc.at(j).at(k)=='#'){
                                                        --cnt_t;
                                                        cc.at(j).at(k) = '.';
                                                }
                                        }
                                }else{
                                        for(k=0;k<h;++k){
                                                if(cc.at(k).at(j-h)=='#'){
                                                        --cnt_t;
                                                        cc.at(k).at(j-h) = '.';
                                                }
                                        }
                                }
                        }
                }
                if(cnt_t==kk) ++ans;
        }
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define INF 2e9
#define ll long long


int main(){
    string s;
    cin>>s;
    int n = s.length();
    int ans[n];

    for(int i=0; i<n; i++){
        ans[i] = 0;
    }

    int r = 0;
    int l = 0;

    int pair1;
    int pair2;

    for(int i=1; i<n; i++){
        if(s[i-1] == 'R' && s[i] == 'R'){
            r++;
        }
        else if(s[i-1] == 'R' && s[i] == 'L'){
            pair1 = i-1;
            pair2 = i;
        }
        else if(s[i-1] == 'L' && s[i] == 'L'){
            l++;
        }
        else{       //s[i-1] == "L" && s[i] == "R";
            ans[pair1] = r/2+l/2+1, ans[pair2] = r/2+l/2+1;

            if(r%2==1){
                ans[pair2]++;
            }
            if(l%2==1){
                ans[pair1]++;
            }
            r = 0, l = 0;
        }
    }

    ans[pair1] = r/2+l/2+1, ans[pair2] = r/2+l/2+1;
    if(r%2==1){
        ans[pair2]++;
    }
    if(l%2==1){
        ans[pair1]++;
    }

    for(int i=0; i<n; i++){
        cout<<ans[i]<<" ";
    }
    cout<<endl;

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
    long a, b;
    scanf("%ld %ld", &a, &b);
    if (a <= 0 && 0 <= b) {
        printf("Zero\n");
        return 0;
    }
    if (0 < a) {
        printf("Positive\n");
        return 0;
    }
    if (a < 0 && b < 0) {
        if ((b - a + 1) % 2 == 0) printf("Positive\n");
        else printf("Negative\n");
        return 0;
    }
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		while (true) {
			int H = scn.nextInt();
			int W = scn.nextInt();
			if (H == 0 && W == 0) {
				break;
			}
			for (int i = 0; i < H; i++) {
				if (i % 2 == 0) {
					for (int j = 0; j < W; j = j + 1) {
						if (j % 2 == 0) {
							System.out.print("#");
						} else if (j % 2 != 0) {
							System.out.print(".");
						}
					}
					System.out.println();
				} else {
					for (int j = 0; j < W; j = j + 1) {
						if (j % 2 == 0) {
							System.out.print(".");
						} else if (j % 2 != 0) {
							System.out.print("#");
						}
					}
					System.out.println();
				}
			}
			System.out.println();
		}
	}
}



Measured memory_bytes: 37356