akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <bitset>
#include <cstdio>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define MAX 200200
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,a[MAX],val[MAX],cnt[MAX];
char s[MAX];
struct SegmentTree
{
#define lson (now<<1)
#define rson (now<<1|1)
	int t[MAX<<2];
	void Build(int now,int l,int r)
	{
		if(l==r){t[now]=1-1e9;return;}
		int mid=(l+r)>>1;
		Build(lson,l,mid);Build(rson,mid+1,r);
		t[now]=max(t[lson],t[rson]);
	}
	void Modify(int now,int l,int r,int p,int w)
	{
		if(l==r){t[now]=w;return;}
		int mid=(l+r)>>1;
		if(p<=mid)Modify(lson,l,mid,p,w);
		else Modify(rson,mid+1,r,p,w);
		t[now]=max(t[lson],t[rson]);
	}
	int Query(int now,int l,int r,int L,int R)
	{
		if(L<=l&&r<=R)return t[now];
		int mid=(l+r)>>1,ret=-1e9;
		if(L<=mid)ret=max(ret,Query(lson,l,mid,L,R));
		if(R>mid)ret=max(ret,Query(rson,mid+1,r,L,R));
		return ret;
	}
}Odd,Even;
bool check(int mx,int Q)
{
	if(Q<0)return false;
	if(Q&1)return Odd.Query(1,1,n,mx,n)>=Q;
	else return Even.Query(1,1,n,mx,n)>=Q;
}
int main()
{
	n=read();
	for(int i=1,mx=0;i<=n;++i)
	{
		a[i]=read();
		if(a[i]>mx)val[i]=2,mx=a[i];
		else val[i]=1;
	}
	Odd.Build(1,1,n);
	for(int i=n;i;--i)
	{
		int mx1=Odd.Query(1,1,n,a[i],n),mx0=Even.Query(1,1,n,a[i],n);
		if(val[i]&1)Odd.Modify(1,1,n,a[i],mx0+val[i]),Even.Modify(1,1,n,a[i],mx1+val[i]);
		else Odd.Modify(1,1,n,a[i],mx1+val[i]),Even.Modify(1,1,n,a[i],mx0+val[i]);
	}
	for(int i=n;i;--i)cnt[i]=cnt[i+1]+val[i]-1;
	int cntX=0,cntY=0,mxX=0,mxY=0;
	for(int i=1;i<=n;++i)
	{
		Odd.Modify(1,1,n,a[i],1-1e9);Even.Modify(1,1,n,a[i],0);
		if(check(mxY,cntX+cnt[i+1]-cntY+(a[i]>mxX)))s[i]='0',cntX+=a[i]>mxX,mxX=max(mxX,a[i]);
		else if(check(max(mxX,a[i]),cntY+cnt[i+1]-cntX-(a[i]>mxX)))s[i]='0',cntX+=a[i]>mxX,mxX=max(mxX,a[i]);
		else s[i]='1',cntY+=a[i]>mxY,mxY=max(mxY,a[i]);
	}
	if(cntX!=cntY){puts("-1");}
	else printf("%s",s+1);
	return 0;
}

Measured memory_bytes: 9872
MOD = 10**9 + 7

N = gets.to_i
S = gets.chomp

char_cnt = {}
S.chars do |c|
  char_cnt[c] = 0 unless char_cnt.key?(c)
  char_cnt[c] += 1
end

ans = 1
char_cnt.each_value do |v|
  ans = (ans * (v + 1) % MOD) % MOD
end
puts ans - 1

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const int MN = 22;

int L;
vector<pii> g[MN];

