akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
constexpr ll TEN(ll n){return n==0?1:10ll*TEN(n-1);}

constexpr ll inf = TEN(9)+5;
constexpr ll linf = 3*TEN(18);

struct SegTree { // 区間min,max
    int n;
    vector<int> Max;
    vector<int> Min;
    void init(int n_) {
        n = 1;
        while (n < n_) n *= 2;
        Max.resize(2 * n);
        Min.resize(2 * n);
        for (int i = 0; i < 2 * n - 1; ++i) {
            Max[i] = 0;
            Min[i] = inf;
        }
    }
    void update(int idx, int val) {
        idx += n - 1;
        Min[idx] = val;
        Max[idx] = val;
        while (idx > 0) {
            idx = (idx - 1) / 2;
            Min[idx] = min(Min[idx * 2 + 1], Min[idx * 2 + 2]);
            Max[idx] = max(Max[idx * 2 + 1], Max[idx * 2 + 2]);
        }
    }
    int get_min(int a, int b, int k = 0, int l = 0, int r = -1) { // [a, b)のmin
        if (r == -1) r = n;
        if (r <= a || b <= l) return inf;
        if (a <= l && r <= b) return Min[k];
        int vl = get_min(a, b, k * 2 + 1, l, (l + r) / 2);
        int vr = get_min(a, b, k * 2 + 2, (l + r) / 2, r);
        return min(vl, vr);
    }
    int get_max(int a, int b, int k = 0, int l = 0, int r = -1) { // [a, b)のmax
        if (r == -1) r = n;
        if (r <= a || b <= l) return 0;
        if (a <= l && r <= b) return Max[k];
        int vl = get_max(a, b, k * 2 + 1, l, (l + r) / 2);
        int vr = get_max(a, b, k * 2 + 2, (l + r) / 2, r);
        return max(vl, vr);
    }
};

SegTree st;

signed main()
{
    int N, K; cin >> N >> K;
    vi A(N);
    rep(i, N) cin >> A[i];

    st.init(300030);

    rep(i, N) {
        int l = max(A[i] - K, 0);
        int r = min(A[i] + K, 300000);

        st.update(A[i], st.get_max(l, r + 1) + 1);
    }

    cout << st.get_max(0, 300001) << endl;
}


Measured memory_bytes: 12716
#include <cstdio>
#include <numeric>
#include <algorithm>
#include <functional>

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

using namespace std;

int main(){
	for(int n;scanf("%d",&n),n;){
		pair<int,int> a[1000];
		rep(i,n) scanf("%d%d",&a[i].first,&a[i].second);
		sort(a,a+n,greater< pair<int,int> >());

		int r[1000],w[1000];
		rep(i,n) r[i]=a[i].first, w[i]=a[i].second;

		// easy case
		if(r[0]<=accumulate(r+1,r+n,0)){
			printf("%d\n",accumulate(r,r+n,0)+accumulate(w,w+n,0));
		}
		// hard case
		else{
			int d=r[0]-accumulate(r+1,r+n,0);
			bool dp[1001]={};
			dp[0]=true;
			for(int i=1;i<n;i++) for(int j=d;j>=w[i];j--) dp[j]|=dp[j-w[i]];
			int j0;
			for(j0=d;!dp[j0];j0--);
			printf("%d\n",2*r[0]+accumulate(w,w+n,0)-j0);
		}
	}

	return 0;
}

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

