akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int MAXN=200005;
vector<int> e[MAXN],col[2];
int dep[MAXN],usd[MAXN],res[MAXN];
void dfs(int u,int fa)
{
    dep[u]=dep[fa]+1;
    col[dep[u]&1].push_back(u);
    for(auto &v:e[u])
        if(v!=fa)dfs(v,u);
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<n;i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        e[a].push_back(b);
        e[b].push_back(a);
    }
    dfs(1,0);
    if(col[0].size()>col[1].size())
        swap(col[0],col[1]);
    if(col[0].size()<=n/3)
    {
        for(size_t i=0;i<col[0].size();i++)
            usd[res[col[0][i]]=3*i+3]=1;
        for(int i=1,j=0;i<=n;i++)
            if(!usd[i])res[col[1][j++]]=i;
    }
    else
    {
        int k=0;
        for(size_t i=0;i<(n+2)/3;i++)
            res[col[0][i]]=3*i+1;
        for(size_t i=(n+2)/3;i<col[0].size();i++)
            res[col[0][i]]=3*(++k);
        for(size_t i=0;i<(n+1)/3;i++)
            res[col[1][i]]=3*i+2;
        for(size_t i=(n+1)/3;i<col[1].size();i++)
            res[col[1][i]]=3*(++k);
    }
    for(int i=1;i<=n;i++)
        printf("%d%c",res[i]," \n"[i==n]);
    return 0;
}

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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

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

    string s; cin >> s;
    cout << s.substr(0,4) << ' ' << s.substr(4) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
const int INF = 1001001001;

int main(void){
    int n;
    cin >> n;
    int minp=INF,ans=0;
    REP(i,n){
        int p;
        cin >> p;
        chmin(minp,p);
        if(minp>=p) ans++;
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 3536
#include <stdio.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int partition(int *a, int lo, int hi)
{
	int i, j, x, t;

	x = a[hi], i = lo-1;
	for (j = lo; j < hi; j++) {
		if (a[j] <= x) i++, t = a[i], a[i] = a[j], a[j] = t;
	}
	t = a[++i], a[i] = a[hi], a[hi] = t;
	return i;
}

int a[100002];

int main()
{
	int n, i, k;
	
	n = in(); for (i = 0; i < n; i++) a[i] = in();
	k = partition(a, 0, n-1);
	printf((!k? "[%d]": "%d"), a[0]);
	for (i = 1; i < n; i++) {
		putchar(' ');
		printf((k==i? "[%d]": "%d"), a[i]);
	}
	putchar('\n');
	return 0;
}



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

using namespace std;

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

  int n, p = 0;
  cin >> n;
  vector<int> A(n);
  int sum = 0;
  for (auto &a : A) {
    cin >> a;
    sum += abs(a-p);
    p = a;
  }
  sum += abs(A[n-1]);

  int res = 0;
  for (int i = 0; i < n; ++i) {
    res = 0;
    if (i > 0 && i < n-1) {
      res = sum - abs(A[i]-A[i-1]) - abs(A[i+1]-A[i]) + abs(A[i-1]-A[i+1]);
    } else if (i == 0) {
      res = sum - abs(A[0]) - abs(A[1]-A[0]) + abs(A[1]);
    } else if (i == n-1) {
      res = sum - abs(A[i]-A[i-1]) - abs(A[n-1]) + abs(A[n-2]);
    }
    cout << res << endl;
  }

  return 0;
}



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


int main(){
    long long judge = 0;
    string c;

    std::cin >> c;
    for(int i = 0; i < c.size(); i++){
  //      std::cout << c[i];
        judge = judge + (int)(c[i] -'0');
    }

//    std::cout << judge;

    if(judge%9 == 0){
        std::cout << "Yes";
    }else{
        std::cout << "No";
    }

    
}

Measured memory_bytes: 3764
<?php
$n = intval(fgets(STDIN));
$a = explode(" ", trim(fgets(STDIN)));
$b = explode(" ", trim(fgets(STDIN)));
$d = array_sum($b) - array_sum($a);
$c = 0;
for($i = 0; $i < $n; $i++){
    if($a[$i]<$b[$i]){
        $c+=ceil(($b[$i] - $a[$i]) / 2);
    }
}
if($c <= $d){
    echo "Yes\n";
}else{
    echo "No\n";
}

Measured memory_bytes: 6648
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll 
int32_t main()
{
	
	#ifndef ONLINE_JUDGE
	freopen("in","r",stdin);
	freopen("out","w",stdout);
	#endif

	int n,z,w;
	cin>>n>>z>>w;
	vector<int> a(n);for(auto &i:a)cin>>i;

	if(n==1){cout<<abs(w-a[0]);return 0;}
	cout<<max(abs(a[n-1]-a[n-2]),abs(a[n-1]-w));

	

}

Measured memory_bytes: 3636
#include<stdio.h>
int main(void){
  int a, b, t;
  int i, j;
  int sum;
  
  scanf("%d %d %d", &a, &b, &t);
  
  i = t / a;
  sum = i * b;
  i++;
  
  j = i * a;
  if(j - t <= 0.5){
    sum++;
  }
  printf("%d\n", sum);
}
  

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <fstream>
#include <climits>
#include <cstdio>
#include <vector>
#include <string>
#include <memory>
#include <queue>
#include <cmath>
#include <list>
#include <set>
#include <map>


using namespace std;

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

int main()
{
    int n;
    scanf("%d",&n);
    char s[128];
    scanf("%s",s);
    vector<char> v;
    v.push_back(s[0]);
    for(int i=1;i<strlen(s);i++)
    {
        if(!v.empty()&&v.back()=='('&&s[i]==')')
            v.pop_back();
        else
            v.push_back(s[i]);
    }
    int cl=0,cr=0;
    for(int i=0;i<v.size();i++)
        if(v[i]=='(') cl++;
        else cr++;
    string res=string(cr,'(')+s+string(cl,')');
    
    cout<<res<<endl;
    return 0;
}


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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define fi first
#define se second
#define mp make_pair
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }

