akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 #include<memory>
 
 using namespace std;

 int main()
 {
   string s,t; 
   while(cin>>s>>t)
   {
     int cnt;
     string str;
     if(t.length()>s.length()) cout<<"UNRESTORABLE"<<endl;
     else
     {
       bool flag=false;
       for(int i=0;i<=(s.length()-t.length());i++)
       {
         int j;
         for(j=0;j<t.length();j++)
         {
           if((s[i+j]!=t[j])&&(s[i+j]!='?')) break;        
         }          
         if(j==t.length())
         { 
           flag=true;
           cnt=i;
           //cout<<cnt<<endl;
         }
       }
       if(!flag) cout<<"UNRESTORABLE"<<endl;
       else
       {
         for(int i=0;i<cnt;i++)
         {
           if(s[i]!='?') str+=s[i];
           else str+='a';        
         }
         //cout<<str<<endl;
         for(int i=cnt;i<(cnt+t.length());i++) str+=t[i-cnt];
         for(int i=(cnt+t.length());i<s.length();i++) 
         {
           if(s[i]!='?') str+=s[i];
           else str+='a';      
         }
         cout<<str<<endl;
       }
     }
   }
   return 0;
 }
 

        

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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//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();}

// Mod int
const int mod = 1000000007;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
typedef vector<mint> vm;
typedef vector<vm> vvm;
//

int main(){
  int n,m;
  cin >> n >> m;
  VI a(n), b(m);
  map<int,int> aidx;
  map<int,int> bidx;
  rep(i,n) cin >> a[i], aidx[a[i]] = i+1;
  rep(i,m) cin >> b[i], bidx[b[i]] = i+1;

  int aa[n];
  int bb[m];
  memset(aa,0,sizeof(aa));
  memset(bb,0,sizeof(bb));
  ll asum = 0;
  ll bsum = 0;
  mint ans = 1;

  for(int i = n*m; i >= 1; i--){
    int aaa = aidx[i] - 1;
    int bbb = bidx[i] - 1;

    if(aaa >= 0 && bbb >= 0){
      asum ++;
      bsum ++;
    }
    else if(aaa >= 0){
      asum ++;
      if(bsum == 0) {
        cout << 0 << endl;
        return 0;
      }
      ans *= bsum;

    }else if(bbb >= 0){
      bsum ++;
      if(asum == 0) {
        cout << 0 << endl;
        return 0;
      }
      ans *= asum;
    }else{
      ll tmp = bsum * asum;
      if(tmp <= 0){
        cout << 0 << endl;
        return 0;
      }
      ans *= tmp - (n*m - i);
    }
    // cout << "i = " << i << ": " << ans << endl;
  }
  cout << ans << endl;
  return 0;
}


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

const int INF = (1 << 30) - 1;

int main() {
    // Debug::set_INF(INF);
    int N, M;  cin >> N >> M;
    vector<vector<int>> dist(N, vector<int>(N, INF));
    for (int i = 0; i < M; ++i) {
        int a, b, c;  cin >> a >> b >> c;
        dist[a - 1][b - 1] = c;
        dist[b - 1][a - 1] = c;
    }
    for (int i = 0; i < N; ++i) dist[i][i] = 0;
    // DUMP(dist);

    map<pair<int, int>, int> cnt;
    auto dist_cp = dist;
    for (int k = 0; k < N; ++k) {
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                if (dist[i][j] > dist[i][k] + dist[k][j]) {
                    dist[i][j] = dist[i][k] + dist[k][j];
                    if (i != j && dist_cp[i][j] != INF) ++cnt[pair<int, int>(i, j)];
                }
            }
        }
    }
    // DUMP(dist, cnt);

    cout << cnt.size() / 2 << endl;
}


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