using namespace std;
int main(){


    int n, W, item, i;

    cin >> n >> W;

    vector<long long>dp(W + 1, 0);//dp[i] = the maximum total value of items weighting exactly equals to k

    for(item = 0; item < n; item++){

        int w, weight_already;

        long long v;

        cin >> w >> v;

        for(weight_already = W - w; weight_already >= 0; weight_already--){

            dp[weight_already + w] = max(dp[weight_already + w], dp[weight_already] + v);
        }
    }
    long long ans = 0;

    for(i = 0; i <= W; i++){

        ans = max(ans, dp[i]);
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 1024
A, B, K = map(int, input().split())

L = []

for i in range(A, min(A+K, B+1)):
  L.append(i)
for i in range(B, max(B-K, A-1), -1):
  L.append(i)

ans = sorted(set(L))

print(*ans, sep="\n")

Measured memory_bytes: 9064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second

const int INF = 1e9+5;


int main() {
	int n;
	cin >> n;
	vector<vector<int>> p(n, vector<int>(3));
	forn(i, n)
		cin >> p[i][0] >> p[i][1] >> p[i][2];
	vector<vector<int>> dp(n, vector<int>(3, 0));
	dp[0][0] = p[0][0];
	dp[0][1] = p[0][1];
	dp[0][2] = p[0][2];
	for(int i = 1; i < n; i++){
		forn(j, 3){
			if(j==0)
				dp[i][j] = max(dp[i-1][1], dp[i-1][2]) + p[i][j];
			else if(j==1)
				dp[i][j] += max(dp[i-1][0], dp[i-1][2]) + p[i][j];
			else
				dp[i][j] += max(dp[i-1][0], dp[i-1][1]) + p[i][j];
		}
	}
	cout << max({dp[n-1][0],dp[n-1][1],dp[n-1][2]}) << endl;
	return 0;

}



Measured memory_bytes: 11136
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/




int main() {
int N;
cin>>N;
bool flag=false;
rep(i,N){
  int a;
  cin>>a;
  if(a%2==1){
    flag=true;
  }
}
if(flag){
  cout<<"first"<<endl;
}
else{
cout<<"second"<<endl;
}
return 0;
}

Measured memory_bytes: 3556
#include <iostream>

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

using namespace std;

int main(){
  string S;
  cin >> S;
  // 入力終了

  int N = S.size();

  // S中に出現した文字を記録
  bool appeared[26] = {false};
  rep(i, N)
    appeared[ S[i]-'a'] = true;

  // 出現していないものがあればそれを尻に引っ付ければヨシ！
  rep(i, 26)
    if(!appeared[i]){
      cout << S << (char)(i+'a') << endl;
      return 0;
    }

  // 全部出現してるとき
  for(int i=N-1; i>=0; i--){
    // 文字列S[i]以降で登場していないものを探す
    for(int j=S[i]-'a'; j<26; j++)
      // 登場していないものがあればS[i]以降をj番目のアルファベットで置き換え
      if(!appeared[j]){
	cout << S.substr(0, i) << (char)(j+'a') << endl;
	return 0;
      }
    // 後ろから使っていないフラグを立てる
    appeared[ S[i] -'a'] = false;
  }

  // 該当なし
  cout << -1 << endl;
  
  return 0;
}


Measured memory_bytes: 3632
N,K=map(int,input().split())
MAP=[list(map(int,input().split())) for i in range(N)]

start = 2*N+1
goal = 2*N+2
V=2*N+5

EDGE=[[[0,0] for j in range(V)] for i in range(V)]

# 0 ～ N : 縦
# N+1 ～　2*N : 横
# 2*N+1 : start
# 2*N+2 : goal

for i in range(N):
    EDGE[start][i]=[K,0]
    EDGE[N+i][goal]=[K,0]
    
for i in range(N):
    for j in range(N):
        EDGE[i][N+j]=[1,10**9-MAP[i][j]]
        EDGE[N+j][i]=[0,-(10**9-MAP[i][j])]

EDGE[start][goal]=[float("inf"),10**9]

BACK=[-1]*V
LA=0
 
import heapq
 
for flow in range(K*N):
    ANS=[float("inf")]*V
    Q=[(0,start)]
    ANS[start]=0
 
    while Q:
        time,fr=heapq.heappop(Q)
        if time>ANS[fr]:
            continue

        for to in range(V):
            c,d = EDGE[fr][to]
            if c>0 and ANS[to]>ANS[fr]+d:
                ANS[to]=ANS[fr]+d
                BACK[to]=fr
                heapq.heappush(Q,(ANS[to],to))

    LA+=ANS[goal]
 
    NOW=goal
    while NOW!=start:
        fr=BACK[NOW]
        EDGE[fr][NOW][0]-=1
        EDGE[NOW][fr][0]+=1

        NOW=fr
 
print(K*N*10**9-LA)
ALIST=[["."]*N for i in range(N)]

for i in range(N):
    for j in range(N):
        if EDGE[i][N+j][0]==0:
            ALIST[i][j]="X"

for alist in ALIST:
    print("".join(alist))

Measured memory_bytes: 74572
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll h, w, n;
	vector<ll> v[100];
	vector<ll> vv;
	ll count = 0;

	cin >> h >> w >> n;

	REP(i, n) {
		ll a;
		cin >> a;

		REP(j, a) {
			vv.push_back(i + 1);
		}
	}

	REP(i, h) {
		REP(j, w) {
			if (i % 2 == 0) {
				v[i].push_back(vv[w * i + j]);
			}
			else {
				v[i].push_back(vv[w * (i + 1) - j - 1]);
			}
		}
	}

	REP(i, h) {
		REP(j, w) {
			if (j != w - 1) {
				cout << v[i][j] << " ";
			}
			else {
				cout << v[i][j] << endl;
			}
		}
	}
}

Measured memory_bytes: 512
/*
I believe on myself and I will achieve
this->author = Fuad Ashraful Mehmet, CSE-UAP
Todo:
https://www.codechef.com/COOK119?itm_campaign=contest_listing
*/
#include<bits/stdc++.h>
#define forn(i,n) for(int i=0;i<(int)n;++i)
#define all(o) (o).begin(),(o).end()
#define dbg(o)  cerr<<"at "<<__LINE__<<" response = "<<o<<endl;
#define pb push_back
using namespace std;

const int N=2e5+5;
typedef long long ll;
int n,m,d,k,cs=1;


void HalfDead()
{
      ll x,k,d;
      cin>>x>>k>>d;

      ll lagbe=abs(x)/d;
      if(lagbe>k)
      {
            ll temp=k*d;
            ll t=abs(x);
            cout<<t-temp<<endl;
            return;
      }
      else
      {
            ll t=abs(x);
            k-=lagbe;
            ll rem=t%d;

            if(k&1)
            {
                  cout<<d-rem<<endl;
            }
            else
            {
                  cout<<rem<<endl;
            }
            return;
            
      }
      
}
int main()
{
      ios_base::sync_with_stdio(0); cin.tie(nullptr);
      int tc=1;
     // cin>>tc;
      while(tc--)
      {
            HalfDead();
      }
      return 0;
}

Measured memory_bytes: 3648
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    string s;
    cin>>s;
    int n=s.size();
    int x=count(s.cbegin(),s.cend(),'0'),y=n-x;
    cout<<2*min(x,y)<<endl;
}
//./problem.exe

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
// #define mp make_pair
#define S second
#define F first
// ll mod=1e9+7 ;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define input_from_file  freopen("input.txt", "r", stdin);
using namespace std::chrono; 
ll n,m,ans=0;vector<vector<ll>> vec;
vector<ll> vis,dist;
void dfs(ll i,ll par){
  if(vis[i]) return;
  vis[i]=1;
  for(auto x:vec[i]){
    if(x!=par){
      dfs(x,i);
      dist[i]=max(dist[i],dist[x]+1);
    }
  }
}
int main(){                fastIO
  // input_from_file
  cin>>n>>m;vec.resize(n+1);vis.resize(n+1,0);dist.resize(n+1,0);
  for(int i=0;i<m;i++){ll u,v;
    cin>>u>>v;vec[u].pb(v);
  }
  for(int i=1;i<=n;i++){
    if(!vis[i]) dfs(i,-1);
  }
  for(int i=1;i<=n;i++) ans=max(ans,dist[i]);
  // for(int i=1;i<=n;i++) cout<<dist[i]<<" ";cout<<endl;
  cout<<ans;
  return 0;
}