using ll = long long; using vll = vector<ll>; using vvll = vector<vll>;
static const long long INF = 1e18;

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll n; 
    while (cin >> n && n) {
        string d(n, ' ');
        vector<char> x(n); rep(i, n) cin >> x[i];
        vector<char> y(n); rep(i, n) cin >> y[i];
        rep(i, n) 
            d[i] = (x[i] - y[i] + 10) % 10 + '0';

        static stack<pair<string, ll>> q;
        stack<pair<string, ll>>().swap(q);

        q.push(mp(d, 0));
        ll ret = INF;
        while (!q.empty()) {
            auto tmp = q.top().fi; auto d = q.top().se; q.pop();

            if (tmp == string(n, '0')) {
                chmin(ret, d);
                continue;
            }

            ll i = 0;
            while (tmp[i] == '0') i++;
            ll number = tmp[i] - '0';
            repi(j, i, n) {
                tmp[j] = '0' + ((tmp[j] - '0' - number) + 10) % 10;
                q.push(mp(tmp, d+1));
            }
        }
        cout << ret << endl;
    }
    return 0;
}

Measured memory_bytes: 2952
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int N = 1<<21;
#define fr(i,a,b) for(int i = a;i <= b; ++i)
#define nfr(i,a,b) for(int i = a;i >= b; --i)

int f[N][22];

int ans;
string str[21];
int n,m;
int main(){
   ans = 0;
   scanf("%d%d",&n,&m);
   memset(f,0,sizeof f);
   int cnt = 0;
   fr(i,0,n){
      cin >> str[i];
      fr(j,0,(1<<i)-1)if(str[i][j] == '1'){
         f[j+(1<<i)][i] = 1;
      }
   }

   nfr(msk,(1<<(n+1))-1,1){
      int leng = (int)log2(msk)-1;
      nfr(z,leng+1,1){
         int w = msk >> z;
         int w2 = msk % (1<<z);
         int curp = w2/(1<<(z-1));
         f[msk][z-1] += f[msk][z];
         int cz = z;
         while(cz > 0 && w2/(1<<(cz-1)) == curp){
            w2 %= (1<<(cz-1)); --cz;
         }
         if(cz){
            f[(w<<(cz))|((curp^1)<<(cz-1))|(w2%(1<<(cz-1)))][cz-1] += f[msk][z];
         }
         f[w][0] += f[msk][z];
      }
   }

   nfr(msk,(1<<(n+1))-1,1){
      if(f[msk][0] >= m){
         if((int)log2(msk) > (int)log2(ans))ans = msk;
         else if((int)log2(msk) == (int)log2(ans) && msk < ans)ans = msk;
      }
   }
   int w = (int)log2(ans);
   if(ans == 0)w = -1;
   nfr(i,w-1,0)printf("%c",(ans & (1<<i)) ? '1' : '0');
   puts(""); return 0;
}


Measured memory_bytes: 183936
#include <stdio.h>
#include <iostream>
#include <climits>
#include <map>
#include <cmath>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <vector>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <utility>
#include <queue>

using namespace std;

#define ll long long
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pii pair <int, int>
#define pll pair <int, int>
#define plp pair <int, pll >
#define pb push_back

ll a[100010];

int main ()
{
  //  freopen("in.txt", "r", stdin);
   // freopen("out.txt", "w", stdout);
  //  ios_base::sync_with_stdio(0); // no printf/scanf must be present
    ll cs, t, i, j, k, x, y, z, ans, q, m, n;

    sl(n);

    for (i = 1; i <= n; i++)
    {
        sl(a[i]);
    }

    x = 0;
    z = 0;

    for (i = 1; i <= n; i++)
    {
        if (!(i%2))
        {
            if ( (a[i] + x) <= 0 )
            {
                z += 1 - (a[i] + x);
                x += a[i] + 1 - (a[i] + x);
            }
            else
            {
                x += a[i];
            }
        }
        else
        {
            if ( (a[i] + x) >= 0 )
            {
                z += (a[i] + x) + 1;
                x += a[i] - ((a[i] + x) + 1);
            }
            else
            {
                x += a[i];
            }
        }
    }

    y = z;

    z = x = 0;

    for (i = 1; i <= n; i++)
    {
        if ((i%2))
        {
            if ( (a[i] + x) <= 0 )
            {
                z += 1 - (a[i] + x);
                x += a[i] + (1 - (a[i] + x));
            }
            else
            {
                x += a[i];
            }
        }
        else
        {
            if ( (a[i] + x) >= 0 )
            {
                z += (a[i] + x) + 1;
                x += a[i] - (a[i] + x + 1);
            }
            else
            {
                x += a[i];
            }
        }
    }

    cout << min(y, z) << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define dd(x) cout << #x << "=" << x << ","
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=(b-1);i>=a;--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl "\n"
#define lowbit(x) x&(-x)
const int N = 20000;
const int M = 1e9+7;

int f[50][50];
int v[50][50];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k,a,b;
	cin>>k>>a>>b;
	for (int i=a; i<=b; i++){
		if (i%k==0){
			cout<<"OK";
			return 0;
		}
	}
	cout<<"NG";
    return 0;
}