int main() {
	cin >> L;

	vi vec;
	int x = L;

	while (x > 0) {
		vec.pb(x & 1);
		x /= 2;
	}

	reverse(ALL(vec));

	int now = 0;
	int ml = 1; //[0, ml)

	for (int i = 1; i < (int)vec.size(); ++i) { 
		if (vec[i]) {
			g[now].eb(now + 1, 1);
			g[now].eb(now + 1, ml + 1);
			g[0].eb(now + 1, 0);
			ml = ml * 2 + 1;
		} else {
			g[now].eb(now + 1, 0);
			g[now].eb(now + 1, ml);
			ml = ml * 2;
		}
		++now;
	}

	int N = now + 1;
	vector<pair<pii, int>> ans;

	rep(i, N) {
		for (auto e : g[i]) {
			ans.eb(mp(i + 1, e.fi + 1), e.se);
		}
	}

	printf("%d %d\n", N, ans.size());
	rep(i, ans.size()) {
		printf("%d %d %d\n", ans[i].fi.fi, ans[i].fi.se, ans[i].se);
	}

	return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
cost = [1000000 for i in range(n)]
cost[0] = 0
for i in range(1,n):
    if i-1>=0 and i-2>=0:
        cost[i] = min(cost[i-1]+abs(h[i]-h[i-1]),cost[i-2]+abs(h[i]-h[i-2]))
    elif i-2<=0 and i-1>=0:
        cost[i] = cost[i-1]+abs(h[i]-h[i-1])
    else:
        print("Error")
print(cost[n-1])



Measured memory_bytes: 13924
import sys
input = sys.stdin.readline

lst = []
lst_append = lst.append
H, W, N = map(int, input().split())
tmplst = [-1, 0, 1]
for _ in range(N):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    for i in range(-1, 2):
        for j in range(-1, 2):
            if 1 <= a + i <= H - 2 and 1 <= b + j <= W - 2:
                lst_append((a + i, b + j))

lst.sort()
ans = [0] * 10
ans[0] = (H - 2) * (W - 2)

tmp = None
count = 0
for i in lst:
    if i == tmp:
        count += 1
    else:
        ans[0] -= 1
        ans[count] += 1
        count = 1
        tmp = i

ans[0] -= 1
ans[count] += 1
print (*ans, sep = '\n')

Measured memory_bytes: 128036
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

int main()
{
  ll n, k;
  ll ans = 0;

  cin >> n >> k;

  for(ll i = k+1; i <= n; i++){
    ll l = 0, r = 100000, m;
    while(l < r){
      m = (l + r) / 2 + 1;
      if(m * i <= n) l = m;
      else r = m - 1;
    }

    ans += (i - k) * l + max(0LL, n - l * i - k + (k != 0));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

vector<int> G[200001];
bool judge(int a,int b){
  if ((a+b)%3 == 0 || (a*b) % 3 == 0) return true;
  else return false;
}

int main(){
  int N,v[100000];
  cin>>N;
  map<int,int> me,mo;
  for (int i(0);i<N;i++){
    cin>>v[i];
    if(i%2 == 0) me[v[i]]++;
    else mo[v[i]]++;
  }
  vector<pair<int,int>> po,pe;
  for (auto mi:me){
    pe.push_back({mi.second,mi.first});
  }
  for (auto mi:mo){
    po.push_back({mi.second,mi.first});
  }
  sort(pe.rbegin(),pe.rend());
  sort(po.rbegin(),po.rend());
  if (pe[0].second == po[0].second){
    if (int(pe.size()) == 1 && int(po.size()) == 1){
      cout << N/2 << endl;
    }else if (int(pe.size()) == 1){
      cout << N - pe[0].first - po[1].first << endl;
    }else if(int(po.size()) == 1){
      cout << N - pe[0].first - pe[1].first << endl;
    }else{
      cout << min(N - pe[0].first- po[1].first,N-pe[1].first-po[0].first) << endl;
    }
  }else{
    cout << N - pe[0].first - po[0].first << endl;
  }
  return 0;
}



Measured memory_bytes: 11132
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <string>
using namespace std;




int main()
{
	string a;
	cin >> a;
	int ans = 0;
	for (int i = 0; i < 4; i++) {
		if (a[i] == '+')
			ans++;
		else
			ans--;
	}
	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
n = int(input())
arr = list(map(int , input().split()))
cur = 0
a = 0
b = 0
prea=0
preb=0
resa = 0
resb =0
for i in range(0 , n):
	prea = prea+arr[i]
	if (i% 2 ==0 and prea<=0):
		resa = resa-prea+1
		prea=1
	if i%2 ==1 and prea>=0:
		resa = resa+prea+1
		prea=-1
for i in range(0 , n):
	preb = preb+arr[i]
	if (i%2==1 and preb<=0):
		resb = resb+(-preb+1)
		preb=1
	if i%2 ==0 and preb>=0:
		resb =resb+ preb+1
		preb=-1
print(min(resa , resb))

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

int N, A[10];

long long DFS(int n, long long a, long long b) {
	if (n == N) return a + b;
	return DFS(n + 1, a, b * 10 + A[n]) + DFS(n + 1, a + b, A[n]);
}

int main() {
	string S;
	cin >> S;
	N = S.size();
	for (int i = 0; i < N; i++) {
		A[i] = S[i] - '0';
	}
	cout << DFS(1, 0, A[0]);
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
void p(string s){
  cout << s <<endl;
}
//-----------------------------------------

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n, m, l;
  cin >> n >> m >> l;

  vvll m1(n,vll(m));
  vvll m2(m,vll(l));

  REP(i,n) REP(j,m) cin >> m1[i][j];
  REP(i,m) REP(j,l) cin >> m2[i][j];

  vvll m3(n,vll(l,0));

  REP(i,n){
    REP(j,l){
      REP(k,m) m3[i][j] += m1[i][k] * m2[k][j];
    }
  }

  REP(i,n){
    REP(j,l){
      if(j) cout << " ";
      cout << m3[i][j];
    }
    cout <<endl;
  }




  return 0;
}



Measured memory_bytes: 3320
#include<stdio.h>
int main()
{
    int n,i;
    char a[100];
    int sum;
    while(scanf("%d",&n)!=EOF)
    {
        sum=0;
        scanf("%s",a);
        for(i=0; i<n; ++i)
        {
            if(a[i]=='A')
            {
                if(a[i+1]=='B' && a[i+2]=='C')
                    sum++;
            }
        }
        printf("%d\n",sum);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	ll n;
	cin >> n;
	
	ll ans = INF;
	for(ll i = 1; i * i <= n; i++) {
		if(n % i == 0) ans = min(ans, n / i + i - 2ll);
	}
	
	cout << ans << endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

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

using namespace std;

#define DB( x ) cout << #x << " = " << x << endl;
#define LEFT(n) (2 * (n))
#define RIGHT(n) (2 * (n) + 1)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> node;
//typedef vector <vector <ll>> matrix;

const ll INF = 1e16;
const double EPS = 1e-9;
const ll MOD = (ll)(1e9 + 7);
const ll MAXV = (ll)(2e5 + 10);
const ll MAXE = (ll)(1e6 + 10);

ll n;

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

	cin >> n;

	cout << (n * (n - 1LL)) / 2LL << "\n";
	return 0;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N; cin >> N;
    vector<ll> A(N); REP(i,N) cin >> A[i];
    SORT(A); REVERSE(A);
    ll ans = 0, ans1 = 0, ans2 = 0;
    if(N%2){
        REP(i,(N+1)/2-2) ans1 += 2*A[i];
        ans1 += A[(N+1)/2-2] + A[(N+1)/2-1];
        REP(i,N/2) ans1 -= 2*A[N-1-i];

        REP(i,N/2) ans2 += 2*A[i];
        REP(i,(N+1)/2-2) ans2 -= 2*A[N-1-i];
        ans2 -= A[(N+1)/2-1] + A[(N+1)/2];
    }
    else{
        REP(i,N/2-1) ans1 += 2*A[i];
        ans1 += A[N/2-1];
        REP(i,N/2-1) ans1 -= 2*A[N-1-i];
        ans1 -= A[N/2];
    }
    ans = max(ans1, ans2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;

    string S,T;
    ll N,ans,A;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>S>>T;
    sort(S.begin(),S.end());
    sort(T.rbegin(),T.rend());
    cout<<(S<T?"Yes":"No");
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();

		if(a<b) {
			System.out.println("a < b");
		}else if(a>b){
			System.out.println("a > b");
		}else {
			System.out.println("a == b");
		}
	}
}



Measured memory_bytes: 26032
import java.util.*;
 
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int diss = Math.max(a, b) - Math.min(a, b);

        if (diss % 2 == 1) {
            System.out.println("IMPOSSIBLE");
        } else {
            int half = diss / 2;
            System.out.println(Math.min(a, b) + half);
        }
	}
}


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

#define unit 0
int N; // 葉の数
vector<int> value; // セグ木,サイズは後。
using ll =long long;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
//Write From this Line
// セグ木操作用の関数の定義
void update(int i, int x) { // 葉の i 番目をxに変更
	i += N - 1;
	value[i] = x;
	while (i > 0){
		i = (i - 1) / 2 ;
		value[i] = max(value[i * 2 + 1], value[i * 2 + 2]);
	}
}
int query(int a, int b, int k, int l, int r) { // [a,b)を聞かれている時,kに聞く。k は[l,r)を担当する(rは担当しない
	if(r <= a || b <= l) return unit; // 区間が全くかぶらない
	if(a <= l && r <= b) return value[k]; // 区間が完全にかぶっている。
	else {
		int c1 = query(a, b, k * 2 + 1, l, (l + r) / 2);
		int c2 = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return max(c1, c2);
	}
}

int main()
{
	int n;
	cin >> n;
	N = 1;
	while(N < n) N *= 2;
	value = vector<int> (2 * N - 1, unit);
	rep(i,n){
		int x;
		cin >> x;
		update(i,x);
	}
	rep(i,n){
		cout << max(query(0,i, 0, 0, N), query(i+1,N,0,0,N)) << endl;
	}
}


Measured memory_bytes: 5284
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>

#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
using namespace std;

int main(int argc, char *argv[]) {
	string s;
	long long int k;
	cin >> s >> k;
	long long int c1 = 0, c2 = 0, c3 = 0;
	string s1 = s, s2 = s + s, s3 = s + s + s;
	for (int i = 1; i < s1.size(); i++) {
		if (s1[i] == s1[i - 1]) {
			s1[i] = ' ';
			c1++;
		}
	}
	for (int i = 1; i < s2.size(); i++) {
		if (s2[i] == s2[i - 1]) {
			s2[i] = ' ';
			c2++;
		}
	}
	for (int i = 1; i < s3.size(); i++) {
		if (s3[i] == s3[i - 1]) {
			s3[i] = ' ';
			c3++;
		}
	}
	if (k == 1)
		cout << c1 << endl;
	else 
		cout << (c3 - c1) * ((k - 1) / 2) + c1 + ((k + 1) % 2) * (c2 - c1) << endl;
	
}














Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

int main() {
    int h, w;
    cin >> h >> w;

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

    vector<vector<int>> cnt(h, vector<int>(w, 1e9));
    cnt[0][0] = s[0][0] == '#' ? 1 : 0;

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (i) {
                if (s[i][j] == s[i - 1][j]) {
                    cnt[i][j] = min(cnt[i][j], cnt[i - 1][j]);
                } else {
                    cnt[i][j] = min(cnt[i][j], cnt[i - 1][j] + 1);
                }
            }
            if (j) {
                if (s[i][j] == s[i][j - 1]) {
                    cnt[i][j] = min(cnt[i][j], cnt[i][j - 1]);
                } else {
                    cnt[i][j] = min(cnt[i][j], cnt[i][j - 1] + 1);
                }
            }
        }
    }

    cout << (cnt[h - 1][w - 1] + 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 3628
def resolve():
    n=int(input())
    s=input()
    mx=0
    alp=list('abcdefghijklmnopqrstuvwxyz')
    l=[0 for i in alp]
    for i in range(n):
        lt=s[:i+1]
        lb=s[i+1:]
        fuku=0
        for j in alp:
            if j in lt and j in lb:
                fuku+=1
        mx=max(mx,fuku)
    print(mx)
resolve()

Measured memory_bytes: 39252
def main():
  ## IMPORT MODULE
  from collections import deque
  import sys
  input=lambda :sys.stdin.readline().rstrip()

  #sys.setrecursionlimit(100000)

  #f_inf=float("inf")
  #MOD=10**9+7
  
  if 'get_ipython' in globals(): 
    ## SAMPLE INPUT
    h, w, k = 3, 5, 2
    x1, y1, x2, y2 = 3, 2, 3, 4
    dist = ['.....', '.@..@', '..@..']

  else:
    ##INPUT 
    h, w, k = map(int, input().split())
    x1, y1, x2, y2 = map(int, input().split())
    dist = [input() for _ in range(h)]

  ## SUBMITION CODES HERE
  x1-=1
  y1-=1
  x2-=1
  y2-=1

  ans = [[-1]*w for _ in range(h)]
  ans[x1][y1] = 0

  que = deque()
  que.append((x1, y1))
  direction = ((1, 0), (-1, 0), (0, -1), (0, 1))
  while que:
    x, y = que.popleft()

    if x == x2 and y == y2:
      exit(print(ans[x][y]))

    for dx, dy in direction:
      for i in range(1, k+1):
        kx = x + dx*i
        ky = y + dy*i

        if not(0 <= kx < h and 0 <= ky < w) or dist[kx][ky] == "@":
          break

        if 0 <= ans[kx][ky] <= ans[x][y]:
          break

        if ans[kx][ky] == -1:
          que.append((kx, ky))

        ans[kx][ky] = ans[x][y]+1

  print(-1)

main()

Measured memory_bytes: 36732
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    string s;cin >> s;
    unordered_map<int, int> m;

    m[0] = 0;
    int xr = 0;
    FOR(i, s.length()){
        xr  ^= (1 << (s[i] - 'a'));
        int ans= 1e9;
        for(int bi  = 0; bi < 26; bi++){
            if(m.find((xr ^ (1 << bi))) != m.end()){
                ans = min(ans, m[(xr ^ (1 << bi))] + 1);
            }
        }
        if(ans <= s.length()){
            if(xr != 0)m[xr]=ans;
        }
    }
    if(xr == 0)cout << 1;
    else cout << m[xr];
}




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

int main( void )
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << ( ( a + b ) > ( c + d )
                  ? "Left"
                  : ( ( a + b ) < ( c + d ) ? "Right" : "Balanced" ) )
         << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>    
using namespace std;
#define ll long long 
#define pi pair<int,int>
#define pb push_back
#define inf 1e16
#define mod 1000000007
#define en '\n'
int pw(int a, int b){
	int ans = 1;
	while(b){
		if(b&1)ans = (ans*a)%mod;
		a = (a*a)%mod;
		b>>=1;
	}
	return ans;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll a,b;cin>>a>>b;
	ll g = __gcd(a,b);
	ll ans = (a*b)/g;
	cout<<ans<<en;
	return 0 ; 
}



Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

typedef pair<int, int> pii;

using namespace std;

int a[100000];

int main()
{
	fill(a, a + 100000, 2147483647);

	int n, q;
	cin >> n >> q;

	for (int i = 0; i < q; i++)
	{
		int c, x, y;
		cin >> c >> x >> y;

		switch (c)
		{
		case 0:
			a[x] = y;
			break;
		case 1:
		{
			int mini = a[x];
			for (int j = x + 1; j <= y; j++)
			{
				mini = min(mini, a[j]);
			}
			cout << mini << endl;
		}
			break;
		}
	}

	return 0;
}




Measured memory_bytes: 3476
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)


int main() {
  ll N, M, L;
  cin >> N >> M >> L;

  ll INF = 1e15;
  vector<vector<ll>> C(N, vector<ll>(N, INF));
  vector<vector<ll>> T(N, vector<ll>(N, INF));

  rep0(i, M) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    C[a][b] = c;
    C[b][a] = c;
  }

  rep0(k, N) {
    rep0(i, N) {
      rep0(j, N) {
        C[i][j] = min(C[i][j], C[i][k] + C[k][j]);
      }
    }
  }

  rep0(i, N) {
    rep0(j, N) {
      if (C[i][j] <= L) T[i][j] = 1;
    }
  }

  rep0(k, N) {
    rep0(i, N) {
      rep0(j, N) {
        T[i][j] = min(T[i][j], T[i][k] + T[k][j]);
      }
    }
  }

  ll Q;
  cin >> Q;
  rep0(i, Q) {
    ll s, t;
    cin >> s >> t;
    s--; t--;
    ll ans = T[s][t];
    if (ans == INF) ans = -1;
    else ans--;
    cout << ans << BR;
  }

  return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, k;
  cin >> a >> b >> k;
  int cnt = 0;
  for(int i = 100; i > 0; i--){
    if(a%i == 0 && b%i == 0) cnt++;
    if(cnt == k){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
import sys
import io, os
input = sys.stdin.buffer.readline
#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

w, h = map(int, input().split())
P = [int(input()) for _ in range(w)]
Q = [int(input()) for _ in range(h)]

E = []
for p in P:
    E.append((p, 0))
for q in Q:
    E.append((q, 1))
E.sort(reverse=True)

a = w+1
b = h+1
ans = 0
while a >1 or b > 1:
    c, t = E.pop()
    if t == 0:
        ans += c*b
        a -= 1
    else:
        ans += c*a
        b -= 1
print(ans)


Measured memory_bytes: 32096
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
int count = 0;
  
  if ((N / 2) * 2 == N) {
    
  for(int j = 0; j < N / 2; j++) {
  count += vec.at(2 * j) - vec.at(2 * j + 1);
  }
  }
    else {
      for(int j = 0; j < (N - 1) / 2; j++) {
  count += vec.at(2 * j) - vec.at(2 * j + 1);
  }
      count += vec.at(N - 1);
    }
      cout << count << endl;
      
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
	"sort"
)

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	var x, y, z, k int
	fmt.Fscan(fp, &x, &y, &z, &k)
	aList := make([]float64, x)
	bList := make([]float64, y)
	cList := make([]float64, z)
	for i := 0; i < x; i++ {
		fmt.Fscan(fp, &aList[i])
	}
	for i := 0; i < y; i++ {
		fmt.Fscan(fp, &bList[i])
	}
	for i := 0; i < z; i++ {
		fmt.Fscan(fp, &cList[i])
	}
	sort.Sort(sort.Reverse(sort.Float64Slice(aList)))
	sort.Sort(sort.Reverse(sort.Float64Slice(bList)))
	sort.Sort(sort.Reverse(sort.Float64Slice(cList)))

	var ans []float64

	for i := 0; i < x; i++ {
		for j := 0; j < y; j++ {
			if (i+1)*(j+1) > 3000 {
				break
			}
			for l := 0; l < z; l++ {
				if (i+1)*(j+1)*(l+1) > 3000 {
					break
				}
				ans = append(ans, aList[i]+bList[j]+cList[l])
			}
		}
	}
	sort.Sort(sort.Reverse(sort.Float64Slice(ans)))

	for i := 0; i < k && i < 3000; i++ {
		fmt.Println(int64(ans[i]))
	}
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b);
#define chmin(a, b) a = min(a, b);
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
	int h, w, k;
	cin >> h >> w >> k;
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	x1--; y1--; x2--; y2--;
	vector<vector<int>> c(h, vector<int>(w));
	rep(i, h)rep(j, w) {
		char ci;
		cin >> ci;
		c[i][j] = ci == '.' ? 0 : 1;
	}
	vector<set<int>> rrest(h);
	vector<set<int>> crest(w);
	rep(i, h)rep(j, w) {
		rrest[i].insert(j);
		crest[j].insert(i);
	}
	vector<vector<int>> dp(h, vector<int>(w, 1001001001));
	vector<P> q{{x1, y1}};
	dp[x1][y1] = 0;
	rrest[x1].erase(y1);
	crest[y1].erase(x1);
	int now = 1;
	while(!q.empty()) {
		vector<P> nq;
		for(auto& p: q) {
			int x = p.first, y = p.second;
			if (!rrest[x].empty()) {
				// move (1, 0)
				auto it = rrest[x].lower_bound(y);
				vector<int> rmlater;
				while(it != rrest[x].end()) {
					int ny = *it;
					if (ny <= y + k && c[x][ny] != 1) {
						rmlater.push_back(ny);
						dp[x][ny] = now;
						nq.emplace_back(x, ny);
					} else break;
					it++;
				}
				for(int ny: rmlater) {
					rrest[x].erase(ny);
					crest[ny].erase(x);
				}
			}
			if (!rrest[x].empty()) {
				// move (-1, 0)
				auto it = rrest[x].lower_bound(y);
				vector<int> rmlater;
				while(it != rrest[x].begin()) {
					it--;
					int ny = *it;
					if (ny >= y - k && c[x][ny] != 1) {
						rmlater.push_back(ny);
						dp[x][ny] = now;
						nq.emplace_back(x, ny);
					} else break;
				}
				for(int ny: rmlater) {
					rrest[x].erase(ny);
					crest[ny].erase(x);
				}
			}
			if (!crest[y].empty()) {
				// move (0, 1)
				auto it = crest[y].lower_bound(x);
				vector<int> rmlater;
				while(it != crest[y].end()) {
					int nx = *it;
					if (nx <= x + k && c[nx][y] != 1) {
						rmlater.push_back(nx);
						dp[nx][y] = now;
						nq.emplace_back(nx, y);
					} else break;
					it++;
				}
				for(int nx: rmlater) {
					rrest[nx].erase(y);
					crest[y].erase(nx);
				}
			}
			if (!crest[y].empty()) {
				// move (0, -1)
				auto it = crest[y].lower_bound(x);
				vector<int> rmlater;
				while(it != crest[y].begin()) {
					it--;
					int nx = *it;
					if (nx >= x - k && c[nx][y] != 1) {
						rmlater.push_back(nx);
						dp[nx][y] = now;
						nq.emplace_back(nx, y);
					} else break;
				}
				for(int nx: rmlater) {
					rrest[nx].erase(y);
					crest[y].erase(nx);
				}
			}
		}
		now++;
		q = move(nq);
	}
	int ans = dp[x2][y2];
	if (ans == 1001001001) ans = -1;
	cout << ans << endl;
}