Measured memory_bytes: 12832
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef pair<int,int> int_pair;
typedef pair<ll,ll> ll_pair;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const int N=101;
int a,b,c,x;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>a>>b>>c>>x;
	int ans=0,xx;

	FOR(i,0,a+1){
		FOR(j,0,b+1){
			FOR(k,0,c+1){
				xx=500*i+100*j+50*k;
				if(xx==x)ans++;
			}
		}
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << ": " << x << '\n';

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;

  int ans = 0;
  for (int i = 1; i < n; i++) {
    int cnt = 0;
    for (char c = 'a'; c <= 'z'; c++) {
      bool left, right;
      left = right = false;
      
      for (int a = 0; a < i; a++) {
        if (s[a] == c) left = true;
      }
      for (int b = i; b < n; b++) {
        if (s[b] == c) right = true;
      }
      if (left && right) cnt++;
    }
    ans = max(ans, cnt);
  }
  cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char A[9]={'A','K','I','H','A','B','A','R','A'},S[55],B[55];
int n,C[55],t;
int main(){
	scanf("%s",S); n=strlen(S);
	for (int i=0,j;i<=n;i=j+1){
		for (j=i;S[j]=='A';++j);
		if (j==n) B[t]='O'; else B[t]=S[j];
		C[t]=j-i; ++t;
	}
	if (t!=6||B[0]!='K'||B[1]!='I'||B[2]!='H'||B[3]!='B'||B[4]!='R'||B[5]!='O') {puts("NO"); return 0;}
	if (C[0]>1||C[1]>0||C[2]>0||C[3]>1||C[4]>1||C[5]>1) {puts("NO"); return 0;}
	puts("YES");
	return 0;
}

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if (A+B>C+D) {
    cout << " Left " << endl;
  }
  else if (A+B == C+D) {
    cout << " Balanced " << endl;
  }
  else if (A+B<C+D){
    cout << " Right " << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d",&a);
	scanf("%d",&b);
	if(a>b){
		printf("a > b\n");
	}
	else if(a<b){
		printf("a < b\n");
	}
	else{
		printf("a == b\n");
	}
	
	return 0;
}


Measured memory_bytes: 2608
#include <bits/stdc++.h>
using namespace std;
bool a[10];
int n,x,s,s1;
int main(){
    scanf("%d",&n);
while (n--){
        scanf("%d",&x);
        if (x<400&&!a[1])a[1]=1,s++;
        if (x>=400&&x<800&&!a[2])a[2]=1,s++;
        if (x>=800&&x<1200&&!a[3])a[3]=1,s++;
        if (x>=1200&&x<1600&&!a[4])a[4]=1,s++;
        if (x>=1600&&x<2000&&!a[5])a[5]=1,s++;
        if (x>=2000&&x<2400&&!a[6])a[6]=1,s++;
        if (x>=2400&&x<2800&&!a[7])a[7]=1,s++;
        if (x>=2800&&x<3200&&!a[8])a[8]=1,s++;
        if (x>=3200)s1++;}
    printf("%d %d\n",max(s,1),s+s1);
return 0;}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	string s;
	cin>>s;
	ll k; cin>>k; k--;
	for(int i = 0; i < s.size(); i++){
		if(s[i] != '1'){
			if(k < i){
				cout<<1<<endl;
			}else{
				cout<<s[i]<<endl;
			}
			exit(0);
		}
	}
	cout<<1<<endl;

	return 0;
}

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

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