Measured memory_bytes: 3640
/******************************************
* NICK : nikhilsinghh59 *
******************************************/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"

#define PB push_back
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
const int M = 1e9+7;

int main()
{   
    

    ll n;
    cin >> n;

    ll ar[n+1];
    for(ll i=1;i<=n;i++){
        cin >> ar[i];
    }

    ll ans=0;
    map<ll , ll>mp;

    for(ll i=1;i<=n;i++){
        ll ask = i - ar[i];
        ans+=mp[ask];
        mp[i + ar[i]]++;
    }

    cout << ans;
    
    return 0;
}

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

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int,int> pii;
using namespace std;
using ll = long long;


int main(){
    int n;
    cin >> n;
    
    int abc[3][n];
    rep(i,n) cin >> abc[0][i] >> abc[1][i] >> abc[2][i];
    
    int dp[3][n+1];
    memset(dp,0,sizeof dp);
    
    for(int i = 1; i <n+1; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 1; k < 3; k++){
                int newj=(j+k)%3;   
                dp[newj][i] = max(dp[newj][i],dp[j][i-1] + abc[newj][i-1]);
            }
        }
    }
    cout << max(dp[0][n],max(dp[1][n],dp[2][n]));
    
}









Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;
using MIte = multimap<long, long, greater<long> >::iterator;

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

	//
	string S;
	cin >> S;

	if (S[0] != 'A') {
		cout << "WA" << endl;
		return 0;
	}

	int cnt1 = 0;
	int pivo1 = -1;
	for (int i = 2; i != S.length() - 1; ++i) {
		if (S[i] == 'C') {
			cnt1++;
			pivo1 = i;
		}
	}

	if (cnt1 != 1) {
		cout << "WA" << endl;
		return 0;
	}

	for (int i = 1; i != S.length(); ++i) {
		if (i == pivo1) continue;

		if (!(S[i] >= 'a' && S[i] <= 'z')) {
			cout << "WA" << endl;
			return 0;
		}
	}

	cout << "AC" << endl;

	return 0;
}

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

const int N = 1e4 + 5;
const int CH = 1e3;

string l, t;
int l_len, t_len;
int idxs[N][CH];
int dp[N][N];
int solve(int idx1, int idx2) {
	if (idx1 >= l_len || idx2 >= t_len)
		return 0;
	int &ret = dp[idx1][idx2];
	if (~ret)
		return ret;
	ret = max(solve(idx1 + 1, idx2), solve(idx1, idx2 + 1));
	if (l[idx1] == t[idx2])
		ret = max(ret, 1 + solve(idx1 + 1, idx2 + 1));
	return ret;
}

void build(int idx1, int idx2) {
	if (idx1 >= l_len || idx2 >= t_len)
		return;
	int &ret = dp[idx1][idx2];
	if (ret == solve(idx1 + 1, idx2)){
		build(idx1+1, idx2);
		return;
	}
	if (ret == solve(idx1, idx2 + 1)){
		build(idx1, idx2+1);
		return;
	}
	else{
		cout << l[idx1];
		build(idx1+1, idx2+1);
		return;
	}
}

int main() {
	memset(dp, -1, sizeof(dp));
	cin >> l;
	cin >> t;
	l_len = l.length();
	t_len = t.length();
	solve(0, 0);
	build(0, 0);
	return 0;
}


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

#define F first 
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int n;
int h[N], e[N], ne[N], idx;
int match[N];
bool st[N];
PII p[N];

void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx ++ ;
}

bool find(int u)
{
	for (int i = h[u]; ~i; i = ne[i])
	{
		int j = e[i];
		if (!st[j])
		{
			st[j] = true;
			if (match[j] == 0 || find(match[j]))
			{
				match[j] = u;
				return true;
			}
		}
	}
	return false;
}

int main()
{
	memset(h, -1, sizeof h);
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++ ) scanf("%d%d", &p[i].F, &p[i].S);
	for (int i = n + 1; i <= 2 * n; i ++ ) scanf("%d%d", &p[i].F, &p[i].S);
	
	for (int i = 1; i <= n; i ++ )
		for (int j = n + 1; j <= 2 * n; j ++ )
			if (p[i].F < p[j].F && p[i].S < p[j].S)
				add(i, j);
				
	int res = 0;
	for (int i = 1; i <= n; i ++ )
	{
		memset(st, 0, sizeof st);
		if (find(i)) res ++ ;
	}
	printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  int flag = 0;
  cin >> a >> b >> c;
  vector<int> vec(b);
  for (int i = 0; i < b; i++) {
    vec.at(i) = (a * (i + 1)) % b;
  }
  for (int i = 0; i < b; i++) {
    if (vec.at(i) == c) flag++; 
  }
  if (flag != 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int A, B, K, ansA, ansB, check, i;
    cin >> A >> B >> K;
        
        for(i=100;i>1;i--)
        {
            ansA = A%i;
            ansB = B%i;
            
            if(ansA == 0 && ansB == 0)
            {
                check++;
                
                if(check == K)
                {
                    break;
                }
            }
            
            ansA=0;
            ansB=0;
        }
    cout << i << endl;
}



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

