akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" <<; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;

ll mod = 1000000007;

int main()
{
	string S;
	cin >> S;

	// ll y=stoll(S.substr(0,4));
	ll m=stoll(S.substr(5,2));
	// ll d=stoll(S.substr(8,2));

	if(m<=4) cout<<"Heisei"<<endl;
	else cout<<"TBD"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
//Compiler version g++ 6.3.0
int fact(LL n){
  if(n==1||n==0){
    return 1; 
  }  
  else{
    return fact(n-1)*n;}
}
int main()
{
  LL n; 
  cin>>n; 
  LL ans[10001];
  memset(ans,0,sizeof(ans));
  for(LL i=1;i<101;i++){
    for(LL j=1;j<101;j++){
      for(LL k=1;k<101;k++){
        LL v=i*i+(j*j)+(k*k)+(i*j)+(j*k)+(k*i);
        if(v<=10000){
          ans[v]++;  
        }
      }  
    }  
  }
  for(LL i=1;i<=n; i++){
    cout<<ans[i]<<endl; 
  }
  return 0;
 }
       


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define INF 1e8
typedef long long int ll;
const double PI = acos(-1);

using Graph = vector<vector<int>>;
int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans = (n / (a + b)) * a;
  if ((n % (a + b)) >= a)
    ans += a;
  else
    ans += (n % (a + b));
  cout << ans << endl;
}


Measured memory_bytes: 3632
//have fun
#include <bits/stdc++.h>
using namespace std;
#define mod 		998244353
#define ll 		long long
#define mp 		make_pair
#define pb 		push_back
#define forn(i,n) 	for(int i=0;i<n;i++)
#define for1(i,n) 	for(int i=1;i<n;i++)
#define ford(i,n) 	for(int i=n-1;i>=0;i--)
#define vi 		vector<int>
#define vl 		vector<ll>
#define pii 		pair<int,int>
#define pll 		pair<ll,ll>
#define vpi 		vector<pair<int,int> >
#define vpl		vector<pair<ll,ll> >
#define vvi 		vector<vector<int> >
#define vvl 		vector<vector<ll> >
#define ull 		unsigned long long
#define IOS 		ios_base::sync_with_stdio(false);
#define PI 		3.1415926535897932384626
#define ff 		first
#define ss 		second
#define char2Int(c) 	(c-'0')
#define FOREACH(i,t) 	for (auto i=t.begin(); i!=t.end(); i++)
#define clr(a,x) 	memset(a,x,sizeof(a)) //set elements of array to some value
#define all(x)		(x).begin(),(x).end()//cout<<"Case #"<<zzz<<": ";
int maxN=(int)1e6+1;
void solve()
{
    int n;cin>>n;
    vi a(maxN,0);vi flag(maxN,1);
    forn(i,n){int x;cin>>x;a[x]+=1;}
    int ans=0;
    for1(i,maxN)
    {
        if(a[i]==0)continue;
        if(flag[i]==1&&a[i]==1)++ans;
        for(int j=i;j<maxN;j+=i)
        {
            flag[j]=0;
        }
    }
    cout<<ans<<endl;
    return;
}
int main()
{
    IOS;cin.tie(NULL);
    int zz=1;
    for(int zzz=1;zzz<=zz;zzz++)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 11120
#pragma once

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection) (collection).begin(), (collection).end()  // begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)       // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)      // repeat reverse
#define size(collection) ((ll) (collection).size())               // collection size

#endif

namespace DPF
{

	struct DP
	{
		ll value;
		bool update;
	};

	void Run()
	{
		string s, t; cin >> s >> t;
		s.insert(0, " ");
		t.insert(0, " ");

		vector<vector<DP>> dp(size(s) + 1, vector<DP>(size(t) + 1));
		rep(j, 1, size(s))
		{
			rep(i, 1, size(t))
			{
				if (s[j] == t[i] && dp[j - 1][i + 1].value == dp[j - 1][i].value)
				{
					dp[j][i + 1].value = dp[j - 1][i].value + 1;
					dp[j][i + 1].update = true;
				}
				else
				{
					dp[j][i + 1].value = max(dp[j - 1][i + 1].value, dp[j][i].value);
					dp[j][i + 1].update = false;
				}
			}
		}

		ll lcs_max = dp[size(s) - 1][size(t)].value;
		vector<ll> lcs_t;
		repr(j, size(dp) - 1, 0)
		{
			repr(i, size(dp[j]) - 1, 0)
			{
				if (size(lcs_t) != 0 && lcs_t.back() < i)
					continue;
				if (dp[j][i].update && dp[j][i].value == lcs_max)
				{
					lcs_t.push_back(i - 1);
					lcs_max--;
					break;
				}
			}
		}
		reverse(all(lcs_t));

		for (auto& e : lcs_t)
			cout << t[e];
	}
}

int main(void)
{
	DPF::Run();

	return 0;
}


Measured memory_bytes: 141312
#include<iostream>

using namespace std;

