akhauriyash/Code-Regression huggingface dataset:
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define CLR2d(x,m,n) memset(x, -1, sizeof(x[0][0]) * m * n)
#define mp make_pair
#define PII pair<int, int>
#define pf printf
#define sf scanf
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >


int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
ll po(ll b,ll p){
    ll res=1;
    while(p){
        res*=b;
        p--;
    }
    return res;
}
ll lg2(ll x){
    ll res=0;
    while(x>1){
        res++;
        x/=2ll;
    }
    return res;
}
void solve(){
    double n;
    cin>>n;
    double res=(ceil(n/2.0)/n);
    cout<<fixed<<setprecision(9)<<res<<endl;
}

signed main()

{
    IOS;
    /*#ifndef ONLINE_JUDGE
        freopen ("input.txt","r",stdin);
        freopen ("output.txt","w",stdout);
    #endif*/
    int t;
    t=1;
    while(t--){
        solve();
    }

     return 0;

}
///Alhamdulillah




Measured memory_bytes: 3824
#include <cstdio>
#define MAX_N 100
using namespace std;

int main() {
    int n, d, x;
    int ans = 0;
    int a[MAX_N];
    scanf("%d %d %d", &n, &d, &x);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= d; j+=a[i]) {
            ans++;
        }
    }
    printf("%d\n", ans + x);
    return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define per(i,n) for(int i = n; i >= 0; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const int MX = 100009;
int dp[MX]; // dp[i] = i円引き出せる最小回数

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

  int n;
  cin >> n;
  rep(i,MX) dp[i] = inf;
  dp[0] = 0;
  rep(i,n+1) {
    for(int j = 1; j+i <= n; j*=6) chmin(dp[i+j], dp[i]+1);
    for(int j = 1; j+i <= n; j*=9) chmin(dp[i+j], dp[i]+1);
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int n,m,p;
char verdict[2];
int ans1=0,ans2=0;
bool b[maxn][2];
int wa[maxn];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++)
	{
		scanf("%d%s",&p,verdict);
		string s=verdict;
		if(s=="WA")
		{
			if(!b[p][1])
			{
				++wa[p];
			}
		}
		else
		{
			if(!b[p][1])
			{
				++ans1;
				b[p][1]=true;
				ans2+=wa[p];
			}
		}
	}
	printf("%d %d\n",ans1,ans2);
	return 0;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 11;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

char in[5];
int main() {
	scanf("%s", in);
	if (in[0] == in[1] && in[1] == in[2]) return !printf("Yes\n");
	if (in[1] == in[2] && in[2] == in[3]) return !printf("Yes\n");
	return !printf("No\n");
}

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

double P[100010]; // iテ・ツ崢榲ゥツ?」テァツカツ堙」ツ?ァテ・ツ仰敕」ツ?、テァツ「ツコテァツ篠?
double dp[100010]; // iテヲツ猟・テァツ崢ョテ」ツ?セテ」ツ?ァテ」ツ?ォテ・ツセツ療」ツつ嘉」ツつ古」ツつ凝ァツ堋ソテ」ツ?ョテヲツ慊淌・ツセツ?・ツ?、

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  P[1] = 1.0;
  double p = 0.5;
  reps(i, 2, 100010) {
    P[i] = P[i-1] * p;
    p /= 2.0;
  }
  dp[1] = 1.0;
  reps(i, 2, 100010) {
    double p = 0.5;
    reps(j, 1, min(i, 100LL)) {
      // j+1テヲツ猟・テァツ崢ョテ」ツ?ァテ・ツ按敕」ツつ?」ツ?ヲティツイツ?」ツ?妥」ツつ凝」ツ?ョテ」ツ?ッテ」ツ?‾[j]*(1-p)テ」ツ?ョテァツ「ツコテァツ篠?」ツ?ァティツオツキテ」ツ?禿」ツつ?
      // テ」ツ?敕」ツつ古」ツ?セテ」ツ?ァテ」ツ?ォjテヲツ楪堙」ツ?ョテァツ堋ソテ」ツつ津・ツセツ療」ツ??」ツ?敕」ツつ古」ツ?ォテ・ツ環?」ツ?暗」ツ?ヲテヲツョツ凝」ツつ格-j-1テヲツ猟・テゥツ鳴禿」ツ?ョテァツ堋ソテ」ツ?ョテヲツ慊淌・ツセツ?・ツ?、テ」ツつ津・ツセツ療」ツつ?
      // テヲツョツ凝」ツつ格-j-1テヲツ猟・テゥツ鳴禿」ツ?ョテァツ堋ソテ」ツ?ョテァツ堋ソテ」ツ?ョテヲツ慊淌・ツセツ?・ツ?、テ」ツ?ッテ」ツ??テヲツ猟・テァツ崢ョテ」ツ?凝」ツつ永-j-1テァツ崢ョテ」ツ?セテ」ツ?ァテ」ツ?ョテヲツ慊淌・ツセツ?・ツ?、テ」ツ?ォテァツュツ嘉」ツ?療」ツ??
      dp[i] += P[j]*(1-p)*(j+dp[i-j-1]);
      p /= 2.0;
    }
    // P[i]テ」ツ?ョテァツ「ツコテァツ篠?」ツ?ァテ・ツ仰敕」ツ?。テァツカツ堙」ツ?妥」ツつ凝」ツ?ィiテヲツ楪堙」ツつ津・ツセツ療」ツつ?
    dp[i] += i*P[i];
  }

  int n;
  while(cin >> n, n) {
    cout << dp[n] << endl;
  }

  return 0;
}