int main() {
    int n; cin >> n;
    map<int, int> mp;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        mp[a[i]]++;
    }
    sort(a.begin(), a.end());
    if (a[a.size() - 1] != a[a.size() - 2]) {
        puts("Impossible");
        return 0;
    }
    else if ((a[a.size() - 1] & 1) && !(a[0] == a[1] && a[0] == a[a.size() - 1] / 2 + 1 && mp[a[0]] == 2)) {
        puts("Impossible");
        return 0;
    }
    else if (!(a[a.size() - 1] & 1) && !(a[0] == a[a.size() - 1] / 2 && mp[a[0]] == 1)) {
        puts("Impossible");
        return 0;
    }
    if (n & 1) {
        for (int i = a[a.size() - 1] / 2 + 2; i < a[a.size() - 1]; i++) {
            if (mp.find(i) == mp.end() || mp[i] < 2) {
                puts("Impossible");
                return 0;
            }
        }
    }
    else {
        for (int i = a[a.size() - 1] / 2 + 1; i < a[a.size() - 1]; i++) {
            if (mp.find(i) == mp.end() || mp[i] < 2) {
                puts("Impossible");
                return 0;
            }
        }
    }
    puts("Possible");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  int big = 0, count = 0, a;
  for(int i = 0; i < N; i++){
    cin >> a;
    if(a >= big){
      count++;
      big = a;
    }
  }
  cout << count << endl;
  return 0;
}

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