int main(){
  int n,y;
 cin >> n >> y;
  
  int res10=-1;
  int res5=-1;
  int res1=-1;
  
  for(int i=0;i<=n;i++){
   for(int j=0;j<=n-i;j++){
    if(10000*i+5000*j+1000*(n-i-j)==y){
     res10=i;
     res5=j;
     res1=n-i-j;
      break;
    }
   }
  }
 cout << res10 << " " << res5 << " " << res1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

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

    cout << (a <= b ? a : a-1) << endl;

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  if(N == 1 ||N == 2 ||N == 3 ||N == 5 ||N == 6 
     ||N == 9 ||N == 10 ||N == 13 ||N == 17){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}

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

int main()
{
	int a,b,c,x,y;
	cin >> a >> b >> c >> x >> y;
	int _max = max(x,y);
	int res = 0;
	
	int xt = a*x;
	int yt = b*y;

	int ab = 2*c*(min(x,y));
	int abc = 2*c*(max(x,y));

	if(max(x,y) == y){
		ab += b*(y - x);
	} 
	else if(max(x,y) == x){
		ab += a*(x - y);
	}

	cout << min(min((xt+yt),ab),abc) << endl;
}

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

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

string s;

int main() {
    cin >> s;
    int n = s.size();
    int k = 15 - n;
    for (int i=0;i<n;i++) {
        if(s[i] == 'o') k++;
    }
    string ans;
    if (k>=8) ans = "YES";
    else ans = "NO";

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

int main(){
  int r; cin >> r;
  cout << 3*r*r << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <queue>
using namespace std;
int main(){
	long long int N; 
	cin >> N; 
	long long int P = 1e9 + 7; 
	long long int dp[64][3] = {}; //dp[a,bの上位i桁まで決定済][上位i桁までの足し算でNがa+bよりどれだけ大きいか．負なら大小逆転，2以上なら追いつけないので確定でOK] = 場合の数 mod P
	dp[0][0] = 1; 
	for(int i = 1; i <= 60; i++){//Leading zerosを補って60桁と見なす．
		if((N >> (60-i)) & 1){
			dp[i][0] = dp[i-1][0]; 
			dp[i][1] = (dp[i-1][0] + dp[i-1][1]) % P; 
          		dp[i][2] = (dp[i-1][1] * 2 + dp[i-1][2] * 3) % P; 
		}
		else{
			dp[i][0] = (dp[i-1][0] + dp[i-1][1]) % P; 
            		dp[i][1] = dp[i-1][1]; 
            		dp[i][2] = (dp[i-1][1] + dp[i-1][2] * 3) % P; 
		}
	}
	cout << (dp[60][0] + dp[60][1] + dp[60][2]) % P << endl;
}

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

int main(void){
  int number[3][3];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>number[i][j];
    }
  }
  int N;
  cin>>N;
  vector<int> b(N);
  for(int i=0;i<N;i++){
    cin>>b[i];
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(number[j][k]==b[i]) number[j][k]=0;
      }
    }
  }
  string ans="No";
  for(int i=0;i<3;i++){
    if(number[i][0]==number[i][1]&&number[i][1]==number[i][2]){
      ans="Yes";
    }
    if(number[0][i]==number[1][i]&&number[1][i]==number[2][i]){
      ans="Yes";
    }
  }
  if(number[0][0]==number[1][1]&&number[1][1]==number[2][2]){
    ans="Yes";
  }
  if(number[0][2]==number[1][1]&&number[1][1]==number[2][0]){
    ans="Yes";
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
const int N=2e5+5;
const int MOD=1e9+7;
ll a[N];

int b[N];
char s[N];
char t[N];
ll f[N];
int used[15];
int cmp1(ll a,ll b)
{
    return b<a;
}

multiset<int> ss;
map<int,int>mp;
int main()
{
    int n;
    ll d;
    cin>>n>>d;
    int ans=0;
    for(int i=1;i<=n;i++){
        ll x,y;
        cin>>x>>y;
        if(x*x+y*y<=d*d) ans++;
    }
    cout<<ans<<endl;
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  s = '.' + s + '.';
  int ans = 0;
  {
    vector<int> l(n + 2, 0), r(n + 2, 0);
    FOR(i, 1, n + 2) {
      int j = n + 1 - i;
      l[i] = l[i - 1] + (s[i] == '>');
      r[i] = r[i - 1] + (s[i] == '<');
    }
    FOR(i, 1, n + 1) {
      int k = lower_bound(begin(r) + i + 1, end(r), l[i] + r[i]) - begin(r);
      if (k < n + 2) ans = max(ans, k);
    }
  }
  {
    vector<int> l(n + 2, 0), r(n + 2, 0);
    FOR(i, 1, n + 2) {
      int j = n + 1 - i;
      l[j] = l[j + 1] + (s[j] == '>');
      r[j] = r[j + 1] + (s[j] == '<');
    }
    FOR(i, 1, n + 1) {
      int j = n + 1 - i;
      int k = lower_bound(rbegin(l) + i + 1, rend(l), l[j] + r[j]) - rbegin(l);
      if (k < n + 2) ans = max(ans, k);
    }
  }
  cout << ans << endl;
}



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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
using Graph = vector<vector<int>>;
queue<int> quex,quey;

int main(){
   int a,b,c,d,n;
   string s,t;
   cin >> a>> b;
   if(a>=10) cout << b << endl;
   else cout << b+100*(10-a) << endl;
   

}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int n, m, a[31][31], k[31], cnt[31]={0} , ans=0, i, j;
  scanf("%d %d", &n, &m);
  
  for(i=0;i<n;i++)
  {
    scanf("%d", &k[i]);
    for(j=0;j<k[i];j++)
    {
      scanf("%d", &a[i][j]);
    }
  }
  
  for(i=0;i<n;i++)
  {
    for(j=0;j<k[i];j++)
    {
      cnt[a[i][j]]++;
    }
  }
  
  for(i=0;i<=m;i++)
  {
    if(cnt[i] == n)
    {
      ans++;
    }
  }
  
  printf("%d",ans);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define NIL -(long long)(1e9)
#define ll long long
// long long n,w;
double datas[3005];
double dp[3005];
int n;







std::vector<double> vd;
int main () {
//memset(dp,-1,sizeof(dp));
cin>>n;

double d1;
		//heads istiyoruz
for (int i = 1; i <= n; ++i)
{
	cin>>datas[i];		//heads glme ihtimali	
}
// cout<<vd[2];
	int k=1;
	dp[0]=1;
	for(int data =1; data<n+1; ++data){
		for(int tura_i = data+1 ;tura_i>=0;--tura_i){
			dp[tura_i]= dp[tura_i] * (1-datas[data]);
			if(tura_i!=0) dp[tura_i]+= dp[tura_i-1] * datas[data];
		}
	}
	double ans=0;
	for (int i = 1; i <= n; i++)
	{
		if (i>n-i)
		{
			ans+= dp[i];
		}
		
	}
	cout.precision(10);
cout<<ans;


	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
	char sm[1024][1024];
	int c,q;
	for(c=0;;c++){
		char s[256],sc[256];

		int m,h[128];
		scanf("%s",s);
		if(strcmp(s,"-")==0){
			break;
		}
		scanf("%d",&m);
		for(int i=0;i<m;i++){
			scanf("%d",&h[i]);
		}
		q=m;
		strcpy(sc,s);
		for(int p=0;p<q;p++){
			for(int r=0;r<h[p];r++){
				sc[strlen(s)-1]=s[0];
				for(int j=0;j<strlen(s)-1;j++){
					sc[j]=s[j+1];
				}
				strcpy(s,sc);
			}

		}
		strcpy(sm[c],sc);
	}
	for(int i=0;i<c;i++){
		printf("%s\n",sm[i]);
	}
    return 0;
}

Measured memory_bytes: 2736
#include <stdio.h>

int main() {
	char date[15] = "yyyy/01/30";
	scanf("%s", date);
	
	date[0] = '2';
	date[1] = '0';
	date[2] = '1';
	date[3] = '8';
	
	printf("%s", date);
	return 0;
}

Measured memory_bytes: 1716
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    string s;
    cin >> s;
    
    if (s[s.size()-1] == 's') {
        cout << s + "es" << endl;
    } else {
        cout << s + "s" << endl;
        
    }

    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    vector<ll> l(n + 1, 0);
    l[0] = 2;
    l[1] = 1;
    for(int i = 2; i <= n; i++){
        l[i] = l[i - 1] + l[i - 2];
    }
    cout << l[n] << endl;
}

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