using namespace std;

typedef long long int lli;

int main () {
    int N;
    cin >> N;
    const lli mod = 1000000007;
    string s1, s2;
    cin >> s1 >> s2;
    lli ans = 1;
    bool dol = true;
    REP (i, 0, N) {
        if (s1[i] == s2[i]) {
            if (i == 0) {
                ans = 3;
            } else {
                if (dol) {
                    ans = ans * 1;
                } else {
                    ans = (ans * 2) % mod;
                }
            }
            dol = false;
        } else {
            if (i == 0) {
                ans = 6;
            } else {
                if (dol) {
                    ans = (ans * 3) % mod;
                } else {
                    ans = (ans * 2) % mod;
                }
            }
            i++;
            dol = true;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long inf = 1LL<<60;

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

    if(n==m) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
#define ll long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define clr(x,y) memset(x,y,sizeof(x))
#define in(a) a=read()
#define out(a) printf("%d\n",a)
inline ll read(){
	char c=getchar();ll f=1,x=0;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9')x=x*10+(c-'0'),c=getchar();
	return x*f;
}
#define mod 1000000007
#define maxn 100010
#define inf (1<<30)
int ans[110];
ll f[110];
int main(){
	int n;
	in(n);
	FOR(i,1,n){
		int x=i;
		int c=2;
		while(x!=1){
			if(x%c==0)x/=c,ans[c]++; 
			 else c++;
		}
	}
	FOR(i,1,n)ans[i]++;
	f[1]=1;
	FOR(i,1,n){
		FORD(j,75,2)
			FOR(k,2,ans[i])
				if(j%k==0)
					f[j]+=f[j/k];
	}
	printf("%lld",f[75]);
}
//5*5*3


Measured memory_bytes: 256
A, B = map(int, input().split())
S = input()

numbers = [str(i) for i in range(10)]

for i in range(A+B+1):
	if i == A:
		if S[i] != '-':
			print("No")
			exit(0)
	else:
		if S[i] not in numbers:
			print("No")
			exit(0)

print("Yes")

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

int main() {
  int a, n, b, c;
  cin >> n >> a;
  
  b = n / 500;
  c = n - 500 * b;
  
  if (c <= a)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

using namespace std;

// 5
// 1 3 5 4 2

int main() {
  int n;
  scanf("%d", &n);

  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
  }

  int count = 0;
  for (int i = 1; i < n - 1; i++) {
    int a = p[i - 1];
    int b = p[i];
    int c = p[i + 1];

    if (a < b && c >= b || c < b && a >= b) {
      count++;
    }
  }
  cout << count << endl;
}


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

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int x = x2, y = y2;
    int vx = x2 - x1;
    int vy = y2 - y1;

    for (int i = 0; i < 2; i++) {
        swap(vx, vy);
        vx *= -1;
        x += vx;
        y += vy;
        cout << x << ' ' << y << endl;
    }
}

Measured memory_bytes: 3628
#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>;
const int mod = 1000000007;
const ll INF = 1001001001;
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; }

int main(){
    int k;
    cin >> k;
    int a,b;
    cin >> a >> b;
    bool ok = false;
    for(int i=a;i<=b;i++){
        if(i%k==0) ok = true;
    }

    if(ok){
        puts("OK");
    }else{
        puts("NG");
    }
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
int n, x, mini(2e9), res;
int main() {
    DAU
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> x;
        mini = min(mini, x);
        res += (x == mini);
    }
    cout << res;
    PLEC
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(br.readLine());
		}
		br.close();

		int x = -1;
		long ans = -1;
		for (int i = 0; i < n; i++) {
			x++;
			if (a[i] > x) {
				System.out.println(-1);
				return;
			}
			if (a[i] == x) {
				ans++;
			} else {
				ans += a[i];
			}
			x = a[i];
		}
		System.out.println(ans);
	}
}


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