int main() {
	
	unsigned long long power;
	int n;
	
	cin >> n;
	
	power = 1;
	
	for ( int i = 1; i <= n; i++ )
	{
		power *= i;
		
		power = power % (1000000007);
	}
	
	cout << power;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	string str;cin >> str;
	string tmp = "AKIHABARA";
	
	if(str.size() > tmp.size())
	{
		cout << "NO" << endl;
		return 0;
	}
	
	int cou = 0;
	for(int i = 0;i < str.size() ;i++)
	{
		if(str[i] == tmp[cou])
		{
			cou++;
		}
		else if(tmp[cou] == 'A')
		{
			cou++;
			i--;
		}
		else
		{
			cout << "NO" << endl;
			return 0;
		}
	}
	
	if(cou == tmp.size() - 1 || cou == tmp.size())
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
  cin>>a>>b;
  if(a==2 && b==1 || a==1&&b==2)
  {
    cout<<3<<endl;
  }
  else if(a==3&&b==1 || a==1&&b==3)
  {
	cout<<2<<endl;
  }
  else
  {
    cout<<1<<endl;
  }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int f(int x,int y){
    rep(i,y) x/=10;
    return x%10;
    
}
char g(int p){
    if(p==1) return '+';
    else if(p==0) return '-';
}
int main(){
    int a;
    cin>>a;
    for(int i=0; i<(1<<3);i++){
        bitset<3> s(i);
        int cal=f(a,3);
        for(int j=0;j<3;j++){
            if(s.test(j)) cal+=f(a,j);
            else cal-=f(a,j);
        }
        if(cal==7){
            cout<<f(a,3)<<g(s[2])<<f(a,2)<<g(s[1])<<f(a,1)<<g(s[0])<<f(a,0)<<"=7";
            break;
        }
    }
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <tr1/unordered_set>
using namespace std;
using namespace std::tr1;

int upb(int n)
{
  int ret=0;
  while(n>0) ret++, n/=2;
  return ret;
}

int main()
{
  for (int n; cin>>n, !(n==0); ){

    vector<vector<int> > pats(n*n+1);
    vector<vector<int> > tmp(n, vector<int>(n, 0));
    for (int i=0; i<n; i++){
      for (int j=0; j<n; j++){
	for (int k=i; k<n; k++){
	  for (int l=j; l<n; l++){
	    for (int a=i; a<=k; a++)
	      for (int b=j; b<=l; b++)
		tmp[a][b]=1;
	    int bd=0;
	    for (int a=0; a<n; a++){
	      for (int b=0; b<n; b++){
		bd=(bd<<1)|tmp[a][b];
	      }
	    }
	    pats[upb(bd)].push_back(bd);
	    for (int a=i; a<=k; a++)
	      for (int b=j; b<=l; b++)
		tmp[a][b]=0;
	  }
	}
      }
    }

    int bd=0;
    for (int i=0; i<n; i++){
      for (int j=0; j<n; j++){
	int t; cin>>t;
	bd=(bd<<1)|t;
      }
    }

    queue<pair<int, int> > mm;
    //vector<bool> close(1<<(n*n), false);
    unordered_set<int> close;
    mm.push(make_pair(0, bd));
    //close[bd]=true;
    close.insert(bd);
    while(!mm.empty()){
      int dep=mm.front().first;
      int cbd=mm.front().second;
      mm.pop();
      //cout<<cbd<<endl;
      int ub=upb(cbd);
      for (int i=0; i<pats[ub].size(); i++){
	int nbd=cbd^pats[ub][i];
	if (nbd==0){
	  for (int i=0; i<=dep; i++)
	    cout<<"myon";
	  cout<<endl;
	  goto _exit;
	}
	//cout<<"*** "<<nbd<<endl;
	//if (close[nbd]) continue;
	//close[nbd]=true;
	if (close.count(nbd)) continue;
	close.insert(nbd);
	mm.push(make_pair(dep+1, nbd));
      }
    }
  _exit:;
  }
  return 0;
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

void solve ( int test_case )
{
    string a , b ;
    cin >> a >> b ;

    cout << b << a ;
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
const long long MOD = 1000000007, INF = 1e18;
/*
#define endl '\n'
#define IOS()                     \
	ios_base::sync_with_stdio(0); \
	cin.tie(0)
*/
string get_str(string s)
{
	s += ',';
	string ret = "";
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == ',')
			ret += "=%ld, ";
		else
			ret += s[i];
	}
	return ret;
}
#define dump(...)                                       \
	printf(get_str(#__VA_ARGS__).c_str(), __VA_ARGS__); \
	cout << endl
//******************************************************************************

int N;
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
int gcd(int x, int y)
{
	if (x == 0)
		return y;
	return gcd(y % x, x);
}
int lcm(int x, int y)
{
	return (x * y / gcd(x, y));
}

int dp[200020][2];

signed main()
{
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++)
	{
		cin >> a[i];
	}
	int ma = 0;
	for (int i = 1; i * i <= a[0]; i++)
	{
		if (a[0] % i)
			continue;
		int now = i;
		int noww = a[0] / i;
		int cnt = 0, cntt = 0;
		for (int j = 1; j < N; j++)
		{
			if (now != gcd(now, a[j]))
				cnt++;
			if (noww != gcd(noww, a[j]))
				cntt++;
		}
		if (cnt <= 1)
			chmax(ma, now);
		if (cntt <= 1)
			chmax(ma, noww);
	}
	int now = a[1];
	for (int i = 1; i < N; i++)
	{
		now = gcd(now, a[i]);
	}
	cout << max(now, ma) << endl;
}

Measured memory_bytes: 1024
n=int(input())
a=list(map(int,input().split()))
num=[0 for i in range(10**5+1)]
sum=0
for i in range(n):
    num[a[i]]+=1
    sum+=a[i]
q=int(input())
for i in range(q):
    b,c=map(int,input().split())
    tmp=num[b]
    sum-=tmp*b
    sum+=c*tmp
    num[b]=0
    num[c]+=tmp
    print(sum)


Measured memory_bytes: 83176
from sys import stdin
import numpy as np

N = int(stdin.readline().rstrip())
H = [int(x) for x in stdin.readline().rstrip().split()]

def func(h_list, now_h):
  if len(h_list) == 0:
    return 0
  min_idx = [i for i, x in enumerate(h_list) if x == min(h_list)]
  min_h = h_list[min_idx[0]]
  ans = min_h - now_h
  l_idx = 0
  for i in min_idx:
    ans += func(h_list[l_idx:i],min_h)
    l_idx = i+1
  ans += func(h_list[l_idx:],min_h)
  return ans

print(func(H,0))
    

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

void recursive_comb(int *indexes, int s, int rest, function<void(int *)> f) {
  if (rest == 0) {
    f(indexes);
  } else {
    if (s < 0) return;
    recursive_comb(indexes, s - 1, rest, f);
    indexes[rest - 1] = s;
    recursive_comb(indexes, s - 1, rest - 1, f);
  }
}

void foreach_comb(int n, int k, function<void(int *)> f) {
  int indexes[k];
  recursive_comb(indexes, n - 1, k, f);
}

int calc(string c) {
  int ret = 0;
  char lastOp = '+';
  for (int i = 0; i < c.size(); i++) {
    if (c[i] == '+') {
      lastOp = '+';
    } else if (c[i] == '-') {
      lastOp = '-';
    } else {
      int num = atoi(c.substr(i, 1).c_str());
      if (lastOp == '+') {
        ret += num;
      } else {
        ret -= num;
      }
    }
  }
  return ret;
}

int main() {
  // 入力
  vector<char> S(4);
  for (int i = 0; i < (int)S.size(); i++)
    cin >> S.at(i);
  
  int n = S.size() - 1;
  for (int k = 0; k <= n; k++) {
    foreach_comb(n, k, [S, n, k](int *indexes) {
      vector<char> op(n);
      for (int i = 0; i < n; i++) {
        op.at(i) = '+';
      }
      for (int i = 0; i < k; i++) {
        op.at(indexes[i]) = '-';
      }
      // 一つの文字列に連結
      string c = "";
      for (int i = 0; i < S.size(); i++) {
        c += S.at(i);
        if (i < op.size()) {
          c += op.at(i);
        }
      }
      // その文字列を計算する
      int ret = calc(c);
      if (ret == 7) {
        cout << c << "=" << ret << endl;
        exit(0);
      }  
    });
  }
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define all(x) (x).begin(),(x).end()
int INF = 1000000000;

int main() {
  int A, B, C; cin >> A >> B >> C;
  bool flag = false;
  rep2(i, 1, 101) {
    if ((A * i) % B == C) {
      flag = true;
    }
  }
  if (flag) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<string> s(n);
	vector<int> t(n);
	for(int i=0;i<n;i++)
		cin >> s[i] >> t[i];
	string x;
	cin >> x;
	long long ans=0;
	bool flg=false;
	for(int i=0;i<n;i++)
	{
		if(flg)ans+=t[i];
		if(x==s[i])flg=true;
	}
	cout << ans << endl;






}


Measured memory_bytes: 256
a,b,c =raw_input().split()
a,b,c = map(int,(a,b,c))
ls = list((a,b,c))
ls.sort()
string_ans=''
for k in ls:
    string=''
    string = str(k)+" "
    string_ans = string_ans + string
print string_ans.strip()

Measured memory_bytes: 4208
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

int isPrime(LL p){
	if(p<=1) return 0;
	if(p==2 || p==3 || p==5 || p==7) return 1;
	if(p==4 || p==6 || p==8 || p==9) return 0;

	LL i;
	int ret = 1;
	for(i=2; i*i<=p; i++){
		if(p%i==0 && i!=p){
			ret = 0;
			break;
		}
	}
	return ret;
}

void factorize(long long N, map<long long, int> &mp){
	if(N == 1){
		return;
	}
	if(isPrime(N)){
		mp[N] += 1;
		return;
	}

	long long i = 2, n = N;
	for(i = 2; n != 1 && i < (N/2) + 1; i++){
		if((n % i)==0){
			if(isPrime(i)){
				int e = 0;
				long long u = n;
				while((u % i)==0){
					e++;
					u = u / i;
					n = u;
				}
				mp[i] = e;
				if(isPrime(n)){
					mp[n] = 1;
					break;
				}
			}
		}
	}
	return;
}

LL N;
vector<LL> P;
vector<int> E;
LL ans = 0;

void dfs(vector<int> &v){
	int l = v.size();
	if(l == E.size()){
		LL d = 1;
		for(int i=0; i<P.size(); i++){
			LL u = 1;
			for(int j=1; j<=v[i]; j++){
				u *= P[i];
			}
			d *= u;
		}
		LL m = (N/d) - 1;
		if(m > 0 && d < m){
			ans += m;
		}
		return;
	}

	int e = E[l];
	for(int i=0; i<=e; i++){
		v.push_back(i);
		dfs(v);
		v.pop_back();
	}
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N;
	if(N == 1 || N==2){
		printf("0\n");
		return 0;
	}

	map<LL, int> M;
	factorize(N, M);
	for(auto itr = M.begin(); itr != M.end(); itr++){
		LL p = itr->first;
		int e = itr->second;
		P.push_back(p);
		E.push_back(e);
	}
	vector<int> v;
	dfs(v);
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3676
import fractions
import itertools
from functools import reduce

n = int(input())
a = [int(x) for x in input().split()]

l = [0]*(n+1)
r = [0]*(n+1)

for i in range(n):
    l[i+1] = fractions.gcd(l[i], a[i])
    r[n-i-1]= fractions.gcd(r[n-i], a[n-i-1])

ans = 0
for i in range(n):
    ans = max(fractions.gcd(l[i], r[i+1]), ans)

print(ans)

Measured memory_bytes: 16080
import java.io.*;
import java.util.*;

class Main {
	static final String YES = "Yes";
	static final String NO = "No";

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		long N;
		N = sc.nextLong();
		long M;
		M = sc.nextLong();
		if (N <= M) System.out.println(YES);
		else System.out.println(NO);


	}
}


Measured memory_bytes: 21844
// <candy.cpp> - Sat Mar 25 16:58:17 2017
// This file is created by XuYike's black technology automatically.
// Copyright (C) 2015 ChangJun High School, Inc.
// I don't know what this program is.

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
typedef long long lol;
template<typename T>
inline void gg(T &res){
    res=0;T fh=1;char ch=getchar();
    while((ch>'9'||ch<'0')&&ch!='-')ch=getchar();
    if(ch=='-')fh=-1,ch=getchar();
    while(ch>='0'&&ch<='9')res=res*10+ch-'0',ch=getchar();
    res*=fh;
}
inline int gi(){int x;gg(x);return x;}
inline lol gl(){lol x;gg(x);return x;}
const int MAXN=100010;
const int INF=1e9;
int a[MAXN];
int main(){
    int n=gi();
    for(int i=1;i<=n;i++)a[i]=gi();
    sort(a+1,a+n+1);
    reverse(a+1,a+n+1);
    for(int i=1;i<=n;i++)
        if(i+1>a[i+1]){
            bool res=1;
            for(int j=i+1;a[j]==i;j++)res^=1;
            res&=(a[i]-i+1)&1;
            printf(res?"Second":"First");
            break;
        }
    return 0; 
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>

using ll = long long;

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

int main()
{
  ll H, N;
  std::cin >> H >> N;

  std::vector<ll> va(N, 0LL);
  for (ll i = 0; i < N; ++i) {
    std::cin >> va[i];
  }
  ll sum = std::accumulate(va.begin(), va.end(), 0LL);

  if (sum >= H) {
    print("Yes");
  } else {
    print("No");
  }
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define INF -2147483647
#define mod 1000000007
int main(){
  int a,b,d=0,q=1,w=1;
  int c[1000000]={};
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>b;
    c[b]++;
  }
  if(c[0]%2==1) c[0]++;
  for(int i=1;i<=a;i++){
    if(c[i]==2) d++;
    if(c[i]==1||c[i]>=3) q=0;
  }
  if(q==1){
    for(int j=0;j<d;j++){
      w=w*2%mod;
    }
    cout<<w%mod<<"\n";
  }
  else cout<<"0\n";
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,M;
    cin >>N>>M;
    vector<pair<long long,long long>> P(N);
    vector<pair<long long,long long>> P1(M);

    for(int i=0;i<N;i++){
        int a,b;
        cin >>a>>b;
        P.at(i)=make_pair(a,b);
    }
    for(int i=0;i<M;i++){
        int a,b;
        cin >>a>>b;
        P1.at(i)=make_pair(a,b);
    }
    for(int i=0;i<N;i++){
         long long maxx=99999999999;
        int memo=0;
        for(int j=0;j<M;j++){
 
        long long x=abs(P.at(i).first-P1.at(j).first)+abs(P.at(i).second-P1.at(j).second);
        if(maxx>x){
         memo=j+1;
            maxx=x;
         }
        }
        cout<<memo<<endl;
    }
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false) ; cin.tie(NULL) ; cout.tie(NULL);
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007


int32_t main(){
IOS;
int h,a;
cin>>h>>a;
cout<<ceil((float)h/a)<<endl;
     
return 0;
}


Measured memory_bytes: 256
def judge(As,K,C):
    count = 0
    for i in range(len(As)):
        if As[i]%C == 0:
            m = As[i]//C - 1
        else:
            m = As[i]//C
        count += m
    if count <= K:
        return True
    else:
        return False

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

l = 0
r = max(As)
while(r-l>1):
    mid = (l+r)//2
    if judge(As,K,mid):
        r = mid -1
    else:
        l = mid + 1
if judge(As,K,r):
    print(r)
else:
    print(r+1)

Measured memory_bytes: 103932
N, A, B = map(int,input().split())
li = []
ans = 0
for i in range(1,N+1,1):
    s = i % 10 
    t = i // 10 % 10 
    u = i // 100 % 10 
    v = i // 1000 % 10 
    w = i // 10000 % 10 
    x = i // 100000 % 10
    sum = (s+t+u+v+w+x)
    if sum >= A and sum <= B:
        li.append(i)
        
for j in range(int(len(li))):
  ans = ans + int(li[j])
  j += 1
  
print(ans)

Measured memory_bytes: 3416
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();

    String name = "";
    String alphabet = "";
    for(char c = 'a'; c <= 'z'; c++){
      alphabet = alphabet + c;
    }

    for(int i=0; i<100; i++){
      if(N <= 26){
        name = alphabet.charAt((int)(N + 25) % 26) + name;
        System.out.println(name);
        return;
      }else{
        int index = (int)((N + 25) % 26);
        name = alphabet.charAt(index) + name;
        N = N - index;
        N = N / 26;
      }
    }
    return;
  }
}

Measured memory_bytes: 39760
MOD = 10**9+7
N,M = map(int,input().split())
a = [int(input()) for _ in range(M)]
dp = [0 for i in range(N+1)]
b = [0 for i in range(N+1)]
dp[0] = 1
for i in range(M):
    b[a[i]] += 1
for i in range(1,N+1):
    if b[i] == 1:
        dp[i] = 0
        continue
    elif i == 1:
        dp[i] = 1
        continue
    dp[i] = (dp[i-1] + dp[i-2]) % MOD
print(dp[N])

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

typedef long long ll;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

ll mod=1e9+7;

using namespace std;


ll inputValue(){
	ll a;
	cin >> a;
	return a;
};

void inputArray(int * p, ll a){
	rep(i, a){
		cin >> p[i];
	}
};

template<typename T>
void inputVector(vector<T>& p, ll a){
	rep(i, a){
		T input;
		cin >> input;
		p.emplace_back(input);
	}
}


template <typename T>
void output(T a) {
    cout << a << "\n";
}

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	// source code
    ll n;
    auto h= vector<ll>();
    cin >> n;
    inputVector(h,n);
    bool yes=true;
    ll con_max=0;

    repd(i,1,n){
        con_max=max(h[i],con_max);
        if( con_max-h[i]>=2){
            yes=false;
            break;
        }
    }

    if(yes)
    { 
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

	return 0;
}


Measured memory_bytes: 1400
s = input()
ans = ""
while len(s) > 1:
    t = s[0]
    s = s[1:]
    if t == "B":
        ans = ans[:-1]
    else:
        ans += t
t = s[0]
if t == "B":
    ans = ans[:-1]
else:
    ans += t
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
using namespace std;

int main() {
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  int setA = n / a;
  int setB = n / c;
  int pa, pb;
  if (n % a == 0) {
    pa = setA * b;
  } else {
    setA++;
    pa = setA * b;
  }
  if (n % c == 0) {
    pb = setB * d;
  } else {
    setB++;
    pb = setB * d;
  }
  cout << min(pa, pb) << endl;
}


Measured memory_bytes: 3104
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

S = input()

A = set(S)

for x in ascii_lowercase:
	if not x in A:
		print(S+x)
		break
else:
	if S == ascii_lowercase[::-1]:
		print(-1)
	else:
		for i in range(len(S)-2, -1, -1):
			if S[i] < S[i+1]:
				for char in sorted(S[i+1:]):
					if S[i] < char:
						print(S[:i]+char)
						exit()


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

int N,K;
int main() 
{
    cin >> N>>K;
    int res = 1;

rep(i,N) 
{
    if (2*res > res + K) res +=  K; 
    else res = 2*res;
}
cout << res  << endl; 
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int n; cin >> n;
    int S[11000]; for (int i = 0; i < n; ++i) cin >> S[i];
    int q; cin >> q;
    int T[1000]; for (int i = 0; i < q; ++i) cin >> T[i];  
    int count = 0;
    for (int i = 0; i < q; ++i) {
        S[n] = T[i];
        int j = 0;
        while(S[j] != T[i]) {
            ++j;
        } 
        if (j != n) ++count;
    }
    cout << count << endl;
}


Measured memory_bytes: 3116
/* https://atcoder.jp/contests/dp/tasks/dp_e */



#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define size 100000
#define ll long long int

struct item
{
	int weight;
	int val;
};
item arr[size];

int main()
{
	int n,w,max_val;
	max_val=0;
	cin>>n>>w;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i].weight>>arr[i].val;	
		max_val+=arr[i].val;	
	}
	ll dp[n][max_val+1];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<=max_val;j++)
		{
			dp[i][j]=INT_MAX;
		}
	}			//Time complexity is O(n*max_val)
								//dp[V][i] represents the minimum weight from the item arr[0 ... i] required to get a value of at least V

	for(int i=0;i<n;i++)
	{
		ll x=0;
		for(int z=0;z<=i;z++)
			x+=arr[z].val;
		for(int j=0;j<=x;j++)
		{
			if(i==0)
				dp[i][j]=arr[i].weight;
			else if(j>arr[i].val)
				dp[i][j]=min(dp[i-1][j],dp[i-1][j-arr[i].val]+arr[i].weight);
			else
				dp[i][j]=min(dp[i-1][j],(ll)arr[i].weight);

			//cout<<dp[i][j]<<" ";
		}
		//cout<<endl;
	}
	for(int i=max_val;i>=0;i--)
	{
		if(dp[n-1][i]<=w)
		{
			cout<<i<<endl;
			break;
		}
	}

}



Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pii pair<ll,ll>
#define sc(x) scanf("%lld",&x)
 
