akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

#define MAX_V (1111)

const int INF = (1 << 27);

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

vector<edge> node[MAX_V];
int used[MAX_V];

int v, e;

void input();
int dfs(int v, int t, int f);
int max_flow(int s, int t);

int main(){
  ios_base::sync_with_stdio(false);

  input();

  cout << max_flow(0, v-1) << endl;

  return 0;
} 


void input(){

  cin >> v >> e;  
  for(int i=0;i<e;i++){
    int from, to, cap;
    cin >> from >> to >> cap;
    node[from].push_back((edge){to, cap, node[to].size()});
    node[to].push_back((edge){from, 0, node[from].size() - 1}); 
  }

  return;
}

int dfs(int v, int t, int f){
  //cout << v << " " << t << " " << f << endl;
  if(v == t){
    //cout << "check1" << endl;
    return f;
  }
  used[v] = true;
  for(int i=0;i<node[v].size();i++){
    edge &e = node[v][i];

    //cout << used[e.to] << ":" << e.cap << endl; 

    if(!used[e.to] && e.cap > 0){
      int d = dfs(e.to, t, min(f, e.cap));

      if(d > 0){
        e.cap -= d;
        node[e.to][e.rev].cap += d;

        //cout << "check2" << endl;

        return d;
      }
    }
  }
  //cout << "hello" << endl;
  return 0;
}

int max_flow(int s, int t){
  int flow = 0;

  while(true){
    fill(used, used + MAX_V, 0);
    int f = dfs(s , t , INF);

    //cout << "f = " << f << endl; 

    if(f == 0)return flow;
    flow += f;
  }

}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