int Search(int K, int S){
  int X,Y,Z ;
  int counter_1=0,counter_2=0,counter_3=0 ;

  for(X=0;X<=K-2;X++){
    for(Y=X+1;Y<=K-1;Y++){
      for(Z=Y+1;Z<=K;Z++){
        if(X+Y+Z == S) counter_1++ ;
      }
    }
  }

  counter_1 = counter_1*6 ;

  for(X=0;X<=K;X++){
    for(Y=0;Y<=K;Y++){
      if(X!=Y && 2*X+Y==S) counter_2++ ;
    }
  }

  counter_2 = counter_2*3 ;

  for(X=0;X<=K;X++){
    if(3*X == S) counter_3++ ;
  }


  return counter_1+counter_2+counter_3 ;
}

int main(){
  int K,S ;
  cin >> K >> S ;
  cout << Search(K,S) ;
}


Measured memory_bytes: 256
S = input()

ans = 0
for i in range(2 ** (len(S)-1)):
    c = ''
    for j in range(len(S)-1):  # このループが一番のポイント
        c = S[len(S)-1-j]+c
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            ans += int(c)
            c = ''
    c = S[0]+c
    ans += int(c)

print(ans)


Measured memory_bytes: 3060
import sys

input = sys.stdin.readline

N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]

# 各曜日時間帯に開くか開かないかは2**10=1024通りしかないので
# O(N*2**10) = O(10**5)で間に合う
# 長さ10の配列に0 or 1を格納するbit全探索を行う。
# F[i][j]: 店i, jは曜日と時間帯を表す0~9