int main(){
	io;
	ll s,w;
	cin>>s>>w;
	if(w>=s){
		cout<<"unsafe";
	}else{
		cout<<"safe";
	}
	return 0;
}


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

using namespace std;


#define PI 3.14159265
#define int long long



main(){


	string s; cin >> s;

	cout << (s[4] == s[5] and s[2] == s[3] ? "Yes" : "No") << 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 rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
  char A;
  cin>>A;
  if((A>= 'a') && (A<='z')){cout<<'a'<<endl;}else{cout<<'A'<<endl;}
}

Measured memory_bytes: 3616
#include <iostream>
#define int long long
#define maxn 101
#define maxw 100005
using namespace std;
int w[maxn], v[maxn], dp[maxw];
main() {
	ios::sync_with_stdio(false);
	//   sync_with_YinHsuan(true);
	cin.tie(0);
	int n, W;
	cin >> n >> W;
	for ( int i=0; i<n; ++i )	cin >> w[i] >> v[i];
	for ( int i=0; i<n; ++i )
		for ( int j=W; j>=w[i]; --j )
			dp[j] = max(dp[j],dp[j-w[i]]+v[i]);
	cout << dp[W] << '\n';
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) {
    if (y > x) swap(x,y);
    if (y == 0) return x;
    else return gcd(y, x % y);
}

