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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
typedef long long ll;
typedef vector<ll> vll;
//typedef pow(2,31)+1 INF;

int cnt;

string to_binString(ll n){
    string bins = "";
    ll size = log2(n);
    for(int i=size;i>=0;i--){
        if(pow(2,i) <= n){
            n -= pow(2,i);
            bins += '1';
        }
        else bins += '0'; 
    }
    return bins;
}

void merge(int n[], int left, int mid, int right)
{
    int num = right - left;
    int *tmp = new int[num];

    int iw = 0;
    int il = left;
    int ir = mid;

    while (il < mid && ir < right)
    {
        if (n[il] <= n[ir])
        {
            tmp[iw++] = n[il++];
        } else {
            tmp[iw++] = n[ir++];
        }
    }

    while (il < mid) tmp[iw++] = n[il++];
    while (ir < right) tmp[iw++] = n[ir++];

    for (int i=0; i<num; i++){
        n[left + i] = tmp[i];
        cnt++;
    }

    delete[] tmp;
}

void merge_sort_sub(int n[], int left, int right)
{
    if (right - left <= 1) return;

    int mid = left + (right - left) / 2;
    merge_sort_sub(n, left, mid);
    merge_sort_sub(n, mid, right);

    merge(n, left, mid, right);
}


void merge_sort(int n[], int len)
{
    merge_sort_sub(n, 0, len);
}

