akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
   ll N,W;
   cin>>N>>W;
   ll w[N+1],v[N+1];
   for(ll i=1;i<=N;i++)
   {
       cin>>w[i]>>v[i];
   }
   
    vector<vector<ll> >V(N+1,vector<ll>(W+1,0));
    for(ll i=0;i<=N;i++)
    {
        for(ll j=0;j<=W;j++)
        {
            if(i==0 || j==0)
            {
                V[i][j]=0;continue;
            }
            
            V[i][j]=(V[i-1][j]);
            if(j-w[i]>=0)
            V[i][j]=max(V[i][j],v[i]+V[i-1][j-w[i]]);
        }
    }
    cout<<V[N][W];
    
    return 0;
}

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

int main(){
    string r, a;
    while(cin >> r >> a, r != "0" || a != "0"){
        int hit=0, blow=0;
        for(int i=0;i<4;++i)
            if(r[i] == a[i])++hit;
        for(int i=0;i<4;++i)
            for(int j=0;j<4;++j)
                if(i != j && r[i] == a[j]){
                    ++blow;
                    break;
                }
        cout << hit << " " << blow << endl;
    }

    return 0;
}


Measured memory_bytes: 3040
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String character = scanner.nextLine();
		List<String> list = new ArrayList<String>();
		String str;
		int count = 0;
		while (true) {
			str = scanner.next();			
			if(str .equals("END_OF_TEXT")) {
				break;
			}else {
				list.add(str);				
			}
		}
		for(int i = 0; i < list.size(); i++) {
			if(character.equalsIgnoreCase(list.get(i))) {
				count ++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 26124
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
using namespace std;
using ll = long long;
using P = pair<double, int>;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
const int MAX_N = 110;
int n, m;
struct edge
{
    int to; double cost;
    edge(int to, double cost) { this->to = to, this->cost = cost; }
};
vector<edge> G[MAX_N];
void print(vector<int> &pathway, int s, int g)
{
    vector<int> res;
    int v = g;
    while(true)
    {
        res.push_back(v);
        if(v == s) break;
        v = pathway[v];
    }
    reverse(res.begin(), res.end());
    for(int i = 0; i < res.size(); i++)
    {
        if(i) cout << " ";
        cout << res[i] + 1;
    }
    cout << endl;
}
void solve(int s, int g)
{
    vector<double> cost(n, INF);
    vector<int> pathway(n, -1);
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, s));
    cost[s] = pathway[s] = 0;
    while(que.size())
    {
        P p = que.top(); que.pop();
        int v = p.second;
        if(v == g)
        {
            print(pathway, s, g);
            return;
        }
        for(int u = 0; u < G[v].size(); u++)
        {
            edge e = G[v][u];
            if(p.first + e.cost < cost[e.to])
            {
                cost[e.to] = p.first + e.cost;
                pathway[e.to] = v;
                que.push(P(cost[e.to], e.to));
            }
        }
    }
    cout << "NA" << endl;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n, n)
    {
        for(int i = 0; i < MAX_N; i++) G[i].clear();
        vector<int> id(n), x(n), y(n);
        for(int i = 0; i < n; i++)
        {
            cin >> id[i] >> x[i] >> y[i];
            id[i]--;
        }
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < n; j++)
            {
                if(i == j) continue;
                int a = x[i] - x[j], b = y[i] - y[j];
                double d = sqrt(a * a + b * b);
                if(d <= 50) G[id[i]].push_back(edge(id[j], d));
            }
        }
        cin >> m;
        for(int i = 0; i < m; i++)
        {
            int s, g; cin >> s >> g;
            s--, g--;
            solve(s, g);
        }
    }
    return 0;
}




Measured memory_bytes: 3028
class SegmentTree():
    def __init__(self,param,default,func):
        if isinstance(param,list):
            n=len(param)
        else:
            n=param
        self.d=default
        self.leaf=1<<(n-1).bit_length()
        if isinstance(param,list):
            self.tree=[default]*(self.leaf-1)+param+[default]*(self.leaf-n)
            for i in range(self.leaf-2,-1,-1):
                self.tree[i]=func(self.tree[i*2+1],self.tree[i*2+2])
        else:
            self.tree=[default]*(self.leaf*2-1)
        self.f=func
    def find(self,i):
        return self.tree[i+self.leaf-1]
    def merge(self,a,b):
        return self.f(a,b)
    def get_top(self):
        return self.tree[0]
    def query(self,a,b): #[a,b)
        T=self.tree
        l,r=a+self.leaf-1,b+self.leaf-1
        res=self.d
        while l<r:
            if not l%2:
                res=self.merge(res,T[l])
                l+=1
            if not r%2:
                r-=1
                res=self.merge(res,T[r])
            l>>=1; r>>=1
        return res

def main():
    inf=10**7
    n,k=map(int,input().split())
    P=list(map(int,input().split()))
    segmax=SegmentTree(P,0,max)
    segmin=SegmentTree(P,inf,min)
    ans=n-k+1
    for i in range(n-k):
        if segmin.query(i,i+k)==P[i] and segmax.query(i,i+k)<P[i+k]:
            ans-=1
    tmp=1
    cnt=0
    for i in range(n-1):
        if P[i]>P[i+1]:
            if tmp>=k:
                cnt+=1
            tmp=1
        else:
            tmp+=1
    if tmp>=k:
        cnt+=1
    if cnt:
        ans-=cnt-1
    print(ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 96000
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, A, B; cin >> N >> A >> B;
  cout << min(A, B) << " " << max(0, B - (N - A)) << endl;
}

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

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

        int ans=0;
        while(n!=0){
                if(n==10 && ans==0){
                        ans=10;
                        n=0;
                        break;
                }
                int tmp=n%10;
                int a=tmp/2;
                int b=tmp-a;
                ans+=a+b;
                n/=10;
        }

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


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

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