int main(void){
    int n;
    cin >> n;
    
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    
    int ans = gcd(a[0],a[1]);
    
    for (int i = 0; i < n; i++) ans = gcd(ans,a[i]);
    
    cout << ans << endl;
}


Measured memory_bytes: 640
#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 n, m;
    cin >> n >> m;
    vector<int> v(n);

    REP(i,m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        v[a]++;
        v[b]++;
    }

    REP(i,n) cout << v[i] << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import math

N = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

min_num = min(a,b,c,d,e)

m = math.ceil(N / min_num)

total = m + 4

print(total)


Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
using ll = long long int;
using ull =  unsigned long long int;


int main() {
	string a;
	cin >> a;
	if (a[0] == a[1] || a[1] == a[2] || a[2] == a[3]) {
		cout << "Bad" << endl;
	}
	else {
		cout << "Good" << endl;
	}
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
#define F first
#define S second
map<ll,vector<pll>> mp;
int main()
{
    ll n, x, d;
    cin >> n >> x >> d;
    if (d == 0) {
        cout << (x ? n + 1 : 1) << endl;
        return 0;
    }
    if (d < 0) {
        x = x + (n - 1) * d;
        d = -d;
    }
    mp[0].emplace_back(0,0);
    for (ll i = 1; i <= n; ++i) {
        ll f = i * x;
        pll s((0+i-1)*i/2, (n-i+n-1)*i/2);
        ll r = (f % d + d) % d;
        s.F += (f-r)/d;
        s.S += (f-r)/d;
        mp[r].emplace_back(s);
    }
    ll ans = 0;
    for (auto & p : mp) {
        auto & v = p.S;
        sort(begin(v),end(v));
        ll cur = LLONG_MIN;
        for (const auto & t : v) {
            ll l, r;
            tie(l, r) = t;
            if (l <= cur) {
                ll nxt = max(r, cur);
                ans += nxt - cur;
                cur = nxt;
            } else {
                ans += r - l + 1;
                cur = r;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 22144
#import numpy as np
N = int(input())
a = [0]+list(map(int,input().split()))
ans = [0]*(N+1)
an = []
for i in range(N,0,-1):
  c =0
  b = [i*j for j in range(2,N//i+1)]
  for j in b:
    c +=ans[j]
  c = c%2
  if c!=a[i]:
    ans[i]=1
    an.append(i)
print(len(an))
for i in range(len(an)):
  print(an[i],end=" ")


Measured memory_bytes: 23476