Measured memory_bytes: 4788
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
char c[100];
int main(){
	n=read();
	scanf("%s",c+1);
	int ans=0;
	for(register int i=1;i<=n-2;i++){
		if(c[i]=='A' && c[i+1]=='B' && c[i+2]=='C')ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<P ,ll> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9)+7;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int n, ans = 1;
map<int, set<P> > vx, vy;
P3 pos[3005];

int main() {
    cin >> n;
    REP(i,n){
        int x, y, dir;
        char d;
        cin >> x >> y >> d;
        if(d == '>') dir = 0;
        if(d == 'v') dir = 1;
        if(d == '<') dir = 2;
        if(d == '^') dir = 3;
        vx[x].insert({y,dir});
        vy[y].insert({x,dir});
        pos[i] = {{x,y},dir};
    }
    REP(i,n){
        auto xs = vx, ys = vy;
        int px = pos[i].first.first, py = pos[i].first.second, dir = pos[i].second, cnt = 1;
        while(1){
            xs[px].erase({py,dir});
            ys[py].erase({px,dir});
            if(dir == 0){
                auto p = ys[py].upper_bound({px,-1});
                if(p==ys[py].end())break;
                px = (*p).first;
                dir = (*p).second;
                cnt++;
            }
            else if(dir == 1){
                auto p = xs[px].upper_bound({py,-1});
                if(p==xs[px].end())break;
                py = (*p).first;
                dir = (*p).second;
                cnt++;
            }
            else if(dir == 2){
                if(ys[py].size()==0) break;
                auto p = ys[py].upper_bound({px,-1});
                if(p==ys[py].begin())break;
                p--;
                px = (*p).first;
                dir = (*p).second;
                cnt++;
            }
            else if(dir == 3){
                if(xs[px].size()==0) break;
                auto p = xs[px].upper_bound({py,-1});
                if(p==xs[px].begin())break;
                p--;
                py = (*p).first;
                dir = (*p).second;
                cnt++;
            }
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4492
#include <bits/stdc++.h>
#define PI 3.141592653589793238462
using namespace std;
typedef long long ll;
typedef long double db;
vector<ll> a,b,c;
int main(){
    ll n,k,mod=1e9+7;cin>>n>>k;
    for(ll i=1;i<=n;i++){
        ll x;cin>>x;
        if(x>0) a.push_back(x);
        if(x<0) b.push_back(x);
        if(x==0) c.push_back(x);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    sort(b.begin(),b.end());
    if(a.size()+b.size()<k){
        cout<<0<<endl;return 0;
    }
    if(a.size()==0&&b.size()>=k){
        if(k%2==0){
            ll sum=1;
            for(ll i=0;i<k;i++){
                sum=sum*((b[i]%mod+mod)%mod);sum%=mod;
            }
            cout<<(sum%mod+mod)%mod<<endl;return 0;
        }
        if(k%2==1){
            if(c.size()>0){cout<<0<<endl;return 0;}
            else{
                reverse(b.begin(),b.end());
                ll sum=1;
                for(int i=0;i<k;i++){
                    sum=sum*((b[i]%mod+mod)%mod);sum%=mod;
                }
                cout<<(sum%mod+mod)%mod<<endl;return 0;
            }
        }
    }
    if(a.size()>=k&&b.size()==0){
        ll sum=1;
        for(ll i=0;i<k;i++){
            sum=sum*a[i];sum%=mod;
        }
        cout<<sum%mod<<endl;return 0;
    }
    ll p=-1e9;
    for(ll i=0;i<=k;i+=2){
        if(b.size()<i) break;
        if(a.size()<k-i) continue;
        p=i;break;
    }
    if(p==-1e9){
        if(c.size()>0) {cout<<0<<endl;return 0;}
        else{
            reverse(a.begin(),a.end());
            reverse(b.begin(),b.end());
            ll p1=0,p2=0,t=0,sum=1;
            while(p1<a.size()&&p2<b.size()&&t<k){
                ll v1=abs(a[p1]),v2=abs(b[p2]);
                if(v1<v2){
                    sum=sum*a[p1];sum%=mod;t++;p1++;
                }
                else{
                    sum=sum*((b[p2]%mod+mod)%mod);sum%=mod;t++;p2++;
                }
            }
            while(t<k&&p1<a.size()){
                sum=sum*a[p1];sum%=mod;p1++;t++;
            }
            while(t<k&&p1<b.size()){
                sum=sum*((b[p2]%mod+mod)%mod);sum%=mod;t++;p2++;
            }
            cout<<(sum%mod+mod)%mod<<endl;return 0;
        }
    }
    ll p1=k-p,p2=p;
    while(p1>1&&p2<b.size()){
        ll v1=a[p1-2]*a[p1-1],v2=b[p2]*b[p2+1];
        if(v2>v1) p2+=2,p1-=2;
        else break;
    }
    ll sum=1;
    for(ll i=0;i<p1;i++){
        sum=sum*a[i];sum%=mod;
    }
    for(ll i=0;i<p2;i++){
        sum=sum*((b[i]%mod+mod)%mod);sum%=mod;
    }
    cout<<sum%mod<<endl;
}

Measured memory_bytes: 5568
#include <bits/stdc++.h>
#define int long long
#define P(x) cout << x << endl
#define D(x) P(#x << ": " << x)
#define F(i,n) for (int i=0; i<(int)(n); i++)
#define DEC(i,n) for (int i=(int)(n); --i>=0;)
#define S(s) (int)((s).size())
#define ALL(v) v.begin(), v.end()
#define MI(a,v) a = min(a,(v))
#define MA(a,v) a = max(a,(v))
#define V vector
#define pb push_back
#define mt make_tuple
using namespace std;
const int D=505;

int res[D][D];

void make(int N, int n, int M) {
    cout<<"Yes\n";
    //D(N), D(n);
    int u = (N+n-1)/n,
        v = N-u,
        w = 1,
        x = n-1;
    int b = u+w, a = v+x;
    assert(u*a > v*b);
    assert(w*a < x*b);
    //D(a), D(b);
    F(i,N) F(j,M) {
        if (i%n)
            res[i][j] = -b;
        else
            res[i][j] = a;
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int N,M,n,m; cin>>N>>M>>n>>m;
    if (N%n) {
        make(N,n,M);
        F(i,N) F(j,M)
            cout<<res[i][j]<<" \n"[j==M-1];
    } else if (M%m) {
        make(M,m,N);
        F(i,N) F(j,M)
            cout<<res[j][i]<<" \n"[j==M-1];
    }
    else cout<<"No\n";
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=2003,INF=1<<30;

vector<int> S[MAX];
int visited[MAX][MAX],N;

int BFS(int u,int lim){
    
    for(int i=0;i<N;i++){
        visited[u][i]=INF;
    }
    
    visited[u][u]=0;
    
    queue<int> Q;
    Q.push(u);
    int cnt=1;
    
    while(!Q.empty()){
        int a=Q.front();Q.pop();
        if(visited[u][a]>=lim) break;
        for(int i=0;i<S[a].size();i++){
            int b=S[a][i];
            if(visited[u][b]!=INF) continue;
            visited[u][b]=visited[u][a]+1;
            Q.push(b);
            cnt++;
        }
    }
    
    return cnt;
}

int BFS2(int u,int v,int lim,int when){
    
    for(int i=0;i<N;i++){
        visited[when][i]=INF;
    }
    
    visited[when][u]=0;
    visited[when][v]=0;
    
    queue<int> Q;
    Q.push(u);
    Q.push(v);
    
    int cnt=2;
    
    while(!Q.empty()){
        int a=Q.front();Q.pop();
        if(visited[when][a]>=lim) break;
        for(int i=0;i<S[a].size();i++){
            int b=S[a][i];
            if(visited[when][b]!=INF) continue;
            visited[when][b]=visited[when][a]+1;
            Q.push(b);
            cnt++;
        }
    }
    
    return cnt;
}

int main(){
    
    int M;cin>>N>>M;
    vector<pair<int,int>> T(N-1);
    for(int i=0;i<N-1;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        S[a].push_back(b);
        S[b].push_back(a);
        T[i]=make_pair(a,b);
    }
    
    if(M%2==0){
        int ans=INF;
        for(int i=0;i<N;i++){
            ans=min(ans,N-BFS(i,M/2));
        }
        cout<<ans<<endl;
    }else{
        int ans=INF;
        for(int i=0;i<N-1;i++){
            int a=T[i].first,b=T[i].second;
            ans=min(ans,N-BFS2(a,b,M/2,i));
        }
        
        cout<<ans<<endl;
    }
    
}




Measured memory_bytes: 16000
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
  str S;
  cin >> S;
  if(S.size() == 2) print(S);
  else cout << S[2] << S[1] << S[0] << "\n";
  


  
  return 0;
}


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

int par[100000];

int root(int a){
  if(par[a]==a) return a;
  else return par[a]=root(par[a]);
}

void unite(int a,int b){
  a=root(a); b=root(b);
  if(a==b) return;
  par[a]=b;
}

int main(){
  int N,M,K; cin >> N >> M >> K;
  
  for(int i=0; i<N; i++) par[i]=i;
  int frd[100000]; for(int i=0; i<N; i++) frd[i]=0;
  int blk[100000]; for(int i=0; i<N; i++) blk[i]=0;
  int gr[100000]; for(int i=0; i<N; i++) gr[i]=0;  
  
  for(int i=0; i<M; i++){
    int a,b; cin >> a >> b;
    a--; b--;
    frd[a]++; frd[b]++;
    unite(a,b);
  }
  
  for(int i=0; i<K; i++){
    int c,d; cin >> c >> d;
    c--; d--;
    if(root(c)==root(d)){
      blk[c]++; blk[d]++;
    }
  }
  
  for(int i=0; i<N; i++) gr[root(i)]++;
  
  for(int i=0; i<N; i++){
    cout << gr[root(i)]-1-frd[i]-blk[i];
    if(i==N-1) cout << endl;
    else cout << " ";
  }
}

Measured memory_bytes: 2944
import collections as c
ip = lambda : map(int, input().split())

#################
N = int(input())
v = list(ip())
c = list(ip())
l = [i-j for i,j in zip(v,c)]
l.sort(reverse=True)
ans = 0
for i in l:
    if i>0:
        ans += i
    else:
        break
print(ans)

Measured memory_bytes: 3572
#include<iostream>
using namespace std;
int main(){
  int n,i,s,kaisuu=0,a,ans=0;
  cin>>n;
  for(i=1;i<=n;i++){
    a=i;
    while(a>0){
    a=a/2;
    kaisuu++;
    }
    if(kaisuu>s){
      s=kaisuu;
      ans=i;    
    }
    kaisuu=0;
  }
  cout<<ans<<endl;
  return 0;
}


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

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  char a,b;
  cin >> a >> b;
  if (a == 'H'&& b == 'H'){
    cout << "H\n" ;
  }
  if (a == 'H' && b == 'D'){
    cout << "D\n";
  }
  if (a == 'D' && b == 'H'){
    cout << "D\n";
  }
  if (a == 'D' && b == 'D')
  {
   cout << "H\n"; 
  }
  return 0;
}

Measured memory_bytes: 256
use std::io;
use std::io::BufRead;

fn main() {
    let stdin = io::stdin();
    for line in stdin.lock().lines() {
        let mut vec: Vec<u16> = line.unwrap()
                    .split_whitespace()
                    .map(|s| s.parse().unwrap())
                    .collect();
        if vec == [0, 0] {break;}
        vec.sort();
        println!("{} {}", vec[0], vec[1]);

    }
}


Measured memory_bytes: 5032
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	int n;
	cin >> n;
	vector<int> x(n), y(n), h(n);
	rep(i, n) {
		cin >> x[i] >> y[i] >> h[i];
	}
	int H;
	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			for (int k = 0; k < n; k++) {
				if (h[k] > 0) {
					H = h[k] + abs(x[k] - i) + abs(y[k] - j);
					break;
				}
			}
			bool check = true;
			for (int k = 0; k < n; k++) {
				if (max(H - abs(x[k] - i) - abs(y[k] - j), 0) != h[k]) {
					check = false; 
					break;
				}
			}
			if (check) {
				cout << i << ' ' << j << ' ' << H << endl;
				return 0;
			}
		}
	}

	return 0;
}

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

int main(){
    int N; 
    string S, T;
    cin >> N >> S >> T;
    for (int i = 0; i < N; i++)
    {
        cout << S.at(i) << T.at(i);
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int W,H; cin>>W>>H;
  vector<pii> A(W+H);
  rep(i,0,W){
    cin>>A[i].first;
    A[i].second=0;
  }
  rep(i,W,H+W){
    cin>>A[i].first;
    A[i].second=1;
  }
  sort(ALL(A));
  vi B(2);
  B[0]=W+1;
  B[1]=H+1;
  int ans=0;
  rep(i,0,H+W){
    ans+=B[A[i].second^1]*A[i].first;
    B[A[i].second]--;
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 3328
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.NoSuchElementException;

public class Main {
	int N;
	String S;
	int[] a;
	@SuppressWarnings("unchecked")
	public void solve() {
		N = nextInt();
		S = next();
		a = new int[26];

		for(int i = 0;i < N;i++){
			if(S.charAt(i) >= 'a' && S.charAt(i) <= 'z')
				a[S.charAt(i)-'a']++;
		}

		ArrayList<Integer>[] list = new ArrayList[10];
		for(int i = 0;i < 10;i++){
			list[i] = new ArrayList<Integer>();
		}

		for(int i = 0;i < 26;i++){
			if(a[i] == 0)continue;
			for(int j = 9;j >= 1;j--){
				if(a[i]%j==0){
					list[j].add(i);
					break;
				}
			}
		}

		int ans = list[1].size() > 0 ? (list[1].size() - 1)* 2 + 1 : 0;

		for(int i = 2;i < 10;i++){

			if(list[i].size() >= 2){
				if(ans == 0)ans += (list[i].size() -1) * 2 + 1 + 4;
				else ans += (list[i].size() -1) * 2 + 4 + 1 + 1;
			}else if(list[i].size() == 1){
				if(ans == 0)ans += 3;
				else ans += 4;
			}
		}

		out.println(ans);
	}
	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 24372
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int a,b;
    cin >> a >> b;
    int cc=floor(log(b)/log(a));
    int ans=0;
    for(int i=0;i<cc;i++){
        ans+=int(pow(a,i));
    }
    ans+=ceil((b-pow(a,cc))/(a-1));
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

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

typedef long long ll;

ll dp[2000][2000];
int cake[2000];
int n;

int main() {
	cin >> n;
	REP(i, n) scanf("%d", &cake[i]);
	
	REP(i, n) {
		REP(j, n) {
			int a = j, b = (j + i) % n;
			
			if ((n - i - 1) % 2 == 0) {
				dp[a][b] = max(dp[(a + 1) % n][b] + cake[a], dp[a][(b - 1 + n) % n] + cake[b]);
			}
			else {
				if (cake[a] > cake[b])
					dp[a][b] = dp[(a + 1) % n][b];
				else
					dp[a][b] = dp[a][(b - 1 + n) % n];
			}
		}
	}
	
	ll ans = 0;
	REP(i, n) ans = max(ans, dp[(i + 1) % n][(i + n - 1) % n] + cake[i]);
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 34416
#include <iostream>
using namespace std;
int main(){
	char graph[6][7] = {{0,  0,  0,  0,  0,  0,  0},
											{0, 97,102,107,112,117,122},
											{0, 98,103,108,113,118,'.'},
											{0, 99,104,109,114,119,'?'},
											{0,100,105,110,115,120,'!'},
											{0,101,106,111,116,121,' '}};
	string s;
	while(cin >> s,!cin.eof()){
		string ans = "";
		if(s.size() % 2 == 1){cout << "NA" << endl;continue;};
		for(int i = 0;i < s.size();i += 2){
			if(s[i] - '0' <= 0 || s[i+1] - '0' <= 0 || s[i] - '0' > 6 || s[i+1] - '0' > 5){ans = "NA";break;}
			ans += graph[s[i+1]-'0'][s[i]-'0'];
		}
		cout << ans << endl;
	}	
}

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

int main()
{
  int N;
  int W[100];
  int ans = 10000;
  cin >> N;
  for(int i = 0; i < N; i++)
    cin >> W[i];
  for(int i = 0; i < N; i++){
    int g1 = 0, g2 = 0;
    for(int j = 0; j < N; j++){
      if(j <= i)
        g1 += W[j];
      else
        g2 += W[j];
    }
    if(ans > abs(g1 - g2))
      ans = abs(g1 - g2);
  }

  cout << ans << endl;
  return 0;
}


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

#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin());
#define io() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));
using namespace std;

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

signed main(){
	io();
	string s; cin >> s;
	for(int i = 0; i < (int)s.size(); ++i){
		s[i] = 'x';
	}
	cout << s << '\n';
	return 0;
}

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

using namespace std;
using llong = long long int;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000007;
const static int IINF = INT_MAX;
const static llong LINF = LLONG_MAX;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

/* --------------- template start --------------- */
template <typename T> 
struct BinaryIndexTree { // [1, n]
    vector<T> array;
    int n;

    BinaryIndexTree(int _n) {
        array.resize(_n + 1, 0);
        n = _n;
    }

    T cumsum(int i) {
        T s = 0;
        while(i > 0) {
            s += array[i];
            i -= i & -i;
        }

        return s;
    }

    T sum(int i, int j) {
        T ret_i = cumsum(i - 1);
        T ret_j = cumsum(j);

        return ret_j - ret_i;
    }

    void add(int i, T x) {
        while (i <= n) {
            array[i] += x;
            i += i & -i;
        }
    }
};

template<typename T>
struct UnionFind {
    vector<int> par;
    vector<T> sz;

    UnionFind(int n) {
        par.resize(n);
        sz.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            sz[i] = 1;
        }
    }

    int find_root(int x) {
        return par[x] == x ? x : par[x] = find_root(par[x]);
    }

    bool same(int x, int y) {
        return find_root(x) == find_root(y);
    }

    void unite(int x, int y) {
        x = find_root(x);
        y = find_root(y);
        if (x == y) return;
        
        if (sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        par[y] = x;
    }

    T size_of_tree(int x) {
        return sz[find_root(x)];
    }
};
/* --------------- template end --------------- */

/* --------------- function start --------------- */
llong my_gcd(llong a, llong b) {
    return (a ? my_gcd(b % a, a) : b);
}
llong my_lcm(llong a, llong b) {
    return a * b / my_gcd(a, b);    
}

llong facmod(llong n) {
    if (n == 0) return 1;

    llong res = n;
    for (int i = n - 1; i > 0; --i) {
        res = (res * i) % MOD;
    }

    return res;
}
llong powmod(llong a, llong n) {
    llong res = 1;
    while (n > 0) {
        if (n & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        n >>= 1;
    }

    return res;
}
llong modinv(llong n) {
    return powmod(n, MOD - 2);
}
llong combmod(llong n, llong k) {
    llong res = 1;
    for (int i = 0; i < k; ++i) {
        res = (res * (n - i)) % MOD;
    }
    res = (res * modinv(facmod(k))) % MOD;

    return res;
}
/* --------------- function end --------------- */

llong recur(llong hp) {
    if (hp == 1) return 1LL;
    else return 1LL + recur(hp / 2) * 2;
}

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

    llong h;
    cin >> h;

    cout << recur(h) << endl;

    return 0;
}

Measured memory_bytes: 256
S = input()

cnt1 = cnt2 = 0
for i in range(len(S)):
    if i%2==0 and S[i]=='1':
        cnt1 += 1
    if i%2==1 and S[i]=='0':
        cnt1 += 1

for i in range(len(S)):
    if i%2==0 and S[i]=='0':
        cnt2 += 1
    if i%2==1 and S[i]=='1':
        cnt2 += 1  

print(min(cnt1,cnt2))  

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

int gcd(int a,int b){return (a%b==0?b:gcd(b,a%b));}

int main() {
	int n,X;cin>>n>>X;
	vector<int> x(n),dist(n);
	for(int i=0;i<n;++i) {
		cin>>x[i];
		dist[i] = abs(X-x[i]);
	}

	int mx=dist[0];
	for(int i=0;i<n;++i) mx=gcd(mx,dist[i]);

	cout<<mx<<endl;
	
  return 0;
}


Measured memory_bytes: 1024
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;
const int MYINF = 1e9+7;
typedef int bool;
const bool true = 1;
const bool false = 0;

#define MAX_N 128
#define MAX_Q (128*129)
int G[MAX_N][MAX_N];
int n;
int sz[MAX_N];
int d[MAX_N];
int visited[MAX_N];
int q[MAX_Q];
int qs, qe;

void enqueue(int x) {
	if ((qe + 1) % MAX_Q == qs % MAX_Q) exit(1);
	q[qe] = x;
	qe = (qe+1) % MAX_Q;
}

int dequeue() {
	if (qs == qe) return -1;
	int res = q[qs];
	qs = (qs+1) % MAX_Q;
	return res;
}

void bfs() {
	int v, i;

	for (i = 1; i <= n; i++) {
		visited[i] = false;
		d[i] = MYINF;
	}

	d[1] = 0;
	enqueue(1);
	while ((v = dequeue()) != -1) {
		if (visited[v]) continue;
		visited[v] = true;
		for (i = 0; i < sz[v]; i++) {
			int next = G[v][i];
			if (d[v] + 1 < d[next]) d[next] = d[v] + 1;
			if (!visited[next]) enqueue(next);
		}
	}
}

int main(int argc, char **argv)
{
	int i, j, u, k, v;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d %d", &u, &k);
		sz[u] = k;
		for (j = 0; j < sz[u]; j++) {
			scanf("%d", &v);
			G[u][j] = v;
		}
	}


	bfs();

	for (i = 1; i <= n; i++) {
		printf("%d %d\n", i, visited[i] ? d[i] : -1);
	}

	return 0;
}

Measured memory_bytes: 652
/*
Author : Devil088
*/
#include<bits/stdc++.h>
using namespace std;
#define MOD 1e+7 
typedef long long ll;
typedef long l;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<l> vl;

int main(){
	string s;
	cin>>s;
	int in = 0, de = 0;
	for(auto x:s){
		if(x == '+')in++;
		else de++;
	}
	
	cout<<in-de<<"\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<queue>
using namespace std;
int main () {
  int H, W, K;
  cin >> H >> W >> K;
  int cake[500][500];
  queue<int>qi;
  queue<int>qj;
  for (int i = 0; i < H; i ++) {
    for (int j = 0; j < W; j ++) {
      cake[i][j] = 0;
      char c;
      cin >> c;
      if (c == '#') {
        cake[i][j] = K;
        K --;
        qi.push(i);
        qj.push(j);
      }
    }
  }
  while (!qi.empty()) {
    int i = qi.front();
    int j = qj.front();
    if (i < H - 1 && cake[i + 1][j] == 0) {
      cake[i + 1][j] = cake[i][j];
      qi.push(i + 1);
      qj.push(j);
    }
    if (i > 0 && cake[i - 1][j] == 0) {
      cake[i - 1][j] = cake[i][j];
      qi.push(i - 1);
      qj.push(j);
    }
    qi.pop();
    qj.pop();
  }
  for (int i = 0; i < H; i ++) {
    for (int j = 1; j < W; j ++) {
      if (cake[i][j] == 0) cake[i][j] = cake[i][j - 1];
    }
  }
  for (int i = 0; i < H; i ++) {
    for (int j = W - 1; j > 0; j --) {
      if (cake[i][j - 1] == 0) cake[i][j - 1] = cake[i][j];
    }
  }
  for (int i = 0; i < H; i ++) {
    for (int j = 0; j < W; j ++) {
      cout << cake[i][j] << ' ';
    }
    cout << endl;
  }
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;

const int maxN = 1e5 + 10; 
int a[maxN];
int b[10*maxN];
int c[10*maxN];
vector<int> w[maxN];
int n;
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=1000;i++)
	{
		int k = (i)*(i-1)/2;
		b[k] = 1;
		c[k] = i;
	}
	if(b[n] != 1)
	{
		puts("No");
		return 0;
	}
	else
	{
		puts("Yes");
		printf("%d\n",c[n]);
		int cnt = 0;
		for(int i=1;i<c[n];i++)
		{
			for(int j=i+1;j<=c[n];j++)
			{
				cnt++;
				w[i].push_back(cnt);
				w[j].push_back(cnt);
			}
		}
		for(int i=1;i<=c[n];i++)
		{
			int sz = w[i].size();
			printf("%d ",sz);
			for(int j=0;j<w[i].size()-1;j++)
			{
				printf("%d ",w[i][j]);
			}
			printf("%d\n",w[i][sz-1]);
		}
	}
    return 0;
}

Measured memory_bytes: 12544
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		double r = stdIn.nextDouble();
		
		double s = r * r * Math.PI;
		double c = 2 * r * Math.PI;
		
		System.out.println(String.format("%.6f",s) + " " + String.format("%.6f", c));
	}
}

Measured memory_bytes: 18888
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
#define mod 100003
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
#define piiii pair<int,piii>
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
FO
#define no {cout<<"NO"<<endl;return;}
#define yes {cout<<"YES"<<endl;return;}

void solve(){
    int n;
    cin>>n;


    set<int> st;
    while(n--){
        int i;
        cin>>i;
        if(st.count(i)) no
        st.insert(i);
    }
    yes
    return;
}
int main(){
    IO
    //TEST
    solve();
    return(0);
}


Measured memory_bytes: 12984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()


int main() {
    ll N;
    cin >> N;
    VL d(N);
    ll ans=0;
    rep(i,0,N)cin>>d[i];
    rep(i,0,N){
        rep(j,i+1,N){
            ans+=d[i]*d[j];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 500'001;
const int LOGN = 19;

int n, m, k;

void solve(int test)
{
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    for (int j = i + 1; j < n; ++j) {
      cout << __builtin_ctz(i ^ j) + 1 << ' ';
    }
    cout << '\n';
  }
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#include <iostream>

using namespace std;


int main() {

    char a, b;
    cin >> a >> b;

    if ((a == 'H' and b == 'H') or (a == 'D' and b == 'D')) {
        cout << 'H' << "\n";
    } else {
        cout << 'D' << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
from sys import exit, stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
A = [int(_) for _ in stdin.readline().rstrip().split()]

ans_one = 0
for i in range(N):
    for j in range(i+1, N):
        if A[i] > A[j]:
            ans_one += 1
ans_two = 0
for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            ans_two += 1

ans = (ans_one * K) + (K * (K-1) // 2 * ans_two)
print(ans % (10**9+7))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int ans,N,K;
  cin>>N>>K;
  if(K%2==0){
    int X=N/K,Y=(N+K/2)/K;
    ans=X*X*X+Y*Y*Y;
  }
  else{
    int X=N/K;
    ans=X*X*X;
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 256
n = int(input())
s = str(input())
list_s = list(s)
cut = 0
ans = 0
while cut < n:
    if ans < len(set(list_s[:cut]) & set(list_s[cut:])):
        ans = len(set(list_s[:cut]) & set(list_s[cut:]))
    cut += 1
print(ans)


Measured memory_bytes: 3060
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;
 
int main(){
    int A,B;
    cin >> A >> B;
    cout << max(max((A-B), A+B), A*B) << endl;
}

Measured memory_bytes: 3620
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] w = new int[n];
        int maxV = Integer.MIN_VALUE;
        for (int i = 0; i < n; i++) {
            w[i] = in.nextInt();
            if (w[i] > maxV) maxV = w[i];
        }
        int result = minCostSort(w, n, maxV);
        System.out.println(result);
    }

    public static int minCostSort(int[] w, int n, int maxV) {
        int ans = 0;  // 初始化结果

        boolean[] visit = new boolean[n];  // 已访问标记数组
        for (int i = 0; i < n; i++) {
            visit[i] = false;
        }

        int[] sortedW = w.clone();  // 有序成本数组
        Arrays.sort(sortedW);

        int[] T = new int[maxV + 1];  // 某成本对应的顺序序号
        for (int i = 0; i < n; i++) {
            T[sortedW[i]] = i;
        }
        int x = sortedW[0];

        for (int i = 0; i < n; i++) {
            if (visit[i]) continue;  // 已访问过，则接着访问下一个
            int cur = i;  // 当前访问位置
            int sum = 0;  // 环路内总成本
            int min = maxV;  // 环路内最小成本
            int count = 0;  // 环路总长度

            // 寻找该成本在实际顺序中的对应位置，即交换位置
            while (!visit[cur]) {
                visit[cur] = true;
                count++;
                int v = w[cur];
                min = Math.min(min, v);
                sum += v;
                cur = T[v];
            }

            ans += Math.min(sum + (count - 2) * min, min + sum + (count + 1) * x);
        }
        return ans;
    }
}



Measured memory_bytes: 30316
/*
ID: leezhen1
TASK: practice
LANG: C++14                 
*/
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <cmath>

using namespace std;
struct Point{
	int x, y;
	int color;
	Point(int a, int b, int c):x(a), y(b), color(c){};
};
bool cmp(Point& p1, Point& p2){
	if(p1.x != p2.x){
		return p1.x < p2.x;
	}else{
		return p1.y < p2.y;
	}
}
int main() {
	int n;
	cin >> n;
	set<int> s;
	vector<Point> points;
	for(int i=0; i<n; i++){
		int a, b;
		cin >> a >> b;
		points.push_back(Point(a, b, 0));
	}
	for(int i=0; i<n; i++){
		int a, b;
		cin >> a >> b;
		points.push_back(Point(a, b, 1));
	}
	sort(points.begin(), points.end(), cmp);
	int ans = 0;
	for(int i=0; i<points.size(); i++){
		if(points[i].color == 0){
			s.insert(points[i].y);
		}else{
			int y = points[i].y;
			int t = -1;
			auto it=s.begin();
			for(; it!=s.end(); it++){
				if(*it >= y) break;
				else
					t = *it;
			}
			if(t!= -1){
				s.erase(--it);
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

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

    int Incnum = Bnum - Anum;

    int Addnum = 1;

    for (int i = 2; i <= 999; i++)
    {
        Addnum += i;
        if (Incnum == i)
        {
            printf("%d", Addnum - Bnum);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0316
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] h = RArInt();
            int[] k = RArInt();
            int[] abcd = RArInt();

            string res = "";
            int hScore = h[0] * abcd[0] + h[1] * abcd[1] + h[0] / 10 * abcd[2] + h[1] / 20 * abcd[3];
            int kScore = k[0] * abcd[0] + k[1] * abcd[1] + k[0] / 10 * abcd[2] + k[1] / 20 * abcd[3];

            if (hScore > kScore) res = "hiroshi";
            else if (kScore > hScore) res = "kenjiro";
            else res = "even";

            Console.WriteLine(res);
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



Measured memory_bytes: 15960
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
const int MAX = 300005;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ll Pow(ll a , ll b){
	if(b == 0) return 1 ;
	ll c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c)% mod )) % mod ;
	return (c * c) % mod ;
}

//check modulo
int main(){
	IOS;
	cout.precision(50) ;
	string s , t ; cin >> s >> t; 
	vector<vi> v(26);
	for(int i = 0 ; i < (int)s.size() ; i++) {v[(int)s[i] - (int)'a'].pb(i) ;}
	ll nb = 0 , last = -1 ;
	int n = (int)t.size() ;
	for(int i = 0 ; i < n ; i++){
		int x = (int)t[i] -  (int)'a' ;
		if(v[x].size() == 0) return cout << -1 << "\n" , 0 ;
		vi::iterator up = upper_bound(v[x].begin() , v[x].end() , last) ;
		if(up == v[x].end()){
			nb++ ;
			up = upper_bound(v[x].begin() , v[x].end() , -1) ;
			last = *up ;
		}
		else last = *up ;
	}
	cout << nb * (ll)s.size() + last + 1 << endl ;
		
	
	
	return 0;
}


Measured memory_bytes: 1228