int main() {
    double A, B; cin >> A >> B;
    for(int i = 1; i < 1300; i++){
        double x_a = 0.08*i;
        double x_b = 0.1*i;
        x_a = floor(x_a);
        x_b = floor(x_b);
        if(x_a == A && x_b == B){
            if(A <= 100 && B <= 100){
                cout << i << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=100000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u];i;i=sq[i].nxt)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 1000000007
#define eps 1e-8
int n,k;
ll f[2020];
vector<int> fac;
 
int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

ll qpow(ll x,int y)
{
	ll ans=1;
	while (y)
	{
		if (y&1) ans=ans*x%maxd;
		x=x*x%maxd;y>>=1;
	}
	return ans;
}

int main()
{
	n=read();k=read();
	for (int i=1;i*i<=n;i++)
	{
		if (n%i) continue;
		fac.pb(i);
		if (i*i!=n) fac.pb(n/i);
	}
	int len=fac.size();
	sort(fac.begin(),fac.end());
	rep(i,0,len-1)
	{
		int x=fac[i];
		f[i]=qpow(k,(x+1)/2);
		rep(j,0,i-1)
			if (x%fac[j]==0)
				f[i]=(f[i]-f[j]+maxd)%maxd;
	}
	ll ans=0;
	rep(i,0,len-1)
		if (fac[i]&1) ans=(ans+f[i]*fac[i])%maxd;
		else ans=(ans+f[i]*(fac[i]/2))%maxd;
	printf("%lld",ans);
	return 0;
}
		


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<vector<int>> A(K, vector<int>(N, 0));
    int d, a;
    rep(0, i, K)
    {
        cin >> d;
        rep(0, j, d)
        {
            cin >> a;
            a--;
            A.at(i).at(a) = 1;
        }
    }
    int ans = 0;
    rep(0, i, N)
    {
        int f = 0;
        rep(0, j, K)
        {
            if (A.at(j).at(i) != 0)
            {
                f++;
            }
        }
        if (f == 0)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

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

#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
using intmap = map<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
const int MOD = 1e9 + 7;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }
inline bool bit (ll b, ll i) { return b & (1 << i); }
inline ll ceiv (ll a, ll b) { return (a + b - 1) / b; }
//struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define debug(x) cerr << #x << ": " << x << '\n'
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

template <class T>
class FenwickTree {
    vector<T> a;
    
public:
    FenwickTree(){};
    FenwickTree(int size) {
        a = vector<T>(size + 1, 0);
    }
    
    // 0-indexed
    void add(int idx, T value) {
        idx++;
        while(0 < idx && idx < a.size()){
            a[idx] += value;
            idx += idx & (-idx);
        }
    }
    
    // 1-indexed
    T sum(int idx) {
        int ret = 0;
        while(idx > 0) {
            ret += a[idx];
            idx -= idx & (-idx);
        }
        return ret;
    }
    
    // 0-indexed, [l, r)
    T sum(int l, int r){
        return sum(r) - sum(l);
    }
};

signed main(){
    int n, Q;
    cin >> n >> Q;
    
    FenwickTree<int> fw(n);
    rep(i,n){
        int a; cin >> a;
        fw.add(i, a);
    }
    
    while(Q--){
        int type; cin >> type;
        if(type == 0){
            int p, x;
            cin >> p >> x;
            fw.add(p, x);
        }else{
            int l, r;
            cin >> l >> r;
            cout << fw.sum(l, r) << endl;
        }
    }
}

Measured memory_bytes: 8208
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */

// http://agc014.contest.atcoder.jp/tasks/agc014_c


int main(const int argc, char * argv [])
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  size_t n, m, k;
  cin >> n >> m >> k;

  vector<string> a(n);
  cin >> a;

  // typedef pair<size_t, size_t> value_t;
  const size_t inf = n * m + 100;

  typedef pair<pair<size_t, size_t>, size_t> value_t;

  const auto comp = [](const value_t & a, const value_t & b) {
    return b.second < a.second;
  };

  priority_queue<value_t, vector<value_t>, decltype(comp)> heap(comp);
  vector<vector<size_t>> dist(n, vector<size_t>(m, inf));

  for(size_t i = 0; i < n && heap.empty(); ++i)
    for(size_t j = 0; j < m && heap.empty(); ++j)
      if(a[i][j] == 'S')
      {
        a[i][j] = '.';
        dist[i][j] = 0;
        heap.push({{i, j}, 0});
      }

  size_t out = inf;

  while(!heap.empty())
  {
    const auto pr = heap.top();
    heap.pop();

    const size_t i = pr.first.first;
    const size_t j = pr.first.second;
    const size_t d = pr.second;
    if(d != dist[i][j]) continue;

    out = min(out, 1 + (i + k - 1) / k);
    out = min(out, 1 + (j + k - 1) / k);

    out = min(out, 1 + (n + k - i - 2) / k);
    out = min(out, 1 + (m + k - j - 2) / k);

    if(d == k) continue;

    if(0 < i && a[i - 1][j] == '.' && d + 1 < dist[i - 1][j])
      heap.push({{i - 1, j}, dist[i - 1][j] = d + 1});

    if(i + 1 < n && a[i + 1][j] == '.' && d + 1 < dist[i + 1][j])
      heap.push({{i + 1, j}, dist[i + 1][j] = d + 1});

    if(0 < j && a[i][j - 1] == '.' && d + 1 < dist[i][j - 1])
      heap.push({{i, j - 1}, dist[i][j - 1] = d + 1});

    if(j + 1 < m && a[i][j + 1] == '.' && d + 1 < dist[i][j + 1])
      heap.push({{i, j + 1}, dist[i][j + 1] = d + 1});
  }

  cout << out;
  return EXIT_SUCCESS;
}



Measured memory_bytes: 6016
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
#define MAX_V 10000
#define INF 1000000001
typedef pair<int,int> P;

struct edge { int to,cap,cost,rev; };

int V;
vector<edge> G[MAX_V];
int h[MAX_V];
int dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];