int main() {
  ll d, g; cin >> d >> g;
  vll p(10), c(10); REP(i, d) cin >> p.at(i) >> c.at(i);
  ll ans = HIGHINF;
  REP(state, (1<<d)) {
    ll cnt=0, pnt=0, maxr=-1;
    REP(j, d) {
      if((state>>j) & 1) {
        pnt += (j+1)*100*p.at(j) + c.at(j);
        cnt += p.at(j);
      } else {
        maxr = j;
      }
    }
    if (pnt < g) {
      ll curp = 100*(maxr+1);
      if((g-pnt+curp-1) / curp >= p.at(maxr)) continue;
      else cnt += (g-pnt+curp-1) / curp;
    }
    ans = min(cnt, ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#include <cassert>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
const long long MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
#define pint pair<int,int>
#define pll pair<ll,ll>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s; cin >> s;
    if((int)s.size()%2!=0) {
        cout << "No" << endl;
        return 0;
    }
    rep(i,s.size()-1) {
        if(s[i]!='h' || s[i+1]!='i') {
            cout << "No" << endl;
            return 0;
        }
        i++;
    }
    cout << "Yes" << endl;

    return 0;
}

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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

using P = pair<int,int>;
int main()
{
	int n,m;
	cin >> n>>m;
	vector<P> p(m);
	rep(i,m) cin >> p[i].first >> p[i].second ;
	rep(x,1000){
		int keta = 1 ;
		int nx = x / 10 ;
		vector<int> d(1,x%10);
		while(nx){
			keta ++ ; 
			d.push_back(nx%10) ; 
			nx /= 10 ;
		}
		if( keta != n ) continue;
		bool ok = true ; 
		rSORT(d);
		//条件に沿ったものかどうかを今から判定する
		rep(i,m){ 
			if (d[p[i].first-1] != p[i].second ) ok = false ;
		}
		if(ok){
			cout << x << endl ; 
			return 0;
		}
	}
	cout << -1 << endl;
}


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 P = pair<int, int>;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> works(m+1);
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    if (a > m) continue;
    works[a].push_back(b);
  }
  ll ans = 0;
  priority_queue<int> que;
  for (auto w : works) {
    for (auto x : w) {
      que.push(x);
    }
    if (!que.empty()) {
      ans += que.top();
      que.pop();
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 8416
#include <stdio.h>
int main(void){
    int k,n,i,ii,temp,ans=0,l[50];
    scanf("%d %d",&n,&k);
    for(i=0;i<n;i++){
        scanf("%d",&l[i]);
    };
    for(i=n-1;i>0;i--){
        for(ii=0;ii<i;ii++){
            if(l[ii]<l[ii+1]){
                temp=l[ii];
                l[ii]=l[ii+1];
                l[ii+1]=temp;
            };
        };
    };
    for(i=0;i<k;i++){
        ans+=l[i];
    };
    printf("%d",ans);
    return 0;
};


Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>

int isprime(int);

int main()
{
  int check,num,count=0,i,x;
  scanf("%d",&num);

  for(i=0; i<num; i++){
    scanf("%d",&x);
    check = isprime(x);
    if(check == 1) count++;
  }
  printf("%d\n",count);

  return 0;

}


int isprime(int x)
{
  int i = 3;
  if (x == 2) return 1;

  else if (x < 2 || x%2 == 0) return 0;

  while (i <= sqrt(x)){
    if(x % i == 0) return 0;
    i = i + 2;
  }
  return 1;
}    

Measured memory_bytes: 596
#include <stdio.h>
#include <stdlib.h>
#define int long long
#define max_size (int)(2e5 + 1)

typedef struct {
	char c;
	int val;
}pair;

#define inv_num_valtype pair

//比較関数
int compare(inv_num_valtype a, inv_num_valtype b){
	return a.val - b.val;
}

//昇順
int inv_num_sub(inv_num_valtype *origin, int left, int right, inv_num_valtype *tmp){
	int ans = 0;
	if(right - left > 1){
		int i, j, k, half = (left + right) / 2;
		ans += inv_num_sub(origin, left, half, tmp);
		ans += inv_num_sub(origin, half, right, tmp);
		for(i = left; i < right; i++){
			tmp[i] = origin[i];
		}
		for(i = left, j = left, k = half; i < right; i++){
			if(k == right){
				origin[i] = tmp[j];
				j++;
			}
			else if(compare(tmp[j], tmp[k]) <= 0 && j < half){
				origin[i] = tmp[j];
				j++;
			}
			else{
				origin[i] = tmp[k];
				ans += k - i;
				k++;
			}
		}
	}
	return ans;
}

//i < j && a[i] > a[j] となる組(i, j)の数
//effect: sortされる
int inv_num(inv_num_valtype *origin, int N){
	inv_num_valtype *tmp = (inv_num_valtype *)malloc(sizeof(inv_num_valtype) * N);
	return inv_num_sub(origin, 0, N, tmp);
}

signed main(){
	int N, i, odd_num, alf_int, ans = 0;
	char *S = (char *)malloc(sizeof(char) * max_size);
	int *alf_num = (int *)malloc(sizeof(int) * 26);
	int *alf_count = (int *)malloc(sizeof(int) * 26);
	for(i = 0; i < 26; i++){
		alf_num[i] = 0;
		alf_count[i] = 0;
	}
	scanf("%s", S);
	for(i = 0; S[i] != '\0'; i++){
		alf_num[(int)S[i] - (int)'a']++;
	}
	N = i;
	for(i = 0, odd_num = 0; i < 26; i++){
		odd_num += alf_num[i] % 2;
	}
	if(odd_num > 1){
		printf("-1\n");
		return 0;
	}
	pair *P = (pair *)malloc(sizeof(pair) * N);
	for(i = 0; i < N; i++){
		P[i].c = S[i];
		alf_int = (int)S[i] - (int)'a';
		alf_count[alf_int]++;
		if(alf_num[alf_int] % 2 == 0){
			if(alf_count[alf_int] <= alf_num[alf_int] / 2){
				P[i].val = 0;
			}
			else{
				P[i].val = 2;
			}
		}
		else{
			if(alf_count[alf_int] <= alf_num[alf_int] / 2){
				P[i].val = 0;
			}
			else if(alf_count[alf_int] == alf_num[alf_int] / 2 + 1){
				P[i].val = 1;
			}
			else{
				P[i].val = 2;
			}
		}
	}
	int **alf_number = (int **)malloc(sizeof(int *) * 26);
	for(i = 0; i < 26; i++){
		alf_number[i] = (int *)malloc(sizeof(int) * alf_num[i]);
		alf_count[i] = 0;
	}
	ans += inv_num(P, N);
//	printf("ans = %lld\n", ans);
	for(i = 0; i < N / 2; i++){
		P[i].val = N / 2 - i;
		alf_int = (int)P[i].c - (int)'a';
		alf_number[alf_int][alf_count[alf_int]] = P[i].val;
		alf_count[alf_int]++;
	}
	for(i = 0; i < 26; i++){
		alf_count[i] = 0;
	}
	for(i = N - 1; i >= (N + 1) / 2; i--){
		alf_int = (int)P[i].c - (int)'a';
//		printf("(i, alf_int) = (%lld, %lld)\n", i, alf_int);
//		printf("alf_count[alf_int] = %lld\n", alf_count[alf_int]);
		P[i].val = alf_number[alf_int][alf_count[alf_int]];
//		printf("P[i].val = %lld\n", P[i].val);
		alf_count[alf_int]++;
	}
/*	for(i = 0; i < N; i++){
		printf("(%c, %lld)\n", P[i].c, P[i].val);
	}
*/	ans += inv_num(&P[(N + 1) / 2], N / 2);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 9088
#include <stdio.h>

int main( void ){
  int i = 1;
  int j = 1;
  for( i = 1; i < 10; i++ ){
	for( j = 1; j < 10; j++ ){
      printf("%dx%d=%d\n",i,j,i*j);
    }
  }
  return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    vector<int> y(x);
    sort(y.begin(),y.end());
    rep(i,n){
        if(x[i] < y[n/2]) cout << y[n/2] << endl;
        else cout << y[n/2 - 1] << endl;
    }
    return 0;
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }


ll h;
int n;
ll a[100005];
void solve() {
    cin >> h >> n;
    rep(i, n) cin >> a[i];

    ll sum = 0;
    rep(i, n) sum += a[i];

    if (h <= sum) cout << "Yes" << endn;
    else cout << "No" << endn;
}

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n,k;cin>>n>>k;
    string s;cin>>s;
    int res=0;
    rep(i,n-1)if(s[i+1]!=s[i])res++;
    cout<<n-max(0,res-2*k)-1<<endl;
}

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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    ll cnt = 0, diff = 0;
    rep(i, n) {
        if (s[i] == 'W'){
            diff += i - cnt;
            cnt ++;
        }
    }
    cout << diff << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <unistd.h>
#include <cctype>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 1 << 30
#define LLINF LLONG_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
using ll = long long;
using Pll = pair<ll,ll>;
using Pii = pair<int,int>;
using Pdd = pair<double,double>;
using dcomplex = complex<double>;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;for(ll i=1;i<=a;i++)b*=i;return b;}
ll power(ll x,ll n){ll a=1;REP(i,n)a*=x;return a;}
double inf() {return std::numeric_limits<double>::infinity();}

ll N, K;
ll dp[4010][4010];

void print(void){
  REP(i,4*K) {
    REP(j,4*K) {
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }
  cout << endl;
}

int main(int argc, char const *argv[]) {
  cin >> N >> K;
  REP(i,N) {
    ll x, y; string c;
    cin >> x >> y >> c;
    if(c[0]=='W') y += K;
    x %= 2*K; y %= 2*K;
    dp[x][y]++;
    dp[x+K][y]--;
    dp[x][y+K]--;
    dp[x+K][y+K]++;
    x += K; y+=K;
    dp[x][y]++;
    dp[x+K][y]--;
    dp[x][y+K]--;
    dp[x+K][y+K]++;
  }
  FOR(i,0,4*K) FOR(j,1,4*K) dp[i][j] += dp[i][j-1];
  FOR(j,0,4*K) FOR(i,1,4*K) dp[i][j] += dp[i-1][j];
  // print();
  FOR(i,0,4*K) FOR(j,0,4*K) {
    ll tmp = dp[i][j];
    dp[i][j] = 0;
    dp[i%(2*K)][j%(2*K)] += tmp;
  }
  // print();
  ll ans = 0;
  REP(i,2*K) REP(j,2*K) ans = max(ans,dp[i][j]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 125568
# include<stdio.h>
long long GCD(long long a,long long b)
{
long long temp;
while(b!=0)
{
temp=a%b;
a=b;
b=temp; 
}
return a;
}
int main()
{
long long a,b,gcd,lcm;
while(scanf("%lld%lld",&a,&b)==2)
{
gcd=GCD(a,b);
lcm=(a/gcd)*(b/gcd)*gcd;
printf("%lld %lld\n",gcd,lcm);
}
return 0;
}

Measured memory_bytes: 596
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())


A,B,C,X,Y = MI()

ans = 10**18
for i in range(0,2*max(X,Y)+1,2):  # i:ABピザを買う枚数
    ans = min(ans,A*max(0,X-i//2)+B*max(0,Y-i//2)+C*i)

print(ans)


Measured memory_bytes: 65816
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = null;
		List<Integer> list=new ArrayList<Integer>();
		try{
			scan = new Scanner(System.in);
			int n = scan.nextInt();
			for(int i = 1;i < 2 * n +1;i++){
				list.add(i);
			}
			int operation = scan.nextInt();
			for(int i = 0;i < operation;i++){
				int op = scan.nextInt();
				if(op == 0){
					Integer [] A = list.toArray(new Integer[2 * n]);
					list.clear();
					for(int j = 0;j < n;j++){
						list.add(A[j]);
						list.add(A[j+n]);
					}
				}else{
					for(int j = 0 ; j < op;j++){
						list.add(list.remove(0));
					}
				}
			}
			Iterator<Integer> it = list.iterator();
			while(it.hasNext())
				System.out.println(it.next());
		}finally{
			if(scan !=null)scan.close();
		}
	}
}

Measured memory_bytes: 25004
#include<stdio.h>
#include<string.h>
typedef struct{
  char sign;
  int num;
}Card;


void Bubble(Card k[],int n)
{
  int i,j,flag=0;
 
  while (flag < n-1)
    {
      int last=n-1;
      for(j=n-1; j>flag; j--)
	if(k[j-1].num>k[j].num){//構造体から抜き出した変数
	  Card tmp;//構造体Card内の変数作成
	  tmp=k[j-1];
	  k[j-1]=k[j];
	  k[j]=tmp;
	  
	  last = j;
	}
      flag=last;
    }
  for(i=0; i<n; i++){
    if(i==n-1)
      printf("%c%d",k[i].sign,k[i].num);
    else
      printf("%c%d ",k[i].sign,k[i].num);
  }
}

void Selection(Card k[], int n)
{
  int i,j;
  for(i=0; i<n-1; i++){
       int min=i;
    for(j=i; j<n; j++)
      if(k[j].num<k[min].num)
	min=j;
    Card tmp;
    tmp=k[i];
    k[i]=k[min];
    k[min]=tmp;
  }
  for(i=0; i<n; i++){
    if(i==n-1)
      printf("%c%d",k[i].sign,k[i].num);
    else
      printf("%c%d ",k[i].sign,k[i].num);
  }
}

void read(Card k[],Card k3[], int n)
{
  int i;
  for(i=0; i<n; i++)
    k3[i]=k[i];
}
void judge(Card k[], Card k3[], int n)
{
  int i,a=0;
  for(i=0; i<n; i++)
    if(k[i].num!=k3[i].num||k[i].sign!=k3[i].sign)
      a++;
  if(a==0)
    printf("Stable");
  else
    printf("Not stable");
 
}  
int main()
{
  int i,n;
  scanf("%d",&n);
  Card k[n];
  Card k2[n];//初期の値を仮代入
  Card k3[n];//Bubbleソートを入れる
  for(i=0; i<n; i++){
    scanf("\t%c%d",&k[i].sign,&k[i].num);//構造体の内部の変数に読み込み
    k2[i]=k[i];
  }
  
  Bubble(k,n);
  read(k,k3,n);
  putchar('\n');
  puts("Stable");//バブルソートは安定
  
  for(i=0; i<n; i++)
    k[i]=k2[i];

  Selection(k,n);
  putchar('\n');
  judge(k,k3,n);
  putchar('\n');
    return 0;
}




Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
vector<pair<int,int> > v[2];
int main()
{
	int n,sum=0;
	cin >> n;
	while (n--)
	{
		string s;
		cin >> s;
		int bal=0,mn=0;
		for (char c:s)
		{
			bal+=(c=='(');
			bal-=(c==')');
		}
		sum+=bal;
		if (bal>=0)
		{
			bal=0;
			for (char c:s)
			{
				bal+=(c=='(');
				bal-=(c==')');
				mn=min(mn,bal);
			}
			v[0].push_back({mn,bal});
		}
		else
		{
			reverse(s.begin(),s.end());
			bal=0;
			for (char c:s)
			{
				bal-=(c=='(');
				bal+=(c==')');
				mn=min(mn,bal);
			}
			v[1].push_back({mn,bal});
		}
	}
	if (sum)
	{
		cout << "No";
		return 0;
	}
	for (int i=0;i<2;i++)
	{
		sort(v[i].begin(),v[i].end(),greater<pair<int,int> >());
		int cur=0;
		for (auto p:v[i])
		{
			if (cur+p.first<0)
			{
				cout << "No";
				return 0;
			}
			cur+=p.second;
		}
	}
	cout << "Yes";
}

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

void solve(long long H, long long W, vector<string> A){
	vector<int> L(H, W), R(H, 0);
	for(int i = 0; i < H; ++i) {
		for(int j = 0; j < W; ++j) {
			if(A[i][j] == '#') {
				L[i] = min(L[i], j);
				R[i] = max(R[i], j);
			}
		}
	}
	for(int i = 1; i < H; ++i) {
		int cnt = 0;
		for(int j = 0; j < W; ++j) {
			if(A[i-1][j] == '#' && A[i][j] == '#') {
				++cnt;
			}
		}
		if(L[i-1] > L[i] || R[i-1] > R[i] || cnt > 1) {
			cout << "Impossible" << endl;
			return;
		}
	}
	cout << "Possible" << endl;
}

int main(){	
	long long W;
	long long H;
	scanf("%lld",&H);
	vector<string> A(H-1+1);
	scanf("%lld",&W);
	for(int i = 0 ; i <= H-1 ; i++){
		cin >> A[i];
	}
	solve(H, W, A);
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n,m,k,a,i,j,ans;
    ans = 0;
    cin >> n >> m;
    int foods[m]={0};
    for(i = 0;i < n;i++){
        cin >> k;
        for(j = 0;j < k;j++){
            cin >> a;
            foods[a-1]++;
        }
    }
    for(i = 0;i < m;i++){
        if(foods[i] == n){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
using namespace std;

int main (void) {
  int N,X;
  cin >> N >> X;
  int m[1100];
  int ans=N;
  int sum=0;
  int min_m=1001;
  for (int i=0; i<=N-1; i++) {
    cin >> m[i];
    sum =sum +m[i];
    min_m=min(min_m, m[i]); 
  }
  X=X-sum;
  ans=ans+X/(min_m);
  cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N;
  int ans,T,C;
  cin >> N;
  ans = N;
  for(int i=0;i<=N;i++){
    C = 0;
    T = N-i;
    //N-i円は6の累乗の和で引き出す
    while(T>0){
      C += T%6;//6の?乗で割り切れないものは6の?-1乗でt%6回引き出す
      T /= 6;//上へ
    }
    T = i;//i円は9の累乗の和で引き出す
    while(T>0){
      C += T%9;//6と同じ
      T /= 9;
    }
    ans = min(ans,C);//最も小さいものを答えとする
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	a := make([]int, n+2)
	for i := 1; i < n+1; i++ {
		a[i] = nextInt()
	}

	sum := make([]int, n+2)
	for i := 0; i < n+1; i++ {
		sum[i+1] += abs(a[i]-a[i+1]) + sum[i]
	}

	for i := 1; i < n+1; i++ {
		ans := sum[n+1] - (sum[i+1] - sum[i-1]) + abs(a[i+1]-a[i-1])
		fmt.Println(ans)
	}
	// fmt.Println(a)
	// fmt.Println(sum)
}

func abs(a int) int {
	if a < 0 {
		return -1 * a
	}
	return a
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std;
typedef long long ll;
const int Maxn = 1e5 + 5;
typedef int arr[Maxn];
//ll Add(ll x, ll y) { return (x += y) >= Mod ? x - Mod : (x < 0 ? x + Mod : x); }
ll min(ll x, ll y) { return x < y ? x : y; }
ll max(ll x, ll y) { return x > y ? x : y; }
inline ll read()
{
	rg ll res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
int n, cnt, ans;
arr fir, deg;
int mk[Maxn][18];
struct
{
	int to, last;
} e[Maxn << 1];
void con(int u, int v)
{
	e[++cnt].to = v;
	e[cnt].last = fir[u];
	fir[u] = cnt;
	deg[u]++;
	deg[v]++;
}
int Solve(int x, int from)
{
	rg int Max = 0;
	for (int next = fir[x], nx; next; next = e[next].last)
	{
		nx = e[next].to;
		if (nx == from)
			continue;
		Max = max(Max, Solve(nx, x));
		for (rg int j = 0; j <= Max; j++)
			mk[x][j] += mk[nx][j];
	}
	rg int res = Max + 1;
	for (int i = Max; i >= 0; i--)
		if (!mk[x][i])
			res = i;
		else if (mk[x][i] > 1)
			break;
	mk[x][res] = 1;
	ans = max(ans, res);
	for (rg int j = res - 1; j >= 0; j--)
		mk[x][j] = 0;
	return Max + (res > Max);
}
int main()
{
	rg int a, b;
	cin >> n;
	for (int i = 1; i < n; i++)
	{
		a = read();
		b = read();
		con(a, b);
		con(b, a);
	}
	Solve(1, 0);
	cout << ans << '\n';
	return 0;
}


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

int main() {
  int N; cin >> N;
  map<int,int> A;
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    A[a]++;
  }
  
  int k = A.size();
  
  if (k % 2 == 0) k--;
  
  cout << k << endl;  
}

Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<ll, ll>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int T; cin >> T;
    vector<bool> ans;
    rep(t, T) {
        int N; cin >> N;
        vector<ll> a(N); rep(i, N) cin >> a[i];
        vector<ll> dp;
        string S; cin >> S;
        bool ok = 0;
        rnr(i, N - 1, 0) {
            ll v = a[i];
            for(ll x : dp)
                v = min(v, v ^ x);
            if(v) {
                if(S[i] == '1') {
                    ok = 1;
                    break;
                }
                dp.pb(v);
            }
        }
        ans.pb(ok);
    }
    rep(i, T) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 3544
h,w = input().split()
if int(h)*int(w) % 2 == 0:
    if int(h) == 1 or int(w) == 1:
        print(1)
    else:
        print(int(int(h)*int(w)/2))
else:
    if int(h) == 1 or int(w) == 1:
        print(1)
    else:
        print(int((int(h)*int(w)+1)/2))

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
#define pb push_back
#define fi0(i,n) for(int i=0; i<n; i++)
#define fi1(i,n) for(int i=1; i<n; i++)
#define fll0(i,n) for(long long i=0; i<n; i++)
#define fll1(i,n) for(long long i=1; i<n; i++)
#define vll vector<long long>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
ll f(ll n)
  {
  	ll i=1;
  	while(1)
  	  {
  	  	ll x=(i*(i+1))/2;
  	  	ll y=x+(i+1);
  	  	if(n==x)  return i;
  	  	if(n>x && n<y)  return i;
  	  	i=i+1;
  	  }
  }

int main()
  {
  	 ll n;
  	 cin>>n;
  	 vll primes;
  	 while(n%2==0)
  	   {
  	   	  n=n/2;
  	   	  primes.pb(2);
  	   }
  	for(ll i=3; i<=sqrt(n); i++)
  	   {
  	   	  while(n%i==0)
  	   	   {
  	   	   	 primes.pb(i);
  	   	   	 n=n/i;
  	   	   }
  	   }
  	if(n!=1)  primes.pb(n);
  	//fll0(i, primes.size())   cout<<primes[i]<<" ";
  	//cout<<endl;
  	unordered_map<ll, ll> hash;
  	for(ll i=0; i<primes.size(); i++)
  	  {
  	  	 hash[primes[i]]++;
  	  }
   ll ans=0;
   for(auto i: hash)
     {
     	ans=ans+f(i.second);
     }
   cout<<ans<<endl;
  }

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

const int LIMIT = 200000;
int n, d[LIMIT], m, t[LIMIT];
map<int, int> mpd, mpt;
string ans = "YES";

int main() {
    cin >> n;
    rep(i, n) {
        cin >> d[i];
        mpd[d[i]]++;
    }
    cin >> m;
    rep(i, m) {
        cin >> t[i];
        mpt[t[i]]++;
    }
    
    rep(i, m) {
        if (mpd[t[i]] < mpt[t[i]]) ans = "NO";
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 20608
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
#include <chrono>
#include <thread>

using namespace std;

//template<typename T>
//using Matrix2D = std::vector<vector<T>>;

//#define cerr


#ifndef M_PI
    const double M_PI = acos(-1.0);
#endif // M_PI

#define y1 roman_kaban
#define rank oryshych_konb
#define ull unsigned long long
#define ll long long
//const int mod = int(1e9) + 7;
const long long infLL = 1e18;
//const int MX2 = 10100500; //  e7
const int MX = 1200500; //       e5
//const int mod = 1e6 + 0.5; // paranoia
int a[MX];

int main()
{
    //freopen("/Users/ozzy/Documents/in.txt","r", stdin);
    int n;
    cin >> n;
    for(int i = 0; i < 3 * n; i++){
        cin >> a[i];
    }
    sort(a, a + 3 * n);
    reverse(a, a + 3 * n);
    long long sum = 0;
    for(int i = 1; i < 2  * n; i+= 2){
        sum += a[i];
    }
    cout << sum << endl;

    return 0;
}


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

int main(){
  int A, B;
  cin >> A >> B;
  
  if(A == B)
    cout << A * 2 << endl;
  else if(A > B)
    cout << A * 2 - 1 << endl;
  else 
    cout << B * 2 -1 << endl;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<math.h>
#include<vector> 
#include<cstdio> 
#include<set>
#include<string.h>
#include<stdio.h>
#include<queue>
#include<cstring>
using namespace std;
int main()
{int a,b,c;
 cin>>a>>b>>c;
 int x=abs(a-b);
 int y=abs(a-c);
 if(x>y)
 cout<<"B"<<endl;
 else
 cout<<"A"<<endl;
 system("pause");
 return 0;
}

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

int main(){
  string s;
  int page;
  map<string , vector<int> > dict;
  while ( cin >> s >> page )
    {
    dict[ s ].push_back( page );
  }
  for ( map<string, vector<int> >::iterator it = dict.begin(); it != dict.end(); it++ )
    {
      cout << it->first << endl;
      sort( it->second.begin(), it->second.end() );
      int i = 0;
      for ( vector<int>::iterator itv = it->second.begin() ; itv != it->second.end(); itv++, i++ )
	{
	  if(i)cout << " ";
	  cout << *itv;
	}
      cout << endl;
    }
  return 0;
}

Measured memory_bytes: 1244
#include <stdio.h>
#include <vector>
#include <utility>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main(void) {
  int n, ans = 0;
  scanf("%d", &n);
  int dis[n];
  rep(i, n) dis[i] = 10e7;
  dis[0] = 0;
  vector< pair<int, int> > vec[n];
  rep(i, n) {
    int u, k;
    scanf("%d%d", &u, &k);
    rep(j, k) {
      int c, v;
      scanf("%d%d", &v, &c);
      pair<int, int> p = make_pair(v, c);
      vec[u].push_back(p);
    }
  }
  /*rep(i, n) {
    vector< pair<int, int> >::iterator it;
    for(it = vec[i].begin(); it != vec[i].end(); ++it) printf("%d:%d ", (*it).first, (*it).second);
    printf("\n");
  }*/
  rep(i, n - 1) {
    rep(j, n) {
      vector< pair<int, int> >::iterator it;
      for(it = vec[j].begin(); it != vec[j].end(); ++it) {
        if(dis[(*it).first] > dis[j] + (*it).second) dis[(*it).first] = dis[j] + (*it).second;
      }
    }
    /*rep(j, n) printf("%d ", dis[j]);
    printf("\n");*/
  }
  rep(i, n) printf("%d %d\n", i, dis[i]);
  return 0;
}


Measured memory_bytes: 2684
#include <bits/stdc++.h>
 
using namespace std;
 
int c(char ch){
    return ch-'0';
}
 
int main(){
    string s;
    while(cin >> s, s != "0"){
	int dp[80010][11],len = s.size(),res = 0;
	memset(dp,0,sizeof(dp));
	dp[0][c(s[0])] = 1;
	for(int i = 1 ; i < len ; i++){
	    if(c(s[i]) > 0){ dp[i][c(s[i])]++; }
	    for(int j = 0 ; j < 11 ; j++){
		dp[i][(10*j+c(s[i]))%11] += dp[i-1][j];
	    }
	    res += dp[i][0];
	}
	cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 6580
N, K = map(int, input().split())

is_appear = [False]*N
for _ in range(K):
    _ = int(input())
    A = list(map(int, input().split()))
    for a in A:
        is_appear[a-1] = True

ans = 0
for b in is_appear:
    if b == False:
        ans += 1

print(ans)

Measured memory_bytes: 9184
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int l = Integer.parseInt(sc.next());
		int[] a = new int[n];
		int absMin = 1000;
		for (int i = 0; i < n; i++) {
			if (Math.abs(l + i) < Math.abs(absMin)) {
				absMin = l + i;
			}
			a[i] = l + i;
		}
		int sum = 0;
		for (int i = 0; i < n; i++) {
			sum += a[i];
		}
		sum -= absMin;
		System.out.println(sum);

	}

}


Measured memory_bytes: 21968
#include <bits/stdc++.h>
using namespace std;
 
int sumsum(int n){
  int sum =0;
  while(n>0){
    sum += n%10;
    n /= 10;
  }
  return sum;
}
int main() {
  int N,min=100;
  cin >>N;
  for(int A =1; A<N; A++){
    if(min> sumsum(A) + sumsum(N-A)){
      min =sumsum(A) + sumsum(N-A);
    }
  }
  cout <<min <<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n; cin >> n;
	while (n--) {
		int a(0), b(0), x;
		bool f(true);
		rep(i, 0, 10) {
			cin >> x;
			if (a < x)a = x;
			else if (b < x)b = x;
			else f = false;
		}
		cout << (f ? "YES" : "NO") << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// solution 
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input!{
        A: usize,
        B: usize,
        C: usize,
        D: usize,
        E: usize,
    }
    let mut dishes = [A, B, C, D, E];
    let dmod = dishes.iter().map(|di| (*di-1) % 10).collect::<Vec<usize>>();
    let mut mind = 0;
    
    for ind in 0..dishes.len() {
        if dmod[ind] < dmod[mind] {
            mind = ind;
        }
    }

    for ind in 0..dishes.len() {
        if ind != mind {
            dishes[ind] = dishes[ind] + 10 - (dmod[ind]+1);
        }
    }

    println!("{}", dishes.iter().sum::<usize>());
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
#define PI (acos(-1))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

#define MAXN 1123456
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;

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

  int h, w, a, b;
  cin>>h>>w>>a>>b;

  string s;
  rep(i,0,a) s += "1";
  rep(i,0,w-a) s += "0";
  string op;
  trav(c, s) op.pb((c == '1' ? '0' : '1')); 

  rep(i,0,h) {
    if (i >= b) cout << op << endl;
    else cout << s << endl;
  }
}


Measured memory_bytes: 1280
n = int(input())
a = [0] + list(map(int, input().split())) + [0]

costs = []
for i in range(n + 1):
    costs.append(abs(a[i + 1] - a[i]))

s = sum(costs)
for i in range(n):
    print(s - costs[i] - costs[i + 1] + abs(a[i] - a[i + 2]))

Measured memory_bytes: 14048
c = {'S' : [0]*13, 'H' : [0]*13, 'C' : [0]*13, 'D' : [0]*13}
n = int(input())
for i in range(n) :
    s, num = input().split()
    c[s][int(num) - 1] = 1
for i in c :
    for j in range(13) :
        if c[i][j] == 0 :
            print(i, j+1)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define pb push_back
const ll mod=1e9+7;
template<typename T> T pow(T a,T b, long long m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
const ll N=1e6+8;
ll dp[N][4];
ll a[N][4],n;
ll func(ll i,ll j){
	if(i>n)
	return 0;
	if(dp[i][j]!=-1)
	return dp[i][j];
	ll maxm=0;
	if(j==0){
		maxm=max(maxm,a[i][1]+func(i+1,1));
		maxm=max(maxm,a[i][2]+func(i+1,2));
		maxm=max(maxm,a[i][3]+func(i+1,3));
	}
	else 
	if(j==1){
		maxm=max(maxm,a[i][2]+func(i+1,2));
		maxm=max(maxm,a[i][3]+func(i+1,3));
	}
	else 
	if(j==2){
			maxm=max(maxm,a[i][1]+func(i+1,1));
			maxm=max(maxm,a[i][3]+func(i+1,3));
	}
	else{
			maxm=max(maxm,a[i][1]+func(i+1,1));
		    maxm=max(maxm,a[i][2]+func(i+1,2));
	}
	return dp[i][j]=maxm;
}
int main(){
	cin>>n;
	for(ll i=1;i<=n;i++){
		for(int j=1;j<=3;j++)
		cin>>a[i][j];
	}
	memset(dp,-1,sizeof(dp));
	cout<<func(1,0);
}

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

bool magic(int a, int b, int c, int k){
  
  int d =0;
while(a >= b){
  b *= 2;
  d++;
}
  while(b >= c){
    c *=2;
    d++;
  }
  
 return d<=k?true:false;
  
}

int main(){
 int a=0, b=0, c=0, k=0;
  
  cin >> a >> b >> c;
  cin >> k;
  string e = magic(a, b, c, k)?"Yes":"No";
    cout << e << endl;

  return 0;
  
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

int a[100010];
signed main(void)
{
  int n;
  cin >> n;
  REP(i, n) cin >> a[i];
  int b = 0, c = 0;
  REP(i, n) {
    if(a[i]%4==0) b++;
    else if(a[i]%2==0) c++;
  }
  n -= b*2;
  if(n <= c || n == 1) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

using namespace std;

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

	int cnt = 0;
	for (int i = 1; i < n - 1; i++){
		if ((p[i] < p[i - 1] && p[i] > p[i + 1]) || (p[i] > p[i - 1] && p[i] < p[i + 1]))
			cnt++;
	}

	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define mp(a, b) make_pair(a, b)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
ll digits(ll x){
  ll length = 0;
  while (x > 0){
    x /= 10;
    length++;
  }
  return length;
  if (x == 0) return 0;
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
template<class T> inline bool chmin(T& a, T b){
  if (a > b){
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b){
  if (a < b){
    a = b;
    return true;
  }
  return false;
}

int main(){
  cout << fixed << setprecision(15);

  int n; cin >> n;
  vector<int> bricks(n);
  rep(i, n) cin >> bricks[i];

  ll ans;
  //string ans;

  int cnt = 0;
  rep(i, n){
    if(bricks[i] == cnt + 1) cnt++;
  }
  ans = n - cnt;
  if(cnt == 0) ans = -1;

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp(a, b) make_pair(a, b)
#define ls (rt << 1)
#define rs (rt << 1 | 1) 
typedef pair<int, int> pii; 
const ll mod = 1e9 + 7;
template <class T> T lowbit(T x){return ((x)&(-(x)));}
const int maxn = 2e5 + 10;
int n, m, a[maxn];
int main()
{
	cin >> n >> m;
	for(int i = 1; i <= m; ++i) cin >> a[i], n -= a[i];
	if(n < 0) puts("-1");
	else printf("%d\n", n);
	
	return 0;
}

Measured memory_bytes: 3752
import java.util.*;
class Main {
  
static Long gcd (Long a, Long b) {return b>0?gcd(b,a%b):a;}
static Long lcm (Long a, Long b) {return a*b/gcd(a,b);}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
      
      	Long a = sc.nextLong();
      	Long b = sc.nextLong();
      	Long ans = lcm(a,b); 	
      	
      System.out.println(ans);
		}
	}

Measured memory_bytes: 35704
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n) for(int i = 0; i < (n); i++)
const int MOD = 1e9+7;
const int INF = 1e9;
int gcd(int a, int b){/*a>=0,b>=0,￢(a=b=0)*/while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);}
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct Edge{int to,weight;};
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
/*----------------------------------------------*/
int dp[110][101010]; //初めのi個のみを考えたときの最適解、重さj以下
int w[110],v[110];

signed main(){
  int n,W;
  cin>>n>>W;
  rep(i,n) cin>>w[i]>>v[i];
  FOR(i,0,W) dp[0][i]=0; //0個選ぶ
  FOR(i,0,n) dp[i][0]=0; //重さ0

  rep(i,n+1)rep(j,W+1){
    if(j>=w[i]) chmax(dp[i+1][j],dp[i][j-w[i]]+v[i]);
    chmax(dp[i+1][j],dp[i][j]);
  }

  cout<<dp[n][W]<<endl;

  return 0;
}


Measured memory_bytes: 82176
#include <complex>
#include <cstdio>
#include <iostream>
using namespace std;
#define X real()
#define Y imag()
#define EPS (1e-10)
typedef complex<double> P;
typedef pair<P, P> L;

double dot(P a, P b){
  return a.X*b.X + a.Y*b.Y;
}

double cross(P a, P b){
  return a.X*b.Y - a.Y*b.X;
}

P projection(P a, P b){
  return dot(a, b)/abs(b)/abs(b)*b;
}

P intersection(L a, L b){
  return a.first + abs(cross(b.second-b.first,a.first-b.first)/(abs(cross(b.second-b.first,a.second-b.first))+abs(cross(b.second-b.first,a.first-b.first))))*(a.second-a.first);;
}

int main(){
  int q;
  cin >> q;
  P points[4];
  for(int i = 0; i < q; ++i){
    for(int j = 0; j < 4; ++j){
      double x, y;
      cin >> x >> y;
      points[j] = P(x, y);
    }
    L l1 = L(points[0],points[1]), l2 = L(points[2], points[3]);
    printf("%.10lf %.10lf\n", intersection(l1, l2).X, intersection(l1, l2).Y);
  }
  return 0;
}

Measured memory_bytes: 3272
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define uu unsigned
#define io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
#define pi pair<int,int>
#define pl pair<ll,ll>
#define mkp make_pair
#define all(x) x.begin(),x.end()
#define ss second
#define ff first
#define mit map<ll,ll>::iterator
#define sit unordered_set<ll>::iterator
#define lit list<ll>::iterator
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define pf push_front
#define printf __mingw_printf
#define printcas cout<<"Case "<<cas<<": "
#define _ continue;
#define endl '\n'
#define __ cout<<endl;continue;
#define vec4d(nam,type,a,b,c,d,fix) vector<vector<vector<vector<type>>>> nam(a,vector<vector<vector<type>>>(b,vector<vector<type>>(c,vector<type>(d,fix))))
int main()
{
     io;
    //string hudai(1000000,'a');
    int T=1;
    //cin>>T;
     for(int cas=1;cas<=T;cas++)
    {
        string s,t;
        cin>>s>>t;
        ll slen=s.size(),tlen=t.size();
        vector<vl> dp(slen+1,vl(tlen+1,0));
        for(ll i=1;i<=slen;i++)
        {
            for(ll j=1;j<=tlen;j++)
            {
                if(s[i-1]==t[j-1])dp[i][j]=1+dp[i-1][j-1];
                else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
        ll lcs=dp[slen][tlen],i=slen,j=tlen;string ans(lcs,' ');
        while(lcs--)
        {
            if(s[i-1]==t[j-1]){ans[lcs]=s[i-1];
               i--,j--;
            }
            else
            {
                lcs++;
                if(dp[i-1][j]>dp[i][j-1])i--;
                else j--;
            }

        }
        cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 73684
from sys import stdin
n, *a = map(int, stdin.read().split())
c2, c4 = 0, 0
for i in a:
    if i % 2 == 0: c2 += 1
    if i % 4 == 0: c4 += 1

if c4 >= len(a) // 2: ans = "Yes"
elif (len(a) - c4 * 2) == (c2 - c4): ans = "Yes"
else: ans = "No"

print(ans)

Measured memory_bytes: 14052
#include <iostream>

using namespace std;

int N;
long long int M, a[100005];

long long int val;

long long int gcd(long long int a, long long int b) {
	if (a < b) { return gcd(b, a); }

	if (b == 0) { return a; }

	return gcd(b, a%b);
}

long long int lcm(long long int a, long long int b) {

	long long int tmp = gcd(a, b);

	long long int ret = a / gcd(a, b);

	ret *= b;

	return ret;

}
long long int inf = 1000000001;
int main(void) {
	cin >> N >> M;

	for (int i = 1; i <= N; i++) { cin >> a[i]; }
	
	val = 1;
	for (int i = 1; i <= N; i++) {
		//cout << i << endl;
		val = lcm(val, a[i] / 2);
		//cout << val << endl;
		if (val > inf) { cout << 0 << endl; return 0; }
	}

//	cout << "val= " << val << endl;

	int check = 1;
	for (int i = 1; i <= N; i++) {
		if ((val / (a[i] / 2)) % 2 == 0) { check = -1; }
	}

	if (check == -1) { cout << 0 << endl; return 0; }

	long long int ans;
	if (val > M) { ans = 0; }
	else {
		ans = (M - val) / (val * 2) + 1;
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    int k[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin>>K;
    cout<<k[K-1]<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 256