akhauriyash/Code-Regression huggingface dataset:
#include <cmath>  
    #include <queue>  
    #include <cstdio>  
    #include <cstdlib>  
    #include <cstring>  
    #include <iostream>  
    #include <algorithm>  
    #include <map>  
    #include <bits/stdc++.h>  
    #define mp make_pair  
    using namespace std;  
      
    constexpr int maxn = 2000010;  
    char s[maxn];  
      
    set <int> S;  
    int nextt[maxn][30];  
    int now[30];  
    int now_tot[maxn];  
      
    void doit(){  
        scanf("%s",s);  
        int len=strlen(s);  
        int tot=0;  
        for (int i=len;i>=1;i--)  
        {  
            S.insert( s[i-1]-'a' );  
            now_tot[i]=tot;  
            if (S.size()==26)  
            {  
                tot++;  
                S.clear();  
            }  
        }  
        if (tot==0)  
            {  
            for (int i=0;i<26;i++)  
                if (S.count (i )==0)  
                    {  
                        printf("%c",i+'a');  
                        return ;  
                    }  
            }  
        memset(now,0,sizeof(now));  
        for (int i=len;i>=1;i--)  
        {  
            for (int j=0;j<26;j++)  
                nextt[i][j]=now[j];  
            now[ s[i-1]-'a' ]=i;  
        }  
        int tmp=0;  
        for (int i=0;i<26;i++)  
            if (S.count (i )==0)  
            {  
                tmp=now[i];  
                break;  
            }  
        printf("%c",s[tmp-1]);  
        for (int i=1;i<tot;i++)  
            {  
                for (int j=0;j<26;j++)  
                    if (now_tot [ nextt[ tmp ][ j ] ]==now_tot [ tmp ] -1 )  
                        {  
                            tmp=nextt[ tmp ][ j ];  
                            printf("%c",s[tmp-1]);  
                            break;  
                        }  
            }  
        for (int i=0;i<26;i++)  
            if (nextt[ tmp ][ i ]==0)  
                {  
                    printf("%c",i+'a');  
                    break;  
                }  
    }  
      
      
    int main(){  
        doit();  
        return 0;  
    }  

Measured memory_bytes: 29696
#include <iostream>

void out(int n, int* a);

int main() {
	int n;
	int a[100];
	std::cin >> n;
	for (int i = 0; i < n; i++) {
		std::cin >> a[i];
	}
	// Bubble Sort
	int count = 0;
	bool flag = true;
	while (flag) {
		flag = false;
		for (int j = n - 1; j >= 1; j--) {
			if (a[j] < a[j - 1]) {
				int aa = a[j - 1];
				a[j - 1] = a[j];
				a[j] = aa;
				flag = true;
				count++;
			}
		}
	}
	out(n, a);
	std::cout << count << std::endl;
	return 0;
}

void out(int n, int* a) {
	std::cout << a[0];
	for (int i = 1; i < n; i++) {
		std::cout << " " << a[i];
	}
	std::cout << std::endl;
}

Measured memory_bytes: 3048
N = int(input())
S = input()
R = []
G = []
B = []
for i in range(N):
    if S[i] == "R":
        R.append(i)
    elif S[i] == "G":
        G.append(i)
    else:
        B.append(i)