void init_edge(){
  for(int i=0;i<V;i++)G[i].clear();
}

void add_edge(int from,int to,int cap,int cost){
  G[from].push_back((edge){to,cap,cost,(int)G[to].size()});
  G[to].push_back((edge){from,0,-cost,(int)G[from].size()-1});
}

int min_cost_flow(int s,int t,int f){
  int res = 0;
  fill(h,h+V,0);
  while(f>0){

    priority_queue< P, vector<P>, greater<P> >  que;
    fill( dist, dist+V , INF );
    dist[s]=0;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      int v = p.second;
      if(dist[v]<p.first)continue;
      for(int i=0;i<(int)G[v].size();i++){
        edge &e = G[v][i];
        if(e.cap>0&&dist[e.to] > dist[v]+e.cost+h[v]-h[e.to]){
          dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
          prevv[e.to]=v;
          preve[e.to]=i;
          que.push(P(dist[e.to],e.to));
        }
      }
    }

    if(dist[t]==INF){
      return -1;
    }
    for(int v=0;v<V;v++)h[v]+=dist[v];

    int d=f;
    for(int v=t;v!=s;v=prevv[v]){
      d=min(d,G[prevv[v]][preve[v]].cap);
    }
    f-=d;
    res+=d*h[t];
    for(int v=t;v!=s;v=prevv[v]){
      edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }
  return res;
}

int main(){
  int E,F,a,b,c,d;
  cin>>V>>E>>F;
  while(E--){
    cin>>a>>b>>c>>d;
    add_edge(a,b,c,d);
  }
  cout<<min_cost_flow(0,V-1,F)<<endl;
  return 0;
}

Measured memory_bytes: 1528
N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

min_cnt = 10**13
divisor = make_divisors(N)

for i in range(len(divisor)):
    b = N // divisor[i]
    min_cnt = min(min_cnt, (divisor[i]-1 + b-1))
print(min_cnt)

Measured memory_bytes: 3264
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


signed main(){
    fast

    int n,w;cin>>n>>w;
    ll wi[n],vi[n];
    f0(i,0,n) cin>>wi[i]>>vi[i];

    ll dp[n][w+1];
    f0(i,0,n){
        if(i==0){
            f0(j,0,wi[i])
                dp[i][j]=0;
            f1(j,wi[i],w)
                dp[i][j]=vi[i];
        }
        else{
            f0(j,0,wi[i])
                dp[i][j]=dp[i-1][j];
            f1(j,wi[i],w)
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-(int)wi[i]]+vi[i]);
        }
    }

    ll ma=0;
    f1(i,0,w){
        ma=max(ma,dp[n-1][i]);
    }
    cout<<ma;
}

Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
struct prob{
	int penality=0;
	int CA=0;
	bool resolve=false;
};
int main(){
	prob tab[100005]={0};
	int N,M,Nprob;
	int AC=0,WA=0;
	string rep;
	cin>>N>>M;
	for (int i = 0; i <M; i++) {
		cin>>Nprob>>rep;
		if (!tab[Nprob].resolve) {
			if (rep=="WA") {
				tab[Nprob].penality++;
			}
			else{
				tab[Nprob].CA=1;
				tab[Nprob].resolve=true;
			}
		}
	}
	for (int i = 0; i <100005; i++) {
		if (tab[i].resolve) {
			AC++;
			WA+=tab[i].penality;
		}
	}
	cout<<AC<<" "<<WA;
	return 0;
}