Measured memory_bytes: 155612
#include <bits/stdc++.h>
#define ll long long
#define For(i,a,b) for (int i=a;i<=b;i++)
#define fi first
#define se second
#define pb push_back
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define inf 1000000007
#define maxn 100007
#define task "A"
#define reset(x) memset(x,0,sizeof(x))
#define dscan(x) scanf("%d", &x)
#define lldscan(x) scanf("%lld", &x)
#define cscan(x) scanf("%c", &x)
#define sscan(x) scanf("%s", &x)
using namespace std;

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

typedef pair<int,int> ii;
int n, ans=0;

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

void open() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
}

void read() {
    cin >> n;
}

bool check(int i) {
    if ((i>=1 && i<=9) || (i>=100 && i<=999) || (i>=10000 && i<=99999)) return true;
    return false;
}

void solve() {
    For(i,1,n) if (check(i)) ans++;
    cout << ans;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

int main()
{
    open();
    read();
    solve();
    return 0;
}

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

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return y;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  double r;
  cin >> r;
  double p = 3.14159265358979;
  double s = r*r*p;
  double l = 2 * r * p;
  printf("%f %f\n",s, l );
}






Measured memory_bytes: 3200
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    static int[] w = new int[100010];
    static int[] v = new int[100010];
    static int[][] dp = new int[110][100010];
    static int k;

    static int chmin(int a, int b) {
        if (a > b) {
            a = b;
            return a;
        }
        return a;
    }

    static int chmax(int a, int b) {
        if (a < b) {
            a = b;
            return a;
        }
        return a;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (b >= a)
            System.out.println(a);
        else
            System.out.println(a - 1);
    }
}


