akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

int cal(int k){
    for(int i = 31;i >= 0;i--){
        if((1<<i) & k) return (1<<i);
    }
    return 0;
}

vector<int> no;
vector<int> nore;

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

    if(K == 0){
        for(int i = 0;i < (1<<m);i++) {
            if(i) printf(" %d",i);
            else printf("%d",i);
        }
        for(int i = (1<<m)-1;i>=0;i--){
            printf(" %d",i);
        }
        printf("\n");
        return 0;
    }

    int max_m = (1 << m)-1;
    if(max_m == K) max_m--;

    int maxk = cal(K);

    if(max_m < maxk) {printf("-1\n");return 0;}

    int another = K ^ max_m;

    for(int i = 0;i < (1<<m);i++){
        if(i!= K && i!=max_m && i != another) no.push_back(i);
    }
    nore = no;
    reverse(ALL(nore));

    int blank = 0;
    if((1 << m) -1 >= K){
        printf("%d",K);
        blank = 1;
    }
    _for(i,0,no.size()){
        if(blank) printf(" %d",no[i]);
        else{printf("%d",no[i]);blank = 1;}
    }

    if(blank)
        printf(" %d %d",max_m,another);
    else{blank = 1; printf("%d %d",max_m,another);}

    if((1 << m) -1 >= K) printf(" %d",K);
    printf(" %d %d",another,max_m);

     _for(i,0,nore.size()){
        printf(" %d",nore[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2936
from itertools import *
N,C,*XV = map(int,open(0).read().split())
X = XV[::2] + [C]
A = [0] + list(accumulate(XV[1::2]))
ans = L = R = 0

for b in range(N + 1):
    T = A[N] - A[b]
    d = C - X[b]
    L = max(L, A[b] - X[b - 1])
    R = max(R, A[b] - 2 * X[b - 1])
    ans = max(ans, L + T - 2 * d, R + T - d)

print(ans)

Measured memory_bytes: 33144
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
//main
signed main(){
  std::vector<string> s(3);
  s[0]="Sunny";
  s[1]="Cloudy";
  s[2]="Rainy";
  string t;cin>>t;
  for(int i=0;i<3;i++)if(s[i]==t)cout<<s[(i+1)%3]<<endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

def pow_r_mod(x, n, mod=10**9+7):
    # 計算量 : log N
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        x %= mod
        n //= 2
    return (K * x) % mod

def  mod_pow(a:int, b:int, mod:int)->int:
    if b % 2 == 0:
        return (mod_pow(a, b//2, mod) ** 2) % mod
    elif b == 1:
        return a % mod
    else:
        return ((mod_pow(a, b//2, mod) ** 2) * a) % mod

m, a, b = mi()

P = 10**9+7
N = 2*(10**5)+1
inv_t = [0]+[1]
for i in range(2, N):
  inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

mca = mcb = 1

for i in range(1, a+1):
    mca *= (m-i+1) * inv_t[i]
    mca %= P

for i in range(1, b+1):
    mcb *= (m-i+1) * inv_t[i]
    mcb %= P

#print((pow_r_mod(2, m)-1-mca-mcb) % P)
print((mod_pow(2, m, P)-1-mca-mcb) % P)

Measured memory_bytes: 11052
//https://atcoder.jp/contests/abc113/tasks/abc113_c

import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        HashMap<Long,Integer> PY = new HashMap<>();
        ArrayList<Long> Y = new ArrayList<>();
        for (int i=0;i<M;i++){
            int p = sc.nextInt();
            long y = sc.nextLong();
            Y.add(y);
            PY.put(y,p);
        }
        sc.close();
        ArrayList<Long> ori = new ArrayList<>(Y);
        Collections.sort(Y);
        HashMap<Integer,Integer> city = new HashMap<>();
        HashMap<Long,String> ans = new HashMap<>();
        for (long x:Y){
            if (city.containsKey(PY.get(x))){
                city.put(PY.get(x),city.get(PY.get(x))+1);
            } else {
                city.put(PY.get(x),1);
            }
            StringBuffer up = new StringBuffer(String.valueOf(PY.get(x)));
            while (up.length()<6){
                up.insert(0, "0");
            }
            StringBuffer under = new StringBuffer(String.valueOf(city.get(PY.get(x))));
            while (under.length()<6){
                under.insert(0, "0");
            }
            ans.put(x,String.valueOf(up)+String.valueOf(under));
        }
        for (long x:ori){
            System.out.println(ans.get(x));
        }
    }
}

Measured memory_bytes: 133248
#include <iostream>
#include <string.h>
using namespace std;

int main()
{
	int n, r, t, m = 0;
	int p[100], q[1000];

	cin >> n >> r >> t;

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

	memset(q, 0, sizeof(q));

	for (int i = 1; i <= t; i++) {
		for (int j = 0; j < n; j++) {
			int u = (p[j] * i) % r;
			if (q[u] == 0)
				m++;
			else
				q[u]--;
		}
		if (i > 1) {
			for (int j = 0; j < n; j++)
				q[(p[j] * i) % r]++;
		}

	}

	cout << m << endl;

	return 0;
}



Measured memory_bytes: 3108
#include <iostream>
using namespace std;
int main()
{
  int a,b;
  char op;
  while(1)
  {
    cin>>a>>op>>b;
    if(op=='?')
      break;
    else
      switch(op)
    {
      case '+':
        cout<<a+b;
        break;
      case '-':
        cout<<a-b;
        break;
      case '*':
        cout<<a*b;
        break;
      case '/':
        cout<<a/b;
        break;
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;

const int mxn=2e5+1;

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

  int t=1;
//  cin>>t;
  int tt=1;
  while(t--){
    int n,i;
    ll cur=0;
    cin>>n;
    pair<ll,ll> arr[n];
    fr(i,0,n)
    {
      cin>>arr[i].se>>arr[i].fi;
    }
    sort(arr,arr+n);
    fr(i,0,n)
    {
      cur+=arr[i].se;
      if(cur>arr[i].fi)
      {
        cout<<"No";
        return 0;
      }
    }
    cout<<"Yes";
   // cout<<"Case #"<<tt<<": ";
   // tt++;
    }
  return 0;
}



Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>

#define ll long long
#define dl double
#define mod 1000000007
#define sz 1005
#define szz 150

using namespace std;

int main()
{
    ll n,k;

    scanf("%lld %lld",&n,&k);

    ll a=1,m=2;

    for(ll i=1;i<=n;i++)
    {
        ll v1=a*m;
        ll v2=a+k;

        a=min(v1, v2);
    }

    printf("%lld\n",a);

    return (0);
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 101
#define WHITE 0
#define GRAY 1
#define BLACK 2

typedef struct {
  int u;
  int k;
  int v[N];
  int d,f;
  int color;
} mat_t;

int n,matrix[N][N],time;
mat_t arr[N];

void dfs_visit(int u){
  int v;
  arr[u].color=GRAY;
  arr[u].d=++time;
  for(v=0;v<n;v++){
    if(matrix[u][v]==0) continue;
    if(arr[v].color==WHITE) dfs_visit(v);
  }
  arr[u].color=BLACK;
  arr[u].f=++time;
}

void dfs(){
  int u;
  for(u=0;u<n;u++){
    arr[u].color=WHITE;
  }
  time=0;
  for(u=0;u<n;u++){
    if(arr[u].color==WHITE) dfs_visit(u);
  }
}

int main(){
  int i,j,k=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d%d",&arr[i].u,&arr[i].k);
    if(arr[i].k==0) continue;
    for(j=0;j<arr[i].k;j++){
      scanf("%d",&arr[i].v[j]);
    }
  }

  for(i=0;i<n;i++){
      for(j=0;j<n;j++){
        if(arr[i].v[k]==j+1) {
          matrix[i][j]=1;
          k++;
        }
        else matrix[i][j]=0;
      }
      k=0;
    }

    dfs();
  for(i=0;i<n;i++){
    printf("%d %d %d\n",arr[i].u,arr[i].d,arr[i].f);
  }
  return 0;
}

Measured memory_bytes: 676
#include <iostream>
#include <cstdio>
using namespace std;
int HtoD(char c){
	if('0'<=c&&c<='9')return c-'0';
	if('A'<=c&&c<='F')return c-'A'+10;
	if('a'<=c&&c<='f')return c-'a'+10;
	return 0;
}
int main(){
	const int BCOL[8][3]={{0,0,0},{0,0,255},{0,255,0},{0,255,255},{255,0,0},{255,0,255},{255,255,0},{255,255,255}};
	const string BCOLN[8]={"black","blue","lime","aqua","red","fuchsia","yellow","white"};
	string s;
	while(cin>>s){
		if(s[0]=='0')break;
		int r=(HtoD(s[1])<<4)+HtoD(s[2]),g=(HtoD(s[3])<<4)+HtoD(s[4]),b=(HtoD(s[5])<<4)+HtoD(s[6]);
		int mind=195075;
		int outn=0;
		for(int i=7;i>=0;--i){
			int d = (r-BCOL[i][0])*(r-BCOL[i][0])+(g-BCOL[i][1])*(g-BCOL[i][1])+(b-BCOL[i][2])*(b-BCOL[i][2]);
			if(d<=mind){
				mind = d;
				outn = i;
			}
		}
		cout<<BCOLN[outn]<<"\n";
	}
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  if (S[0] == 'R' && S[1] == 'R' && S[2] == 'R') cout << 3 << endl;
  else if (S[0] == 'R' && S[1] == 'R') cout << 2 << endl;
  else if (S[1] == 'R' && S[2] == 'R') cout << 2 << endl;
  else if (S[0] == 'R' || S[1] == 'R' || S[2] == 'R') cout << 1 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
#define fr first
#define ii pair<int,int>
#define sc second
#define mp make_pair
#define All(v) v.begin(),v.end()
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
int a[n];
memset(a,0,sizeof(a));
for(int i=0;i<m;i++)
{
    int x,y;
    scanf("%d%d",&x,&y);
    x--;
    y--;
    a[x]++;
    a[y]++;
}
int ok = 1;
for(int i=0;i<n;i++)
    if(a[i]%2 == 1)
      ok = 0;
if(ok)
    cout<<"YES";
else 
    cout<<"NO";
}


Measured memory_bytes: 640
#include<stdio.h>

int main() {
    int A[3][3];
    int i,j;
    for(i = 0; i < 3; i++) {
        for(j = 0; j < 3; j++) {
            scanf("%d", &A[i][j]);
        }
    }  
 
    int N;
    scanf("%d", &N);

    int B[N];
    int k;
    for(k = 0; k < N; k++) {
        scanf("%d", &B[k]);

        for(i = 0; i < 3; i++) {
            for(j = 0; j < 3; j++) {
                if(B[k] == A[i][j]) {
                    A[i][j] = 0;
                }
            }
        } 

    } 

    int ans = 0;

    if((A[0][0] + A[0][1] + A[0][2]) == 0) ans = 1;
    else if((A[1][0] + A[1][1] + A[1][2]) == 0) ans = 1;
    else if((A[2][0] + A[2][1] + A[2][2]) == 0) ans = 1;
    else if((A[0][0] + A[1][0] + A[2][0]) == 0) ans = 1;
    else if((A[0][1] + A[1][1] + A[2][1]) == 0) ans = 1;
    else if((A[0][2] + A[1][2] + A[2][2]) == 0) ans = 1;
    else if((A[0][0] + A[1][1] + A[2][2]) == 0) ans = 1;
    else if((A[0][2] + A[1][1] + A[2][0]) == 0) ans = 1;
    else ans = 0;

    if(ans == 1) {
        printf("Yes");
    } else {
        printf("No");
    }

return 0;
}

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

int main(){
	ios::sync_with_stdio(0);
	cout << setprecision(10) << fixed;
	long long h;
	cin >> h;
	int ans = 0;
	while (h > 0){
		ans++;
		h /= 2;
	}
	cout << (1ll << ans) - 1ll;
	return 0;
}



Measured memory_bytes: 256
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li      int32_t
#define lli     long long
#define ulli unsigned long long

#define pn           printf("\n")
#define nl           cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))

#define pb      push_back
#define pob     pop_back
#define itr     iterator
#define sz()    size()
#define szof    sizeof
#define lb      lower_bound
#define ub      upper_bound
#define mp      make_pair
#define vlli    vector<lli>
#define plli    pair<lli,lli>
#define vplli   vector<plli >
#define F       first
#define S       second
#define Dup     erase(unique(V.begin(),V.end()),V.end())

#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound

#define ALL(V)  V.begin(),V.end()

#define MX1     100000
#define MX2     1000000
#define mod     1000000007
#define Inf     1000000000000000
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/

    lli N;
    cin>>N;
    
    cout<<"ABC"<<N;
    








 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
#define asn ans
bool dbg = false;

int n, m, a[101010];
int start_tot[101010], start_cnt[101010];
int end_tot[101010], end_cnt[101010];

void solve() {
    int ans = INF;

    int now = 0;
    int cnt = 0;
    int res = 0;
    FOR(n - 1) {
        if (a[i + 1] < a[i]) {
            now += a[i + 1];
            cnt++;
        } else
            res += a[i + 1] - a[i];

        start_tot[a[i]] += (a[i + 1] - a[i] + m) % m;
        start_cnt[a[i]]++;
        end_tot[a[i + 1]] += (a[i + 1] - a[i] + m) % m;
        end_cnt[a[i + 1]]++;
    }
    FOR(x, m) {
        now += start_tot[x];
        res -= start_tot[x];
        chmin(ans, now + res + cnt);
        //cout << x + 1 << " : " << now << " " << res << endl;
        cnt += start_cnt[x];
        cnt -= end_cnt[x];
        res += end_tot[x];

        now -= cnt;
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    cin >> n >> m;
    FOR(n) {
        cin >> a[i];
        a[i]--;
    }

    solve();
    return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

int cnt[100010];

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

	rep(i, n) {
		int a;
		cin >> a;
		cnt[a]++;
	}

	if (n % 2) {
		if (cnt[0] != 1) {
			cout << 0 << endl;
			return 0;
		}
		for (int i = 2; i < n; i += 2) {
			if (cnt[i] != 2) {
				cout << 0 << endl;
				return 0;
			}
		}
	} else {
		for (int i = 1; i < n; i += 2) {
			if (cnt[i] != 2) {
				cout << 0 << endl;
				return 0;
			}
		}
	}

	n /= 2;

	int ret = 1;
	rep(i, n) {
		ret *= 2;
		ret %= MOD7;
	}

	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int N, M, A[100];

int main(void){
	//IO("test.in", "test.out");
	scanf("%d", &N);
	for(int i = 0; i < N; i++) scanf("%d", &A[i]);
	for(int i = 0; i < N - 1; i++)
		for(int j = i + 1; j < N; j++)
			if(abs(A[j] - A[i]) > M) M = abs(A[j] - A[i]);
	printf("%d\n", M);
}

Measured memory_bytes: 256
import math
A, B, H, M = map(int, input().split())

H = H - 12 if H>12 else H
zahyou_H = [A*math.sin(math.radians(360*H/12+30*M/60)), A*math.cos(math.radians(360*H/12+30*M/60))]
zahyou_M = [B*math.sin(math.radians(360*M/60)), B*math.cos(math.radians(360*M/60))]

kyori = math.sqrt((zahyou_H[0] - zahyou_M[0])**2 + (zahyou_H[1] - zahyou_M[1])**2)
print(kyori)

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

long long int gcd(long long int l, long long int r) {
	assert(l > 0 && r > 0);
	if (l > r)return gcd(r, l);
	else {
		const long long int num = r%l;
		if (num) {
			return gcd(l, num);
		}
		else {
			return l;
		}
	}
}
long long int lca(long long int l, long long int r) {
	return l / gcd(l, r)*r;
}
int getans(const int num, const int rest) {
	if (rest) {
		int ans = 0;
		for (int i = 0; i <= 9; ++i) {
			if (num >= i) {
				ans += getans(num - i, rest - 1);
			}
		}
		return ans;
	}
	else {
		return num == 0;
	}
}
int main() {
	int N;
	cin >> N;
	while (N--) {
		vector<int>nums(10);
		bool ok = false;
		for (int i = 0; i < 10; ++i)cin >> nums[i];
		for (int j = 0; j < 1024; ++j) {
			bitset<10>bs(j);
			vector<int>a, b;
			for (int k = 0; k < 10; ++k) {
				if (bs[k])a.emplace_back(nums[k]);
				else b.emplace_back(nums[k]);
			}
			if (is_sorted(a.begin(), a.end()) && is_sorted(b.begin(), b.end()))ok = true;


		}
		if (ok)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

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


const int MAX_N=2000005;
const ll mod=1000000007;
ll fact[MAX_N+1];
ll inv[MAX_N+1],finv[MAX_N+1];
int inv_init(ll n,ll p){
    inv[1]=1;
    FOR(i,2,n+1) inv[i]=p-(p/i)*inv[p%i]%p;
    fact[0]=finv[0]=1;
    FOR(i,1,n+1){
        fact[i]=fact[i-1]*i%p;
        finv[i]=finv[i-1]*inv[i]%p;
    }
    return 0;
}
ll comb_mod(ll n,ll k,ll p){
    if(k<0||n<k) return 0;
    return finv[k]*finv[n-k]%p*fact[n]%p;
}
int r1,c1,r2,c2;
int main(){
    cin>>r1>>c1>>r2>>c2;
    inv_init(2000004,mod);
    cout<<(comb_mod(r2+c2+2,c2+1,mod)-comb_mod(r2+c1+1,c1,mod)-comb_mod(r1+c2+1,r1,mod)+comb_mod(r1+c1,c1,mod)+mod*10)%mod<<endl;
    return 0;
}

Measured memory_bytes: 47104
# coding:utf-8

import sys
import math
import time
import numpy as np
import collections
from collections import deque
import queue
import copy

# 最大公約数
def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z

# 幅優先探索(BFS)でスタート座標(x, y)からの最大距離返す
def bfs(SS, x, y, H, W):#入力(座標系(迷路), x, y, xの端, yの端)
  x_next = [0, 0, -1, 1]
  y_next = [1, -1, 0, 0]
  tempx = x
  tempy = y
  mlength = 0
  q = deque()
  xytuple = (x, y, 0)
  q.append(xytuple)


  while q:
    xytuple = q.popleft()
    SS[xytuple[0]][xytuple[1]] = "x" #探索した場所は探索できないようにする
    for i in range(4): #このforで上下左右を調べてる
      tempx = xytuple[0] + x_next[i]
      tempy = xytuple[1] + y_next[i]
      #print(tempx, tempy, xytuple[2])
      #print(S)
      if(0 <= tempx and tempx < H and 0 <= tempy and tempy < W and SS[tempx][tempy] == "."):
        temptuple = (tempx, tempy, xytuple[2]+1)
        SS[temptuple[0]][temptuple[1]] = "x" #探索した場所は探索できないようにする
        mlength = max(mlength, xytuple[2] +1)
        q.append(temptuple)
      #print(q)
  return mlength


#X = str(input()).split()
ab = str(input()).split()
a = int(ab[0])
b = int(ab[1])
A = ab[0]
B = ab[1]
C = ""
D = ""

# S = [[0 for i in range(W)] for j in range(H)]

for i in range(a):
  C += B

for i in range(b):
  D += A

if(A>B):
  print(C)
elif(A<B):
  print(D)
else:
  print(D)



Measured memory_bytes: 21668
m,d = gets.chomp.split(/\s/).map{|x| x.to_i}

days = 0
for mm in 1..m
    for dd in 22..d
        e1 = dd.to_s[0].to_i
        e2 = dd.to_s[1].to_i
        days += 1 if e1 >= 2 and e2 >= 2 and e1*e2 == mm
    end
end

puts days

Measured memory_bytes: 1788
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

int gcd(int x, int y) {
    // 最大公約数を求める
    if (y == 0)
        return x;
    gcd(y, x % y);
}

int gcd(vector<int> x) {
    // すべての vector の最大公約数を求める
    int ans = x[0];
    if (x.size() == 1)
        return ans;
    for (int i = 1; i < x.size(); i++) {
        ans = gcd(ans, x[i]);
    }
    return ans;
}

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

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    vector<int> L(N + 1), R(N + 1);
    REP(i, N) { L[i + 1] = gcd(L[i], A[i]); }
    RREP(i, N - 1) { R[i] = gcd(R[i + 1], A[i]); }
    int ans = 0;
    REP(i, N) {
        int left  = L[i];
        int right = R[i + 1];

        ans = max(ans, gcd(left, right));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
use std::io::stdin;
use std::str::FromStr;

fn main(){
    let n: usize = get_one();
    let mut ans = vec![0; n+1];
    for x in 1..101 {
        for y in 1..101 {
            for z in 1..101 {
                let f = x*x + y*y + z*z +
                    x*y + y*z + z*x;
                if f <= n {
                    ans[f] += 1
                }
            }
        }
    }
    for i in 1..n+1 {
        println!("{}", ans[i]);
    }
}

#[allow(dead_code)]
fn get_line() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn get_vec<T: std::str::FromStr>() -> Vec<T> {
    let line = get_line();
    line.split_whitespace().filter_map(|x| x.parse().ok()).collect()
}

#[allow(dead_code)]
fn get_one<T: FromStr + Copy>() -> T {
    let v = get_vec();
    v[0]
}

#[allow(dead_code)]
fn get_pair<T: FromStr + Copy>() -> (T, T) {
    let v = get_vec();
    (v[0], v[1])
}

#[allow(dead_code)]
fn get_triple<T: FromStr + Copy>() -> (T, T, T) {
    let v = get_vec();
    (v[0], v[1], v[2])
}

#[allow(dead_code)]
fn get_chars() -> Vec<char> {
    get_line().chars().collect()
}

#[allow(dead_code)]
fn vec_min(xs: &Vec<i64>) -> i64 {
    xs.iter().map(|&x|x).fold(std::i64::MAX, std::cmp::min)
}

#[allow(dead_code)]
fn vec_max(xs: &Vec<i64>) -> i64 {
    xs.iter().map(|&x|x).fold(std::i64::MIN, std::cmp::max)
}

#[allow(dead_code)]
fn vec_sum(xs: &Vec<i64>) -> i64 {
    xs.iter().fold(0, |acc, &x| acc+x)
}


Measured memory_bytes: 1984
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int mod = 1e9 + 7;
const int maxn = 16;
int n;
int G[maxn][maxn];
LL dp[1<<maxn];
LL p[1<<maxn];


LL dfs(const int i)
{
    if (dp[i] != -1)
        return dp[i];
    dp[i] = p[i];
    for (int k=1; k < i; k++) {
        if ((k & i) != k)
            continue;
        dp[i] = max (dp[i], dfs(k) + dfs(i-k));
    }
    return dp[i];
}

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    
    while (cin >> n) {
        memset(dp,-1,sizeof(dp));
        memset(p,0,sizeof(p));
        FOR(i,0,n) FOR(j,0,n)
            cin >> G[i][j];
        FOR(i,0,1<<n) FOR(j,0,n) FOR(k,j+1,n)
            if ((i & (1<<j)) && (i & (1<<k)))
                p[i] += G[j][k];
        cout << dfs((1<<n) - 1) << endl;
    }
    return 0;
}



Measured memory_bytes: 1280
N=int(input())
W=[input() for i in range(N)]
flag=True
def has_duplicates(seq):
    return len(seq) == len(set(seq))

for i in range(N-1):
    if W[i][-1]!=W[i+1][0]:
        flag=False
if has_duplicates(W) and flag:
    print('Yes')
else:
    print('No')
    


Measured memory_bytes: 3060
N, M = map(int, input().split())
H = [int(x) for x in input().split()]
good = [1]*N
for k in range(M):
    A, B = map(int, input().split())
    if H[A - 1] >= H[B - 1]:
        good[B - 1] = 0
    if H[A - 1] <= H[B - 1]:
        good[A - 1] = 0
print(sum(good))


Measured memory_bytes: 20124
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

int main() {
    int a, b;
    cin >> a >> b;
    for (int x = 1; x <= 100000; ++x) {
        if (x * 8 / 100 == a && x * 10 / 100 == b) {
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>x>>y;
	cout<<(x-1)*(y-1)<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
ans = 0
for _ in range(n):
    a = list(map(int, input().split()))
    acc = c
    for i in range(m):
        acc += a[i] * b[i]
    if acc > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main ()
{
    int n, a, p, k;
    cin >> n;
    a = n / 100;
    k = a * 100 + a * 10 + a;
    p = (a + 1) * 100 + (a + 1) * 10 + a + 1;
    if(n <= k)
        cout << k;
    else
        cout << p;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>

using namespace std;

int main(void){

  int n;
  char ten;
  string blood;
  int a,b,ab,o;
  a = b = ab = o = 0;
  while( cin >> n >> ten >> blood ){
    if( blood == "A" )a++;
    if( blood == "B" )b++;
    if( blood == "AB")ab++;
    if( blood == "O" )o++;
  }
  cout << a << endl;
  cout << b << endl;
  cout  <<  ab << endl;
  cout  << o << endl;
  return 0;
}

Measured memory_bytes: 1204
from math import sqrt

x = int(input()) - 1
pnums = []
if x >= 4:
    for i in range(2, int(sqrt(x))+1):
        for j in pnums:
            if i % j == 0:
                break
        else:    
            pnums.append(i)

while True:
    x += 1
    x_sqrt = sqrt(x)
    if x_sqrt.is_integer():
        pnums.append(x_sqrt)
        continue
    
    for a in pnums:
        if x % a == 0:
            break
    else:
        print(x)
        break


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> prl;
typedef vector<ll> vcl;
typedef map<ll,ll> mapl;
typedef unordered_map<ll,ll> umap;
#define pb push_back
#define all(v) v.begin(), v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;

int main() {
    // your code goes here
    int x;
    cin >> x;
    x=x/200;
    cout << 10-x << endl;
    return 0;
}

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

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

// -------------------------------------------

const long long MOD = 1000000007;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint dp[100010][13];

void solve(std::string S){
  ll n = S.size();
  dp[0][0] = 1;
  for(ll i=0; i<n; i++) {
    if(S[i]=='?') {
      for(ll d=0; d<=9; d++) {
	for(ll j=0; j<13; j++) {
	  dp[i+1][(j*10+d)%13] += dp[i][j];
	}
      }
    } else {
      for(ll j=0; j<13; j++) {
	dp[i+1][(j*10+(S[i]-'0'))%13] += dp[i][j];
      }
    }
  }
    
  std::cout << dp[n][5] << std::endl;
}

int main(){
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
int main(){
 int N;
  cin>>N;
  vector<int>ans(1000000,0);
  for(int i=1;i<=100;i++){
  	for(int j=1;j<=100;j++){
    	for(int k=1;k<=100;k++){
        int num=i*i+j*j+k*k+i*j+j*k+k*i;
          ans.at(num)+=1;
        }
    }
  }
  for(int i=1;i<=N;i++){
  	cout<<ans.at(i)<<endl;
  }
}


Measured memory_bytes: 7052
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
char a[50][50], b[50][50];
int main()
{
	int n;
	scanf("%d", &n);
	string s;
	cin >> s;
	n = 0;
	int m = 0;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'I')n++;
		else n--;
		m = max(m, n);
	}
	printf("%d\n", m);
}

Measured memory_bytes: 256
n, m = map(int, input().split())
pyidx = []
for i in range(m):
    py_tmp = list(map(int, (input()).split() + [str(i)]))
    pyidx += [py_tmp]

pyidx = sorted(pyidx, key=lambda x: x[1])

counter = [1] * n

ans = []
for i, pyx in enumerate(pyidx):
    p, y, idx = pyx[0], pyx[1], pyx[2]
    x_new = counter[p-1]
    counter[p-1] += 1
    ans.append([str(p).zfill(6) + str(x_new).zfill(6), idx])

ans = sorted(ans, key=lambda x: x[1])
for i in ans:
    print(i[0])

Measured memory_bytes: 47136
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Comparator;
import java.util.PriorityQueue;
public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));
        String n = scan.readLine();
        comp c = new comp();
        PriorityQueue<Integer> set = new PriorityQueue<>(2000000, c);
        while (!n.equals("end")){
            if(n.startsWith("insert")){
                int x = Integer.parseInt(n.substring(n.indexOf(" ") + 1));
                set.add(x);
            }
            else{
                System.out.println(set.poll());
            }
            n = scan.readLine();
        }
    }
    static class comp implements Comparator<Integer>{
        public int compare(Integer x, Integer y){
            if(x > y){
                return -1;
            }
            else{
                return 1;
            }
        }
    }
}


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

public class ABC156_A
{

    public static void Main()
    {
        int a = 0, b = 0;
        InLine(ref a, ref b);
        if (a < 10) b += 100 * (10 - a);
        Out(b);
    }

    //Template
    private static object[] nullobjs = null;
    private static object nullobj = null;

    public static int ConvertInt(char c)
    {
        return c;
    }

    public static void InArgs<A>(int count, ref A[] var)
    {
        InArgs(count, ref var, ref nullobjs, ref nullobjs);
    }

    public static void InArgs<A, B>(int count, ref A[] var1, ref B[] var2)
    {
        InArgs(count, ref var1, ref var2, ref nullobjs);
    }

    public static void InArgs<A, B, C>(int count, ref A[] var1, ref B[] var2, ref C[] var3)
    {
        A a = default(A);
        B b = default(B);
        C c = default(C);
        for (int i = 0; i < count; i++)
        {
            InLine(ref a, ref b, ref c);
            var1[i] = a;
            if (var2 != null) var2[i] = b;
            if (var3 != null) var3[i] = c;
        }
    }

    public static void InLine<A>(ref A var)
    {
        InLine(ref var, ref nullobj, ref nullobj);
    }

    public static void InLine<A, B>(ref A var1, ref B var2)
    {
        InLine(ref var1, ref var2, ref nullobj);
    }

    public static void InLine<A, B, C>(ref A var1, ref B var2, ref C var3)
    {
        object[] o = new object[] { var1, var2, var3 };
        Type[] t = new Type[] { typeof(A), typeof(B), typeof(C) };
        if (var3 == null)
        {
            if (var2 == null) o = new object[] { var1 };
            else o = new object[] { var1, var2 };
        }

        string[] s = Console.ReadLine().Split(' ');
        for (int i = 0; i < s.Length; i++)
        {
            if (typeof(int) == t[i]) o[i] = int.Parse(s[i]);
            else if (typeof(long) == t[i]) o[i] = long.Parse(s[i]);
            else if (typeof(double) == t[i]) o[i] = double.Parse(s[i]);
            else o[i] = s[i];
        }
        var1 = (A)o[0];
        if (var2 != null) var2 = (B)o[1];
        if (var3 != null) var3 = (C)o[2];
    }

    public static string JoinString(object[] obj, string sep)
    {
        return string.Join(sep, obj.Select(i => i.ToString()).ToArray());
    }

    public static void Out(object o)
    {
        Console.WriteLine(o);
    }

    public static void OutYes()
    {
        Console.WriteLine("Yes");
    }

    public static void OutNo()
    {
        Console.WriteLine("No");
    }
    public static void OutYES()
    {
        Console.WriteLine("YES");
    }

    public static void OutNO()
    {
        Console.WriteLine("NO");
    }

    private static Dictionary<A, B> PutDict<A, B>(A[] key, B[] value)
    {
        if (key.Length != value.Length) return null;
        var dic = new Dictionary<A, B>();
        for (int i = 0; i < key.Length; i++)
        {
            if (!dic.ContainsKey(key[i])) dic.Add(key[i], value[i]);
            else dic[key[i]] = value[i];
        }
        return dic;
    }
}

Measured memory_bytes: 11220
def f(h, w):
    for i in range(h):
        if i == 0 or i == (h - 1):
            print("#"*w)
        else:
            print("#"+"."*(w-2)+"#")

while True:
    h, w = map(int, input().split())
    if h == w == 0:
        break

    f(h, w)
    print()


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

struct StNumCnt
{
  StNumCnt() : m_nNum(0), m_nCnt(0) { }

  int m_nNum;
  int m_nCnt;
};

class CGreater_nCnt
{
  public:
    bool operator()(const StNumCnt& lhs, const StNumCnt& rhs)
    {
      return lhs.m_nCnt > rhs.m_nCnt;
    }
};

void input(vector<int>& rvnNum)
{
  int nNumSiz;
  cin >> nNumSiz;
  rvnNum.resize(nNumSiz);

  for (int& rnNum : rvnNum)
    cin >> rnNum;
}

int calcMinChangeCnt(const vector<int>& cnrvnNum)
{
  map<int, int> mpNumCntEvn, mpNumCntOdd;

  for (int i = 0; i < cnrvnNum.size(); ++i)
    if ( i % 2 == 0 )
      mpNumCntEvn[ cnrvnNum[i] ]++;
    else
      mpNumCntOdd[ cnrvnNum[i] ]++;

  vector<StNumCnt> voNumCntEvn( mpNumCntEvn.size() ),
                   voNumCntOdd( mpNumCntOdd.size() );

  int n = 0;
  for (pair<int, int> PNumCnt : mpNumCntEvn)
  {
    voNumCntEvn[n].m_nNum   = PNumCnt.first;
    voNumCntEvn[n++].m_nCnt = PNumCnt.second;
  }

  n = 0;
  for (pair<int, int> PNumCnt : mpNumCntOdd)
  {
    voNumCntOdd[n].m_nNum   = PNumCnt.first;
    voNumCntOdd[n++].m_nCnt = PNumCnt.second;
  }

  sort(begin(voNumCntEvn), end(voNumCntEvn), CGreater_nCnt() );
  sort(begin(voNumCntOdd), end(voNumCntOdd), CGreater_nCnt() );

  int nMinChangeCnt = INT_MAX;

  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 2; ++j)
      if (voNumCntEvn[i].m_nNum != voNumCntOdd[j].m_nNum)
        nMinChangeCnt = 
          min( nMinChangeCnt, 
               (int)cnrvnNum.size() - voNumCntEvn[i].m_nCnt - voNumCntOdd[j].m_nCnt );

  return nMinChangeCnt;
}
  
int main()
{
  vector<int> vnNum;
  
  input(vnNum);
  cout << calcMinChangeCnt(vnNum) << endl;

  return 0;
}

Measured memory_bytes: 8964
#include <bits/stdc++.h>
#include <time.h>
#define first fi
#define second se
 
 
using namespace std;
 
typedef long long ll;
typedef double db;
int xx[4] = {1,-1,0,0};
int yy[4] = {0,0,1,-1};
const double eps = 1e-9;
typedef pair<int,int>  P;
const int maxn = 2e6 + 5000;
const ll mod = 1e9 + 7;
inline int sign(db a) {
    return a < -eps ? -1 : a > eps;
}
inline int cmp(db a,db b) {
    return sign(a - b);
}
ll mul(ll a,ll b,ll c) {
    ll res = 1;
    while(b) {
        if(b & 1) res *= a,res %= c;
        a *= a,a %= c,b >>= 1;
    }
    return res;
}
ll phi(ll x) {
    ll res = x;
    for(ll i = 2; i * i <= x; i++) {
        if(x % i == 0) res = x / i * (i - 1);
        while(x % i == 0) x /= i;
    }
    if(x > 1) res = res / x  * (x - 1);
    return res;
}
ll c,n,k,x,y;
string str;
ll a[maxn],b[maxn],r[maxn],fa[maxn];
ll Find(int x) {
    if(x == fa[x]) return fa[x];
//    int i = fa[x];
    fa[x] = Find(fa[x]);
//    r[x] += r[i];
    return fa[x];
}
int main() {
    int m;
    ios::sync_with_stdio(false);
    while(cin >> n >> m) {
        for(int i = 1; i <= n; i++) fa[i] = i,r[i] = 1;
        for(int i = 1; i <= m; i++) {
            cin >> a[i] >> b[i];
        }
        vector<ll>anss;
        ll ans = (n - 1) * (n)  / 2;
        for(int i = m; i >= 1; i--) {
                anss.push_back(ans);
            int X = Find(a[i]);
            int Y = Find(b[i]);
            if(X != Y) {
                fa[Y] = X;
                ans -= r[X] * r[Y];
                r[X] += r[Y];
            }
        }
        reverse(anss.begin(),anss.end());
        for(auto d:anss){
            cout << d <<endl;
        }
 
    }
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}

Measured memory_bytes: 13300
import heapq
x, y ,z, k = map(int, input().split( ))

a = list(map(int, input().split( )))
b = list(map(int, input().split( )))
c = list(map(int, input().split( )))

a.sort(reverse = True)
b.sort(reverse = True)
c.sort(reverse = True)
K = []
flag = False

for i in range(x):
    for j in range(y):
        for l in range(z):
            heapq.heappush(K,a[i]+b[j]+c[l])
            if len(K)>k:
                mn = heapq.heappop(K)
                if a[i]+b[j]+c[l] == mn:
                    break
        if l == 0:
            break
    if j ==0:
        break
K.sort(reverse= True)
for i in range(k):
    print(K[i])


Measured memory_bytes: 56156
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)
#define RRANGE(i, m, n) for(ll i = (m); i >= (n); --i)
#define POSITIVE(x) (x)=((x) < 0) ? 0 : (x)

ll pow(ll x, ll y) {
    ll ret = 1;
    while(y-- > 1) ret *= x;
    return ret;
}

ll gcd(ll x, ll y) {
    if (x < y) swap(x, y);
    if (y == 0) return x;
    ll r = x / y;
    return gcd(y, x-y*r);
}

int run(istream& in, ostream& out) {
    ll N;
    in >> N;
    vector<ll> X(N);
    ll total = 0;
    REP(i, N) {
        in >> X[i];
        total += X[i];
    }
    ll P = (double)total/N;
    ll c1 = 0, c2 = 0;
    REP(i,N) {
        c1 += (X[i] - P)*(X[i] - P);
        c2 += (X[i] - P-1)*(X[i] - P-1);
    }
    ll ans = min(c1, c2);
    out << ans << endl;
    return 0;
}

int main() {
    return run(cin, cout);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    string s = "";
    for (int i = 0; i < 4; i++) {
        int n;
        cin >> n;
        s += to_string(n);
    }
    sort(s.begin(), s.end());
    if (s == "1479") {
        puts("YES");
    }
    else {
        puts("NO");
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <map>
#define INF 10000000
using namespace std;
typedef pair<string ,int>P;
int cnt;

int bfs(string worm){
  map<string,int>used;
  queue<P> que;
  que.push(P(worm,0));
  string next;
  
  while(!que.empty()){
    char tmp;
    P p = que.front();
    que.pop();
    if(used[p.first] == 1)continue;
    bool f = true;
    string str = p.first;
    for(int i = 0 ; i < p.first.size()-1 ; i++ ){
      if(str[i] != str[i+1])f = false;
    }
    if(f)return p.second;
    used[p.first] = 1;
    for(int i = 0 ; i < worm.size()-1 ; i++ ){
      if(str[i] != str[i+1]){
	if(str[i] != 'r' && str[i+1] != 'r'){
	  tmp = 'r';
	}else if(str[i] != 'g' && str[i+1] != 'g'){
	  tmp = 'g';
	} else {
	  tmp = 'b';
      }
	next = str;
	next[i] = next[i+1] = tmp;
	que.push(P(next,p.second+1));

      }
    }
  }
  return -1;
}

int main(){
  string worm;
  while(cin >> worm){
    if(worm[0] == '0')break;
    cnt = 0;
    int ret = bfs(worm);
    if(ret == -1){
      cout << "NA" << endl;
    }else cout << ret << endl;
    
  }
  return 0;
}

Measured memory_bytes: 3392
import java.util.*;
//import java.math.BigInteger;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        //ArrayList <String> arrlist = new ArrayList <String>();
        TreeMap <String,Integer> treemap = new TreeMap <String,Integer>();
        int max = 0;
        
        for(int i=0; i<N; i++){
            String S = sc.next();
            if(treemap.containsKey(S)){
                treemap.put(S, treemap.get(S)+1);
            }else{
                treemap.put(S, 1);
            }
            //System.out.println(treemap);
        }
        //for(Map.Entry<String, String> entry : treemap.entrySet()){
        for(String S: treemap.keySet()){
            if(max < treemap.get(S)){
                max = treemap.get(S);
            }
        }
        for(String S: treemap.keySet()){
            if(max == treemap.get(S)){
                System.out.println(S);
            }
        }
    }
}

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

int main()
{
    int n;
    cin>>n;
    
    if(n%10==7)
    {
        cout<<"Yes";
    }
    else
    {
        n=n/10;
        if(n%10==7)
        {
            cout<<"Yes";
        }
        else
        {
            n=n/10;
            if(n%10==7)
            {
                cout<<"Yes";
            }
            else
            {
                cout<<"No";
            }
        }
    }
}

Measured memory_bytes: 3632