Measured memory_bytes: 1408
/*
 * main.c
 *
 *  Created on: 2020/03/28
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}

void yesno(int ans) {
	if (ans == 1) {	printf("Yes\n");
	} else {		printf("No\n");	}
	return;
}

void okng(int ans) {
	if (ans == 1) { printf("OK\n");
	} else { 		printf("NG\n");	}
	return;
}

#define FIX_VAL (1000000000 + 7)
ll A[200002] = {0};
ll add[200002] = {0};
int main()
{
	int N = 0;
	scanf("%d", &N);
	int i = 0;
	for (i = 0; i < N; i++) {
		scanf("%lld", &A[i]);
	}

	int j = 0;
	ll prev = 0;
	for (j = N-1; j > 0; j--) {
		add[j] += A[j] + prev;
		prev = add[j];
		//printf("%lld A=%lld\n", add[j], A[j]);
	}


	ll ans = 0;
	for (i = 0; i < N-1; i++) {
		//printf("A=%lld * val=%lld\n", A[i], add[i+1]);
		ll val = add[i+1] % FIX_VAL;
		ans += A[i] * val;
		ans %= FIX_VAL;
	}
	printf("%lld\n", ans);
	return 0;
}


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

int main() {
  int i=0,count=0,j;
  string s;
  cin >> s;
  j = s.size();
  vector<char> s1(j);
  while(i<s.size()){s1.at(i)=s.at(i); i++;}
  reverse(s1.begin(),s1.end());
  if(s.size()!=1){
  for(i=0;i<s.size()/2;i++){
    if(s.at(i)!=s1.at(i)){
      count++;
    }
  }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
//#define all(v) ((v).begin(),(v).end())
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

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

    rep(i,1,4){
        if((a*b*i)%2==1){
            cout<<"Yes"<<endl;
            return 0;
        }    
    }
    cout<<"No"<<endl;
    return 0;

}




Measured memory_bytes: 256
#!venv/bin/python

import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq

#N,M = [int(x) for x in input().split()]

N = int(input())
A = [-1 * int(x) for x in input().split()]

alives = N
A = sorted(A)

heap = heapq.heapify(A)
heap = A
num = 0
while alives > 1:
    biggest = -1 * heapq.heappop(heap)
    second = -1 * heapq.heappop(heap)
    times = int(math.floor(biggest / second))
    new_hp = biggest - second * times
    if new_hp <= 0:
        alives -= 1
    heapq.heappush(heap, second * -1)
    heapq.heappush(heap,new_hp * -1)
    num += 1

for a in A:
    if a < 0:
        print (a * -1)
        break


Measured memory_bytes: 25328
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    int a[n];
    int b[n];
    int c[n];
    for(int i = 0; i<n; i++){
        cin >> a[i];
    }
    for(int i = 0; i<n; i++){
        cin >> b[i];
    }
    for(int i = 0; i<n; i++){
        cin >> c[i];
    }
    sort(a,a+n);
    sort(b,b+n);
    sort(c,c+n);
    long long valb[n];
    int p = 0;
    for(int i = 0; i<n; i++){
        while(p<n && a[p]<b[i]){
            p++;
        }
        valb[i] = p;
    }
    long long tot = 0LL;
    p = 0;
    long long ans = 0LL;
    for(int i = 0; i<n; i++){
        while(p<n && b[p]<c[i]){
            tot += valb[p++];
        }
        ans += tot;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef long long int ld;
typedef unsigned long long int lu;
typedef vector< int > vi;
typedef vector < ld > vd;
typedef set <ld> sd;
typedef vector< vi > vvi;
typedef vector< vd > vvd;
typedef pair< int,int > ii;
typedef pair< ld,ld > id;
#define sz(a) ld((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())

#define rep(i,a,b) for(i=a;i<b;i++)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define reprev(i,a,b) for(i=a;i>=b;i--)


#define Vi vector
#define pr pair
#define isnum(a) (a>=48 && a<=57)
#define isS(a) (a>='a' && a<='z')
#define isU(a) (a>='A' && a<='Z')
#define toS(a) (isU(a)?a+32:a)
#define toU(a) (isS(a)?a-32:a)
#define toC(a) a&15

vector<char> prime (10000000+1, true);
void sieve(ld n)
{	
	//O(nloglogn) time
	prime[0] = prime[1] = false;
	for (ld i=2; i<=n; ++i)
		if (prime[i])
			if (i * 1ll * i <= n)
				for (ld j=i*i; j<=n; j+=i)
					prime[j] = false;
}


vd v1;
vector <bool> visit;
vvd g;
vvd g1;
vd ar;
vvd final;
//ld mind = 1000000006;
vd mind;
ld c;

//for topological sort of a graph
void dfs(ld i,ld n)
{
	visit[i] = true;
	ld j,k;
	for(j=0;j<g[i].size();j++)
	{
		if(!visit[g[i][j]])
		{
			dfs(g[i][j],n);
		}
	}
	v1.pb(i);
}
//next step
//from transposed graph g1,get strongly connected components
void dfs1(ld i,ld n,ld len)
{
	visit[i] = true;
	ld j,k;
	final[len].pb(i);
	mind[len] = min(mind[len],ar[i]);
	rep(j,0,g1[i].size())
	{
		if(!visit[g1[i][j]])
		{
			dfs1(g1[i][j],n,len);
		}
	}
}

int main(){
	ld n,i,j;
	cin >> n;
	ld ar[n];
	for(i=0;i<n;i++)
	{
		cin >> ar[i];
	}
	ld dp[n+1] = {0};
	//cout << dp[2] << endl;
	dp[1]=0;
	dp[2] = dp[1]+abs(ar[1]-ar[0]);
	//cout << dp[2] << endl;
	rep(i,3,n+1)
	{
		dp[i] = 100000000;
		dp[i] = min(dp[i-1]+abs(ar[i-1]-ar[i-2]),dp[i-2]+abs(ar[i-1]-ar[i-3]));
	}
	cout << dp[n] << endl;
	return 0;
}	

Measured memory_bytes: 11520
N = int(input())
A = []
B = []
C = []
for _ in range(N):
  a,b,c = map(int, input().split())
  A.append(a)
  B.append(b)
  C.append(c)

Ha = [-1 for _ in range(N)]
Hb = [-1 for _ in range(N)]
Hc = [-1 for _ in range(N)]

Ha[0] = A[0]
Hb[0] = B[0]
Hc[0] = C[0]

for i in range(1, N):
  Ha[i] = max(Hb[i-1] + A[i], Hc[i-1] + A[i])
  Hb[i] = max(Ha[i-1] + B[i], Hc[i-1] + B[i])
  Hc[i] = max(Ha[i-1] + C[i], Hb[i-1] + C[i])

print(max(Ha[N-1], Hb[N-1], Hc[N-1]))

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

using namespace std;

#define max(a,b) (a>b? a:b)
#define min(a,b) (a<b? a:b)
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define ONLINE_JUDGE

#pragma GCC Optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment (linker,"/stack:200000000")

typedef long long ll;

bool Finish_read;

template<class T>inline void read(T &x){Finish_read=0;x=0;T f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}

const int Maxn=2e5+5;
unsigned a[Maxn],y[Maxn],n;

int main() {
#ifndef ONLINE_JUDGE
    FO(FileName)
#endif
    read(n);
    for(unsigned i=1;i<=n;++i)
        read(a[i]);
    memcpy(y,a,sizeof(a));
    stable_sort(a+1,a+1+n);
#define mid (1+n>>1)
    for(unsigned i=1;i<=n;++i)
        if(y[i]==a[mid])
            write(a[mid+1]),putchar('\n');
        else if(y[i]==a[mid+1])
            write(a[mid]),putchar('\n');
        else if(y[i]<a[mid])
            write(a[mid+1]),putchar('\n');
        else if(y[i]>a[mid+1])
            write(a[mid]),putchar('\n');
    return 0;
}

Measured memory_bytes: 3716
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
const int INF = (1 << 30);

//毎回変える定数
#define N_MAX 200


//変数
LL k, num_max, num_min;
vector<LL> a;
bool flag;

//サブ関数
//入力
void input(){
	cin >> k;
	REP(i, k) {
		LL tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
	num_max = a.back() * 2 - 1;
	num_min = a.back();
	flag = (a.back() == 2);
}


//計算
void calc(){
	if (flag==false)return;
	for (int i = k - 2; i > -1; i--) {
		//DEBUGING(num_min << " " << num_max);
		LL group = num_min / a[i];
		while (a[i] * group < num_min)group++;
		if (!(num_min <= a[i] * group && a[i] * group <= num_max)) {
			flag = false;
			break;
		}
		num_min = a[i] * group;

		group = num_max / a[i];
		while (a[i] * group <= num_max)group++;
		num_max = a[i] * group - 1;
	}
}


//出力
void output(){
	if (flag) {
		DEBUGING(num_min << " " << num_max);
	}
	else {
		DEBUGING(-1);
	}
}

//デバッグ
void debug(){
	int N;
	cin>>N;
}


//メイン関数
int main(){
	
	input();
	calc();
	output();
	debug();
	
	return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
 
using namespace std;

#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)

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

long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;
 
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int main(){
	int a, b;
	
	cin >> a >> b;
	
	if (a%3 == 0 || b%3 == 0 || (a+b)%3 == 0) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 101
#define WH 0
#define GR 1
#define BL 2
void DFSV(int);
void DFS(void);
int G[MAX][MAX];
int D[MAX];
int F[MAX];
int color[MAX];
int n;
int time;
main(){
  int i, j, a, b, v;
  scanf("%d",&n);

  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){

      G[i][j] = 0;

    }
  }

  for(i = 1; i <= n; i++){

    scanf("%d %d", &b, &a);

    for(j = 1; j <= a; j++){

      scanf("%d",&v);

      G[i][v] = 1;
    }
  }
 
  DFS();

  for(i = 1; i <= n; i++)
    {
      printf("%d %d %d\n", i, D[i], F[i]);
    }

 return 0;

}




void DFS(void){
  int i;

  for( i = 1; i <= n; i++ ){

    color[i] = WH;

  }

  time = 0;

 for( i = 1; i <= n; i++ ){
   if( color[i] == WH )
     DFSV(i);

  }

}

void DFSV(int x){
  int j;

  color[x] = GR;

  time++;
 
  D[x] = time;

  for(j = 1; j <= n ; j++){

    if(G[x][j] == 1 && color[j] == WH)
      DFSV(j);
  }
  color[x] = BL;
  F[x] = ++time;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<int> order(N + 1);
    REP(i, 1, N + 1) {
        int a; cin >> a;
        order[a] = i;
    }

    ll ans = 0;
    set<int> used = {0, N + 1};
    REP(i, 1, N + 1) {
        int l, r;
        auto itr = used.lower_bound(order[i]);
        r = (*itr);
        l = *(--itr);
        // cout << "# i : " << i << " idx : " << order[i] << " l : " << l << " r : " << r << endl;
        ans += (ll)i * (order[i] - l) * (r - order[i]);
        used.insert(order[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10368
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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








int main(){
    int D; std::cin >> D;
    std::vector<int> c(26), t(D+1);
    std::vector<std::set<int>> days(26);
    for(int i(0); i < 26; ++i){
        days[i].emplace(0);
        days[i].emplace(D+1);
    }
    std::vector<std::vector<int>> s(D+1, std::vector<int>(26));
    for(int i(0); i < 26; ++i) std::cin >> c[i];
    for(int i(1); i <= D; ++i){
        for(int j(0); j < 26; ++j) std::cin >> s[i][j];
    }

    for(int i(1); i <= D; ++i){
        std::cin >> t[i];
        --t[i];
        days[t[i]].emplace(i);
    }
    long long v(0);
    
    for(int i(1); i <= D; ++i){
        long long dcr(0);
        for(int j(0); j < 26; ++j){
            auto itr(std::upper_bound(std::begin(days[j]), std::end(days[j]), i));
            dcr += c[j] * (i - *(--itr));
        }
        v += s[i][t[i]] - dcr;
    }
    int M; std::cin >> M;
    {
        int d, q;
        for(int qq(0); qq < M; ++qq){
            std::cin >> d >> q;
            --q;

            auto itr(days[t[d]].find(d));
            long long d1(*(--itr));
            itr = std::upper_bound(std::begin(days[t[d]]), std::end(days[t[d]]), d);
            long long d2((*itr)-1);
            v -= c[t[d]] * ((d1-d)*(d-d2) + d - d1);

            itr = std::lower_bound(std::begin(days[q]), std::end(days[q]), d);
            d1 = *(--itr);
            itr = std::upper_bound(std::begin(days[q]), std::end(days[q]), d);
            d2 = (*itr)-1;
            v += c[q] * ((d1-d)*(d-d2) + d - d1);

            v += s[d][q] - s[d][t[d]];
            days[t[d]].erase(d);
            days[q].emplace(d);
            t[d] = q;
            std::cout << v << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll A,B,v,ans=0;cin>>A>>B;
  if(A%2==0) {
    if(B%2==0) {
      v=(B-A)/2;
      ans=B^(v%2);
    }
    else {
      v=(B-A+1)/2;
      ans=v%2;
    }
  }
  else {
    if(B%2==0) {
      v=(B-1-A)/2;
      ans=A^(v%2);
      ans^=B;
    }
    else {
      v=(B-A)/2;
      ans=A^(v%2);
    }
  }
  print(ans);
  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 ;
}
int ke (int n){
    n--;
    if(n == 1 )return 0;
    int ans = 1;
    while (0 < n){
        ans *= n;
        n--;
    }
    return ans ;

}

void go(ll n , ll k){
    ll mi = INF;
    REP(i,3){
        mi = min(mi, abs(n-k));
        n = abs(n-k);
    }

    cout << mi <<endl;
    
    return  ;


}
int main(){
    int k;
    cin >> k;

    vector<string> vec;
    queue <string> piko;
    FOR(i,1,10){
        piko.push(to_string(i));
        vec.push_back(to_string(i));
    }

    if(k < 10){
        cout << k <<endl;
        return 0;
    }
    
    while(k >  vec.size()){
        string  i = piko.front(); piko.pop();
        char i1,i2,i3;
        i2 = i[i.size()-1];
        i1 = i2; i3 = i2;
        if(i2 == '0'){
            i1 ++;
            string ii1 = i + i1, ii2 = i + i2;
            piko.push(ii2) ; piko.push(ii1);
            vec.push_back(ii2); vec.push_back(ii1) ;
            continue;
        }
        i1--;
        if(i2 == '9'){
            string ii1 = i + i1, ii2 = i + i2;
            piko.push(ii1) ; piko.push(ii2);
            vec.push_back(ii1);vec.push_back(ii2);
            continue;
        }
        i3 ++;
        string ii1 = i + i1, ii2 = i + i2, ii3 = i + i3;
        piko.push(ii1) ; piko.push(ii2); piko.push(ii3); 
        vec.push_back(ii1); vec.push_back(ii2) ; vec.push_back(ii3);
       
    }

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


    

}





Measured memory_bytes: 7412
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
int main(){
    int n; cin>>n; int x=0; string hoge;cin>>hoge;
    int ans=0;
    rep(i,hoge.size()){if(hoge[i]=='D'){--x; ans=max(ans,x);}else if(hoge[i]=='I'){++x; ans=max(ans,x);}}
    cout<<ans<<endl;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(A + 1):
  if 500 * i > X:
    break
  for j in range(B + 1):
    if 500 * i + 100 * j > X:
      break
    if X - 500 * i - 100 * j <= 50 * C:
      ans += 1
print(ans)

Measured memory_bytes: 63868
import sys
def input():
    return sys.stdin.readline()[:-1]
n,w=map(int,input().split())
wv=[list(map(int,input().split())) for i in range(n)]
weights=[[float("inf")]*(10**5+1) for i in range(n+1)]
for i in range(n):
    weights[i+1][wv[i][1]]=min(weights[i+1][wv[i][1]], wv[i][0])
    for j in range(10**5+1):
        if weights[i][j]!=0:
            weights[i+1][j]=min(weights[i+1][j], weights[i][j])
            if weights[i][j]+wv[i][0]<=w:
                weights[i+1][j+wv[i][1]]=min(weights[i+1][j+wv[i][1]], weights[i][j]+wv[i][0])

for i in range(10**5+1):
    if weights[-1][10**5-i]!=float("inf"):
        print(10**5-i)
        quit()

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

int main(){
    int n,k,v,s;
    scanf("%d %d",&n ,&k);
    vector<int> cnt(n);
    for(int i=0;i<k;i++){
        scanf("%d", &s);
        for(int j=0;j<s;j++) {
            scanf("%d",&v);
            cnt[v-1]++;
        }
    }
    int res = 0;
    for(int a : cnt) if(a==0) res++;
    printf("%d\n", res);
}


Measured memory_bytes: 3748
#include <stdio.h>
int boxcount(int);
int max(int,int);
int count[40000];
int nimotsu[40000];
int H;

int main(){
  int i,n,x,y;
  for(i=0;i<40000;i++){
    count[i]=-1;
	nimotsu[i]=0;
  }
    scanf("%d %d",&H,&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&x,&y);
    nimotsu[x+y*4]=1;
  }
  printf("%d\n",boxcount(0));
  return 0;
}

int boxcount(int num){
  if(num >= H*4-4){return 0;}
  if(count[num] > -1){return count[num];}
  else{
  	
	if((num%4)==0){
      if(nimotsu[num]==0 && nimotsu[num+1]==0 && nimotsu[num+4]==0 && nimotsu[num+5]==0){
        if(nimotsu[num+2]==0 && nimotsu[num+3]==0 && nimotsu[num+6]==0 && nimotsu[num+7]==0){
		  count[num]=max(boxcount(num+1),2+boxcount(num+8));
		  return count[num];
        }
		else{
		  count[num]=max(boxcount(num+1),1+boxcount(num+6));
		  return count[num];          
		}
      }
      else{
	  	count[num]=boxcount(num+1);
	    return count[num];
      }
	}

	else if((num%4)==1){
      if(nimotsu[num]==0 && nimotsu[num+1]==0 && nimotsu[num+4]==0 && nimotsu[num+5]==0){
		count[num]=max(boxcount(num+1),1+boxcount(num+7));
		return count[num];          
      }
	  else{
		count[num]=boxcount(num+1);
		return count[num];          	  	
	  }
	}

	else if((num%4)==2){
      if(nimotsu[num]==0 && nimotsu[num+1]==0 && nimotsu[num+4]==0 && nimotsu[num+5]==0){
        if(num<H*4-8 && nimotsu[num+2]==0 && nimotsu[num+3]==0 && nimotsu[num+6]==0 && nimotsu[num+7]==0){
		  count[num]=max(boxcount(num+1),2+boxcount(num+8));
		  return count[num];
        }
		else{
		  count[num]=max(boxcount(num+1),1+boxcount(num+6));
		  return count[num];          
		}
      }
      else{
	  	count[num]=boxcount(num+1);
	    return count[num];
      }
	}
		
	else{
      count[num]=boxcount(num+1);
	  return count[num];
	}
  }
  return 0;
}

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


Measured memory_bytes: 3300
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<u128> = procon_read();
	let mut v:Vec<u128> = procon_read();
	v.sort();
	if v[0] != 0 {
	    let mut r = 1;
	    let mut order = 0;
    	let mut flag = true;
    	let mut orderflag = true;
	    for i in (0..v.len()).rev() {
	        let beforeorder = order;
	        if orderflag {
    	        for j in (1..19).rev() {
	                if 10_u128.pow(j) <= v[i] {
	                    order += j;
                        break;
                    }
	            }
	            if order - beforeorder == 0 {
	                orderflag = false;
	            }
	        }
	        if order > 18 {
	                println!("-1");
	                flag = false;
	                break;
	        }
	        r *= v[i];
	        if r > 10_u128.pow(18) {
	            println!("-1");
	            flag = false;
	            break;
            }
	    }
	    if flag {
	        println!("{}", r);
	    }
	}else{
	    println!("0");
	}
}


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

int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	if(a+b>c+d)
		cout << "Left" << endl;
	else if(a+b==c+d)
		cout << "Balanced" << endl;
	else
		cout << "Right" << endl;
	return 0;
}

Measured memory_bytes: 256
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {

    const lines = input.split('\n')
    const [N, M, K] = lines[0].split(' ').map(Number)
    const A = lines[1].split(' ').map(Number)
    const B = lines[2].split(' ').map(Number)

    const a = []
    a[0] = 0
    for (let i = 0; i < N; i++) {
        a[i + 1] = a[i] + A[i]
        if (a[i + 1] > K) {
            a.pop()
            break
        }
    }

    const b = []
    b[0] = 0
    for (let i = 0; i < M; i++) {
        b[i + 1] = b[i] + B[i]
        if (b[i + 1] > K) {
            b.pop()
            break
        }
    }

    let dp = Array(N + M).fill(Infinity)

    let count =  0
	let j = 0
    for (let i = a.length - 1; i >= 0; i--) {
        for (; j < b.length; j++) {     
            if (a[i] + b[j] > K) {
                count = Math.max(count, i + j - 1)
                break
            } else {
                count = Math.max(count, i + j)
            }
        }
    }

    console.log(count)

})(input)


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

int main() {
    int N,Y;
    cin >> N >> Y;
    int i, j, k;
    for(i = 0; i <= N; ++i) {
        for(j = 0; i + j <= N; ++j) {
            k = Y/1000 - 10 * i - 5 * j;
            if(k >= 0 && i + j + k == N) {
                printf("%d %d %d\n", i, j, k);
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");
}


Measured memory_bytes: 256
n = int(input())
S = [input() for _ in range(n)]

from collections import Counter

C = Counter(sorted(S))

ans = []
numMax = C.most_common()[0][1]
for key, num in C.most_common():
    if num == numMax:
        ans.append(key)
[print(a) for a in sorted(ans)]

Measured memory_bytes: 127588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;

//xを２進展開した時、各けたの数字を格納した。
vll calc(ll x){
  vll v;
  for (int l=0;l<100;l++){
    ll c=x%2;
    v.push_back(c);
    x/=2;
  }
  return v;
}

//xは、A_1,A_2,...,A_Nのつもり。数字の列。
vll counter(vll x){
  //初期化した。
  ll N=x.size();
  vll cnt(100);
  for (int l=0;l<100;l++){
    cnt[l]=0;
  }
  //各xの各げんA_iの各桁を計算して、その分cntにたす。
  for(ll i=0;i<N;i++){
    vll v=calc(x[i]);
    for(ll l=0;l<100;l++){
      cnt[l]+=v[l];
    }
  }
  
  return cnt;
}


int main(){
  //入力の受け取り
  ll N,K;cin>>N>>K;
  vll x;
  for(ll i=0;i<N;i++){
    ll a;cin>>a;
    x.push_back(a);
  }
  //各桁の買ううんとをした。
  vll count=counter(x);
  //Kをbinary representした。
  vll bin_K=calc(K);

  //maxを与えるXを求める。
  ll X=0;
  int flag=0;
  //大きい方から決めてく。
  for(int l=99;l>=0;l--){
    //X_lは、Xのl桁目？
    int X_l=0;
    //Kの上位とXの上位が一致していて、かつKのl桁目が0だったり
    if((flag==0)&&(bin_K[l]==0)){
      X+=0;
    }
    //Nが偶数かつ個数が拮抗七衛うなら。
    else{
      if((N%2==0) and(count[l]==N/2)){
        X+=0;
      }
      else if(count[l]<=N/2){
        //1が真に少数派ならpow(2,l)をたす。
        X+=pow(2,l);
        X_l=1;
      }
      else{
        X+=0;
      }
    }

    if (X_l!=bin_K[l]){
      //Kのl桁目とXのl桁目が一致していないなら、flag=1。上から決めてるからね。
      flag=1;
    }
  }
  //最後に、実際の値を計算する。
  ll ans=0;
  for (ll i=0;i<N;i++){
    ans+=X^x[i];
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 1908
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
#define F first
#define S second
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long 
#define ld long double
#define pii pair <int ,int >
#define bug(x)  cout<<"passed "<<x<<endl;
long long const inf = 1e18, linf = 2e9, mod = 1e9+7;
int const mxn = 5e5+10;
 
ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

long long dp[mxn] , h[mxn] , v[mxn]; 

int main(){
	int n , w ; 
	cin>>n>>w ; 
	for (int i = 1 ; i <=n ; i++)
		cin>>h[i]>>v[i] ; 
	
	for (int i = 0 ; i <= 1e5 ; i++)
			dp[i] = inf ; 
			
	dp[0] = 0 ; 
	
	for (int i = 1 ; i <= n ; i++ ){
		for (int j = 1e5; j >=0 ; j--){
			if (v[i] <= j)
				dp[j] = min (dp[j] , dp[j - v[i]] + h[i] ) ; 
		}
	}
	int ans = 0 ; 
	for (int i = 0 ; i <=1e5 ; i++ ){
		if (dp[i] <=w) ans = max (ans , i);
	}
	cout<<ans;  
}




Measured memory_bytes: 6400