Measured memory_bytes: 78932
import java.util.*;

public class Main {
	static int N,A,B;
	static int[] h;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		A = sc.nextInt();
		B = sc.nextInt();
		h = new int[N];
		for(int i=0; i<N; i++)
			h[i] = sc.nextInt();
		
		int min = 0;
		int max = 1<<30;
		while(min+1<max) {
			int mid = (min + max)/2;
			if(ok(mid))
				max = mid;
			else
				min = mid;
		}
		
		System.out.println(max);
		sc.close();
	}
	
	static boolean ok(int x) {
		long ex = 0;
		for(int i=0; i<N; i++) {
			ex += (Math.max(0, h[i]-(long)B*x)+(A-B-1))/(A-B);
		}
		return ex<=x;
	}
}


Measured memory_bytes: 50696
N = int(input())
h = list(map(int,input().split()))

dp = [0]*N

dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2,N):
  dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]))

print(dp[N-1])

Measured memory_bytes: 13980
f=lambda:map(int,input().split())
h,w,n=f()
d={}
while n:
 n-=1;x,y=f()
 for i in range(9):
  a=(x+i%3,y+i//3)
  if h>=a[0]>2<a[1]<=w:d[a]=d.get(a,0)+1
c=[0]*10
for i in d:c[d[i]]+=1
c[0]=(h-2)*(w-2)-sum(c)
print(*c)

Measured memory_bytes: 166532
#include <iostream>

using namespace std;

int main(void) {
    int n;
    cin >> n;
    string s[n];
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }

    long long m = 0, a = 0, r = 0, c = 0, h = 0;
    for (int i = 0; i < n; ++i) {
        switch (s[i][0]) {
            case 'M':
                m++;
                break;
            case 'A':
                a++;
                break;
            case 'R':
                r++;
                break;
            case 'C' :
                c++;
                break;
            case 'H' :
                h++;
                break;
        }
    }

    long long total = 0;
    total += m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h +
             r * c * h;
    cout << total << endl;
    return 0;
}

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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
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;
}

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) (x).erase(unique(all(x)), (x).end())
#define int long long

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;