int main() {
	int n, x;
	cin >> n >> x;
	vector<int> a(n);
	rep (i, n) {
		cin >> a[i]; 
		a[i] = abs(a[i] - x);
	}
	int ans = 0;
	rep(i, n) {
		ans = gcd(ans, a[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
#define r(w,e) for(int w=0;w<e;w++)
int main(){
	int a,b,_a[100],_b[100],d;
	TOP:
	while(cin>>a>>b,a+b){
		r(i,a)cin>>_a[i];r(i,b)cin>>_b[i];
		if((d=accumulate(_a,_a+a,0)-accumulate(_b,_b+b,0))%2!=0){cout<<"-1"<<endl;goto TOP;}
		d/=2;
		r(p,100)r(i,a)if(_a[i]==p)r(j,b)if(_b[j]==p-d){cout<<_a[i]<<" "<<_b[j]<<endl;goto TOP; }
		cout<<"-1"<<endl;
	}
}

Measured memory_bytes: 2992
#include <bits/stdc++.h>
using namespace std;
#define DEBUG 0
#define nl          '\n'
#define fori(n)			for(int i = 0; i < n; ++i) 
#define forj(n)			for(int j = 0; j < n; ++j)
#define fork(n)			for(int k = 0; k < n; ++k)
#define forl(n)			for(int l = 0; l < n; ++l)
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define ppb push_back
typedef long long ll;typedef pair<int,int> pii;typedef vector<bool> vbool;
typedef vector<int> vint;typedef vector<ll> vll;typedef long double ld;
typedef vector<vector<int>> vvi; typedef vector<vbool> vvb;

const ll N = 100010;
const ll INF = 0x3f3f3f3f;
const ll MOD = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll k, x; cin >> k >> x; if (k*500 >= x) cout << "Yes" << nl; else cout << "No" << nl;	
	
	#if DEBUG
	cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << " s" << nl;
	#endif
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = []

A.append(1)
for i in range(1,7):
    A.append(6**i)
for i in range(1,6):
    A.append(9**i)
    
    
A.sort()
dp = [10*5+5]*(N+1)
dp[0] = 0
for i in range(1, N+1):
    for s in range(len(A)):
        if i-A[s] >= 0:
            dp[i] = min(dp[i-A[s]]+1, dp[i])
            
            
print(dp[N])

Measured memory_bytes: 41836
from itertools import combinations

N, K = map(int, input().split())

if K > (N-1)*(N-2)//2:
  print(-1)
else:
  M = N*(N-1)//2 - K
  print(M)
  for i in range(2, N+1):
    print(1, i)
  M -= N-1
  for ab in combinations(range(2, N+1), 2):
    if M == 0:
      break
    else:
      a, b = ab
      print(a, b)
      M -= 1

Measured memory_bytes: 9232
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include<string>
#include <stack>
#include<queue>
#include<map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int n, w;
	cin >> n;
	deque<int> a;
	if (n % 2 == 0) {
		for (int i = 0; i < n; i++) {
			cin >> w;
			if (i % 2 != 0) {
				a.push_front(w);
			} else {
				a.push_back(w);
			}
		}

	} else {
		for (int i = 0; i < n; i++) {
			cin >> w;
			if (i % 2 == 0) {
				a.push_front(w);
			} else {
				a.push_back(w);
			}
		}
	}
	for (int i = 0; i < a.size(); i++) {
		cout << a.at(i) << " ";
	}
	cout << endl;

}


Measured memory_bytes: 2944
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		//Scanner reader=new Scanner(System.in);
		String s;//=reader.readLine();
		//int in=reader.nextInt();
		int[] in=new int[100];
		while((s=reader.readLine())!=null){
			int i=Integer.parseInt(s);
			in[--i]++;
		}
		int max=0;
		for(int i=1;i<=100;i++)if(in[i-1]>max)max=in[i-1];
		for(int i=1;i<=100;i++)if(in[i-1]==max)System.out.println(i);
		//System.out.println(max);
	}
}

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

int main(void){
  int n,i,max,id;
  cin >> n;

  int *a = new int[n];
  int *b = new int[n];
  int *c = new int[n-1];

  for(i=0;i<n;i++){
    cin >> a[i];
  }
  for(i=0;i<n;i++){
    cin >> b[i];
  }
  for(i=0;i<n-1;i++){
    cin >> c[i];
  }

  id = 0;
  max = 0;

  for(i=0;i<n;i++){
    id = a[i];
    max = max+b[id-1];
    if((i>0) && a[i-1]==a[i]-1 ){
      max = max + c[a[i-1]-1];
    }
  }
  cout << max << "\n";

  delete[] a;
  delete[] b;
  delete[] c;
  return 0;



}


Measured memory_bytes: 256
/*
the top of the losers
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    Lcm(a,b)  ((a*b)/(__gcd(a,b)))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define    x            real()
#define    y            imag()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define     point        complex<double>
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
typedef  long long     ll ;
typedef  unsigned long long     ull ;
const double eps= (1e-9);
using namespace std;
using namespace __gnu_pbds;
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
vector< pair<int,pair<int,int> > >v1,v2;
string tst;
ll get_res(){
    int cnt=0;
    for(int i=0;i<sz(tst)-1;i++){
        if(tst[i]==tst[i+1])
            cnt++;
    }
    return cnt;
}
void up(int a,int b){
   for(int i=a;i<=b;i++){
    if(tst[i]=='L') tst[i]='R';
    else tst[i]='L';
   }
}
int main(){
    GO();
    int n,k;
    string st;
    cin>>n>>k>>st;
    int lf=0;
    tst=st;
    for(int i=0;i<n;i++){
        if(i+1<n&&st[i]==st[i+1]){
            ;
        }
        else{
            int stat=0;
            if(i>0&&lf<n)
                stat=2;
            else if(i==0&&lf==n-1){
                stat=0;
            }
            else{
               stat=1;
            }
            if(st[i]=='L')
            v1.pb(mp(stat,mp(lf,i)));
            else
            v2.pb(mp(stat,mp(lf,i)));
            lf=i+1;
        }
    }
    int cnt=0;

    sort(allr(v1));
    sort(allr(v2));
    int rem=k;
    ll add=0;
    for(int i=0;i<sz(v1)&&rem>0;i++){
        rem--;
        up(v1[i].second.first,v1[i].second.second);
    }
    cnt=get_res();

    int ans=0;
    ans=max(cnt,ans);

    rem=k;
    add=0;
    tst=st;

    for(int i=0;i<sz(v2)&&rem>0;i++){
        rem--;
        up(v2[i].second.first,v2[i].second.second);
    }
    cnt=get_res();
    ans=max(ans,cnt);
    cout<<ans<<endl;
}




Measured memory_bytes: 1932
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int f(int a[][16],int b[][16],int c[16][16],int x,int y,int gx,int gy){
  int s=0;
  if(x==gx&&y==gy)
    return 1;
  if(c[x][y]!=-1)
    return c[x][y];
  if(a[x][y]==0)
    s+=f(a,b,c,x,y+1,gx,gy);
  if(b[x][y]==0)
    s+=f(a,b,c,x+1,y,gx,gy);
  c[x][y]=s;
  return s;
}
int main(){
  int h,i,j;
  int a[16][16],b[16][16],c[16][16],gx,gy,m,n,s;
  memset(a,-1,sizeof(a));
  memset(b,-1,sizeof(b));
  cin>>m;
  for(h=0;h<m;h++){
    cin>>gx>>gy>>n;
    for(i=0;i<gy;i++)
      for(j=0;j<gx+1;j++)
	a[j][i]=0;
    for(i=0;i<gy+1;i++)
      for(j=0;j<gx;j++)
	b[j][i]=0;
    for(i=0;i<n;i++){
      int t,u,v,w;
      cin>>t>>u>>v>>w;
      if(t==v)
	a[t][min(u,w)]=-1;
      else
	b[min(t,v)][u]=-1;
    }
    memset(c,-1,sizeof(c));
    s=f(a,b,c,0,0,gx,gy);
    if(s)
      cout<<s<<endl;
    else
      cout<<"Miserable Hokusai!"<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int Z = sc.nextInt();
		int K = sc.nextInt();

		long[] A = new long[X+1];
		long[] B = new long[Y+1];
		long[] C = new long[Z+1];

		for(int i = 1 ; i <= X ; i++){
			A[i] = sc.nextLong();
		}
		for(int i = 1 ; i <= Y ; i++){
			B[i] = sc.nextLong();
		}
		for(int i = 1 ; i <= Z ; i++){
			C[i] = sc.nextLong();
		}
		sc.close();

		long[] ANS = new long[1000000];

		Arrays.sort(A);
		Arrays.sort(B);
		Arrays.sort(C);

		int count = 0;
		for(int i = 1 ; i <= X ; i++){
			for(int j = 1 ; j <= Y ; j++){
				for(int k = 1 ; k <= Z ; k++){

					if(i*j*k <= 3000){
						ANS[count] = A[X+1-i]+B[Y+1-j]+C[Z+1-k];
						count++;
					}
					else{
						break;
					}
				}
			}
		}

		Arrays.sort(ANS);
		int p = ANS.length;

		for(int i = 0 ; i < K; i++){
			System.out.println(ANS[p-i-1]);
		}

	}
}

Measured memory_bytes: 36296
#include <iostream>
using namespace std;
int a,b,c;
int main()
{
  int n,i,j,k,t;
 cin>>a>>b>>c; 
 k=0;
for (i=1; i<=a; i++)  
  {
  cin>>t;
  if (t<b||t>=c) k++;	
  }
  cout<<k<<endl;
  return 0;  
}


Measured memory_bytes: 256
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using INT=mp::cpp_int;
using namespace std;
using ll=long long;
using vec=vector<ll>;
using vect=vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
INT LCM(INT x,INT y){
  INT z=gcd(x,y);
  return x*y/z;
}
ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}
INT modinv(INT a, INT m) {
    INT b = m, u = 1, v = 0;
    while (b) {
        INT t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int main() {
  cout << fixed << setprecision(30);
  ll n,m,k;
  cin3(n,m,k);
  bool check=false;
  loop(i,n+1){
    loop(j,m+1){
      ll s=i;
      ll t=j;
      if(n*t+m*s-2*s*t==k)check=true;
    }
  }
  if(check)putout("Yes");
  else putout("No");
}


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


long long lcm(vector<long long> v) {
    long long n = v.size();
    long long res = v[0];

    for (long long i = 1ll; i < n; i++) {
        // g := gcd(res, v[i])
        // res := lcm(res, v[i]) = res / g * v[i]
        long long g;
        long long a = res;
        long long b = v[i];

        while (true) {
            if (a < 0) a = -a;
            if (b < 0) b = -b;
            if (b == 0) {
                g = a;
                break;
            }
            else {
                long long x = a % b;
                a = b;
                b = x;
                continue;
            }
        }

        res = res / g * v[i];
    }

    return res;
}


int main() {
    long long n;
    cin >> n;
    vector<long long> t(n);
    for (long long i = 0; i < n; i++) {
        cin >> t[i];
    }

    long long res = lcm(t);

    cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define RI register int
const int N=105;
int a[N],b[N],n,mx;
int main()
{
	scanf("%d",&n);
	for(RI i=1;i<=n;++i) scanf("%d",&a[i]),mx=max(mx,a[i]),++b[a[i]];
	if(mx&1) {
		for(RI i=mx;i>=(mx+1)/2;--i)
			if(b[i]<2) {puts("Impossible");return 0;}
		for(RI i=1;i<(mx+1)/2;++i)
			if(b[i]) {puts("Impossible");return 0;}
		if(b[(mx+1)/2]>2) {puts("Impossible");return 0;}
	}
	else {
		for(RI i=mx;i>mx/2;--i)
			if(b[i]<2) {puts("Impossible");return 0;}
		for(RI i=1;i<mx/2;++i)
			if(b[i]) {puts("Impossible");return 0;}
		if(b[mx/2]!=1) {puts("Impossible");return 0;}
	}
	puts("Possible");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
int n,m,k,mm;
cin>>n>>m>>k>>mm;
int cnt(0);
while(m<=n)
{
m*=2;
++cnt;
}
while(k<=m)
{
k*=2;
++cnt;
}
if(cnt<=mm)
cout<<"Yes\n";
else
cout<<"No\n";
return 0;
}



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

int main() {
  long long N,P;
  cin >> N;
  P = N % 10;
  if (P == 3) {
    cout << "bon" << endl;
  }
  else if (P == 0 || P == 1 || P == 6 || P == 8) {
    cout << "pon" << endl;
  }
  else {
    cout << "hon" << endl;
  }
}


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

using namespace std;

typedef long long ll;

const long long MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int N;
  cin >> N;
  vector<int> A1(N + 1, 0), A2(N + 1, 0);
  int sum = 0;
  for (int i = 0; i < N; ++i) {
    int A;
    cin >> A;
    A1[i + 1] = A1[i] + A;
  }
  for (int i = 0; i < N; ++i) {
    int A;
    cin >> A;
    A2[i + 1] = A2[i] + A;
  }
  int res = 0;
  for (int i = 0; i < N; ++i) {
    res = max(res, A1[i + 1] + (A2[N] - A2[i]));
  }
  cout << res << endl;
}

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


int32_t main()
{
    string s;
    cin >>s;
    for(int i=1;i<4;++i)
    {
      if(s[i]==s[i-1])
      {
      	cout<<"Bad"<<endl;
      	return 0;
      }
    }
    cout<<"Good"<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;
	LL ans = 1;
	LL tot = 1;//奇数の組み合わせを計算しておく
	for(int i=0;i<N;++i){
		ans *= 3;//3^Nを計算しておく

		int A;
		cin >> A;
		if( A&1 ){
			
		}else{
			tot *= 2;
		}
	}
	cout << ans - tot << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define mod 1000000007 
#define check exit(0)
#define nl cout<<endl;
#define inp 200005
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define deb(v) for(int i=0;i<v.size();i++) {cout<<v[i]; (i==v.size()-1) ? cout<<"\n":cout<<" "; }
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace __gnu_pbds;
using namespace std;

// Pick yourself up, 'cause...

int main()
{
    jaldi

    int n;
    cin>>n;

    bool zero=false;

    vector<ll> v(n);
    for(ll &x:v)  {  cin>>x; zero|=(x==0); }

    if(zero)  { cout<<0; return 0; }
    ll ans=1;
    for(ll x:v)
    {
        if(ans>1000000000000000000/x) { cout<<-1; return 0; }
        ans*=x;
    }
    cout<<ans;
    return 0;
}


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

int main(){
  long long K;
  cin>>K;
  if(K<100000){
  if(K%2 == 0){
    cout<<2<<endl;
    cout<<setprecision(18)<<K/2+1<<" "<<K/2+1<<endl;
    return 0;
  }
  else{
    cout<<2<<endl;
    cout<<setprecision(18)<<K/2<<" "<<K/2+3<<endl;
    return 0;
  }
  }
  long long A[50];
  for(int i=0;i<50;i++){
    A[i]=i;
  }
  long long M=K/50;
  long long D=K%50;
  for(int j=0;j<D;j++){
    sort(A,A+50);
    A[0]+=50;
    for(int i=1;i<50;i++){
      A[i]-=1;
    }
  }
  for(int i=0;i<50;i++){
    A[i]+=M;
  }
  sort(A,A+50);  
  cout<<50<<endl;
  for(int i=0;i<50;i++){
    if(i != 0){
      cout<<" ";
    }
    cout<<A[i];
  }
  cout<<endl;
  return 0;
}


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

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> prefer(n,vector<int>(m,0));
  int ans = 0;
  for(int i = 0; i<n; i++){
    int k;
    cin >>k;
    for(int j = 0; j<k; j++){
      int a;
      cin >> a;
      prefer.at(i).at(a-1) = 1;
    }
  }
  for (int l=0; l<m; l++){
    int tmp = 1;
    for (int i=0; i<n; i++){
      tmp *= prefer.at(i).at(l);
    }
    ans += tmp;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    a, b, x = map(int, input().split())
    ans = b//x - (a-1)//x
    print(ans)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 3060
n,m,c=map(int,input().split())
b=list(map(int,input().split()))

def prod(a,b,init=0):
  total=init
  for a_,b_ in zip(a,b):
    total+=a_*b_  
  return total

cnt=0
for i in range(n):
  a=list(map(int,input().split()))
  if 0 < prod(a,b,init=c):
    cnt+=1
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp make_pair
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

class UnionFind {
public:
  vector<int> par, rank;
  UnionFind(int sz) : par(sz, -1), rank(sz, 0){}
  int find(int x){
    if(par[x]<0) return x;
    else return par[x] = find(par[x]);
  }
  void unite(int x, int y){
    x=find(x); y=find(y);
    if(x==y) return;
    if(rank[x] < rank[y]) swap(x,y);
    par[x] += par[y];
    par[y] = x;
    if(rank[x]==rank[y]) rank[x]++;
  }
  inline bool same(int x, int y){ return find(x) == find(y); }
  inline int size(int x){ return -par[find(x)]; }
};

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> p(n);
  rep(i,n) cin>>p[i];

  UnionFind uf(n);

  rep(i,m){
    int x,y;
    cin>>x>>y;
    x--;y--;
    uf.unite(x,y);
  }

  int ans = 0;
  rep(i,n){
    if(uf.same(i, p[i]-1)) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
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();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int dx[]={-1,0,1,0},dy[]={0,-1,0,1};
int main(){
	int w,h;
	while(cin>>w>>h,w|h){
		vvi ver(h,vi(w-1));
		vvi hor(h-1,vi(w));
		REP(i,h){
			REP(j,w-1){
				cin>>ver[i][j];
			}
			if(i<h-1){
				REP(j,w){
					cin>>hor[i][j];
				}
			}
		}
		queue<pii> q;
		vvi cost(h,vi(w));
		q.push(make_pair(0,0));
		cost[0][0]=1;
		while(!q.empty()){
			pii p=q.front();q.pop();
			REP(d,4){
				int y=p.first+dy[d];
				int x=p.second+dx[d];
				if(y>=0&&x>=0&&y<h&&x<w&&!cost[y][x]){
					bool ok=false;
					switch(d){
					case 0:
						ok=!ver[y][x];break;
					case 2:
						ok=!ver[y][x-1];break;
					case 1:
						ok=!hor[y][x];break;
					case 3:
						ok=!hor[y-1][x];break;
					}
					if(ok){
						q.push(make_pair(y,x));
						cost[y][x]=cost[p.first][p.second]+1;
					}
				}
			}
		}
		cout<<cost[h-1][w-1]<<endl;
	}
}

Measured memory_bytes: 1248
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(void){
    // Your code here!
    char w[10];
    char t[1000];
    int flg=0,i;
    //char input[100];
    scanf("%s",w);
    scanf("%s",t);
    //printf("%s\n",input);
    for(i = 0; t[i] != '\0'; i++){
            t[i] = tolower(t[i]);
        }
    if(strcmp(w,t)==0){
        flg++;
    }
    for(;;){
        scanf("%s",t);
        
        if(strcmp(t,"END_OF_TEXT")==0){
            break;
        }
        for(i = 0; t[i] != '\0'; i++){
            t[i] = tolower(t[i]);
        }

        if(strcmp(w,t)==0){
            flg++;
        }
        //printf("%s\n",t);
    }
    printf("%d\n",flg);
    return 0;
    
}



Measured memory_bytes: 2112
#include<iostream>
#include<string>

int main() {
	long long int k,n;
	char ch;
	std::string str;
	std::cin >>str>>k;

	for (int i = 0; i < str.size();i++) {
		if (str[i]!='1') {
			ch = str[i];
			n = i;
			break;
		}
		if (i == str.size() - 1) {
			ch = '1';
		}
	}

	if (k <= n) {
		std::cout << '1' << std::endl;
	}
	else {
		std::cout << ch << std::endl;
	}


	return 0;
}

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

#define YNUM(X) ( X < 0 ? X + 3 : X )

typedef std::pair<int, int> WH;
//typedef std::vector<WH> whvec;

int h, w;
bool map[502][502];
std::string in;
//std::vector<std::vector<whvec> > data(3, std::vector<whvec>(502));
WH data[3][502][500];
int data_max = 0;
int height_sum[502][502], width_sum[502][502];
int data_pt[3][502];
WH wh;

int main(){
	while( std::cin >> h >> w, w + h != 0 ){
		data_max = 0;

		memset( data_pt, 0, sizeof(data_pt) );
		memset( height_sum, 0, sizeof(height_sum) );
		memset( width_sum, 0, sizeof(width_sum) );

		for( int i = 1; i <= h; ++i ){
			std::cin >> in;
			for( int l = 1; l <= w; ++l ){
				map[i][l] = ( in[l - 1] == '.' );
				if(map[i][l]){
					width_sum[i][l] = width_sum[i][l - 1] + 1;
					height_sum[i][l] = height_sum[i - 1][l] + 1;
				}
			}
		}

		for( int i = 1, n = 1; n <= h; n++, i = n % 3 ){
			for( int l = 1; l <= w; l++ ){
				data_pt[i][l] = 0;

				if( map[n][l] ){
					if( map[n - 1][l] && map[n][l - 1] ){
						int x_cnt = width_sum[n][l], y_cnt = height_sum[n][l];

						for( int m = 0; m < data_pt[YNUM(i - 1)][l]; ++m ){
							wh = WH( std::min(data[YNUM(i - 1)][l][m].first, x_cnt), data[YNUM(i - 1)][l][m].second + 1 );
							if( std::find( data[i][l], data[i][l] + data_pt[i][l], wh ) == data[i][l] + data_pt[i][l] ){
								data[i][l][ data_pt[i][l] ] =  wh, data_pt[i][l]++;
								data_max = std::max( data_max, wh.first * wh.second );
							}
						}
						for( int m = 0; m < data_pt[i][l - 1]; ++m ){
							wh = WH( data[i][l - 1][m].first + 1, std::min(data[i][l - 1][m].second, y_cnt) );
							if( std::find( data[i][l], data[i][l] + data_pt[i][l], wh ) == data[i][l] + data_pt[i][l] ){
								data[i][l][ data_pt[i][l] ] = wh, data_pt[i][l]++;
								data_max = std::max( data_max, wh.first * wh.second );
							}
						}
						
					}else if( map[n - 1][l] ){
						for( int m = 0; m < data_pt[YNUM(i - 1)][l]; ++m ){
							data[i][l][ data_pt[i][l] ] = (wh = WH( 1, data[YNUM(i - 1)][l][m].second + 1 )), data_pt[i][l]++;
							data_max = std::max( data_max, wh.first * wh.second );
						}

					}else if( map[n][l - 1] ){
						for( int m = 0; m < data_pt[i][l - 1]; ++m ){
							data[i][l][ data_pt[i][l] ] = (wh = WH( data[i][l - 1][m].first + 1, 1 )), data_pt[i][l]++;
							data_max = std::max( data_max, wh.first * wh.second );
						}

					}else data[i][l][ data_pt[i][l] ] = (wh = WH( 1, 1 )), data_pt[i][l]++, data_max = std::max( data_max, wh.first * wh.second );

				}	
			}
		}

		std::cout << data_max << std::endl;
 	}
	return 0;
}

Measured memory_bytes: 9320
#include <string>
#include <iostream>
#include <stdlib.h> // @atoi
#include <map>
#include <algorithm>
using namespace std;


int main(void)
{
	std::string input;
	cin >> input;

	std::map<string, string> pairMap = {
		{ "A", "T"},
		{ "T", "A"},
		{ "C", "G"},
		{ "G", "C"},
	};

	cout << pairMap[input] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
int main(int argc, const char * argv[]) {
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
    if(a < b)
      if(b < c){
        printf("Yes\n");
        return 0;
      }
  printf("No\n");
  return 0;
}

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

int main ()
{
        int n, a0, a1, dp0, dp1;

        cin >> n >> a0 >> a1;
        dp0 = 0;
        dp1 = abs(a0 - a1);

        while (--n > 1) {
                int a2, dp2;
                cin >> a2;
                dp2 = min(dp0 + abs(a0 - a2), dp1 + abs(a1 - a2));
                dp0 = dp1, dp1 = dp2;
                a0 = a1, a1 = a2;
        }
        cout << dp1 << '\n';

        return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>

int main() {
  char c;
  int sum[26] = {0};
  while (scanf("%c", &c) == 1) {
    if (!isalpha(c))
      continue;
    c = tolower(c);
    ++sum[c - 'a'];
  }
  for (int i = 0; i < 26; i++) {
    printf("%c : %d\n", i + 'a', sum[i]);
  }
  return 0;
}

Measured memory_bytes: 984
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
    string S;
    bool c=0;
    cin >> S;
    for(int i=2;i<=S.size();i+=2){
        for(int j=0;j<(S.size()-i)/2;j++){
            c=0;
            if(S[j]!=S[j+(S.size()-i)/2]){
                c=1;
                break;
            }
        }
        if(c==0){
            cout << S.size()-i << endl;
            return 0;
        }
        
    }
    return 0;
}


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

int main( void )
{
    char c;
    cin >> c;
    if ( c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' )
    {
        cout << "vowel";
    }
    else
    {
        cout << "consonant";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false

int totient(int N){
    if(N<0){
        return 0;
    }
    int R = N;
    for(int i=2;i*i<=N;i++){
        if(N%i==0){
            R -= R/i;
            while(N%i==0){
                N/=i;
            }
        }
    }
    if(N>1){
        R -= R/N;
    }
    return R;
}

std::vector<int> totient_array(int N){
    std::vector<int> R(N+1);
    for(int i=0;i<=N;i++){
        R[i]=i;
    }
    for(int i=2;i<=N;i++){
        if(R[i]!=i)continue;
        for(int j=i;j<=N;j+=i){
            R[j]-=(R[j]/i);
        }
    }
    return R;
}

long long power(long long b,long long e){
    long long r=1;
    while(e){
        if(e&1){
            r=(r*b)%MOD;
        }
        b=(b*b)%MOD;
        e >>=1;
    }
    return r;
}

signed main(void){
    int N,K;
    cin >> N >> K;
    int Ans=0;
    vector<int> tot = totient_array(K);
    for(int i=1;i<=K;i++){
        int b = power(K/i,N);
        int phi = tot[i];
        int r = (b*phi)%MOD;
        //cout << b MM phi MM r << endl;
        Ans=(Ans+r)%MOD;
    }
    cout << Ans << endl;
    
    return 0;
}



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

int main() {
  int N, L[200];
  cin >> N;
  for (int i = 0; i < 2 * N; i++) cin >> L[i];
  sort(L, L + 2 * N);
  int ans = 0;
  for (int i = 0; i < 2 * N; i += 2) ans += min(L[i], L[i + 1]);
  cout << ans << endl;
  return 0;
}

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


int main() {
   int n;
   double a, p, q;
   priority_queue<double, vector<double>, greater<double> > que;
   
   cin>>n;
   for(int i=0;i<n;i++) {
       cin>>a;
       que.push(a);
   }
   for(int i=0;i<n-1;i++) {
       p = que.top(); que.pop();
       q = que.top(); que.pop();
       que.push((p + q) / 2);
   }
   cout<<fixed<<setprecision(10)<<que.top()<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define  rep(i,a,b)for(int i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const int INF=1000000000LL;
const ll r197=1000000007;
typedef pair<ll,int>P;
typedef pair<int,P>Pa;
int n;
ll a[200001];
int dp[200001]={};
vector<P> v;
int calc(int l,int r,int c){
	if(l==r){
		return l;
	}
	int s=(l+r)/2;
	if(v[s].first<c){
		return calc(s+1,r,c);
	}
	if(v[s].first>c){
		return calc(l,s,c);
	}
	return s;
}
int main() {
	cin>>n;
	rep(i,0,n){
		cin>>a[i];
	}
	sort(a,a+n);
	ll c=a[0],d=0;
	rep(i,0,n){
		if(c!=a[i]){
			v.push_back(P(c,d));
			c=a[i];
			d=1;
		}else d++;
	}
	v.push_back(P(c,d));

	ll ans=0;
	rrep(i,v.size()-1,0){
		if(dp[i]==v[i].second)continue;
		ll b=1;
		while(b<=v[i].first){
			b*=2;
		}
		if(b/2==v[i].first){
			int k=v[i].second-dp[i];
			ans+=k/2;
		}else{
			int o=calc(0,v.size(),b-v[i].first);
			if(v[o].first==b-v[i].first&&v[o].second>dp[o]){
				ans+=min(v[i].second-dp[i],v[o].second-dp[o]);
				dp[o]+=min(v[i].second-dp[i],v[o].second-dp[o]);
			}
		}
	}
	cout<<ans<<endl;
}


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

signed main(void)
{
	int n, ans;
	cin >> n;

	ans = 0;
	rep(i, n)
	{
		if (i * i > n)
			break;
		ans = i;
	}
	cout << ans * ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    vector<long long> vec(3);
    cin >> vec[0] >> vec[1] >> vec[2];
    long long red,blue;
    long long h,w;
    long long ans;
    if(vec[0]%2==0 || vec[1]%2==0 || vec[2]%2==0){
        cout << "0" << endl;
    }else{
        sort(vec.begin(),vec.end());
        h = vec[2]/2;
        w = vec[2]-h;
        red = h*vec[1]*vec[0];
        blue = w*vec[1]*vec[0];
        ans = abs(red-blue);
        cout << ans << endl;
    }
}



Measured memory_bytes: 3600
def f(n):
  c=0
  while n>0:
    n%=format(n, 'b').count('1')
    c+=1
  return c

N=int(input())
X=input()
nums=[0]+[f(i) for i in range(1, N+1)]

a=0
b=0
for i in range(N):
  if X[i]=='0':
    a+=1
  else:
    b+=1

s=0
t=0
if b>1:
  for i in range(N):
    s=(s+int(X[i])*pow(2, N-1-i, b+1))%(b+1)
    t=(t+int(X[i])*pow(2, N-1-i, b-1))%(b-1)
else:
  for i in range(N):
    s=(s+int(X[i])*pow(2, N-1-i, b+1))%(b+1)
    
if b==1:
  for i in range(N):
    if X[i]=='0':
      tmp=(s+pow(2, N-1-i, b+1))%(b+1)
      print(nums[tmp]+1)
    else:
      print(0)
  exit()

for i in range(N):
  if X[i]=='0':
    tmp=(s+pow(2, N-1-i, b+1))%(b+1)
    print(nums[tmp]+1)
  else:
    tmp=(t-pow(2, N-1-i, b-1))%(b-1)
    print(nums[tmp]+1)

Measured memory_bytes: 87816
#include <iostream>
#include <math.h>
#define MAX 1000010
using namespace std;

int main(){
	int n;
	int *prime,i,j;
	prime = new int[80000];
	int *answer = new int[MAX];
	int count;
	bool flag;

	count = 0;
	answer[0] = 0;
	answer[1] = 0;
	answer[2] = 1;
	for(i = 3; i <= 1000000; i+=2){
		flag = true;
		for(j = 0; j < count; j++){
			if(i % prime[j] == 0){
				flag = false;
				break;
			}
			if(prime[j] * prime[j] > i) break;
		}
		if(flag == true){
			prime[count++] = i;
		}
		answer[i] = count + 1;
		answer[i+1] = count + 1;
	}
	while((cin >> n)!= NULL){
		cout << answer[n] << endl;
	}
	return 0;
}

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

int main() {
    string N;
    cin >> N;
    int ans = 0;
    for (int i = 0; i < N.size(); i++) {
        int x = N[i] - '0';
        if (x != 0 && x != 9) {
            ans = (ans + x) % 9;
        }
    }
    if (ans == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

using namespace std;
long long n,a[10001],b,c,s=0;
int main()
{
	   
cin >> n;
for(int i=0;i<n;i++)
{
	cin >> a[i];
}
sort(a,a+n);
cout<<a[n-1]-a[0];
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N,A[3][3],B[10];
  for (int i=0; i<3; i++){
    for (int j=0; j<3; j++){
      cin>>A[i][j];
    }
         }
  cin>>N;
  for(int i=0;i<10;i++) cin>>B[i];
  bool C[3][3];
  for (int i=0; i<3; i++){
    for (int j=0; j<3; j++){C[i][j]=false;
      for (int k=0; k<10; k++){
        if (A[i][j]==B[k]) C[i][j]=true;
      }}}
  bool des=false;
        if (C[0][0] && C[0][1] && C[0][2]) des=true;
if (C[1][0] && C[1][1] && C[1][2]) des=true;
  if (C[2][0] && C[2][1] && C[2][2]) des=true;
  if (C[0][0] && C[1][0] && C[2][0]) des=true;
  if (C[0][1] && C[1][1] && C[2][1]) des=true;
  if (C[0][2] && C[1][2] && C[2][2]) des=true;
  if (C[0][0] && C[1][1] && C[2][2]) des=true;
  if (C[0][2] && C[1][1] && C[2][0]) des=true;
  if (des) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#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<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
//作者:中国江苏南京丁天行
using namespace std;
//数组不要开小了
//数组不要开反了
ll f[200],n,ans=1;
int main()
{
    char c=getchar();
    while(c!='\n'){
                   ans-=1ll*f[c];
                   n++;
                   f[c]++;
                   c=getchar();
    }
    ans+=n*(n-1ll)/2ll;
    cout<<ans<<endl;
	//system("pause");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(void)
{
	int A, B, C, D, L, R;

	cin >> A >> B >> C >> D;
	L = A + B;
	R = C + D;
	if (L > R)
    {
      cout << "Left" << endl;
    }
	else if (L == R)
    {
      cout << "Balanced" << endl;
    }
	else if (L < R)
    {
      cout << "Right" << endl;
    }
  return (0);
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <sstream>
#include <bitset>
#include <stack>
#include <cstdlib>
#include <utility> //pair

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

typedef long long ll;

using namespace std;

int main() {
    
    int ans=0;
    int cnt1=0,cnt2=0;
    string s;
    cin >> s;
    if(s[0] == 'A'){
        FOR(i, 0, s.size()-3){
            if(s[2+i]=='C'){
                cnt1++;
            }
        }
        FOR(i, 0, s.size()){
            if((s[i]>= 'a') && (s[i]<='z')){
                cnt2++;
        }
        }
        
        if((cnt1==1)&&(cnt2==s.size()-2)){
            ans = 1;
        }
    }
    if(ans==1){
        cout << "AC" << endl;
    }else{
        cout << "WA" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,i,j,h,w[10],l[10],t,u[10];
	char q[11],g;
	while(1){
		for(i=0;i<10;i++){
			w[i]=0;
			l[i]=0;
		}	
		scanf("%d",&n);
		if(n<2) break;
			for(i=0;i<n;i++){
				u[i]=i;
				scanf(" %c",&q[i]);
				for(j=0;j<n-1;j++){
					scanf("%d",&h);
					if(h==0){
						w[i]++;
					}
					if(h==1){
						l[i]++;
					}
				}
			}
			for(i=0;i<n-1;i++){
				for(j=i+1;j<n;j++){
					if(w[i]<w[j]||(w[i]==w[j]&&l[i]>l[j])||(w[i]==w[j]&&l[i]==l[j]&&u[i]>u[j])){
						t=w[i];
						w[i]=w[j];
						w[j]=t;
						
						t=l[i];
						l[i]=l[j];
						l[j]=t;
						
						t=u[i];
						u[i]=u[j];
						u[j]=t;
					
						g=q[i];
						q[i]=q[j];
						q[j]=g;
					}				
				}	
			}		
			for(i=0;i<n;i++){			
				printf("%c\n",q[i]);
			}
	}
	return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    for(int i=0; i<m; i++) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> dist(n, -1), prev(n, -1);
    queue<int> que;
    que.push(0);
    dist[0] = 0;
    while(!que.empty()) {
        int v = que.front();
        que.pop();
        for(auto nv : g[v]) {
            if(dist[nv] == -1) {
                dist[nv] = dist[v] + 1;
                prev[nv] = v;
                que.push(nv);
            }
        }
    }
    cout << "Yes" << endl;
    for(int i=1; i<n; i++) cout << prev[i] + 1 << endl;
}

Measured memory_bytes: 10572
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	vector<array<int, 4>> v;
	vector<int> a;

	void solve() {
		int n, m, q;
		cin >> n >> m >> q;

		v.resize( q );
		for( int i = 0; i < q; ++i ) {
			cin >> v[i][0] >> v[i][1] >> v[i][2] >> v[i][3];
			v[i][0] -= 1;
			v[i][1] -= 1;
		}

		a.push_back( 1 );
		cout << dfs( n-1, m ) << endl;
	}

	int dfs( int n, int m ) {
		if( n == 0 ) {
			return calc();
		}

		int r = 0;
		for( int i = a.back(); i <= m; ++i ) {
			a.push_back( i );
			r = max( r, dfs( n-1, m ) );
			a.pop_back();
		}

		return r;
	}

	int calc() {
		int r = 0;
		for( int i = 0; i < (int)v.size(); ++i ) {
			if( a[v[i][1]] - a[v[i][0]] == v[i][2] ) {
				r += v[i][3];
			}
		}

		return r;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();

	return 0;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int t;cin>>t;while(t--)
typedef long long int ll;
#define REP(i,n) for (int i = 1; i <= n; i++)
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define lli long long int
#define INF 1000000000
const double pi = 3.14159265358979323846;


void solve()
{
	int i=0,j=0,n=0,m=0,flag=0;
	long double prod=1;
    cin>>n;
    while(n--)
    {
        long double y;
        cin>>y;
        if(y==0)
        {
            cout<<0;
            return;
        }
        if(floor(log10(prod))+floor(log10(y))>18 or prod*y>1e18)
        {
            flag=1;
        }
        prod*=y;
    }
    if(flag==0)
    cout<<ll(prod);
    else cout<<-1;
    
}

int main() {
    fast
    //test
    {
        
        solve();
		
		      
    }
    return 0;
}


Measured memory_bytes: 3836