n = 10
max_profit = - float("inf")
for bit in range(1, 1<<n):  # 2**10まで2進数で(1つ以上の時間帯で営業しないといけないから000000000を除くため、1スタート)
    profit = 0
    for i in range(N):  # 店の数
        count = 0
        for j in range(n):  # bit（10桁）のどこに1があるか調べる
            if F[i][j] == 1 and (bit>>j) & 1:  # 右シフトしたbitの最後の桁が1ならTrue
                    # 10回シフトして最後の桁が1か調べる == bitのj桁目に1があればTrue
                count += 1
        profit += P[i][count]
    max_profit = max(max_profit, profit)

print(max_profit)

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

int main() {
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll ans = max(a*c,a*d);
  ans = max(ans,b*c);
  ans = max(ans,b*d);
  cout << ans << endl;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        System.out.println((int)Math.min(b/a, c));
        in.close();
    }
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int K = int.Parse(Console.ReadLine().Split(' ').Last());
        List<int> h = Console.ReadLine().Split(' ').Select(o => int.Parse(o)).ToList();

        Console.WriteLine(h.Where(o => o >= K).Count());
    }
}

Measured memory_bytes: 16864
N = int(input())
detayatsu = dict()
ans = 0
for i in range(N):
    S_i = "".join(sorted(list(input())))
    if S_i in detayatsu.keys():
        ans += detayatsu[S_i]
        detayatsu[S_i] += 1
    else:
        detayatsu[S_i] = 1
print(ans)


Measured memory_bytes: 17808
// this is the third test submission for debugging a helper tool
//#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define forr(i,m,n) for (int i=(m); i<=(n); i++)

#define MAXN 100000
int main() {
  int n;
  int a[MAXN];
  int h[MAXN];
  cin >> n;
  forr(i,0,n-1)
    cin >> h[i];
  a[0] = 0;
  a[1] = abs(h[1] - h[0]);
  forr(i,2,n-1) {
    a[i] =
     min(a[i-1] + abs(h[i] - h[i-1]), a[i-2] + abs(h[i] - h[i-2]));
  }
  cout << a[n-1] << endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define mod ( (int)1e9 + 7 )
using namespace std;
const int N = 100005;
vector <int> g[N];
int black[N] , white[N];

void dfs(int from )
{
	black[from] = white[from] = 1;
	
	for(int i = 0; i < (int)g[from].size(); i++)
	{
		int to = g[from][i];
		if(black[ to ])continue;
		dfs( to );
		black[from] *= white[to] , black[from] %= mod;
		white[from] *= ( (black[to] + white[to]) % mod ) , white[from] %= mod;
	}
	
}

main()
{
	int n;
	cin >> n;
	for(int i = 1; i < n; i++)
	{
		int a , b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	
	dfs(1);
	cout << (black[1]  + white[1]) % mod << endl;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=110000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll gcd(ll x, ll y){
  if(x%y==0)return y;
  return gcd(y,x%y);
}
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  ll n;
  cin >> n;
  
  ll ans=0;
  for(ll i=1ll;i*i<=n;i++){
    if((n-i)%i==0 && (n-i)/i>i)ans+=(n-i)/i;
  }
  cout << ans<< endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>

using namespace std;


int main(){
    int N;
    cin >> N;
    long long A[N],B[N],C[N];
    for(int i = 0; i < N; i ++){
        cin >> A[i];
    }
    for(int i = 0; i < N; i ++){
        cin >> B[i];
    }
    for(int i = 0; i < N; i ++){
        cin >> C[i];
    }

    sort(A, A+N);
    sort(B, B+N);
    sort(C, C+N);

    long long count = 0;

    for(int j = 0; j < N; j++){

        long long i = lower_bound(A,A+N,B[j]) - A;
        long long k = N - (upper_bound(C,C+N,B[j]) - C);

        count += i*k;
    }


    cout << count << endl;

    return 0;
}


Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    private static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static long[] buildPrefixArray(FastReader in, int n) {
        String[] tokens = in.nextLine().split(" ");
        long[] a = new long[n + 1];
        a[0] = 0;
        for (int i = 1; i <= n; i++) {
            a[i] = a[i - 1] + Long.parseLong(tokens[i - 1]);
        }
        return a;
    }

    public static void main(final String[] args) throws IOException {
        FastReader in = new FastReader();
        PrintWriter out = new PrintWriter(System.out, true);

        int n = in.nextInt();
        int m = in.nextInt();
        long k = in.nextInt();

        long[] a = buildPrefixArray(in, n);
        long[] b = buildPrefixArray(in, m);

        int books = 0;
        int j = m;
        for (int i = 0; i <= n; i++) {
            if (a[i] > k) {
                break;
            }
            while (b[j] > k - a[i]) {
                j--;
            }
            books = Math.max(books, i + j);
        }
        out.println(books);
    }
}

Measured memory_bytes: 75880
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String[] tmpArray = br.readLine().split(" ");
			
			int n = Integer.parseInt(tmpArray[0]);
			int m = Integer.parseInt(tmpArray[1]);
			
			if(n == 0 && m == 0){
				break;
			}
			
			int[] height = new int[n];
			int[] width = new int[m];
			
			for(int i = 0; i < n; i++){
				height[i] = Integer.parseInt(br.readLine());
			}
			
			for(int i = 0; i < m; i++){
				width[i] = Integer.parseInt(br.readLine());
			}
			
			System.out.println(solve(height, width));
		}
	}
	
	static int solve(int[] height, int[] width){
		int result = 0;
		
		//長さiの辺の数
		int[] hlist = new int[1500*1000];
		int[] wlist = new int[1500*1000];
		
		//スタート地点
		for(int i = 0; i < height.length ; i++){
			int len = 0;
			//ゴール地点
			for(int j = i; j < height.length ; j++){
				len += height[j];
				hlist[len]++;
			}
		}
		
		//スタート地点
		for(int i = 0; i < width.length ; i++){
			int len = 0;
			//ゴール地点
			for(int j = i; j < width.length ; j++){
				len += width[j];
				wlist[len]++;
			}
		}
		
		for(int i = 0; i < wlist.length ; i++){
			result += wlist[i]*hlist[i];
		}
		return result;
	}

}