int main()
{
#define ROOP(i,n) for(int i=0; i<n; i++)
    
    long N, M;
    cin >> N >> M;
    
    vector<long> x(N), y(N), z(N);
    ROOP(i,N)   cin >> x.at(i) >> y.at(i) >> z.at(i);
    
    vector<long> a1(N);
    ROOP(i,N)   a1.at(i) = x.at(i) + y.at(i) + z.at(i);
    sort(a1.begin(),a1.end());
    reverse(a1.begin(),a1.end());
    long A1 = 0;
    ROOP(i,M)   A1 += a1.at(i);
    
    vector<long> a2(N);
    ROOP(i,N)   a2.at(i) = x.at(i) + y.at(i) - z.at(i);
    sort(a2.begin(),a2.end());
    reverse(a2.begin(),a2.end());
    long A2 = 0;
    ROOP(i,M)   A2 += a2.at(i);

    vector<long> a3(N);
    ROOP(i,N)   a3.at(i) = x.at(i) - y.at(i) + z.at(i);
    sort(a3.begin(),a3.end());
    reverse(a3.begin(),a3.end());
    long A3 = 0;
    ROOP(i,M)   A3 += a3.at(i);

    vector<long> a4(N);
    ROOP(i,N)   a4.at(i) = x.at(i) - y.at(i) - z.at(i);
    sort(a4.begin(),a4.end());
    reverse(a4.begin(),a4.end());
    long A4 = 0;
    ROOP(i,M)   A4 += a4.at(i);

    vector<long> a5(N);
    ROOP(i,N)   a5.at(i) = - x.at(i) + y.at(i) + z.at(i);
    sort(a5.begin(),a5.end());
    reverse(a5.begin(),a5.end());
    long A5 = 0;
    ROOP(i,M)   A5 += a5.at(i);

    vector<long> a6(N);
    ROOP(i,N)   a6.at(i) = - x.at(i) + y.at(i) - z.at(i);
    sort(a6.begin(),a6.end());
    reverse(a6.begin(),a6.end());
    long A6 = 0;
    ROOP(i,M)   A6 += a6.at(i);

    vector<long> a7(N);
    ROOP(i,N)   a7.at(i) = - x.at(i) - y.at(i) + z.at(i);
    sort(a7.begin(),a7.end());
    reverse(a7.begin(),a7.end());
    long A7 = 0;
    ROOP(i,M)   A7 += a7.at(i);

    vector<long> a8(N);
    ROOP(i,N)   a8.at(i) = - x.at(i) - y.at(i) - z.at(i);
    sort(a8.begin(),a8.end());
    reverse(a8.begin(),a8.end());
    long A8 = 0;
    ROOP(i,M)   A8 += a8.at(i);

    long max;
    
    max = A1;
    if(max < A2)    max = A2;
    if(max < A3)    max = A3;
    if(max < A4)    max = A4;
    if(max < A5)    max = A5;
    if(max < A6)    max = A6;
    if(max < A7)    max = A7;
    if(max < A8)    max = A8;

    cout << max << endl;
    
}


Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
    int n,h[21],i,j,k,m=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&h[i]);
    for(i=0;i<n;i++){
        k=0;
        for(j=0;j<i;j++){
            if(h[i]>=h[j])
                k++;
        }
        if(k==i)
            m++;
    }
    printf("%d\n",m);
    return 0;
}

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

#define inf 0x3f3f3f3f
#define INF 1000111000111000111LL
#define mod 1000000007
#define endl '\n'
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(cc) (cc).begin(),(cc).end()
using pii = pair<int, int> ;
using vi = vector<int> ;
using vb = vector<bool> ;
using vvi = vector<vector<int>> ;
using vlli = vector<long long int> ;
using vpii = vector<pair<int, int>> ;