s = len(R)*len(G)*len(B)
for i in range(N):
    for j in range(i+1,(N+i+1)//2):
        if S[i] != S[j] and S[j] != S[2*j-i] and S[i] != S[2*j-i]:
            s -= 1
print(s)

Measured memory_bytes: 9220
/*
    Author: MEHXM
*/
#include <bits/stdc++.h>
using namespace std;

#define cp_io ios_base::sync_with_stdio(0);cin.tie(0)
#define ll long long int
#define oo 1000000010
#define MAX 1000000
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define nl "\n"

int main()
{
    cp_io;
    #ifndef ONLINE_JUDGE
    freopen("z_input.txt","rt",stdin);
    freopen("z_output.txt","wt",stdout);
    #endif
    int n,x,t;
    cin >> n >> x >> t;

    cout << (int)(ceil((double)n/x))*t;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int N, M;
    cin >> N >> M;
    ll ans[N];
    for(int i = 0; i < N; i++) ans[i] = -1;
    for(int i = 0; i < M; i++) {
        int s, c;
        cin >> s >> c;
        s--;
        if(ans[s] != -1 && ans[s] != c) {
            cout << -1;
            return 0;
        }
        ans[s] = c;
    }
    if(ans[0] == 0 && N != 1) {
        cout << -1;
        return 0;
    }
    if(N == 1 && M == 0) {
        cout << 0;
        return 0;
    }
    ll foroutput = 0, tmp = 1;
    for(int i = N - 1; i >= 0; i--) {
        if(ans[i] != -1)
            foroutput += tmp * ans[i];
        else if(i == 0)
            foroutput += tmp;
        tmp *= 10;
    }
    cout << foroutput;
    return 0;
}

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

#define ll long long

ll gcd(ll x, ll y)
{
    ll r;
    if (x < y)
        swap(x, y);

    while (y > 0)
    {
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll lcm = (c/gcd(c, d)*d);
    ll ans1 = (a - 1) - ((a - 1) / c) - ((a - 1) / d) + ((a - 1) /lcm) ;
    ll ans2 = b - (b / c) - (b / d) + (b / lcm);

    cout << ans2 - ans1 << endl;
}

Measured memory_bytes: 256
N = input()
n = int(N)
k = n% 10
if ( k == 0 or k ==1 or k ==6 or k ==8 ):
  print('pon')
elif (  (k ==2 or k ==4 or k ==5 or k ==7 or k ==9 ) ):
  print('hon')
else:
  print('bon')


Measured memory_bytes: 9116
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

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

using namespace std;


int main() {

	int n, m;
	cin >> n >> m;
	n--;
	m--;
	cout << n*m << endl;
	return 0;
	
}


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

int main(void){
    int N;
    string S;
    cin >> N;
    cin >> S;
    int count = 0;
    char c = ' ';
    REP(i,N){
        if(c!=S[i]){
            count += 1;
            c = S[i];
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 512
/*
author : Lalit Kumar
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;

int main()
{
	string s,t;
	cin>>s>>t;
	ll ans=0;
	for(int i=0;i<s.size();++i)
	{
		if(s[i]!=t[i]) ans++;
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 3856
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

struct UnionFind{
    vl par;
    vl rank;
    map<ll, ll> size;
    UnionFind(ll N) : par(N, 0), rank(N, 0){
        for(int i = 0; i < N; i++){
            par[i] = i; size[i] = 1;
        }
    }
    
    ll root(ll x){
        if(par[x] == x) return x;
        else{
            par[x] = root(par[x]); // compression
            return par[x];
        }
    }
    
    void unite(ll x, ll y){
        ll rx = root(x); ll ry = root(y);
        if(rx == ry) return;
        if(rank[rx] < rank[ry]) swap(rx, ry);
        if(rank[rx] == rank[ry]) ++rank[rx];
        par[ry] = rx;
//        if(rx != ry) size[rx] = size[rx] + size[ry];
//        else{
//            size[rx] = max(size[rx], size[ry]);
//        }
    }
    
    ll get_size(ll x){
        return size[root(x)];
    }
    
    bool same(ll x, ll y){
        return root(x) == root(y);
    }
};


int main(){
    ll N, M; cin >> N >> M;
    auto uf = new UnionFind(N);
    vl ps(N, 0); REP(i, N){ ll p; cin >> p; ps[i] = p-1;};
    REP(i, M){
        ll x, y; cin >> x >> y;
        uf->unite(x-1, y-1);
    }
    map<ll, vector<ll>> m1, m2;
    REP(i, N){
        ll root = uf->root(ps[i]);
//        if(m1[root].size()==0) m1[root].reserve(1024*128);
        m1[root].pb(i);
    }
    
    ll ret = 0;
    for(auto it : m1){
        for(auto v : it.ss){
            if(binary_search(it.ss.begin(), it.ss.end(), ps[v])) ret++;
        }
    }
    cout << ret << endstr;
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    int Adj[n][n] = {};
    int d[n] = {};
    for (int i = 0; i < n; i++)
    {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++)
        {
            int v;
            cin >> v;
            Adj[u - 1][v - 1] = 1;
        }
        d[i] = -1;
    }

    int src = 0;
    queue<int> q;
    d[src] = 0;
    q.push(src);
    while (!q.empty())
    {
        int cur = q.front();
        q.pop();
        for (int dst = 0; dst < n; dst++)
        {
            if (Adj[cur][dst] && d[dst] == -1)
            {
                d[dst] = d[cur] + 1;
                q.push(dst);
            }
        }
    }

    for (int i = 0; i < n; i++)
    {
        cout << i + 1 << " " << d[i] << endl;
    }

    return 0;
}



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

using namespace std;

int main()
{
    /*int s=0;
    char a[10];
    scanf("%s",a);
    int i,l;
    l=strlen(a);
    for(i=0;i<l;i++)
    {
        if(a[i]=='-')
            s--;
        else
            s++;
    }
    printf("%d\n",s);*/
    int n,s=0,t=0;
    scanf("%d",&n);
    t=n;
    while(t)
    {
        s+=t%10;
        t=t/10;
    }
    int r;
    r=n/s;
    if(r*s==n)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int a, b;
	cin >> a >> b;
	cout << max({ a + b,a - b,a * b }) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

signed main()
{
  int N;
  cin >> N;

  vector<int> A(N + 1);
  for (int i = 0; i < N + 1; i++)
  {
    cin >> A.at(i);
  }
  vector<int> B(N);
  for (int i = 0; i < N; i++)
  {
    cin >> B.at(i);
  }
  
  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    int b = B.at(i);
    if (A.at(i) >= b)
    {
      ans += b;
      A.at(i) -= b;
    }
    else
    {
      b -= A.at(i);
      ans += A.at(i) + min(b, A.at(i + 1));
      A.at(i) = 0;
      A.at(i + 1) -= min(b, A.at(i + 1));
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

bool arr[1000000010];
bool Eratosthenes(int N){
	for(int i = 0; i < N; i++){
		arr[i] = 1;
	}
	for(int i = 2; i < sqrt(N); i++){
		if(arr[i]){
			for(int j = 0; i * (j + 2) < N; j++){
				arr[i *(j + 2)] = 0;
			}
		}
	}

	return arr[N];
}
signed main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n, m;
	cin >> n >> m;
	
	int ans = -1;
	for(int i = sqrt(m);i >= 1;i--){
		int p = -2;
		if(m % i == 0){
			int a = i, b = m/i;
			if(b <= m/n) p = b;
			else if(a <= m/n) p = a;
		}
		if(p > ans) ans = p;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)
 
int main() 
{	
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
 
	int a;
	cin>>a;
	int b[a];
	forr(i,0,a)
		cin>>b[i];
	sort(b,b+a);
	forr(i,0,a-1)
	{
		if(b[i]==b[i+1])
		{
			cout<<"NO"; return 0;
		}
	}
	cout<<"YES";
	
	return 0;	
}

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

typedef long long int ll;

#define endl '\n'

ll dp[10005][2][105];
ll d;
string k;
ll n;
ll mod = 1e9+7;
ll solve(ll u,ll f1,ll mask)
{
    //cout<<u<<" "<<f1<<" "<<mask<<endl;
    if(u==n){
        if(mask%d == 0)
        return 1;
        return 0;
    }

    if(dp[u][f1][mask]==-1){
        ll val = 0;
        if(f1==0){
            val = solve(u+1,0,(mask+(k[u]-'0'))%d);
            for(ll i=0;i<=9 and i<(k[u]-'0');i++){
                val = (val+solve(u+1,1,(mask+i)%d)+mod)%mod;
            }
        }
        else{

            for(ll i=0;i<=9;i++){
                val = (val+solve(u+1,1,(mask+i)%d)+mod)%mod;
            }

        }
        dp[u][f1][mask] = val;
    }
    return dp[u][f1][mask];


}

int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    memset(dp,-1,sizeof(dp));
    cin>>k;
    cin>>d;
    n = k.size();
    ll ans = 0;

    cout<<(mod+solve(0,0,0)-1)%mod<<endl;

}


Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int n;
ll ans = INF * 100ll;
set<pair<ll, ll>> b, c;
vector<pair<ll, ll>> d;

ll solve(set<pair<ll, ll>> s, ll p, ll q, ll x, ll y)
{
    s.erase({x, y});
    if (s.empty()) {
        return 0;
    } else if (s.find({x-p, y-q}) != s.end()) {
        return solve(s, p, q, x-p, y-q);
    } else {
        return solve(s, p, q, s.begin()->first, s.begin()->second) + 1;
    }
}

int main()
{
    cin>>n;
    REP(i,n) {
        ll x, y;
        cin>>x>>y;
        b.insert({x,y});
        d.push_back({x,y});
    }
    if (n == 1) {
        cout<<1<<endl;
        return 0;
    }
    SORT(d);
    REP(i,n) FOR(j,i+1,n) {
        c.insert({d[i].first - d[j].first, d[i].second - d[j].second});
    }
    for (auto itr : c) {
        set<pair<ll, ll>> s(b);
        ans = min(ans,
                solve(s, itr.first, itr.second, s.begin()->first, s.begin()->second) + 1);
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 384
//21:04
//C- 21:08 AC
//[21:08-21:12) free time

#include<bits/stdc++.h>
using namespace std;
int g[109][109];
int a[100009];
main(){
    int H, W, N;
    cin >> H >> W >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    vector<pair<int,int> > v;
    for(int i = 0; i < H; i++){
        if(i%2){
            for(int j = 0; j < W; j++)
                v.push_back({i,j});
        }
        else{
            for(int j = W-1; j >= 0; j--)
                v.push_back({i,j});
        }
    }
    int S = 0;
    for(int i = 0; i < N; i++){
        for(int j = S; j < S + a[i]; j++)
            g[v[j].first][v[j].second] = i + 1;
        S += a[i];
    }
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cout<<g[i][j]<<" ";
        }
        cout<<endl;
    }
}


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

int main() {
  int arr[3][3];
  bool call[3][3];
  memset(call, 0, sizeof(call));
  for (int i=0; i<3; i++) {
    for (int j=0; j<3; j++) {
	  cin >> arr[i][j];
    }
  }
  int n;
  cin >> n;
  for (int i=0; i<n; i++) {
	int a;
    cin >> a;
    for (int j=0; j<3; j++) {
	  for (int k=0; k<3; k++) {
		if (arr[j][k] == a) call[j][k] = 1;
      }
    }
  }
  bool poss = false;
  for (int i=0; i<3; i++) {
	  for (int j=0; j<3; j++) {
	    if (call[i][j] == 0) continue;
      if (i == 0 && j == 0) {
	      if (call[i+1][j] == 1 && call[i+2][j] == 1) {
	        cout << "Yes";
          return 0;
        }
        if (call[i][j+1] == 1 && call[i][j+2] == 1) {
          cout << "Yes";
          return 0;
        }
        if (call[i+1][j+1] == 1 && call[i+2][j+2] == 1) {
	        cout << "Yes";
          return 0;
        }
      }
      if (i == 0 && j == 1) {
        if (call[i+1][j] == 1 && call[i+2][j] == 1) {
          cout << "Yes";
          return 0;
        }
      }
      if (i == 0 && j == 2) {
        if (call[i+1][j] == 1 && call[i+2][j] == 1) {
          cout << "Yes";
          return 0;
        }
      }
      if (i == 1 && j == 0) {
        if (call[i][j+1] == 1 && call[i][j+2] == 1) {
          cout << "Yes";
          return 0;
        }
      }
      if (i == 2 && j == 0) {
        if (call[i][j+1] == 1 && call[i][j+2] == 1) {
          cout << "Yes";
          return 0;
        }
        if (call[i-1][j+1] == 1 && call[i-2][j+2] == 1) {
          cout << "Yes";
          return 0;
        }
      }
    }
  }
  cout << "No";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

int main(){
  FAST_IO
  int N; cin >> N;

  cout << (int)sqrt(N) * (int)sqrt(N) << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
 
    int N; cin >> N;
    int cur; cin >> cur; cur--;
    int data[N-1]; FOR(i, 1, N) cin >> data[i-1];
    FOR(i, 1, N) {
        int nxt = data[i-1];
        if (nxt > cur) {
            nxt--;
        }
        if (nxt < cur) {
            cout << "No" << endl;
            return 0;
        }
        cur = nxt;
    }
 
    cout << "Yes" << endl;
 
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#define N 100000

typedef struct {
  int parent;
  int left;
  int right;
} Node;

Node Tree[N];

int getDepth(int x) {
  int depth = 1;
  if(Tree[x].parent == -1) return 0;
  depth += getDepth(Tree[x].parent);
  return depth;
}

int main() {
  int i, j, n, m, k, p;
  int number, depth, child; 

  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    Tree[i].parent = -1;
    Tree[i].left = -1;
    Tree[i].right = -1;
  }
  for(i = 0; i < n; i++) {
    scanf("%d", &number);
    scanf("%d", &m);
    for(j = 0; j < m; j++) {
      scanf("%d", &child);
      Tree[child].parent = number;
      if(j == 0) {
	Tree[number].left = child;
      }
      else {
	Tree[k].right = child;
      }
      k = child;
    }
  }

  for(i = 0; i < n; i++) {
    depth = getDepth(i);
    printf("node %d: parent = %d, depth = %d, ", i, Tree[i].parent, depth);
    if( Tree[i].parent == -1) {
      printf("root, [");
      if(Tree[i].left != -1) {
	printf("%d",Tree[i].left );
	p = Tree[i].left;
	while(Tree[p].right != -1) {
	  printf(", %d", Tree[p].right);
	  p = Tree[p].right;
	    }
      }
      printf("]\n");
    }
  
    else if(Tree[i].left != -1){
      printf("internal node, [");
      if(Tree[i].left != -1) {
	printf("%d",Tree[i].left );
	p = Tree[i].left;
	while(Tree[p].right != -1) {
	  printf(", %d", Tree[p].right);
	  p = Tree[p].right;
	    }
      }
      printf("]\n");
    }
    else printf("leaf, []\n");
  }
  
  return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

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

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


map <string , int> m;

int main(){
	int n;
	cin>>n;
	string aux;
	string str;
	cin>>str;
	aux=str;
	m[str]++;
	string Rpta="Yes";


	for(int i=1 ; i<n ; i++){

		cin>>str;

		if(str[0]==aux[aux.size()-1]){
			
			aux=str;
			m[str]++;
			
			if(m[str]>1){
				Rpta="No";

			}
		}else{

			Rpta="No";
			
		}

	}
	
	cout<<Rpta;

	return 0;
}


Measured memory_bytes: 256
s = input()
t = input()
len_s = len(s)
len_t = len(t)

# dp[i][j] = sのi-1文字目,tのj-1文字目まででの最長共通部分列の長さ
dp = [[0]*(len_t+1) for i in range(len_s+1)]
# 遷移記録用（0,1が両方-1ならその文字を追加する）
prevs = [[0]*(len_t+1) for i in range(len_s+1)]
prevt = [[0]*(len_t+1) for i in range(len_s+1)]
for i in range(len_s+1) :
    for j in range(len_t+1) :
        # どちらかが空文字列の場合
        if i == 0 or j == 0 :
            dp[i][j] = 0
            continue
        # i-1文字目とj-1文字目が一致する場合
        if s[i-1] == t[j-1] :
            dp[i][j] = dp[i-1][j-1] + 1
            prevs[i][j] = -1
            prevt[i][j] = -1
        # 一致しない場合
        else : 
            if dp[i-1][j] >= dp[i][j-1] :
                if dp[i-1][j] > dp[i][j] :
                    dp[i][j] = dp[i-1][j]
                    prevs[i][j] = -1
            else :
                if dp[i][j-1] > dp[i][j] :
                    dp[i][j] = dp[i][j-1]
                    prevt[i][j] = -1

ans = 0
si = len_s
ti = len_t
ans = ['' for i in range(dp[len_s][len_t])]
index = dp[len_s][len_t] - 1
# 遷移をたどっていく
for i in range(10**18) :
    if prevs[si][ti] == -1 and prevt[si][ti] == -1 :
        ans[index] = s[si-1]
        index -= 1
    st = si ; tt = ti
    si += prevs[st][tt] ; ti += prevt[st][tt]
    if si == st and ti == tt :
        break

print(*ans, sep='')

Measured memory_bytes: 248456
#include <bits/stdc++.h>
using namespace std;
const int oo = 27081993;

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

  int n;
  string s[222];
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> s[i];

  int dist[222][222];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (i != j && s[i][j] == '0') dist[i][j] = oo;
      else dist[i][j] = s[i][j] - '0';

  for (int k = 0; k < n; k++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      if (s[i][j] == '1')
        for (int k = 0; k < n; k++)
          if (k != i && k != j && dist[k][i] + 1 != dist[k][j] && dist[k][j] + 1 != dist[k][i])
          {
            cout << -1 << endl;
            return 0;
          }

  int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      ans = max(ans, dist[i][j]);

  cout << ans + 1 << endl;
}


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

using namespace std;
int main() {

	int a;
	string s;

	cin >> a;
	cin >> s;

	if (a >= 3200)
	{
		cout << s;
	}
	else {
		cout << "red";
	}
}

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

using namespace std;

int main() {
    const int MOD = 1e9 + 7;
    int N, M;
    cin >> N >> M;
    set<int> break_stairs;
    for (int i = 0; i < M; i++) {
        int a;
        cin >> a;
        break_stairs.emplace(a);
    }

    int dp[3] = {};
    dp[0] = 1;
    for (int i = 0; i < N; i++) {
        if (break_stairs.count(i) == 0) {
            for (int j = 0; j < 2; j++) {
                if (break_stairs.count(i + j + 1) == 0) {
                    (dp[j + 1] += dp[0]) %= MOD;
                }
            }
        }
        dp[0] = dp[1];
        dp[1] = dp[2];
        dp[2] = 0;
    }
    cout << dp[0] << endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <stdio.h>
using namespace std;

int main()
{
    int n;
    cin >> n;
    
    long long int a;
    long long int sum = 0;
    bool noadd = false;
    for(int i=0; i<n; i++){
        cin >> a;
        if(a == 0){
            cout << "0" << endl;
            return 0;
        }
        if(sum > 1000000000000000000/a){
            //cout << "-1" << endl;
            noadd = true;
        }
        if(noadd == true) continue;
        
        if(i==0) sum = a;
        else sum = sum * a;
    }
    if(noadd == true){
            cout << "-1" << endl;
            return 0;
    }
          //       1000000000000000000
          //       1000000000000000001
    else if(sum > 1000000000000000000){
        cout << "-1" << endl;
        return 0;
    }
    else{
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>

using namespace std;

int main() {
    size_t n;
    cin >> n;
    vector<size_t> h(n);
    for (size_t i = 0; i < n; ++i)
        cin >> h[i];
    size_t a = 0;
    size_t b = 0;
    for (size_t i = 1; i < n; ++i) {
        if (h[i] > h[i - 1]) {
            b = max(a, b);
            a = 0;
        } else {
            ++a;
        }
    }
    cout << max(a, b) << endl;
    return 0;
}

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

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

    vector<long long> power(3 * N);
    for (int i = 0; i < 3 * N; i++){
        cin >> power.at(i);
    }

    sort(power.begin(), power.end());

    long long ans = 0;
 
    for(int i = N; i < 3 * N; i = i + 2){
        ans += power.at(i);
    }

    cout << ans << endl;

    return 0;
}

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

char character(int i,int j){
  if(i%2==0){
    return j%2==0 ? '#':'.';
  }else{
    return j%2==0 ? '.':'#';
  }
}
void make_board(int h, int w){
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++) cout<<character(i,j);
    cout<<"\n";
  }
  cout<<"\n";
}
int main(){
  int h,w;
  while(1){
    cin>>h>>w;
    if(h==0 && w==0) break;
    make_board(h,w);
  }
}

Measured memory_bytes: 3052
#
#    ------------------------------------------------
#           ____          _     Generatered using
#          / ___|        | |
#         | |    __ _  __| | ___ _ __  ______ _
#         | |   / _` |/ _` |/ _ \ '_ \|_  / _` |
#         | |__| (_| | (_| |  __/ | | |/ / (_| |
#          \____\____|\____|\___|_| |_/___\____|
#
#      GNU Affero General Public License v3.0
#    ------------------------------------------------
#    Author   : prophet
#    Created  : 2020-07-25 08:02:16.186310
#    UUID     : qCDp7J4mC32f2bXJ
#    ------------------------------------------------
#
production = True

import sys, math, collections

def input(f = 0, m = 0):

    if m > 0: return [input(f) for i in range(m)]
    else:
        l = sys.stdin.readline()[:-1]

        if f >= 10:
            u = False
            f = int(str(f)[-1])
        else: u = True

        if f == 0: p = [l]
        elif f == 1: p = list(map(int, l.split()))
        elif f == 2: p = list(map(float, l.split()))
        elif f == 3: p = list(l)
        elif f == 4: p = list(map(int, list(l)))
        elif f == 5: p = l.split()

        return p if u else p[0]

def out(l, f = 0, n = True):

    if f == 0: p = str(l)
    elif f == 1: p = " ".join(map(str, l))
    elif f == 2: p = "\n".join(map(str, l))
    elif f == 3: p = "".join(map(str, l))

    print(p, end = "\n" if n else "")

def log(*args):
    if not production:
        print("$$$", end = "")
        print(*args)

enu = enumerate
ter = lambda a, b, c: b if a else c
ceil = lambda a, b: -(-a // b)
flip = lambda a: (a + 1) & 1

def mapl(i, f = 0):

    if f == 0: return list(map(int, i))
    elif f == 1: return list(map(str, i))
    elif f == 2: return list(map(list, i))

#
#   >>>>>>>>>>>>>>> START OF SOLUTION <<<<<<<<<<<<<<
#


def solve():

    n = input(11)

    if n < 600:
        a = 8
    elif n < 800:
        a = 7
    elif n < 1000:
        a = 6
    elif n < 1200:
        a = 5
    elif n < 1400:
        a = 4
    elif n < 1600:
        a = 3
    elif n < 1800:
        a = 2
    else:
        a = 1

    out(a)
        

    return


solve()

#
#   >>>>>>>>>>>>>>>> END OF SOLUTION <<<<<<<<<<<<<<<
#


Measured memory_bytes: 65512
n,x = map(int,input().split())
a = list(map(int,input().split()))
if sum(a) == x:
    print(n)
elif sum(a) < x:
    print(n-1)
else:
    a.sort()
    ans = 0
    for i in a:
        if i > x:
            break
        else:
            x -= i
            ans += 1
    print(ans)


Measured memory_bytes: 9132
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

char min_bit[1<<10];

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	memset(min_bit, 1, sizeof(min_bit));
	for(int i = 2; i < (1<<10); i += 2)
		min_bit[i] = 1 + min_bit[i/2];
	int N;
	cin >> N;
	for(int i = 0; i < N-1; i++)
		for(int j = i+1; j < N; j++)
			cout << 1*min_bit[i^j] << ((j == N-1) ? "\n" : " ");
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
	int sum=0,a,b,c,d,e,f;
	cin >> a >> b >> c >> d >> e >> f;
	sum=a+b*5+c*10+d*50+e*100+f*500;
	if(sum>=1000){
		cout << 1 << endl;
	}else{
		cout << 0 << endl;
	}
}


Measured memory_bytes: 3052
from collections import deque

H, W = map(int, input().split())
c = [list(input()) for _ in range(H)]

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

def bfs(sx, sy):
    d = [[-1] * W for _ in range(H)]

    que = deque([])
    que.append((sx, sy))
    d[sy][sx] = 0

    res = 0
    while que:
        x, y = que.popleft()

        for k in range(4):
            nx = x + dx[k]
            ny = y + dy[k]

            if 0 <= nx < W and 0 <= ny < H and d[ny][nx] == -1 and c[ny][nx] == '.':
                que.append((nx, ny))
                tmp = d[y][x] + 1
                d[ny][nx] = tmp
                res = max(res, tmp)

    return res

ans = 0
for i in range(H):
    for j in range(W):
        if c[i][j] == '.':
            tmp = bfs(j, i)
            ans = max(ans, tmp)

print(ans)


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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define pb push_back


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = 1000100010010010;
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};


/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>auto cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */



signed main(){


    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; 
    int a, b;
    cin >> n >> a >> b;
    int ax = 0, bx = 0, cx = 0;
    rep(i,0,n){
        int t = input();

        if(t <= a) ax++;
        if(a + 1 <= t && t <= b) bx++;
        if(b  + 1 <= t) cx++;
    }

    print(min({ax, bx, cx}));
    
    



    



    


    

}



Measured memory_bytes: 256
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll n;
    cin>>n;
    vl v;
    rep(i,n)
    {
        ll c;
        cin>>c;
        v.pb(c);
    }
    vl w;
    for(int i=0;i<n;i++)
    {
        if(i==0)
        {
            w.pb(v[i]);
        }
        else
        {
            if(w.back()!=v[i])
            {
                w.pb(v[i]);
            }
        }
    }
    swap(v,w);
    ll money=1000;
    ll stocks=0;
    n=v.size();
    for(int i=0;i<n-1;i++)
    {
        if(v[i+1]>v[i])
        {
            int j=i+1;
            while(true)
            {
                if(j==n)
                    break;
                if(v[j]>v[j-1])
                {
                    j++;
                    continue;
                }
                else
                {
                    break;
                }
            }
            j--;
            stocks+=(money/v[i]);
            money%=v[i];
            money+=(v[j]*stocks);
            stocks=0;
            i=j;
        }
        else
        {
            int j=i+1;
            while(true)
            {
                if(j==n)
                    break;
                if(v[j]<v[j-1])
                {
                    j++;
                    continue;
                }
                else
                {
                    break;
                }
            }
            j--;
            i=j-1;
        }
    }
    cout<<money<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 15564
#include <cstdio>
#include <algorithm>

int main(){
    int w[100000];
    int i,n,k;
    long long int maxw=0;
    long long int sumw=0;
    scanf("%d %d",&n,&k);
    for(i=0;i<n;i++){
        scanf("%d",w+i);
        sumw+=w[i];
        if(w[i]>maxw)maxw=w[i];
    }
    long long int avgp=(sumw-1)/k+1;
    long long int p = std::max(avgp,maxw);
    long long int load;
    int truck;
    while(true){
        truck = 1;
        load = 0;
        for(i=0;i<n;i++){
            if(load+w[i]>p){
                truck++;
                load=w[i];
            }else{
                load+=w[i];
            }
        }
        if(truck>k){
            p++;
            continue;
        }
        break;
    }
    printf("%d\n",p);
    return 0;
}



Measured memory_bytes: 3052
import java.util.*;

// CODEFES_B 2017-C
// http://code-festival-2017-qualb.contest.atcoder.jp/tasks/code_festival_2017_qualb_c	

public class Main {
	
	public static void main (String[] args) throws InterruptedException {
		Scanner in = new Scanner(System.in);
		
		
	    int A = in.nextInt();
	    int B = in.nextInt();
	    int C = in.nextInt();
	    
	    if (A == B) {
	      System.out.println(C);
	    } else if (A == C) {
	      System.out.println(B);
	    } else {
	      System.out.println(A);
	    }
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
#define ip(arr, n) for(int i=1; i<=n; i++) cin>>arr[i];
#define op(arr, n) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
#define fstIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MAX 100005

int main(){
    int n;
    cin>>n;
    int height[n+1];
    ip(height, n);
    
    ll dp[MAX]={0};
    
    for(int i=2; i<=n; i++){
        dp[i] = dp[i-1]+abs(height[i]-height[i-1]);
        if(i>2)
            dp[i] = min(dp[i], dp[i-2]+abs(height[i]-height[i-2]));
    }
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 1408
n = int(input())
a = list(map(int, input().split()))

d = {}
m = 0
for i in a:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
        m += 1
print(m - 1) if (n-m) % 2 else print(m)

Measured memory_bytes: 21728
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define MP make_pair
#define pb push_back
const int INF = 1e18;
const int MOD = INF+7;
using P = pair<int,int>;

signed main(){
    int A,B,C;
    cin >> A >> B >> C;
    cout << A * B / 2 << endl;
    
}

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

using namespace std;

int main(void) {
	int H, W;
	cin >> H >> W;
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];
	int dx = 1;
	int x = 0;
	vector<vector<int>> g(H, vector<int>(W));
	int i = 0;
	for (int y = 0; y < H; y++) {
		while (x >= 0 && x < W) {
			if (a[i] == 0) i++;
			a[i]--;
			g[y][x] = i + 1;
			x += dx;
		}
		dx *= -1;
		x += dx;
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << g[i][j];
			if (j < W - 1) cout << " ";
		}
		cout << endl;
	}

	system("pause");
	return 0;
}

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

int main(){
  int a,b,c,x;
  cin>>a>>b>>c>>x;
  int cnt = 0;

  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= b; j++) {
      for (int k = 0; k <=c; k++) {
        if (i*500+j*100+k*50 == x) cnt++;
      }
    }
  }

cout << cnt << endl;
}


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

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
	return x * f;
}

const int N = 1e5 + 5;
struct node{ int v, c, d; };
vector<node> G[N], Q[N];
int dep[N], par[N][20], dis[N];
int cnt[N], sum[N], ans[N];

void dfs(int u, int fa)
{
	dep[u] = dep[fa] + 1;
	par[u][0] = fa;
	for (int i = 1; i <= 18; ++i)
		par[u][i] = par[par[u][i - 1]][i - 1];
	
	for (auto i : G[u]) if (i.v != fa)
		dis[i.v] = dis[u] + i.d, dfs(i.v, u);
}

int LCA(int u, int v)
{
	if (dep[u] > dep[v]) swap(u, v);
	for (int i = 18; i >= 0; --i)
		if (dep[par[v][i]] >= dep[u])
			v = par[v][i];
	if (u == v) return u;
	
	for (int i = 18; i >= 0; --i)
		if (par[u][i] != par[v][i])
			u = par[u][i], v = par[v][i];
	return par[u][0];
}

void solve(int u, int fa)
{
	for (auto i : Q[u])
	{
		if (i.v > 0) ans[i.v] += dis[u] - sum[i.c] + cnt[i.c] * i.d;
		else ans[-i.v] -= 2 * (dis[u] - sum[i.c] + cnt[i.c] * i.d);
	}
	
	for (auto i : G[u]) if (i.v != fa)
	{
		cnt[i.c]++; sum[i.c] += i.d;
		solve(i.v, u);
		cnt[i.c]--; sum[i.c] -= i.d;
	}
}

int main()
{
	int n = read();
	int q = read();
	for (int i = 1; i < n; ++i)
	{
		int u = read(), v = read();
		int c = read(), d = read();
		G[u].push_back((node){v, c, d});
		G[v].push_back((node){u, c, d});
	}
	dfs(1, 0);
	
	for (int i = 1; i <= q; ++i)
	{
		int c = read(), d = read();
		int u = read(), v = read();
		Q[u].push_back((node){i, c, d});
		Q[v].push_back((node){i, c, d});
		Q[LCA(u, v)].push_back((node){-i, c, d});
	}
	solve(1, 0);
	
	for (int i = 1; i <= q; ++i) printf("%d\n", ans[i]);
	
	return 0;
}


Measured memory_bytes: 28600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){
  
  int n;
  cin >> n;
  
  int ans = 0;
  
  rep(i,n){
    int d,e;
    cin >> d >> e;
    if(d == e) ans ++;
    else ans = 0;
    if(ans == 3){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    string s,t;
    cin >> s;
    cin >> t;
    vector<char> a(2*n);
    int k=0,l=0;
    for(int i=0;i<2*n;i++){
        if(i%2==0){
            a.at(i)=s.at(k);
            k++;
        }
        if(i%2==1){
            a.at(i)=t.at(l);
            l++;
        }
    }
    for(int i=0;i<2*n;i++){
        cout << a.at(i);
    }
    cout << endl;
    
    
}

Measured memory_bytes: 256
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = getLine >> readLine >>= printRes . solve . sortBy (flip compare) 
    where
        printRes b
            | b = putStrLn "Yes"
            | otherwise = putStrLn "No"

solve :: [Int] -> Bool 
solve (x : xs) = x < sum xs

readLine :: IO [Int]
readLine = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const int Inf = 1000000000;
const ll INF= 1e18;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    bool ret = true;
    for(int i = 0;i < N;i++) {
        if(vec.at(i) % 2 != 0) {
            ret = false;
        }
    }
    if(ret == true) {
        cout << "second" << endl;
    }
    else {
        cout << "first" << endl;
    }
}

Measured memory_bytes: 640
#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);

	int n; cin>>n;
	set<pair<int, int> > a, b;
	for(int i = 0; i < n; i++){
		int x, y;
		cin>>x>>y;
		a.insert({x, y});
	}
	for(int i = 0; i < n; i++){
		int x, y;
		cin>>x>>y;
		b.insert({x, y});
	}
	int ans = 0;
	for(auto pp : b){
		int x = -1, y = -1;
		for(auto qq : a){
			if(qq.first < pp.first && qq.second < pp.second){
				if(y < qq.second){
					x = qq.first;
					y = qq.second;
				}
			}
		}
		if(x != -1){
			a.erase({x, y});
			ans++;
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256