Measured memory_bytes: 443008
#include<bits/stdc++.h>
      using namespace std;
      #define ll long long
      #define pb push_back
      #define pll  pair <long long,long long>
      #define mp make_pair
      #define ss second
      #define ff first
      #define maa 998244353
      #define endl '\n'
      #define ld long double
      #define all(x) x.begin(),x.end()
      bool is(ll  i)
      {
        if(i==1)
            return 0 ;
        ll  f=0 ;
        for(ll  j=2;j<=sqrt(i);j++)
        {
            if(i%j==0)
            {
                f=1 ;
                break ;
            }
        }
        return !f ;
      }
      int main()
      {
        ll n,m ;
        cin>>n>>m ;
        vector<ll>v(n,0) ;
        vector<ll>pre(n+1,0) ;

        for(ll i=0;i<n;i++)
        {
            cin>>v[i] ;
            ///pre[i]=pre[i-1]+v[i] ;
        }
        sort(all(v));
        for(ll i=1;i<=n;i++)
        {
            pre[i]=pre[i-1]+v[i-1] ;
        }
        ll lo=0,hi=200000 ;
        ll mx=hi ;
        while(lo<=hi)
        {
            ll mi=(lo+hi)/2 ;
            ll cnt=0 ;
            for(ll i=0;i<n;i++)
            {
                ll x=mi-v[i] ;
                vector<ll>::iterator it=lower_bound(all(v),x) ;
                ll in=(it-v.begin()) ;
                cnt+=n-in ;

            }
           // cout<<mi<<" "<<cnt<<endl ;
            if(cnt>=m)
            {
                mx=mi ;
                lo=mi+1 ;
            }
            else
            {
                hi=mi-1 ;
            }
        }
        ll cc=0 ;
        ll ans=0 ;

        for(ll i=0;i<n;i++)
            {
                ll x=mx+1-v[i] ;

                vector<ll>::iterator it=lower_bound(all(v),x) ;
                ll in=(it-v.begin()) ;
                cc+=n-in ;

                ans+=pre[n]-pre[in]+(n-in)*v[i] ;

            }
           /// cout<<mx<<endl ;

            ans+=(m-cc)*mx ;


            cout<<ans ;

      }



Measured memory_bytes: 1792
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N, Q;

	public static void main(String[] args) {
		while (true) {
			N = sc.nextInt();
			if (N == 0) break;
			int S = sc.nextInt();
			int W = sc.nextInt();
			Q = sc.nextInt();
			int[] A = new int[N];
			int g = S;
			for (int i = 0; i < N; ++i) {
				A[i] = (g / 7) % 10;
				if (g % 2 == 0) {
					g = g / 2;
				} else {
					g = (g / 2) ^ W;
				}
			}
			System.out.println(solve(A));
		}
	}

	static long solve(int[] A) {
		long ans = 0;
		if (Q == 2 || Q == 5) {
			int nonzero = 0;
			for (int i = 0; i < N; ++i) {
				if (A[i] != 0) ++nonzero;
				if (A[i] % Q == 0) {
					ans += nonzero;
				}
			}
			return ans;
		}
		HashMap<Long, Integer> map = new HashMap<Long, Integer>();
		long sum = 0;
		long base = 1;
		for (int i = 0; i < N; ++i) {
			sum += A[N - 1 - i] * base;
			sum %= Q;
			base *= 10;
			base %= Q;
			Integer ci = map.get(sum);
			int c = ci == null ? 0 : ci.intValue();
			if (A[N - 1 - i] != 0) {
				ans += c;
				if (sum == 0) ans++;
			}
			map.put(sum, c + 1);
		}
		return ans;
	}

}

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