int main()
  {
    ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
    int n ;
    char c ;
    string s="" ;
    cin>> c ;
    s+=c ;
    cin>> c ;
    s+=c ;
    cin>> c ;
    s+=c ;
    n=stoi(s) ;
    if(n%4==0) cout<< "YES" ;
    else cout<< "NO" ;
  }


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

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;}}
void YesNo(int a) {if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(int a) {if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
void AorB(int a,string b,string c) {if(a){cout<<b<<endl;}else{cout<<c<<endl;}}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

const Vi dx = {0,1,0,-1};
const Vi dy = {1,0,-1,0};

signed main(){start();
    int h,w,black=0,ans=-1;
    cin>>h>>w;
    Vs s(h);
    REP(i,0,h){
        cin>>s[i];
        REP(j,0,w) if(s[i][j]=='#') black++;
    }
    
    VVi used(h,Vi(w,0));
    queue<Tiii> q;

    q.push(mt(0,0,0));
    while(!q.empty()){
        int nowx,nowy,dnow;
        tie(nowy,nowx,dnow)=q.front();
        q.pop();
        if(used[nowy][nowx]) continue;
        if(nowx==w-1 && nowy==h-1) {ans=dnow;break;}
        used[nowy][nowx]=1;
        REP(d,0,dx.size()){
            int newx=nowx+dx[d],newy=nowy+dy[d];
            if(0<=newx && newx<w && 0<=newy && newy<h){
                if(s[newy][newx]=='.') q.push(mt(newy,newx,dnow+1));
            }
        }
    }
    if(ans==-1) cout<<ans<<endl;
    else cout<<h*w-black-ans-1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define ALL(v) v.begin(),v.end()
typedef long long ll;

double getDistance(int x, int y, int x2, int y2) {
    double distance = sqrt((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y));

    return (double) distance;
}

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  rep(i,n){
    cin >> x.at(i) >> y.at(i);
  }
  double sum;
  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      sum+=getDistance(x.at(i),y.at(i),x.at(j),y.at(j));
    }
  }
  cout << fixed << setprecision(10) << sum/n << endl;
  
}



Measured memory_bytes: 764
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
int calm(string s){
        stack<int>num;
    int res = 0;
    rep(i,s.size()){
        char c = s[i];
        if(c == '*'){
            int t = (s[++i]-'0') * num.top();
            num.pop();
            num.push(t);
        } else if(c == '+'){
        } else num.push(c-'0');
    }
    while(not num.empty()){res += num.top(); num.pop();}
    return res;
}
int call(string s){
    int res = 0;
    rep(i,s.size()){
        char c  = s[i];
    if('0' <= c and c <= '9')res += c -'0';
    else if(c == '*'){
        res *= (s[++i] - '0');
    } else
        res += (s[++i] - '0');
    }
    return res;
}
#define int ll
signed main(){
    string s; cin >> s;
    int val; cin >> val;
    int m = calm(s);
    int l = call(s);
    if(m == l and l == val) cout << "U" << endl;
    else if(val == m) cout << "M" << endl;
    else if(val == l)cout << "L" << endl;
    else cout << "I" << endl;
}






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

using namespace std;