/* main */
signed main(void)
{
    int n, m;
    cin >> n >> m;
    int nx[n], ny[n];
    int mx[m], my[m];
    rep(i, n)
    {
        cin >> nx[i] >> ny[i];
    }
    rep(i, m)
    {
        cin >> mx[i] >> my[i];
    }
    int mini;
    int ans;
    rep(i, n)
    {
        ans = inf;
        rep(j, m)
        {
            mini = abs(nx[i] - mx[j]) + abs(ny[i] - my[j]);
            if (ans > mini)
            {
                ans = mini;
            }
        }
        rep(j, m)
        {
            if (abs(nx[i] - mx[j]) + abs(ny[i] - my[j]) == ans)
            {
                cout << j + 1 << endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    int n;cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++)cin>>v[i];
    ll a=0;
    for(int i=0;i<n;i++)a+=v[i];
    a/=n;
    ll b=a+1;
    ll ans=0,ans1=0;
    for(int i=0;i<n;i++){ans+=(v[i]-a)*(v[i]-a);ans1+=(v[i]-b)*(v[i]-b);}
    cout<<min(ans,ans1);
    
}

Measured memory_bytes: 384
#include<stdio.h>
int main()
{
    int n;
    int a,b,c,t;
    scanf("%d",&n);
    if(n>=500)
	{
		a=n/500;
		n=n%500;
		b=a*1000;
		n=n/5;
		c=n*5;
		t=c+b;
		printf("%d\n",t);
	}
	else
	{
		a=n/5;
		b=a*5;
		printf("%d\n",b);
	}
     return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <queue>
#include <stack>
using namespace std; 
typedef pair<long long int,long long int> pa;
#define resize(A) A.resize(unique(A.begin(), A.end()) - A.begin())
#define pb push_back
#define  MAX 200000
long long int MOD=998244353;
long long int INF=1e18;
                                                 /*:-]*/
 
int main()
{
         ios_base::sync_with_stdio(false); 
         cin.tie(NULL);
         cout.tie(NULL);
         long long int i,j,k=0,l=0,r=0,m=0,n,c,p=0,cnt=0,cnt1=0,x,y,z=0,a,b,low,mid,high,ans=0,maxi=0,mini=INF,t,x1,y1;
       cin>>n;
    vector<pa>V;
    for(i=0;i<n;i++)
    {
        cin>>x;
        V.pb({x,i});
        
    }
    sort(V.begin(),V.end());

   for(i=0;i<n;i++)
   {
       cout<<V[i].second+1<<" ";
   }
}
    

Measured memory_bytes: 2544
m,k=map(int,input().split())
if k>=2**m:
    print(-1)
elif m==1:
    if k==0: print(0,0,1,1)
    else: print(-1)
else:
    tmp=k
    for i in range(1,2**m):
        tmp^=i
    ans=[i for i in range(2**m) if i!=k]+[k]+[i for i in range(2**m-1,-1,-1) if i!=k]+[k]
    print(*ans)


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

int main()
{
    int arr[100];
    int n;
    int x = 0;
    cin >> n;

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

    for(int i = 0; i < n; i++)
    {
        if((i+1) != arr[i])
            x++;
    }
    //cout << x << endl;
    if(x == 0 || x == 2)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,x,i,u=0;
	cin>>a>>b;
	string s;
	cin>>s;
	x=s.size();
	if(x!=(a+b+1) || s[a]!='-' )
	{
		cout<<"No"<<endl;
		return 0;
	}
	for(i=0;i<x;i++)
	{
		if(s[i]=='-')
		{
			u++;
		}
	}
	if(u>1)
	{
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 3596
#define _CRT_SECURE_NO_WARINGS
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<set>
#include<cmath>
#include<bitset>
#include<iterator>
#include<queue>
using namespace std;
int main()
{
	fast; 
	string s;
	cin >> s;
	s[3] = '8';
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
a, b = map(int, input().split())
c = []
f = [0] * a
for i in range(b):
    d, e = map(int, input().split())
    c.append([d, e, i, ""])
c = sorted(c, key=lambda x: (x[0], x[1]))
for i in range(b):
    f[c[i][0]-1] += 1
    c[i][3] = ("000000" + str(c[i][0]))[-6:] + ("000000" + str(f[c[i][0]-1]))[-6:]
c = sorted(c, key=lambda x: x[2])
for i in range(len(c)):
    print(c[i][3])


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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i=0;i<n;i++) cin >> d[i];
  int m;
  cin >> m;
  vector<int> t(m);
  for(int i=0;i<m;i++) cin >> t[i];

  sort(d.begin(), d.end());
  sort(t.begin(), t.end());

  vector<int> result;
  set_intersection(d.begin(), d.end(), t.begin(), t.end(), back_inserter(result));

  if(result.size() == t.size()) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 2936
#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))
//-------------------------------------------------------

int A,B,X;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>A>>B>>X;
	if(A<=X && X<=A+B) cout<<"YES"<<endl;
	else cout<<"NO"<<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
#include <bits/stdc++.h>
using namespace std;

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n;
string s[300];

int main() {
	cin >> n;
	inc(i, n) { cin >> s[i]; s[i] += s[i]; }
	
	int ans = 0;
	inc(k, n) {
		bool f = true;
		inc(i, n) {
		inc(j, n) {
			if(s[i][k + j] != s[j][k + i]) { f = false; }
		}
		}
		if(f) { ans += n; }
	}
	
	cout << ans << endl;
	
	return 0;
}


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

using namespace std;

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

    long long x = (-1+sqrt(8*n+1))/2;

    if((x*(x+1))/2 < n)
        cout<<x+1;
    else
    {
        cout<<x;
    }
    

}

Measured memory_bytes: 3640
from heapq import heappush, heappop
while True:
  h, w = map(int, input().split())
  if h == 0:
    break
  mp = [[-1] + list(map(int, input().split())) +[-1] for _ in range(h)]
  mp.insert(0, [-1] * (w + 2))
  mp.append([-1] * (w + 2))
  sy, sx = map(int, input().split())
  gy, gx = map(int, input().split())
  sy += 1
  sx += 1
  gy += 1
  gx += 1
  que = []
  heappush(que, (0, sx, sy, 1, 2, 3))
  dic = {}
  dic[(sx, sy, 1, 2, 3)] = 0
  vec = ((1, 0), (0, -1), (-1, 0), (0, 1))
  def spin(top, south, east, direct):
    if direct == (1, 0):
      return 7 - east, south, top
    if direct == (0, -1):
      return south, 7 - top, east
    if direct == (-1, 0):
      return east, south, 7 - top
    if direct == (0, 1):
      return 7 - south, top, east
  while que:
    pena, x, y, top, south, east = heappop(que)
    if (x, y) == (gx, gy):
      print(pena)
      break
    for dx, dy in vec:
      nx, ny = x + dx, y + dy
      if mp[ny][nx] == -1:
        continue
      new_top, new_south, new_east = spin(top, south, east, (dx, dy))
      new_pena = pena + (7 - new_top) * mp[ny][nx]
      if (nx, ny, new_top, new_south, new_east) not in dic:
        dic[(nx, ny, new_top, new_south, new_east)] = new_pena
        heappush(que, (new_pena, nx, ny, new_top, new_south, new_east))


Measured memory_bytes: 5888
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
bool isprime(int n) { //素数判定
    if(n==1)return false;
    if(n==2)return true;
    for(int i = 2;i<=sqrt(n);i++) {
        if(n%i==0) return false;
    }
    return true;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int n;cin >> n;
    vector<P> v(n);
    rep(i, n) {
        cin >> v[i].first;
        v[i].second=i+1;
    }
    sort(all(v));
    rep(i, n)cout << v[i].second << ' ';
    return 0;
}

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

using namespace std;

const int mod = 1e9+7;

bool u[10001];

set<int> p;
map<int, int> ma;

int main()
{
    for (int i = 2; i <= 1000; i++){
        if (u[i])
            continue;
        p.insert(i);
        for (int j = i * i; j <= 1000; j += i)
            u[j] = 1;
    }
    int n;
    cin >> n;
    for (int i = 2; i <= n; i++){
        int ii = i;
        for (int j = 2; j <= i; j++)
            while (p.count(j) && ii % j == 0)
                ma[j]++, ii /= j;
    }

    long long ans = 1;
    for (auto i = ma.begin(); i != ma.end(); i++){
        ans *= i->second + 1;
        ans %= mod;
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;

ll n;

void input(void){
cin>>n;
}
void solve(void){
    ll ans=0;
    ans+=min(n,9LL);
    if(n>99){
        ans+=min(n,999LL)-99;
    }
    if(n>9999){
        ans+=min(n,99999LL)-9999;
    }
  cout<<ans<<endl;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

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

int main(){
	int a,b;
  	cin >> a >>b ;
  		if(a * b % 2 == 0){
        	cout << "Even" <<endl;
        } else if(a * b % 2 == 1){
        	cout << "Odd" <<endl;
        }
}

Measured memory_bytes: 3628