int knapsack(int w, int wt[], int val[], int n){
    int dp[n+1][w+1];
    for(int i=0; i<=n; ++i){
        for(int j=0; j<=w; ++j){
            if(i==0 || j==0) dp[i][j]=0;
            else if(wt[i-1] <= j){
                dp[i][j] = max(val[i-1] + dp[i-1][j-wt[i-1]], dp[i-1][j]);
            }else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    return dp[n][w];
}

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

    int n, w;
    cin >> n >> w;
    int val[n], wt[n];
    for(int i=0; i<n; ++i) cin >> wt[i] >> val[i];
    cout << knapsack(w,wt,val,n);

    return 0;
}

Measured memory_bytes: 79232
import math

n = int(input())
x1 = math.floor(n / 1.08)
x2 = math.ceil(n / 1.08)

if math.floor(x1 * 1.08) == n:
    print(x1)
elif math.floor(x2 * 1.08) == n:
    print(x2)
else:
    print(':(')


Measured memory_bytes: 2940
N, M = map(int, input().split())
KA = []
box = [0] * N
for i in range(N):
    KA.append(list(map(int, input().split())))
    box[i] = [0] * M
    for j in range(1, M+1):
        if j in KA[i][1:]:
            box[i][j-1] = 1

temp = [0] * M
for i in range(N):
    for j in range(M):
        temp[j] += box[i][j]
        
print(temp.count(N))

Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func main() {
	var w, h int

	for {
		fmt.Scan(&h, &w)

		if w == 0 && h == 0 {
			break
		}

		for i := 0; i < h; i++ {
			for j := 0; j < w; j++ {
				fmt.Print("#")
			}
			fmt.Println()
		}
		fmt.Println()
	}
}



Measured memory_bytes: 1124
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int num = 1;
        for (int i = 0; i < n; i++) {
            int d = num * 2;
            int p = num + k;
            num = Math.min(d, p);
        }
        int result = num;

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main()
{
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }

        vector<string> v;
        for (int i = 0; i < n; ++i) {
            string s;
            cin >> s;
            v.push_back(s);
        }

        auto check = [&v](int start, int num) {
            int count{0};
            for (int j = start; j < v.size(); ++j) {
                count += v[j].size();
                if (count > num) {
                    break;
                }
                if (count == num) {
                    return make_pair(true, j + 1);
                }
            }
            return make_pair(false, start + 1);
        };
        int s = 0;
        while (true) {
            auto r1 = check(s, 5);
            if (r1.first) {
                auto r2 = check(r1.second, 7);
                if (r2.first) {
                    auto r3 = check(r2.second, 5);
                    if (r3.first) {
                        auto r4 = check(r3.second, 7);
                        if (r4.first) {
                            auto r5 = check(r4.second, 7);
                            if (r5.first) {
                                cout << (s + 1) << endl;
                                break;
                            }
                        }
                    }
                }
            }
            ++s;
        }
    }
}

Measured memory_bytes: 3228
#include<iostream>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef long long ll;
#define MAX 10000
int sosu[MAX]={1,1,0};
int main(){
	ll out[100]={0};
	out[99]=1;
	loop(i,2,1500)if(sosu[i]==0){
		for(int j=i;j<MAX;j+=i)sosu[j]=i;
		ll tmp=0;
		for(int j=99;j>=1;j--){
			out[j]=out[j]*i+tmp;
			tmp=out[j]/(int)1e9;
			out[j]%=(int)1e9;
		}
	}
	out[99]+=2;
	bool h=false;	
	rep(i,100)if(out[i]||h){
		if(h)printf("%09d",out[i]);
		else printf("%d",out[i]);
		h=true;
	}
	cout<<endl;
	int n;cin>>n;
	rep(i,n)cout<<sosu[i+2]<<endl;
}

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 998244353LL;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template <typename T>
vector<T> finv(map<ll,T> m){
  vector<T> ret(200005);
  ret[0] = (T)1/m[0];
  for(int i = 1; i < 200005; i++){
    for(auto x:m){
      if(x.second!=0&&x.first<=i&&x.first!=0){
        ret[i] = (ret[i] - x.second*ret[i-x.first])%mod;
      }
    }
    ret[i] /= m[0];
  }
  rep(i,200005) {
      if(ret[i]<0) ret[i] += mod;
  }
  return ret;
}

int main(){
    ll N,K;
    cin>>N>>K;
    vector<ll> cnt(200005);
    rep(i,K){
        ll l,r;
        cin>>l>>r;
        cnt[l]++;
        cnt[r+1]--;
    }
    rep(i,200005) cnt[i] = -cnt[i];
    cnt[0]++;
    cnt[1]--;
    vector<ll> ans(200005);
    map<ll,ll> m;
    rep(i,200005) {
        if(cnt[i] != 0) m[i] = cnt[i];
    }
    ans = finv<ll>(m);
    vector<ll> anss(200005);
    rep(i,200004){
        anss[i+1] = ans[i];
    }
    rep(i,200005) ans[i] = (ans[i] - anss[i])%mod;
    if(ans[N-1]<0) ans[N-1] += mod;
    cout<<ans[N-1]<<endl;
}

Measured memory_bytes: 7928
import sys
from functools import lru_cache
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')

@lru_cache(maxsize=None)
def f(N, *A):
    dp = [[INF] * (N + 1) for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][i] = 0
    for l in range(1, N + 1):
        for i in range(N - l + 1):
            j = i + l
            if (N - l) % 2 == 0:
                dp[i][j] = max(dp[i + 1][j] + A[i], dp[i][j - 1] + A[j - 1])
            else:
                dp[i][j] = min(dp[i + 1][j] - A[i], dp[i][j - 1] - A[j - 1])
    print(dp[0][N])