int calc(vector<int> color) {
  int check = 0;
  while (!color.empty()) {
    //cout << "[0] = " << color[0] << endl;                                                                                                                                                                                                                    
    vector<int>::iterator p = find(color.begin(), color.end(), color[0] + 1);
    vector<int>::iterator q = find(color.begin(), color.end(), color[0] + 2);
    if (p != color.end() && q != color.end()) {
      //cout << "p = " << *p << endl;                                                                                                                                                                                                                          
      //cout << "q = " << *q << endl;                                                                                                                                                                                                                          
      check++;
      color.erase(q);
      color.erase(p);
      color.erase(color.begin());
    } else if (color[0] == color[1] && color[0] == color[2]) {
      //cout << "[1] = " << color[1] << endl;                                                                                                                                                                                                                  
      //cout << "[2] = " << color[2] << endl;                                                                                                                                                                                                                  
      check++;
      color.erase(color.begin());
      color.erase(color.begin());
      color.erase(color.begin());
    } else {
      break;
    }
  }
  return check;
}
int main(int argc, char *argv[]) {
  int n, num[9];
  vector<int> red, green, blue;

  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 9; j++) {
      cin >> num[j];
    }

    red.clear(), green.clear(), blue.clear();
    for (int j = 0; j < 9; j++) {
      char c;
      cin >> c;
      if (c == 'R') {
        red.push_back(num[j]);
      } else if (c == 'G') {
        green.push_back(num[j]);
      } else {
        blue.push_back(num[j]);
      }
    }

    if (red.size() % 3 != 0 || green.size() % 3 != 0 /*|| blue.size() % 3 != 0*/) {
      cout << 0 << endl;
      continue;
    }
    sort(red.begin(), red.end());
    sort(green.begin(), green.end());
    sort(blue.begin(), blue.end());
    int check = calc(red) + calc(green) + calc(blue);
    if (check == 3) {
      cout << 1 << endl;
    } else {
      cout << 0 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define MOD 10000007
 
int main()
{
     ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
     string a,b;
     cin >> a >> b;
     vector<vector<ll>> y(26);
     for(ll i=0;i<a.size();i++)
     {
          y[a[i]-'a'].pb(i+1);
     }
     ll ans = 0;
     ll index = 0;
     for(ll i=0;i<b.size();i++)
     {
          if(y[b[i]-'a'].size()==0)     return cout<<"-1",0;
          ll temp = upper_bound(y[b[i]-'a'].begin(),y[b[i]-'a'].end(),index) - y[b[i]-'a'].begin();
          if(temp==y[b[i]-'a'].size())   temp = 0;
          ll gett = y[b[i]-'a'][temp];
          if(index<gett)  ans += (gett-index);
          else
          {
               ans += gett;
               ans += (a.size()-index);
          }
          index = gett;
     }
     cout<<ans;
}
 

Measured memory_bytes: 1736
#include <iostream>
#include <numeric>
#include <vector>
#include <algorithm>
#include <map>
#include<queue>
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}
using namespace std;
int main(){
    string S;
    cin >> S;
    int size = S.size(),ans = 0;

    char x = S[0];
    
    if(x == '0'){
        for(int i=1;i<size;i++){
            if(i%2!=0 && S[i]=='0') ans++;
            else if(i%2==0 && S[i] == '1') ans++;
        }
    }else{
        for(int i=1;i<size;i++){
            if(i%2!=0 && S[i]=='1') ans++;
            else if(i%2==0 && S[i] == '0') ans++;
        }
    }

    cout << ans <<endl;
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;
import java.text.*;

public class Main {
	public static void main(String[] args) {
		simArrays();
	}
	
	public static void sieve(int max) {		
		boolean[] isComposite = new boolean[max+1];
		for(int i=2; i<=max; i++) 
			if(!isComposite[i])
				for(int j=i*i; j<=max; j+=i)
					isComposite[j]=true;
					
		for(int i=2; i<=max; i++) if(!isComposite[i]) System.out.println(i + " ");
	}
	
	public static void simArrays() {
		Reader reader = new Reader();
		
		int n = reader.nextInt();
		int res = 1;
		res = exponential(3, n);
		
		int[] arr = new int[n];
		for(int j = 0; j < n; j++) arr[j] = reader.nextInt();
		
		int oddWays = 1;
		for(int j = 0; j < n; j++) if(arr[j] % 2 == 0) oddWays *= 2;
		
		System.out.println(res - oddWays);
	}
	
	public static int exponential(int base, int exp) {
		if(exp == 0) return 1;
		else if(exp % 2 == 0) return exponential((base*base), exp/2);
		return base*exponential((base*base), exp/2); //integer cutoff means (exp - 1)/2 unnecessary
	}
}

class Reader {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st;
    String next() {
        while(st==null||!st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch(Exception e) {}
        }
        return st.nextToken();
    }
	
    int nextInt() {
        return Integer.parseInt(next());
    }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define all(_v) _v.begin(), _v.end()
#define ll long long

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	ll sum = 0;
	for(int i = 1; i <= n; ++i) {
        if(i % 3 == 0 || i % 5 == 0) continue;
        sum += i;
	}
	cout << sum;
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<int, int>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int card[3][3] = {{0}};
    REP(i, 0, 3) {
        REP(j, 0, 3) {
            cin, card[i][j];
        }
    }
    int n;
    cin, n;
    REP(i, 0, n) {
        int t;
        cin, t;
        REP(a, 0, 3) {
            REP(b, 0, 3) {
                if (card[a][b] == t) {
                    card[a][b] = -1;
                }
            }
        }
    }
    REP(i, 0, 3) {
        bool ok = true;
        REP(j, 0, 3) {
            ok &= (card[i][j] == -1);
        }
        if (ok) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    REP(i, 0, 3) {
        bool ok = true;
        REP(j, 0, 3) {
            ok &= (card[j][i] == -1);
        }
        if (ok) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    {
        bool ok = true;
        REP(i, 0, 3) {
            ok &= (card[i][i] == -1);
        }
        if (ok) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    {
        bool ok = true;
        REP(i, 0, 3) {
            ok &= (card[i][2 - i] == -1);
        }
        if (ok) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
from fractions  import gcd
a, b = map(int,input().split())
g = gcd(a,b)
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(n**0.5) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i,cnt])
    # 上のループを通した後にtempが1じゃなかったら、だけど、nが素数以外にそんなケースある？
    if temp!=1:
        arr.append([temp, 1])
    
    # 素数だったときの処理
    if arr == []:
        arr.append([n,1])

    return arr
factors = factorization(g)
common_divide = [1] + [factor[0] for factor in factors]
total = len(common_divide)
if common_divide == [1,1]:
    total = 1
print(total)


Measured memory_bytes: 5076
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>

#define ll long long int

using namespace std;

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

bool formula(string &str, int &vals, int b, int e){
    char c = str[b];
    
    if(c == 'T')
        return true;
    else if(c == 'F')
        return false;
    
    if('a'<=c && c<='k')
        return vals>>(c-'a')&1;
    
    if(c == '-')
        return !formula(str, vals, b+1, e);

    //c == '('
    int count = 0;
    for(int i=b+1; i<e; i++){
        char c = str[i];
        
        if(c == '(')
            count++;
        if(c == ')')
            count--;
        if(count == 0){
            if(c == '*')
                return formula(str, vals, b+1, i) & formula(str, vals, i+1, e-1);
            if(c == '+')
                return formula(str, vals, b+1, i) | formula(str, vals, i+1, e-1);
            if(str[i] == '-' && str[i+1] == '>')
                return !formula(str, vals, b+1, i) | formula(str, vals, i+2, e-1);
        }
    }
    //No Implement
    return true;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string equation;
    while(cin>>equation, equation!="#"){
        int s = equation.find("=");
        
        bool is_identity = true;
        for(int i=0; i<1<<11; i++)
            is_identity &= formula(equation, i, 0, s)==formula(equation, i, s+1, equation.size());
        
        cout << (is_identity ? "YES" : "NO") << endl;
    }
    return 0;
}

Measured memory_bytes: 1268
#include<iostream>
using namespace std;
int main()
{
    long t,x,y,n;
    bool flag=true;
    cin>>n;
    for(long i=1;i<=n;i++)
    {
        cin>>t>>x>>y;
        if((x+y)%2!=t%2||x+y>t) flag=false;
    }
    if(flag) cout<<"Yes"<<endl; else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }


ll bs(ll left, ll right, int A, int B, vector<ll>& points)
{
    while (left < right)
    {
        ll mid = (left + right) / 2;
        ll ans = 0;

        for (int i = 0; i < points.size(); ++i)
        {
            double tmp = points[i] - mid * B;
            if (tmp <= 0.0) continue;

            ans += ceil(tmp / (A - B));
        }

        if (ans <= mid)
            right = mid;
        else
            left = mid + 1;
    }

    return right;
}

ll solve()
{
    int N, A, B;

    cin >> N >> A >> B;

    vector<ll> points(N);
    ll tmp;
    ll minValue = std::numeric_limits<int>::max();
    ll maxValue = std::numeric_limits<int>::min();

    for (int i = 0; i < N; ++i)
    {
        cin >> tmp;
        points[i] = tmp;
        minValue = std::min(minValue, tmp);
        maxValue = std::max(maxValue, tmp);
    }

    int minAttacks = minValue / A + 1;
    int maxAttacks = maxValue / B + 1;

    return bs(minAttacks, maxAttacks, A, B, points);
}

int main()
{
    cout << solve() << endl;

    return 0;
}

Measured memory_bytes: 1024
//#include <bits/stdc++.h>
 
#include <iostream>
#include <algorithm>
 
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <cstring>
#include <string>
#include <utility>
#include <array>
#include <complex>
#include <valarray>
 
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>
 
 
using namespace std;
#define int long long
 
typedef long long ll;
typedef unsigned long long ull;
//typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;
 
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
 
const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll INFLL = 1LL<<62;
const double EPS = 1e-12;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;
 
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod
#define inside(y, x, h, w) (0 <= (y) && (y) < (h) && 0 <= (x) && (x) < (w)) ? true : false

int l;
string s, t;

signed main() {	
    cin.tie(0);
    ios::sync_with_stdio(false);
	cin >> l;
	cin >> s;
	cin >> t;
	if (s > t) swap(s, t);
	int n = s.size();
	int m = t.size();
	bool ok = true;
	if (n < m) {
		string ss;
		while (ss.size() < 2 * m) ss += s;
		string tt = t + t;
		rep(i, 2 * m) {
			if (ss[i] == tt[i]) continue;
			if (ss[i] > tt[i]) {
				ok = false;
				break;
			}
			if (ss[i] < tt[i]) {
				ok = true;
				break;
			} 
		}
	}
	if (!ok) {
		swap(s, t);
		n = s.size();
		m = t.size();
	}
	int mx = 0;
	rep2(i, 1, l + 1) {
		if (n * i <= l) {
			if ((l - n * i) % m == 0) {
				mx = max(mx, i);
			}
		}
	}
	string ans = "";
	rep(i, mx) ans += s;
	while (ans.size() < l) ans += t;
	cout << ans << endl;
}


Measured memory_bytes: 1556