int main()
{
    int n;
    cin >> n;
    int A[n];
    rep(i,n)cin >> A[i];

    merge_sort(A, n);

    rep(i,n){
        cout << A[i];
        if(i != n-1)cout << " ";
        else cout << endl;
    }
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 7628
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef long long ll;
typedef long long integer;
//////////////////////////////////////////////////
int main(){
    string A;
    getline(cin,A);
    integer N = (integer)A.length();
    integer inv = 0;

    for(char c = 'a'; c <= 'z' ; ++c){
        integer a = 0;
        REP(i,N){
            if (A[i] == c) a++;
        }

        inv += a*(a-1) / 2;
    }

    PRINTLLD( (N*(N-1)/2) + 1 - inv);
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
template<typename X>
class Graph {
private:
  int n;// 頂点数
  int m;// 辺の数
  vector<vector<pair<int,X>>> edge; // 重み付き有向辺
  vector<vector<X>> d;// d[i][j] := 頂点iから頂点jの最短距離
  const X inf = 1e+17;

public:
  Graph(int _n, int _m, vector<int> a, vector<int> b, vector<X> c) {
    n = _n;
    m = _m;
    edge.resize(n);
    rep(i,m) {
      add_edge(a[i], b[i], c[i]);
      add_edge(b[i], a[i], c[i]);      
    }
    d.resize(n);
  }

  void add_edge(int from, int to, X cost) {
    edge[from].push_back( {to, cost} );
  }

  void dijkstra(int s) {
    d[s].resize(n, inf);
    d[s][s] = 0;
    priority_queue< pair<X,int>, vector<pair<X,int>>, greater<pair<X,int>> > pq;
    pq.push( {0, s} );
    while( !pq.empty() ) {
      pair<X,int> p = pq.top(); pq.pop();
      int v = p.second;
      if( d[s][v] < p.first ) continue;
      for(auto w : edge[v]) {
	int t = w.first; // 頂点wから頂点tに向かう
	X c = w.second; // w -> t のコストがc
	if( d[s][t] > d[s][v] + c) {
	  d[s][t] = d[s][v] + c;
	  pq.push( {d[s][t], t} );
	}
      }
    }
  }

  X get_d(int u, int v) {
    return d[u][v];
  }
  
};
int main()
{
  int n,m,s,t;cin >> n >> m >> s >> t;
  s--; t--;
  vector<int> u(m), v(m);
  vector<ll> a(m), b(m);
  rep(i,m) {
    cin >> u[i] >> v[i] >> a[i] >> b[i];
    u[i]--; v[i]--;
  }
  
  Graph<ll> gpen(n, m, u, v, a);
  Graph<ll> gpsn(n, m, u, v, b);

  gpen.dijkstra(s);
  gpsn.dijkstra(t);

  vector<ll> res(n);
  rep(i,n) {
    res[i] = gpen.get_d(s, i) + gpsn.get_d(t, i);
  }

  ll M = 1e+15;
  ll tmp = M;
  vector<ll> ans(n);
  for(int i = n - 1;i >= 0;--i) {
    tmp = min(tmp, res[i]);
    ans[i] = M - tmp;
  }

  rep(i,n) cout << ans[i] << "\n";
  
  return 0;
}


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

int main()
{
  int h, w, n;
  cin >> h >> w >> n;
  vector<int> a(n);
  for (auto&& e : a) cin >> e;

  queue<int> color;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < a[i]; j++) {
      color.push(i + 1);
    }
  }

  vector<vector<int>> grid(h, vector<int>(w));

  for (int i = 0; i < h; i++) {
    if (i % 2 == 0) {
      for (int j = 0; j < w; j++) {
        grid[i][j] = color.front();
        color.pop();
      }
    } else {
      for (int j = w - 1; j >= 0; j--) {
        grid[i][j] = color.front();
        color.pop();
      }
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cout << grid[i][j];
      if (j != w - 1) cout << ' ';
    }
    cout << endl;
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

const long long MOD = 1000000007LL;
const long long INF = 1e18;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

int n;
long double dist[9][2], tot = 0, cnt = 0;
bitset<9> vis;
vector<int> mov;
void helper(int p, long double t = 0, int prev = -1){
    if(p == n){
        //cout << t << " " << vis.count() << endl;
        t = 0;
        for(int p, i, j = 1; j < n; ++j){
            //cout << "FUCK " << dist[i][0] - dist[p][0] << endl;
            //cout << "FUCK " << dist[i][1] - dist[p][1] << endl;
            p = mov[j - 1];
            i = mov[j];
            t += sqrt(pow(dist[i][0] - dist[p][0], 2) + pow(dist[i][1] - dist[p][1], 2));
        }
        //cout << t << endl << endl;
        ++cnt;
        tot += t;
        return;
    }
    for(int i = 0; i < n; ++i){
        if(vis[i]) continue;
        vis[i] = 1;
        mov.push_back(i);
        helper(p + 1, t + sqrt(pow(dist[i][0] - dist[p][0], 2) + pow(dist[i][1] - dist[p][1], 2)), i);
        mov.pop_back();
        vis[i] = 0;
    }
}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin >> n;
    for(int a, b, i = 0; i < n; ++i){
        cin >> dist[i][0] >> dist[i][1];
    }
    for(int i = 0; i < n; ++i){
        vis[i] = 1;
        mov.push_back(i);
        helper(1, 0, i);
        mov.pop_back();
        vis[i] = 0;
    }

    cout << setprecision(7) << fixed << tot / cnt << "\n";

    return 0;

}


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



int main ()
{
    double  a,b,cnt=0;
    cin >> a >> b ;
   int c=a,d=b;
   
   cout << fixed << setprecision(7);

    cout << c/d <<" " << c%d << " " << a/b << endl;
}



Measured memory_bytes: 3280
#include <iostream>

using namespace std;

int main(void) {
  int N, C, D;
  cin >> N;
  C = (N / 4) + 1;
  D = (N / 7) + 1;

  for (int i = 0; i < C; i++) {
    for (int j = 0; j < D; j++) {
      if(N == i * 4 + j * 7){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

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

int N;
vector<vector<vector<int>>> path(100000);
vector<long long> minpath(100000,0);
vector<bool> reach(100000,false);

void func(int now,long long cost){
  minpath[now]=cost;
  reach[now]=true;
  for(auto a:path[now]){
    if(reach[a[0]]==false){
      func(a[0],cost+a[1]);
    }
  }
}

int main(){
  cin >> N;
  for(int i=0; i<N-1; i++){
    int a,b,c;
    cin >> a >> b >> c;
    a--; b--;
    path[a].push_back({b,c});
    path[b].push_back({a,c});
  }
  int Q,K; cin >> Q >> K;
  func(K-1,0);
  for(int i=0; i<Q; i++){
    int x,y;
    cin >> x >> y;
    cout << minpath[x-1]+minpath[y-1] << endl;
  }
}

Measured memory_bytes: 25216
import java.io.*;

class Main{
	private Node first, last;

	public Main(){
		int n, limit = 0, timeSt = 0;
		String[] tmp;
		Node[] process;

		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in), 1);
		try{
			tmp = br.readLine().split(" ");
			n = Integer.parseInt(tmp[0]);
			limit = Integer.parseInt(tmp[1]);
			process = new Node[n];

			for(int i=0; i < n; i++){
				tmp = br.readLine().split(" ");
				process[i] = 
					new Node(tmp[0], Integer.parseInt(tmp[1]));
				enqueue(process[i]);
			}

		}catch(IOException e){
			System.out.println(e);
		}
		Node node = null;
		while( (node = dequeue()) != null){
			if( node.getTime() <= limit){
				timeSt += node.getTime(); 
				System.out.println(node+" "+timeSt);
			}else{
				timeSt += limit;
				int t = node.getTime();
				node.setTime(t - limit);
				enqueue(node);
			}
		}
	}

	void enqueue(Node p){
		if(first == null){
			last = p;
			first = last; 
		} else{
			last.next = p;
			last = last.next;
		}
	}
	Node dequeue(){
		if(first != null){
			Node tmp = first;
			first = first.next;
			tmp.next = null;
			return tmp;
		}
		return null;
	}

	void printQueue(){
		Node n = first;
		while(n != null){
			System.out.println(n);
			n = n.next;
		}
	}
	
	public static void main(String[] args){
		new Main();
	}
}

class Node{
	private String name;
	private int time;
	Node next;

	Node(String name, int time){
		this.name = name;
		this.time = time;
	}
	int getTime(){
		return this.time;
	}
	void setTime(int time){
		this.time = time;
	}
	void setNext(Node n){
		next = n;
	}
	@Override
	public String toString(){
		return name;
	}
}

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

#define LLINF (1LL<<60)
typedef long long ll;

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

template<typename T> inline T divrup(T a, T b) { if (a % b!=0) return a/b+1; else return a/b;}

//C++14 (GCC 5.4.1)
int main() {
    ll N;
    cin >>N;

    vector<ll> s(5);//ABCDE->Hpm(01234)
    rep(i,5) cin >> s[i];
    
    //-----------------------------------
    //可換
    //昇順に並べることで初回以外は+1で良い
    ll mini=s[0];
    repd(i,1,5){
        mini=min(mini,s[i]);
    }

    cout <<divrup(N,mini)+4 <<endl;
    return (0);
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 333
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int tot,n,m,ans[N][N];
char mp[N][N]; 
int main(){
	n=read(),m=read(),tot=read();
	for(int i=1;i<=n;++i){
		scanf("%s",mp[i]+1);
	}
	int pos=0;
	for(int i=1;i<=n;++i){
		bool ok=false;
		for(int j=1;j<=m;++j){
			if(mp[i][j]=='#'){
				ok=true;
				break;
			}
		}
		if(!ok){
			if(pos)memcpy(ans[i],ans[i-1],sizeof(ans[i]));
		}
		else{
			if(!pos)pos=i;
			int k=0;
			for(int j=1;j<=m;++j){
				if(mp[i][j]=='#'){
					if(!k)k=j;
					ans[i][j]=tot--;
				}
				else{
					ans[i][j]=ans[i][j-1];
				}
			}
			for(int j=k-1;j>=1;--j){
				ans[i][j]=ans[i][k];
			}
		}
	}
	for(int i=pos-1;i>=1;--i){
		memcpy(ans[i],ans[pos],sizeof(ans[i]));
	}
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			printf("%d ",ans[i][j]);
		}
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 4292
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a;
    int b;
    int c;
    int x;
    scanf("%d %d %d",&a,&b,&c);
    if (a > b) {
        x=a;      //a??¨b?????\?????????   a=x??¨??????
        a=b;      //               b?????´??????a?????\??????
        b=x;      //               a(x)?????´??????b?????\??????
    }if (b > c) {
        x=b;      //b??¨c?????\???????????????b=x??¨??????
        b=c;      //               c?????´??????b?????\??????
        c=x;      //               b(x)?????´??????c?????\??????
    }if (a > b) {
        x=a;      //??\??????????????????a??¨b?????\?????????
        a=b;      //
        b=x;      //
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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; }
const ll MOD = 1e9+7;

const int MAX_N = 3000000;

ll fact[MAX_N+100];
ll frev[MAX_N+100];

ll rev(ll a, ll p){
    if(p == 0) return 1;
    ll tmp = rev(a, p/2);
    tmp = tmp * tmp % MOD;
    if(p % 2 == 1) tmp = tmp * a % MOD;
    return tmp;
}


void calc_fact(){
    fact[0] = frev[0] = 1;
    for(int i = 1; i <= MAX_N; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        frev[i] = rev(fact[i], MOD-2);
    }
}


ll comb(int n, int k){
    if(n < 0 || k < 0 || n < k) return 0;
    if(n == 0 || k == 0) return 1;
    return fact[n] * frev[k] % MOD * frev[n-k] % MOD;
}


ll func(int r, int c){
    return comb(r+c+1, c);
}

int main(){
    ll R1, C1, R2, C2;
    cin >> R1 >> C1 >> R2 >> C2;

    //in main function
    fact[0] = frev[0] = 1;
    for(int i = 1; i <= MAX_N; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        frev[i] = rev(fact[i], MOD-2);
    }

    ll ans = 0;
    REPi(r, R1, R2+1){
        ans += func(r, C2);
        ans %= MOD;
    }

    REPi(r, R1, R2+1){
        //ans += MOD - func(r, C1-1);
        ans -= func(r, C1-1);
        ans += MOD;
        ans %= MOD;
    }

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


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  string s; cin >> s;
  int N = s.size();
  int ans = N;
  for (int i = 0; i + 1 < N; i++) {
    if (s[i] != s[i+1]) {
      chmin(ans, max(i + 1, N - i - 1));
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}



Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
int main(void)
{
	int n,i,j;
	int temp,data[10];
	char tn[11][21],temps[21];
	int k,m,h;
	scanf("%d" ,&n);
	while(n!=0){
		for(j=0;j<10;j++){
			data[j]=0;
		}
		for(j=0;j<n;j++){
			scanf("%s %d %d %d",tn[j],&k,&m,&h);
			data[j]+=k*3;
			data[j]+=h;
		}
		for(i=0;i<n-1;i++){
			for(j=n-1;j>i;j--){
				if(data[j]>data[j-1]){
					temp=data[j];
					data[j]=data[j-1];
					data[j-1]=temp;
					strcpy(temps,tn[j]);
					strcpy(tn[j],tn[j-1]);
					strcpy(tn[j-1],temps);
				}
			}
		}
		for(j=0;j<n;j++){
				printf("%s,%d\n",tn[j],data[j]);
		}
		scanf("%d",&n);
		if(n!=0){
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1044
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define bits_count __builtin_popcountll
#define endl '\n'
#define double double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int L = 40;
int dp[L];

bool cmp(pair<int,int> a,pair<int,int> b){
    return a.first*b.second > b.first*a.second;
}

void solve(){
    int n,T; cin>>n>>T; T++;
    dp[0] = 1;
    FOR(j,1,L-1) dp[j] = T+1;

    vector<int> offs = {0};
    vector<pair<int,int>> shops;

    for(int i=0;i<n;i++){
        int a,b; cin>>a>>b; b++;
        if(a == 0) offs.push_back(b);
        else shops.push_back({a,b});
    }

    sort(all(shops),cmp);

    for(auto sp:shops){
        for(int m = L-2;m >= 0;m--){
            int off = dp[m] + dp[m]*sp.first + sp.second;
            if(off <= T) dp[m+1] = min(dp[m+1],off);
        }
    }

    sort(all(offs));
    for(int i=1;i<sz(offs);i++) offs[i] += offs[i-1];

    int j = sz(offs) - 1;

    int ans = 0;

    for(int m=0;m<L;m++){
        while(j >= 0 && dp[m] + offs[j] > T) j--;
        if(j < 0) break;
        ans = max(ans,m + j);
    }

    cout<<ans<<endl;
}

signed main(){

   FastRead;    


    int t = 1; 
    // cin>>t; 
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}


Measured memory_bytes: 6512
n = int(input())
s = input()

t = []
num = 0
for i in range(n):
    if num == 0 and s[i] == ')':
        t.insert(0, '(')
        t.append(')')
    else:
        t.append(s[i])
        if s[i] == '(':
            num += 1
        else:
            num -= 1

if num > 0:
    for i in range(num):
        t.append(')')

for i in t:
    print(i, end='')

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(abs(a-c)<=d){
    cout << "Yes" << endl;
  }else if((abs(a-b)<=d)&&(abs(b-c)<=d)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#define	MOD = 1000000007;
using namespace std;

int main()
{
	long W, a, b;
	cin >> W >> a >> b;

	if (a + W < b) {
		cout << b - (a + W) << endl;
	}
	else if (b + W < a)
	{
		cout << a - (b + W) << endl;
	}
	else {
		cout << 0;
	}

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        ReadLine();
        var s = ReadLine();
        var ans = 0;
        for (int i = 0; i < s.Length; i++)
        {
            var c = 0;
            var x = s.Take(i);
            var y = s.Skip(i);
            var xc = new bool[26];
            var yc = new bool[26];
            foreach (var item in x)
            {
                xc[item - 'a'] = true;
            }
            foreach (var item in y)
            {
                yc[item - 'a'] = true;
            }
            for (int j = 0; j < 26; j++)
            {
                if (xc[j] && yc[j]) c++;
            }
            if (c > ans) ans = c;
        }
        WriteLine(ans);
    }
}

Measured memory_bytes: 13268
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for(int i=(a);i<(int)(n);i++)
#define repc(i, a, n) for(int i=(a);i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
#define DBG(str) cerr<<(str)<<endl;
int main() {
	vector<int>a(3);
	rep(i, 0, 3)cin >> a[i];
	sort(all(a));
	int sum = a[2]-a[0];
	int sum2 = abs(a[0] - a[2]);
	cout << min(sum, sum2);


	return 0;
}





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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int n;
	cin >> n;

	vector<int> a(n);
	rep (i, 0, n)
		cin >> a[i];

	sort(a.begin(), a.end());
	int kind = 1;
	int count = 0;
	int tmp = a[0];
	rep (i, 1, n) {
		if (a[i] == tmp) {
			count++;
		} else {
			tmp = a[i];
			kind++;
		}
	}

	int res = kind - ((count & 1) ? 1 : 0);
	cout << res << endl;

	return 0;
}
 


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

int main() {
	// your code goes here
	int n, m; cin >> n >> m;
	
	if(n % 3 == 0 || m % 3 == 0 || (n + m) % 3 == 0) 
		cout << "Possible" << endl;
	else cout << "Impossible" << endl;
	
	return 0;
}

Measured memory_bytes: 256
from collections import deque
n,*L=map(int,open(0).read().split())
G=[[]for _ in range(n)]
db=[-1]*n;db[0]=0
dw=[-1]*n;dw[-1]=0
for a,b in zip(*[iter(L)]*2):
	G[a-1]+=[b-1]
	G[b-1]+=[a-1]
q=deque([0])
while q:
	cur=q.popleft()
	for nxt in G[cur]:
		if db[nxt]<0:
			q.append(nxt)
			db[nxt]=db[cur]+1
q=deque([n-1])
while q:
	cur=q.popleft()
	for nxt in G[cur]:
		if dw[nxt]<0:
			q.append(nxt)
			dw[nxt]=dw[cur]+1
b=w=0
for i,j in zip(db,dw):
	if i<=j:b+=1
	else:w+=1
if b<=w:print("Snuke")
else:print("Fennec")

Measured memory_bytes: 37232
#include<stdio.h>
#include<ctype.h>
int main(void){
    int count[26] = {0};
    char ch;
    int i, num;
    
    while(scanf("%c", &ch)!= EOF){
        if(islower(ch)){
            num = ch - 'a';
        }else if(isupper(ch)){
            num = ch - 'A';
        }else{
            continue;
        }
        count[num]++;
    }
    for(i = 0; i < 26; i++){
        printf("%c : %d\n", 'a'+i, count[i]);
    }
    return 0;
}


Measured memory_bytes: 2708
n, m = map(int, input().split())
ac = []
for _ in range(m):
    ai, bi = map(int, input().split())
    ci = list(map(lambda x: 2 ** (int(x) - 1) , input().split()))
    ac.append((ai, sum(ci)))

INF = 100 ** 18
dp = [INF] * (2**n)
dp[0] = 0
for ai, ci in ac:
    for j in range(0, 2**n):
        dp[j | ci] = min(dp[j | ci], dp[j] + ai)

ans = dp[2**n-1]
if ans == INF:
    print(-1)
    exit()
print(ans)



Measured memory_bytes: 45912
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const ll mod= 1e9+7;
long double pi = acosl(-1);
const int inf = 1e9;
const int nmax = 1e5+5;
const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;



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

    ll n,p;
    cin>>n>>p;
    if(n==1) cout<<p, exit(0);

    vector<ll> v;
    for(ll i=2; i*i<=p; i++){
        if(p%i) continue;
        int cnt=0;
        while(p%i==0) cnt++, p/=i;
        ll cur=1;
//        cout<<cnt<<"  "<<i<<endl;
        cnt/=n;
        while(cnt--) cur*=i;
        v.push_back(cur);
    }
    sort(v.rbegin(), v.rend());
    ll ans=1;
    for(int i=0; i<v.size(); i++){
//        cout<<v[i]<<endl;
        ans*=v[i];
    }

    cout<<ans;
}


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

int main(){
  int a,c=0;
  cin >> a;
  vector<int>b(a);
  for(int i=0;i<a;i++){
    cin >> b.at(i);
  }
  for(int i=0;i<a;i++){
    for(int j=i+1;j<a;j++){
      c=c+b.at(i)*b.at(j);
    }
  }
  cout <<c;
}


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

using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n, M[N][N];
int d[N];

void bfs(int s){
  queue<int> q;
  q.push(s);
  for(int i=0;i<N;i++) d[i] = INFTY;
  d[s] = 0;
  int u;
  while(!q.empty()){
    u = q.front();
    q.pop();
    for(int v=0;v<n;v++){
	if(M[u][v] == 0) continue;
	if(d[v] != INFTY) continue;
	d[v] = d[u] + 1;
	q.push(v);
    }
  }
  for(int i=0;i<n;i++){
    cout << i+1 << " " << ((d[i] == INFTY) ? (-1) : d[i]) << endl;
  }
}

int main(){
  int u, k, v;

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

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

  bfs(0);

  return 0;
}



Measured memory_bytes: 3112
///not today

#include <bits/stdc++.h>
using namespace std;

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
//#define int long long
#define pipii pair<int, pair<int, int> >
#define pf push_front

int f(double n){
    int l = 0, r = 10000* 10000;
    while(r - l > 1){
        int mid = (r + l)/ 2;
        if(mid > n)
            r = mid;
        else
            l = mid;
    }
    return l;
}

int32_t main(){
    int n;
    cin >>n;
    int l = 0, r = 1000* 1000;
    while(r - l > 1){
        int mid = (r + l)/ 2;
        if(f((double)mid * (1.08)) > n)
            r = mid;
        else
            l = mid;
    }
    if(f((double)l * (1.08)) == n)
        cout <<l <<endl;
    else
        cout <<":(" <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

// https://www.geeksforgeeks.org/longest-repeating-and-non-overlapping-substring/
string longestRepeatedSubstring(string str) 
{ 
    int n = str.length(); 
    int LCSRe[n+1][n+1]; 
  
    // Setting all to 0 
    memset(LCSRe, 0, sizeof(LCSRe)); 
  
    string res; // To store result 
    int res_length  = 0; // To store length of result 
  
    // building table in bottom-up manner 
    int i, index = 0; 
    for (i=1; i<=n; i++) 
    { 
        for (int j=i+1; j<=n; j++) 
        { 
            // (j-i) > LCSRe[i-1][j-1] to remove 
            // overlapping 
            if (str[i-1] == str[j-1] && 
                LCSRe[i-1][j-1] < (j - i)) 
            { 
                LCSRe[i][j] = LCSRe[i-1][j-1] + 1; 
  
                // updating maximum length of the 
                // substring and updating the finishing 
                // index of the suffix 
                if (LCSRe[i][j] > res_length) 
                { 
                    res_length = LCSRe[i][j]; 
                    index = max(i, index); 
                } 
            } 
            else
                LCSRe[i][j] = 0; 
        } 
    } 
  
    // If we have non-empty result, then insert all 
    // characters from first character to last 
    // character of string 
    if (res_length > 0) 
        for (i = index - res_length + 1; i <= index; i++) 
            res.push_back(str[i-1]); 
  
    return res; 
} 

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

  int n;
  cin >> n;
  string s;
  cin >> s;

  cout << longestRepeatedSubstring(s).size() << endl;
}


Measured memory_bytes: 97920
#include<iostream>

using namespace std;

int main(){
	long long n,k;
	cin>>n>>k;
	
	if(k%2==0){
		long long i=n/k;
		long long j=(n+k/2)/k;
		long long result = i*(i-1)*(i-2)+i*(i-1)*3+i;
		result += j*(j-1)*(j-2) + j*(j-1)*3 + j;
		cout <<result;
	}else{
		long long i = n/k;
		long long result = i*(i-1)*(i-2)+i*(i-1)*3+i;
		cout <<result;
	}
	
}

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

const int MOD = 1000000007;
const int MAX = 200000;

ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
// n= 200000までのやつ
void COMinit(){
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

int main() {
  ll n, m;
  cin >> n >> m;
  COMinit();
  if(abs(m - n) > 1){
    cout << 0 << endl;
    return 0;
  }
  ll ans = fac[n] * fac[m] % MOD;
  if(m == n) ans *= 2; ans %= MOD;
  cout << ans << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pll;

const ll N = 1e2 + 8;
const ll W = 1e5 + 8;

ll n, w;
struct item {
    ll w, v;
};
vector <item> a;

ll dp[W][N] {};

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ///freopen("input.in", "r", stdin);
    ///freopen("output.out", "w", stdout);
    cin >> n >> w;
    a.resize (n + 1);
    for (ll i = 1; i <= n; ++i)
        cin >> a[i].w >> a[i].v;
    for (ll k = 1; k <= n; ++k) {
        for (ll x = 0; x <= w; ++x) {
            if (x - a[k].w >= 0)
                dp[x][k] = max ({dp[x][k], dp[x - a[k].w][k - 1] + a[k].v});
            dp[x][k] = max (dp[x][k], dp[x][k - 1]);
        }
    }
    cout << dp[w][n] << '\n';
    return 0;
}


Measured memory_bytes: 84608
N = int(input())
ans = 0


def fizzbuzz(n):
    if n % 15 == 0:
        return 'FizzBuzz'
    elif n % 3 == 0:
        return 'Fizz'
    elif n % 5 == 0:
        return 'Buzz'
    else:
        return n


for n in range(1, N + 1):
    if fizzbuzz(n) == n:
        ans += n
print(ans)

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  
  int ans = 0;
  for (int i = 1; i < N; i++) {
    string X = S.substr(0, i), Y = S.substr(i, N - i);
    vector<int> A(26), B(26);
    int K = 0;
    for (int j = 0; j < X.size(); j++) A.at(X.at(j) - 'a') = 1;
    for (int j = 0; j < Y.size(); j++) B.at(Y.at(j) - 'a') = 1;
    for (int j = 0; j < 26; j++) {
      if (A.at(j) == 1 && B.at(j) == 1) K++;
    }
    ans = max(ans, K);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int help(int arr[],int n,int &k,int dp[])
{
 if(n==0)
   return 0;
   if(n==1)
   return abs(arr[1]-arr[0]);

  if(dp[n]!=-1)
    return dp[n];
  int m=INT_MAX;
  for(int i=k;i>0;i--)
  { 
    if(n-i>=0)
      m=min(m,help(arr,n-i,k,dp)+abs(arr[n-i]-arr[n]));

  }
  dp[n]=m;
//cout<<dp[n]<<endl;
return dp[n];
}
int main()
{
 int n;
cin>>n;
int k;
cin>>k;
int arr[n];
for(int i=0;i<n;i++)
cin>>arr[i];
  int dp[n];

  memset(dp,-1,sizeof(dp));
 cout<<help(arr,n-1,k,dp)<<endl;
  
  
  
  
  
}

Measured memory_bytes: 10368
N = gets.chomp.to_i
h = gets.chomp.split(" ").map(&:to_i)

max = h[0]
checker = true

for i in 1...N do
  max = [max, h[i]].max
  if max - h[i] > 1 then
    checker = false
    break
  end
end

checker ? (puts "Yes") : (puts "No")


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(abs(c-a) <= d){
        puts("Yes");
    }else if(abs(c-b) <= d && abs(a - b) <= d){
        puts("Yes");
    }else{
        puts("No");
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <vector>


using namespace std;

const long long TINF=100000000000000000ll;

template<class T> class segmintree
{
private:
  T ragin(int i,int j,int k,int a,int b)
  {
    return a<=j&&k<=b?seg[i]:k<=a||b<=j?TINF:min(ragin(2*i,j,(j+k)/2,a,b),ragin(2*i+1,(j+k)/2,k,a,b));
  }
public:
  T *seg;
  int S;
  segmintree(int n)
  {
    S=0;
    while((1<<S)<=n)S++;
    seg=(T *)calloc(sizeof(T),1<<(S+1));
    for(int i=0;i<1<<(S+1);i++){
      seg[i]=TINF;
    }
  }
  void set(int i,T k){
    int p=i+(1<<S);
    seg[p]=k;
    while(p>1){
      p/=2;
      seg[p]=min(seg[2*p],seg[2*p+1]);
    }
  }
  T rag(int a,int b){
    return ragin(1,0,1<<S,a,b);
  }
  T val(int i){
    int p=i+(1<<S);
    return seg[p];
  }
};

int main()
{
  int n,m;
  scanf("%d%d",&n,&m);
  vector<int> L(m),R(m);
  vector<vector<int> > E(n);
  vector<long long> C(m);
  for(int i=0;i<m;i++){
    scanf("%d%d%lld",&L[i],&R[i],&C[i]);
    L[i]--,R[i]--;
    E[R[i]].push_back(i);
  }
  segmintree<long long> seg(n+1);
  seg.set(0,0);
  for(int i=1;i<n;i++){
    long long V=TINF;
    for(int x=0;x<E[i].size();x++){
      int j=E[i][x];
      V=min(V,seg.rag(L[j],i)+C[j]);
      //printf("%d %d %lld\n",L[j],i,seg.rag(L[j],i)+C[j]);
    }
    seg.set(i,V);
  }
  long long ans=seg.val(n-1);
  printf("%lld\n",ans==TINF?-1:ans);
  return 0;
}


Measured memory_bytes: 9232
def sieve_of_eratosthenes(n):
    prime = list(range(n + 1))
    prime[0] = prime[1] = 0
    for i in range(2, n + 1):
        if i**2 > n:
            break
        if prime[i] > 0:
            for j in range(i**2, n + 1, i):
                prime[j] = 0
    return prime
    

x = int(input())
prime = sieve_of_eratosthenes(3 * 10**5)
for i in range(x, 3 * 10**5):
    if prime[i]:
        print(i)
        exit()

Measured memory_bytes: 15092
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#define IN1
#define OUT1
using namespace std;
template<typename T>void scan(T &x)
{
    char ch;
    bool f=0;
    x=0;
    ch=getchar();
    while(!isdigit(ch)&&ch!='-')
        ch=getchar();
    if(ch=='-') f=1,ch=getchar();
    while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
    if(f==1) x=-x;
}
int n,m,minn=0x7fffffff;
int a[100005];
int ans[100005];
int main()
{
    #ifdef IN
    	freopen("C.in","r",stdin);
    	#ifdef OUT
    	    freopen("C.out","w",stdout);
    	#endif
    #endif
    scan(n),scan(m);
    for(register int i=1;i<=n;i++)
        scan(a[i]);
    sort(a+1,a+n+1);
    for(register int i=1;i<=n-m+1;i++)
        ans[i]=a[i+m-1]-a[i],minn=min(minn,ans[i]);
    printf("%d\n",minn);
    return 0;
}

Measured memory_bytes: 1024
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

n = int(input())
s = int(input())
for _ in range(n - 1):
    t = int(input())
    s = lcm(s, t)
print(s)

Measured memory_bytes: 2940
#![allow(unused_imports)]

use std::cmp::{max, min};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let _n: usize = input().unwrap();
    let a: Vec<usize> = input_vec().unwrap();

    let mut ava = HashMap::new();
    for e in a {
        let h = ava.entry(e).or_insert(0);
        *h += 1usize;
    }

    let mut two = Vec::new();
    let mut four = Vec::new();

    for (k, v) in ava {
        if v >= 4 {
            four.push(k);
            two.push(k);
        } else if v >= 2 {
            two.push(k);
        }
    }

    two.sort_by(|a, b| b.cmp(a));

    let biggest_two = if two.len() <= 1 { 0 } else { two[0] * two[1] };
    let biggest_four = if four.len() == 0 { 0 } else { four.iter().max().unwrap().pow(2) };
    let ans = max(biggest_two, biggest_four);
    println!("{}", ans);
}

pub fn input<T: FromStr>() -> Result<T, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    Ok(buf.trim().parse().ok().unwrap())
}

pub fn input_vec<T: FromStr>() -> Result<Vec<T>, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    Ok(buf
        .trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>())
}

pub fn input_two<T: FromStr, U: FromStr>() -> (T, U) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
    )
}

pub fn input_three<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
        s[2].parse::<V>().ok().unwrap(),
    )
}

pub fn input_four<T: FromStr, U: FromStr, V: FromStr, W: FromStr>() -> (T, U, V, W) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse().ok().unwrap(),
        s[1].parse().ok().unwrap(),
        s[2].parse().ok().unwrap(),
        s[3].parse().ok().unwrap(),
    )
}


Measured memory_bytes: 12540
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

int main(){
  int N;
  while(~scanf("%d",&N)){
    int count = 0;
    for(ll i=1;i<N;i*=3) count++;
    printf("%d\n",count);
  }
}

Measured memory_bytes: 1188
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int myPower(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}


const int maxn = (int) 1e5 + 10;
int a[maxn];
int n;

int read() {
  if (scanf("%d", &n) < 1) {
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  return 1;
}

pair<int, int> tosort[maxn];

int b[maxn];

void solve() {
  for (int i = 0; i < n; ++i) {
    tosort[i] = mp(a[i], i);
  }
  sort(tosort, tosort + n);

  for (int i = 0; i < n; ++i) {
    b[tosort[i].second] = (i & 1);
  }

  long long res = 0;
  for (int i = 0; i < n; ++i) {
    if (b[i] && !(i & 1)) {
      ++res;
    }
  }
  printf("%lld\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>

int main()
{
	int A;
	int B;

	std::cin >> A >> B;

	if (A >= 13)
		std::cout << B << "\n";
	else if (A >= 6)
		std::cout << (B/2) << "\n";
	else
		std::cout << "0\n";
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, P[222222], C = 0;

  std::cin >> N;

  for (int i = 0; i < N; i ++)
    std::cin >> P[i];

  std::set<int> set;

  for (int i = 0; i < N; i ++) {
    if (set.empty()) {
      C ++;
    }
    else if (*set.begin() >= P[i]) {
      C ++;
    }

    set.insert(P[i]);
  }

  std::cout << C << std::endl;

  return 0;
}


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

int main(){
  int A,B,K;
  cin >> A >> B >> K;
  int cnt =0;
  //今まで見つかった数
  for(int i=100;i>=1;i--){
    if ((A%i)==0 & (B%i)==0){
      cnt++;
    }
    if(cnt==K){ //K番目に大きい数が見つかった時のiが答えである
      cout << i <<endl;
      return 0;
    }
  }

}


Measured memory_bytes: 3628
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*                                                    
      I ♥ CLARICE STARLING...                                                               
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
void solve()
{
    string s;cin>>s;
    int cnt=0,mx=0;
    int i=0;
    while(i<3)
    {
        while(i<3&&s[i]=='S')i++;
        cnt=0;
        while(i<3&&s[i]=='R')i++,cnt++;
        mx=max(mx,cnt);
    }
    cout<<mx<<"\n";
}
int main()
{
   fastio
   //Test_cases
   solve();
  return 0;
}
//**always check if you are not killing input in between
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>; 
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//string2=string1.substr(pos,length);if len no specified then till end
//void fill (ForwardIterator first, ForwardIterator last, const T& val);
//The range filled is [first,last), which contains all the elements between first and last, including the element pointed by first but not the element pointed by last.


//If wrong on pretest 2 means logically wrong
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll N;
string X;
void input(){
    fast_io();
    cin >> N;
    cin >> X;
}

template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}

vector<ll> memo;
ll f(ll n){
    if(n==0) return 0LL;
    if(memo[n]) return memo[n];
    return memo[n] = (1LL+f(n%__builtin_popcountll(n)));
}

int solve(){
    ll px = 0LL;
    for (int i = 0; i < N; i++) if(X[i]=='1') px++;
    ll XmodP = 0LL, XmodM = 0LL;
    if(px>2){
        for (int i = 0; i < N; i++)
        {
            XmodP *= 2LL;
            XmodM *= 2LL;
            if(X[i]=='1') {
                XmodP++;
                XmodM++;
            }
            XmodP %= (px+1);
            XmodM %= (px-1);
        }
    }
    if(px==1 || px==2){
        for (int i = 0; i < N; i++)
        {
            XmodP *= 2LL;
            if(X[i]=='1') {
                XmodP++;
            }
            XmodP %= (px+1);
        }
    }
    vector<ll> one_step(N,0);
    for (int i = 0; i < N; i++)
    {
        if(X[i]=='0'){
            one_step[i] = XmodP+mod_pow(2LL,N-1-i,px+1);
            one_step[i] %= (px+1);
        }
        else{
            if(px>1){
                one_step[i] = XmodM-mod_pow(2LL,N-1-i,px-1);
                one_step[i] += (px-1);
                one_step[i] %= (px-1);
            }
            else{
                one_step[i] = -1;
            }
        }
    }
    memo.assign(N+10,0LL);
    for (int i = 0; i < N; i++)
    {
        if(one_step[i]==-1) cout << 0 << endl;
        else cout << (f(one_step[i])+1LL) << "\n";
    }
    return 0;
}   

int main()
{
    input();
    solve();    
    return 0;
}

Measured memory_bytes: 6772