def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    f(N,*A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 390944
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	string c1 ,c2, c3;
	cin >> c1 >> c2 >> c3;
	cout << c1[0] << c2[1] << c3[2] << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();

        int answer = 0;
        for (int i = 0; i < 4; i++) {
            if (S.charAt(i) == '+') {
                answer++;
            } else {
                answer--;
            }
        }

        System.out.println(answer);
    }
}


Measured memory_bytes: 22612
/* ANTHOR KUMAR DAS
KUET ECE 2K18*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sc(a) scanf("%d",&a)
#define sc1(n) scanf("%lld",&n)
#define sc2(b,c) scanf("%lld%lld",&b,&c)
#define f(a,b) for(a=0;a<b;a++)
#define pb(a) push_back(a)
#define br break
int main()
{
    ll int r;
    cin>>r;
    cout<<r*r<<endl;


    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://agc004.contest.atcoder.jp/tasks/agc004_b>
問題文============================================================
 高橋君は異世界に住んでいます。 この世界には N 色のスライムがいます。
 最初、高橋君はどの色のスライムも飼っていません。 高橋君の目標は、全色のスライムを一緒に飼うことです。
 
 高橋君は次の 2 種類の操作を行えます。
 
 今飼っていないスライムの色 i (1≤i≤N) をひとつ選ぶ。 色 i のスライムを捕まえて飼う。この操作には ai 秒掛かる。
 
 魔法を唱える。 すると、今飼っている各スライムについて、色 i (1≤i≤N−1) のスライムは色 i+1 へ変色する。
 ただし、色 N のスライムは色 1 へ変色する。 この操作には x 秒掛かる。
 
 高橋君が全色のスライムを一緒に飼うためには、最短で合計何秒掛かるかを求めてください。
=================================================================

解説=============================================================

================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N,x; cin >> N >> x;
    vector<ll> a(N);
    for(auto &in:a) cin >> in;
    vector<ll> b(N,LINF);
    ll ans = LINF;
    // i * x + Σb[j]_i
    for(int i = 0; i < N;i++){
        ll tmp = 0;
        for(int j = 0; j < N;j++){
            b[j] = min(b[j],a[(j-i+N)%N]);
            tmp += b[j];
        }
        ans = min(ans,i*x+tmp);
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)
 
ll ii(){ ll x; cin >> x; return x; }
string is(){ string x; cin >> x; return x; }
ld id(){ ld x; cin >> x; return x; }
void oi(ll x){ cout << x; }
void od(ld x){ cout << fixed << setprecision(10) << x; }
void os(string x){ cout << x; }
void oe(){ cout << endl; }
void oie(ll x){ oi(x); oe(); }
void ode(ld x){ od(x); oe(); }
void ose(string x){ os(x); oe(); }

ll mod=1000000007;

int main(){
    vector<string> ss={"AC", "WA", "TLE", "RE"};
    vector<ll> sm(4,0);
    ll N=ii();
    REP(i,0,N){
        string s=is();
        REP(i,0,4){
            if(ss[i]==s){
                sm[i]++;
            }
        }
    }
    REP(i,0,4){
        cout << ss[i] << " x " << sm[i] << endl;
    }
    return 0;
}

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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )

const int INF = 1e9;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;

int main() {

    ll q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;

    ll menor1L = min(4 * q, min(2 * h, s));
    ll menor2L = min(2 * menor1L, d);

    ll ans = (n / 2) * menor2L + (n & 1) * menor1L;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n,m,x=map(int,input().split())
c=[list(map(int,input().split())) for i in range(n)]
ans=10**10
for i in range(1<<n):
    a=[0]*m
    res=0
    for j in range(n):
        if i>>j&1:
            res+=c[j][0]
            for k in range(m):
                a[k]+=c[j][k+1]
    f=1
    for i in a:
        if i<x:
            f=0
            break
    if f:
        ans=min(ans,res)
print(ans if ans<10**10 else -1)


Measured memory_bytes: 68532
def func(i, j):
  il = len(str(i))
  jl = len(str(j))
  if il > jl:
    return il
  return jl

n = int(input())
min = len(str(n))
for i in range(1, n+1):
  if i**2 > n:
    break
  if n % i == 0:
    fr = func(i, int(n/i))
    if min > fr:
      min = fr
print(min)


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

#define LL long long

int N;
LL sum = 0;

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

  cin >> N;

  for(int i = 1; i <= N; i++) {
    if(i % 3 != 0 && i % 5 != 0) sum += i;
  }

  cout << sum << "\n";

  return 0;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppiii;

const int MAX_N = 9;
const int WANT = 7;

void solve() {
  int n, x;
  cin >> n >> x;
  if(x == 1 || x == 2*n-1) {
    cout << "No\n";
    return;
  }
  if(n == 2) {
    cout << "Yes\n1\n2\n3\n";
    return;
  }
  vector<int> ret;
  ret.resize(2*n-1);
  set<int> used;
  if(x == 2) {
    ret[n-2] = 3;
    ret[n-1] = 2;
    ret[n] = 1;
    ret[n+1] = 4;
    used.insert(1);
    used.insert(2);
    used.insert(3);
    used.insert(4);
  }
  else {
    ret[n-2] = x-1;
    ret[n-1] = x;
    ret[n] = x+1;
    ret[n+1] = x-2;
    used.insert(x-2);
    used.insert(x-1);
    used.insert(x);
    used.insert(x+1);
  }
  int lhs = 1;
  for(int i = 0; i < ret.size(); i++) {
    if(ret[i]) continue;
    while(used.count(lhs)) lhs++;
    ret[i] = lhs++;
  }
  cout << "Yes\n";
  for(int out: ret) cout << out << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
  solve();
}


Measured memory_bytes: 2304
A = list(map(int,input().split()))
B =list(map(int,input().split()))
C = list(map(int,input().split()))

N = int(input())

for i in range(N):
    X = int(input())
    
    if X in A:
        A[A.index(X)] = 0
    
    if X in B:
        B[B.index(X)] = 0
    
    if X in C:
        C[C.index(X)] = 0
        
ans = False
for i in range(3):
    
    if A[i]+ B[i] + C[i] ==0:
        ans = True
        
if sum(A)==0 or sum(B)==0 or sum(C)==0 or A[0] + B[1] + C[2] == 0 or A[2] + B[1] + C[0] == 0:
    ans = True
    
if ans:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38452
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>

template <class Integer>
auto boost_irange(Integer last) { return boost::irange(static_cast<Integer>(0), last); }
template <class Integer>
auto boost_irange(Integer first, Integer last) { return boost::irange(first, last); }

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { cout << std::endl; }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << val << ' ';
            return *this;
        }
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy operator<<(T&& val)
    {
        cout << val << ' ';
        return {};
    }
};

int main()
{
    input in;
    output out;

    int N, Q;
    in >> N, Q;

    std::vector<std::vector<int>> tree(N);
    for (int i = 0; i < N - 1; ++i) {
        int a, b;
        in >> a, b;
        tree[a - 1].push_back(b - 1);
        tree[b - 1].push_back(a - 1);
    }

    std::vector<int> c(N);
    for (int i = 0; i < Q; ++i) {
        int p, x;
        in >> p, x;
        c[p - 1] += x;
    }

    std::queue<std::pair<int, int>> q;
    q.push(std::make_pair(0, -1));
    while (!q.empty()) {
        auto x = q.front();
        q.pop();
        for (auto child : tree[x.first]) {
            if (child == x.second) continue;
            c[child] += c[x.first];
            q.push(std::make_pair(child, x.first));
        }
    }

    for (int x : c) {
        std::cout << x << " ";
    }

    return 0;
}


Measured memory_bytes: 16372
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<int>x;
    x.push_back(4);
    x.push_back(7);
    int ind = 0;
        for(int i=0;i<x.size();i++){
            ind++;
            x.push_back(x[i]+4);
            x.push_back(x[i]+7);
            if(ind>35000){
              break;
            }
        }

    sort(x.begin(),x.end());
    if(binary_search(x.begin(),x.end(),n)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
	return 0;
}

Measured memory_bytes: 892
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max()/2;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<vector<Edge>>g;
vector<edge>edges;
vector<Pll>v;
map<string, LL>ma;
multiset<LL>st;
LL h, w, n, m, k, t, s, p, q, last, cnt, sum, ans, b[210000], d[200000];
Pll a[210000];
string str, ss;
bool f[110000];
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
int main() {
	cin >> n >> m;
	rep(i, n) {
		cin >> a[i].first >> a[i].second;
	}
	sort(a, a + n);
	LL cnt = 0;
	priority_queue<LL>pq;
	rep(i, m) {
		while (cnt < n&&a[cnt].first <= i+1) {
			pq.push(a[cnt].second);
			cnt++;
		}
		if (!pq.empty()) {
			ans += pq.top();
			pq.pop();
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2936
#include<bits/stdc++.h>
const int N=6e3+5;
int n,mo,i,j,k,f[N][N][3],ans;
int main(){
	scanf("%d%d",&n,&mo);
	f[0][0][0]=1;
	for(i=0;i<n*3;++i)for(j=0;j<=n;++j){
		f[i+1][j][0]=(1ll*f[i][j][0]+f[i][j][1]+f[i][j][2])%mo;
		f[i+1][j+1][1]=1ll*f[i][j][0]*i%mo;
		f[i+1][j][2]=1ll*f[i][j][1]*i%mo;
	}
	for(i=0;i<=n;++i)for(j=0;j<3;++j)ans=(ans+f[n*3][i][j])%mo;
	printf("%d\n",ans);
}

Measured memory_bytes: 420992
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	ll W, H, x, y;
	cin >> W >> H >> x >> y;
	
	printf("%.15lf %d\n", H * W / 2.0, x * 2 == W && y * 2 == H);
	
	return 0;
}


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

#define endl '\n'

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

    string s;
    cin >> s;
    int res = 0;
    for(char c : s) {
        if(c == '1')
            res++;
    }
    cout << res;

    return 0;
}

Measured memory_bytes: 768