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

const int MAXN = (1LL<<21);

int n, k, conv[MAXN], nex[MAXN][2];

string find(int m, vector<int> ct) {
	assert(ct.size() == (1<<(m+1)));
	int sum = 0;
	for (int t : ct)
		sum += t;
	if (sum < k)
		return "a";
	if (m == 0)
		return "";

	string best = "";
	vector<int> v;
	v.resize(1<<m);

	for (int i = 1; i < ct.size(); ++i)
		if (nex[i][0] != -1)
			v[nex[i][0]] += ct[i];

	string ans0 = find(m-1, v);
	if (ans0 != "a") {
		ans0 = "0" + ans0;
		if (best.length() < ans0.length())
			best = ans0;
		else if (best.length() == ans0.length())
			best = min(best, ans0);
	}

	v.clear();
	v.resize(1<<m);

	for (int i = 1; i < ct.size(); ++i)
		if (nex[i][1] != -1)
			v[nex[i][1]] += ct[i];

	string ans1 = find(m-1, v);
	if (ans1 != "a") {
		ans1 = "1" + ans1;
		if (best.length() < ans1.length())
			best = ans1;
		else if (best.length() == ans1.length())
			best = min(best, ans1);
	}

	return best;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	vector<int> v;
	v.resize(1<<(n+1));

	for (int i = 0; i <= n; ++i) {
		string g;
		cin >> g;
		assert(g.size() == (1<<i));
		for (int j = 0; j < (1<<i); ++j)
			if (g[j] == '1')
				v[(1<<i) + j]++;
	}

	for (int l = 0; l <= n; ++l)
		for (int j = 0; j < (1<<l); ++j) {
			if (l == 0) {
				nex[(1<<l)+j][0] = nex[(1<<l)+j][1] = -1;
				continue;
			}

			if (j/(1<<(l-1)) == 0) {
				nex[(1<<l)+j][0] = (1<<(l-1))+j;
				nex[(1<<l)+j][1] = nex[(1<<(l-1))+j][1];
			} else {
				nex[(1<<l)+j][0] = nex[j][0];
				nex[(1<<l)+j][1] = j;
			}
		}

	cout << find(n, v) << endl;
}

Measured memory_bytes: 51516
main = do
  li <- getLine
  li <- getLine
  let hs = map read $ words li
  let ans = compute hs
  putStrLn $ if ans then "Yes" else "No"

compute :: [Int] -> Bool
compute hs = loop True hs

-- b は「h1は1下げられる」フラグ
loop _ [_] = True
loop b (h1:h2:hs)
  | h1 < h2 = loop True (h2:hs)
  | h1 == h2 = loop b (h2:hs)
  | h1 - 1 == h2 = b && loop False (h2:hs)
  | otherwise = False

Measured memory_bytes: 36220
#include<stdio.h>
int main(){

  int a,b,d,r;
  double f;
  scanf("%d%d",&a,&b);
  d = a / b;
  r = a % b;
  f =(double)a / b;

  printf("%d %d %lf\n",d,r,f);
  return 0;
}

Measured memory_bytes: 636
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=2e3+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
   }


   mi mp1;
   
	void solve(){
   		  int n;
   		  cin>>n;
   		  vi v(n,0);
   		  rep(i,0,n) {
			  cin>>v[i];
			  mp1[v[i]]++;
		  }
		 int tot=0;
		 for(auto to:mp1) {
			    if(to.se>1) {
					  tot+=(to.se*(to.se-1))/2;
					}
			 }
			 
			 //~ cout<<tot<<endl;
			  
		 rep(i,0,n) {
			    int yo=mp1[v[i]] ;
			    yo*=(yo-1);
			    yo/=2;
			    int nax=mp1[v[i]]-1;
			    nax*=(nax-1);
			    nax/=2;
			    cout<<tot-yo+nax<<endl; 
			 } 
		  
   		   		 
	  
	}

int32_t main() {
	cool;
	int t=1;
	//cin>>t;
	while(t--)
	solve();


return 0;	   
}


Measured memory_bytes: 11136
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll x;
    cin >> x;

    ll y = x/100;
    
    if(100*y <= x && x <= 105*y) {
        out(1);
    }
    else {
        out(0);
    }

    re0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,solve = 100000;
  cin >>n;
  while(n--){
    solve = solve*1.05;
    if(solve%1000 > 0) solve = solve/1000*1000+1000;
  }
  cout <<solve<<endl;
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a==b){
    cout<<"Draw"<<endl;
  }else if(a==1){
    cout<<"Alice"<<endl;
  }else if(b==1){
    cout<<"Bob"<<endl;
  }else if(a>b){
    cout<<"Alice"<<endl;
  }else{
    cout<<"Bob"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb  push_back
using namespace std ;
vector<long long >g[200005];
bool  vis[200005];
long long lazy[200005];
long long cnt [200005];
    void  dfs (int i)
    {
        if(vis[i])return ;
        vis[i]=1;
        cnt[i]+=lazy[i];
        for(int j = 0;j<g[i].size();j++)
        {
        if(!vis[g[i][j]])
        {
            cnt[g[i][j]]+=cnt[i];
            dfs(g[i][j]);
        }
        }
    }

int main ()
{
    long long   n ,q;
    cin >> n >> q;
    for(long long i = 1;i<n;i++)
    {
         long long a,b;
        cin >> a>> b;
        g[a].pb(b);
        g[b].pb(a);
     }
    while(q--)
    {
        long long  x, p;
        cin >>x>>p;
        lazy[x]+=p;
    }
     dfs (1);
     for(long long  i= 1 ;i<=n ;i++)cout<<cnt[i]<<' ';
   return 0 ;
}


Measured memory_bytes: 25856
k,x = map(int,input().split())
k = k-1
Min = x - k
Max = x + k
if(Min<=-1000000):
  Min = -1000000
if(Max>=1000000):
  Max = 1000000
n = Min
while True:
  print(n)
  if(n==Max):
    break
  n+=1
  

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>

int main()
{
    char s[100];
    int i;
    long long k, ans = 0;

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

    int len = strlen(s);
    int cnt = 1, a = 1, b = 1;

    for (i = 1; i < len; i++) {
        if (s[i - 1] != s[i])break;
        a++;
    }
    if (i == len)
    {
        printf("%lld", k * len / 2);
    }
    else
    {
        for (i = 1; i < len; i++)
        {
            if (s[i - 1] == s[i])cnt++;
            else
            {
                ans += cnt / 2;
                cnt = 1;
            }
        }
        ans += cnt / 2;

        if (s[0] == s[len - 1])
        {
            for (i = len - 1; i > 0; i--)
            {
                if (s[i - 1] != s[i])break;
                b++;
            }
            printf("%lld", k * ans - (a / 2 + b / 2 - (a + b) / 2) * (k - 1));
        }
        else
        {
            printf("%lld", k * ans);
        }

    }

}


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

int main(){
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  char a=s[0];
  map<char,bool> check;
  
  for(char i:s){//for(変数宣言:範囲)
    if (check.count(i)) continue;
    else {
      int t = count(s.begin(),s.end(),i);//第3引数は探したい対象
      if (t % 2 != 0){
        cout << "No" << "\n";
        return 0;
      }
    }
  }
  cout << "Yes" << "\n";
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        

        Scanner sc = new Scanner(System.in);
        
        int D = sc.nextInt();
        int N = sc.nextInt();
        int num =0;
        
        if(D==0&&N!=100){
            System.out.println(1*N);
            return;
        }else if(N==100){
            num =(int)(Math.pow(100,D))*(N+1);
            System.out.println(num);
            return;
        }
        else{
            num =(int)(Math.pow(100,D))*N;
        }
        
        System.out.println(num);
    }
    
} 

Measured memory_bytes: 35600
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top,S[1000];

void push(int x){
	top++;
	S[top] = x;
}
int pop(){
	top--;
	return S[top+1];
}

int main(void){
	int a,b;
	top = 0;
	char s[100];
	while( scanf("%s",s) != EOF ){
		if(s[0] == '+'){
			a = pop();
			b = pop();
			push(a + b);
		}else if(s[0] == '-'){
			b = pop();
			a = pop();
			push(a - b);
		}else if(s[0] == '*'){
			a = pop();
			b = pop();
			push(a * b);
		}else{
			push(atoi(s));
		}
	}
	printf("%d\n",pop());
	
	return 0;
}


Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
#define sz(a) ll(a.size())
ll hell=pow(10,9)+7;
bool comp(ll a,ll b){
	return abs(a)>abs(b);
}
void solve(){
	ll n,k,res=1,f=0;
	cin>>n>>k;
	vector<ll> v(n);
	for(ll i=0;i<n;i++){
		cin>>v[i];
		if(v[i]>0)
		f=1;
	}
	if(k==n){
		for(ll i=0;i<n;i++)
		res=(res*v[i])%hell;
		if(res<0)
		res+=hell;
		cout<<res;
		exit(0);
	}
	sort(v.begin(),v.end(),comp);
	if(!f&&k%2==1){
		reverse(v.begin(),v.end());
		for(ll i=0;i<k;i++)
		res=(res*v[i])%hell;
		if(res<0)
		res+=hell;
		cout<<res;
		exit(0);
	}
	ll cnt=0;
	for(ll i=0;i<k;i++){
		if(v[i]<0)
		cnt++;
		if(v[i]==0){
			cout<<0;
			exit(0);
		}
	}
	if(cnt%2){
		ll a=hell,b=hell,c=0,d=0;
		for(ll i=0;i<k;i++)
		if(v[i]>0)
		a=min(a,v[i]);
		else
		b=min(b,-v[i]);
		for(ll i=k;i<n;i++)
		if(v[i]>0)
		d=max(d,v[i]);
		else
		c=max(c,-v[i]);
		if(a*d>=b*c||a==hell){
			for(ll i=0;i<k;i++)
			if(v[i]<0&&abs(v[i])==b){
				swap(v[i],d);
				break;
			}
		}
		else{
			c*=(-1);
			for(ll i=0;i<k;i++)
			if(v[i]>0&&v[i]==a){
				swap(v[i],c);
				break;
			}
		}
	}
	for(ll i=0;i<k;i++)
	res=(res*v[i])%hell;
	if(res<0)
	res+=hell;
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++)
	solve();
}


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

int n, m;
string a[60], b[60];

int match(int x, int y) {
    // 与えられた開始地点から、画素を比較するループ
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < m; j++) {
            if (a[x+i][y+j] != b[i][j]) {
                return false;
            }
        }
    }
    return true;
}

int main() {
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < m; i++) cin >> b[i];

    // 開始地点を探るループ
    for (int i = 0; i <= n-m; i++) {
        for (int j = 0; j <= n-m; j++) {
            if (match(i, j) == true) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define lpsbd(i, s, b, d) for(size_t i = (s); i < (b); i+=(d))
#define lpsb(i, s, b) for(size_t i = (s); i < (b); i++)
#define lpn(i, n) for(size_t i = 0; i < (n); i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

const ll MOD = 1000000007;

int main(void)
{
    string S;
    cin >> S;
    string ans = "Yes";
    int N = S.size();
    lpn(i, N)
    {
        if ((!(i%2) && S[i] == 'L') || (i%2 && S[i] == 'R')) ans = "No";
    }
    cout << ans << endl;
    return 0;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int h,w,k; cin>>h>>w>>k;
	vector<string> g(h);
	vector<int> row;
	for (int i=0; i<h; i++) {
		cin>>g[i];
		bool has=false;
		for (int j=0; j<w; j++)
			if(g[i][j]=='#')
				has=true;
		if(has) row.push_back(i);
	}
	row.push_back(h);
	map<int,int> len;
	for (int i=0; i<row.size()-1; i++)
		len[row[i]]=row[i+1]-row[i];
	vector<vector<int>> ret(h,vector<int>(w,-1));
	int ct=1;
	for (int i=0; i<h; i++) {
		if(!len[i]) continue;
		vector<int> col;
		col.push_back(-1);
		for (int j=0; j<w; j++)
			if(g[i][j]=='#')
					col.push_back(j);
		col.back()=w-1;
		for (int j=0; j<col.size()-1; j++) {
			bool up=false;
			for (int u=col[j]+1; u<=col[j+1]; u++)
				for (int t=0; t<len[i]; t++)
					ret[i+t][u]=ct, up=true;
			if(up) ct++;
		}
	}
	
	for (int j=0; j<w; j++)
		for (int i=h-1; i>=1; i--)
			if(ret[i-1][j]==-1)
				ret[i-1][j]=ret[i][j];

	for (int i=0; i<h; i++) {
		for (int j=0; j<w; j++) {
			cout<<ret[i][j]<<" ";
		}
		cout<<"\n";
	}
	return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 998244353;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int64 mypow(int32 n, int32 r){
    if(r == 0)return 1;
    if(r % 2 == 0){
        int64 x = mypow(n, r / 2);
        return x * x % MOD;
    }else{
        return n * mypow(n, r - 1) % MOD;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    map<int32,int32> mp;
    int32 d0;
    cin >> d0;
    if(d0 != 0){
        cout << 0 << endl;
        return 0;
    }
    REP(i,n-1){
        int32 d;
        cin >> d;
        mp[d]++;
    }
    int64 ans = 1;
    int32 prevd = 0;
    int32 prevCnt = 1;
    for(pii p : mp){
        int32 d, c;
        tie(d, c) = p;
        // cout << d << " " << c << endl;
        if(prevd + 1 != d){
            cout << 0 << endl;
            return 0;
        }
        prevd = d;
        ans *= mypow(prevCnt, c);
        ans %= MOD;
        prevCnt = c;
    }
    ANS(ans);
    return 0;
}

Measured memory_bytes: 6528
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n;cin>>n;
  ll m;cin>>m;
  vl a(n);
  rep(i,n)cin>>a[i];
  map<ll,ll>M;
  M[0]++;
  vl sum(n);
  sum[0]=a[0];
  sum[0]%=m;
  M[sum[0]]++;
  rep(i,n-1){
    sum[i+1]=a[i+1]+sum[i];
    sum[i+1]%=m;
    M[sum[i+1]]++;
  }
  ll ans=0;
  for(auto p:M){
    ans+=p.second*(p.second-1)/2;
  }
  cout<<ans<<endl;
}
  
  


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define big 998244353
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589
int power(int x,int y){
    int r=1,z=x;
    while(y){
        if(y & 1)r*=z;
        z*=z;y=y>>1;}
    return r;}
int powerm(int x,int y,int p){
    int r=1;
    while(y){
        if(y & 1)r=(r*x)%p;
        y=y>>1;
        x=(x*x)%p;}
    return r%p;}
int modinv(int x,int m){
    return powerm(x,m-2,m);}
int logarithm(int a,int b){
    int x=0;
    while(a>1){
        x++;
        a/=b;}
    return x;}
vector<int> ad[100005],ad1[100005];
int vis[100005],dp[100005];
vector<int> topo;
void dfs(int x){
    vis[x]=1;
    for(auto p:ad[x])
        if(!vis[p])
            dfs(p);
    topo.pb(x);
}
int solve(int i){
    if((int)ad1[i].size()==0)
        return dp[i]=0;
    if(dp[i]!=-1)
        return dp[i];
    for(auto p:ad1[i])
        dp[i]=max(dp[i],solve(p)+1);
    return dp[i];
}
int32_t main(){
    fast;
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        ad[u].pb(v);
        ad1[v].pb(u);
    }
    for(int i=1;i<=n;i++)
        if(!vis[i])
            dfs(i);
    memset(dp,-1,sizeof(dp));
    memset(vis,0,sizeof(vis));
    for(int i=0;i<n;i++){
        int t=topo[i];
        if(dp[t]==-1)
            dp[t]=max(dp[t],solve(t));
    }
    int ans=0;
    for(int i=1;i<=n;i++)
        ans=max(ans,dp[i]);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 21044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 1e7 + 5;
const ll MOD = 1e9 + 7;
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pis pair<ll,string>
#define F first
#define S second
#define LCM(a,b) ((a*b)/__gcd(a,b))
#define inf 1e10
#define test ll cse;cin>>cse;for(ll _i=1;_i<=cse;_i++)
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const double EPS = 1E-9;
typedef vector< vector<double> > matrix;
typedef vector<int> vi;

int main() {
    fast;

    string s; cin >> s;

    int ans = 0;
    int cnt = 0;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == 'R') cnt++; else cnt = 0;

        ans = max(ans, cnt);
    }

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

Measured memory_bytes: 3632
import java.util.*;

public class Main{
	
	public static void main(String... args){
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int[] stick = new int[n];
		for(int i = 0; i < n; i++){
			stick[i] = scan.nextInt();
		}
		Arrays.sort(stick);
		
		long count = 0;
		for(int a = 0; a < n; a++){
			for(int b = a + 1; b < n; b++){
				int h = higherBound(stick, stick[a] + stick[b]);
				count += h - b - 1;
			}
		}
		
		System.out.println(count);
		
	}
	
	public static int higherBound(int[] array, int value){
		int left = -1;
		int right = array.length;
		while(right - left > 1){
			int mid = (left + right) / 2;
			if(array[mid] < value){
				left = mid;
			} else {
				right = mid;
			}
		}
		return right;
	}
}

Measured memory_bytes: 26760
using System;
using System.Linq;
class p
{
  static void Main()
  {
    string[] input = Console.ReadLine().Split(' ');
    int N = int.Parse(input[0]);
    int M = int.Parse(input[1]);
    int X = int.Parse(input[2]);
    int Y = int.Parse(input[3]);
    
    input = Console.ReadLine().Split(' ');
    int[] xArr = new int[N];
    for (int i = 0; i < N; i++) {
      xArr[i] = int.Parse(input[i]);
    }
    
    input = Console.ReadLine().Split(' ');
    int[] yArr = new int[M];
    for (int i = 0; i < M; i++) {
      yArr[i] = int.Parse(input[i]);
    }
    
    bool result = false;
    for (int z = X + 1; z <= Y; z++) {
      if (xArr.Max() < z && z <= yArr.Min()) {
        result = true;
        break;
      }
    }
    if (result) {
      Console.WriteLine("No War");
    } else {
      Console.WriteLine("War");
    }
  }
}


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

using namespace std;

string p[] = {"Sunny", "Cloudy", "Rainy"};

int main() {
  string s; cin >> s;
  if(s[0] == 'S') cout << p[1] << '\n';
  else if(s[0] == 'C') cout << p[2] << '\n';
  else cout << p[0] << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/math/common_factor.hpp> 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define mkp make_pair
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(int i=start;i<end;i++)
#define N 100001
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl;
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<endl;
#define pi M_PI
int main()
{
	fastio();
	ll a,b,c,d;cin>>a>>b>>c>>d;
	ll total = b-a+1;
	ll dbc = b/c - a/c;
	ll dbd = b/d - a/d;
	if(a%c==0)
		dbc++;
	if(a%d==0)
		dbd++;
	ll x = boost::math::lcm(c,d);
  	//cout<<x<<endl;
	ll dbx = b/x-a/x;
	if(a%x==0)
		dbx++;
  	//cout<<total<<" "<<dbc<<" "<<dbd<<" "<<dbx<<endl;
	cout<<total-(dbc+dbd-dbx)<<endl;
	return 0;
}	

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    String S=gs();
	    long k=0;
	    long b=0;
	    for (int i=0; i<S.length();i++) {
	    	char c=S.charAt(i);
	    	if(c=='B') {
	    		b++;
	    	} else {
	    		k+=b;
	    	}

	    }
	    System.out.println(k);
//        if(k%2==0) {
//
//		    System.out.println(a-b);
//        } else {
//        	System.out.println(b-a);
//
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 40236
#include<bits/stdc++.h>
#define LL long long
using namespace std;

inline int read() {
	char c=getchar(); int f=1,ret=0;
	while (c<'0'||c>'9') {if(c=='-')f=-1;c=getchar();}
	while (c<='9'&&c>='0') {ret=ret*10+c-'0';c=getchar();}
	return ret * f;
}

int main() {
	int n=read(),cnt=0;
	for (int i=1,tmp;i<=n;i++) {
		tmp = read();
		cnt += (tmp & 1);
	}
	if (cnt & 1) cout<<"NO";
	else cout<<"YES";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include<vector>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include<cmath>
#include <limits>
using namespace std;
typedef long long ll;

typedef pair<ll, ll> P;
const int INF = 100000000;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
const int MOD = 1000000007;


int main() {
	int N,i,j,H,ans;
	char S[100001];
	cin >> H >> N;
	vector<int>A(N);
	ll sum = 0;
	REP(i, 0, N){
		cin >> A[i];
		sum += A[i];
	}
	if (sum >= H) {
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;
	
	
	return 0;
}



Measured memory_bytes: 640
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.range;

void main()
{
  auto N = readln.split[0].to!int;
  iota(1, N + 1).map!"a.to!string"
    .map!"a.length"
    .count!"(a & 1) == 1"
    .writeln;
}


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

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

    set<string> s;
    rep(i,0,n){
        string _s;
        cin>>_s;
        s.insert(_s);
    }

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

Measured memory_bytes: 19224
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N , M ;
    cin >> N >> M ; 
    vector<ll> X, diffx;;
    
    rep(i, M){
        ll x;
        cin >> x;
        X.pb(x);
    }
    
    sort(all(X));
    
    rep(i, X.size()){
        if(i == 0) continue;
        diffx.pb(X[i]-X[i-1]);
    }
    
    sort(rall(diffx));
    
    ll ans = 0;
    rep(i, diffx.size()){
        if(i < N-1) continue;
        ans += diffx[i] ;
    }
    
    cout << ans << endl;
    
    
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 2548
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return [LIST() for _ in range(n)]
def NSTR(n): return [input() for _ in range(n)]


INF = float("inf")
MOD = 10**9 + 7


def main():
    L, R, d = MAP()
    count = 0
    for i in range(L, R+1):
        if i % d == 0:
            count += 1
    print(count)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9064
n=int(input())
a=0
b=0
for i in range(1,n+1):
    a+=(n-i+1)*(n-i+2)//2
for i in range(n-1):
    u,v=map(int,input().split())
    b+=min(u,v)*(n-max(u,v)+1)
print(a-b)

Measured memory_bytes: 9140
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll MOD = 1e9+7;

int main(){
  int n;
  cin>>n;
  if(n==3||n==5||n==7)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define Fors(n) for(int i=1;i<=n;i++)
#define For(n) for(i=0;i<n;i++)
#define ll long long
#define vint(s) vector<int> s
#define pb(x)  push_back(x)
#define mpair(x,y) make_pair(x,y)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll x=0,y=0,n=0,i=0;

int main(){
    IOS;
    cin >> n;
    string s;
    map <string, ll> mp;
    for(i=0;i<n;i++){
    	cin >> s;
    	sort(s.begin(),s.end());
    	//cout << s << " : ";
    	mp[s]++;
    }
    ll ans = 0;
    for (auto it = mp.begin(); it!=mp.end(); it++){
    	x = it->second;
    	y = (x*(x-1))/2 ;
    	ans += y;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11264
n = int(input())
g = [[0] * n for _ in range(n)]

while n:
    l = list(map(int, input().split()))
    cg = g[l[0] - 1]
    for i in l[2:]:
        cg[i - 1] = 1
    n -= 1

for v in g:
    print(*v)

Measured memory_bytes: 8456
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


int main(){

    int A,B,C;
    cin >> A >> B >> C;
    int swap;

    swap = B;
    B = A;
    A = swap;

    swap = C;
    C = A;
    A = swap;

    cout << A << ' ' << B << ' ' << C << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
using namespace std;

int solution(){
    int n,k; cin>>n>>k;
    vector<int> h(n);
    for(int i = 0;i < n;i++) cin>>h[i];
    
    vector<int> dp(n, INT_MAX);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i = 2; i < n; i++){
        for(int j = max(0, i-k); j < i; j++){
            dp[i] = min( dp[i], dp[j] + abs(h[i]-h[j]) );
        }
    }
    cout<<dp[n-1]<<"\n";
    return 0;  
}

int main(){
    FAST_IO;
    int T = 1; //cin>>T;
    while(T--)
        solution();
    return 0;
}

Measured memory_bytes: 3952
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,i;
    cin>>n;
    ll a;
    map<ll,int> f;
    vector<ll> choose;
    for (i=0;i<n;i++)
    {
        cin>>a;
        f[a]++;
    }
    for (auto e: f)
    {
        if (e.ss>=2)
            choose.pb(e.ff);
    }
    sort(choose.begin(),choose.end());
    if (choose.size()==0)
        cout<<"0\n";
    else if (f[choose[choose.size()-1]]>=4)
        cout<<choose[choose.size()-1]*choose[choose.size()-1]<<endl;
    else if (choose.size()>=2)
        cout<<choose[choose.size()-1]*choose[choose.size()-2]<<endl;
    else
        cout<<"0\n";
}

Measured memory_bytes: 6528
import sys
def make_divisors(n):
  lower_divisors , upper_divisors = [], []
  i = 1
  while i*i <= n:
    if n % i == 0:
      lower_divisors.append(i)
      if i != n // i:
        upper_divisors.append(n//i)
    i += 1
  return lower_divisors + upper_divisors[::-1]
N,M=map(int,input().split())
c=M//N
L=make_divisors(M)
L=list(reversed(L))
for i in range(len(L)):
  if L[i]<=c:
    print(L[i])
    sys.exit()

Measured memory_bytes: 9132
#include<bits/stdc++.h>
using namespace std;
#define int  long long int
#define fi first
#define se second
#define pb push_back
#define soo(v) sort(v.rbegin(),v.rend())
#define so(v) sort(v.begin(),v.end())
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define endl '\n'
#define dbv(v) cout<<endl;cout<<#v<<"-->> ";for(auto it:v){cout<<it<<" ";}cout<<endl;
#define dbm(m)cout<<endl;cout<<#m<<"-->> ";for(auto it:m){cout<<it.fi<<" "<<it.se.fi<<" "<<it.se.se<<endl;}
#define dbs(s)cout<<endl;cout<<#s<<"-->> ";for(auto it:s){cout<<it<<" ";}cout<<endl;
#define mod 1000000007
#define db1(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl;
#define mx 1e18
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v)  *min_element(v.begin(),v.end())
#define double long double
#define io std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define re(s) reverse(s.begin(),s.end())

int32_t main()
{
  io
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<max({a*c,b*d,a*d,b*c})<<endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  string ans="No";
  REPP(i,1,10) {
    REPP(j,1,10) {
      if(i*j==N) {
        ans="Yes";
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[20000000];
int main()
{
    int sum=0,flag=0,a=0,b=0;
   scanf("%s",s);
   for(int i=strlen(s)-1;i>=1;i--)
    {
        if(s[i]-'0'==10)
     {  s[i-1]++;
        continue;
     }

      if(s[i]<'5')sum=sum+s[i]-'0';
      else if(s[i]>'5')
        sum+=10-(s[i]-'0'),s[i-1]++;
       else
       {  if(s[i-1]>='5')s[i-1]++;
          sum+=5;
       }
    }
     if(s[0]<='5')sum=sum+s[0]-'0';
      else
        sum+=11-(s[0]-'0');
    printf("%d",sum);
}


Measured memory_bytes: 1280
N = int(input())
A = list(map(int,input().split()))
mod = pow(10,9)+7
B = [0]*N
for a in A:B[a]+=1
if max(B)>2:print(0)
elif N%2 and B[0]>1:print(0)
else:print(pow(2,N//2,mod))

Measured memory_bytes: 14008
twotime::[a]->[a]
twotime [] =[]
twotime (x:xs)= x:x:(twotime xs)

solver::[[Char]]->[[Char]]
solver x = twotime x

--hight -> width -> do
get_pic::Int -> Int -> IO [[Char]]
get_pic 0 _ = return []
get_pic h w = do
  d<-getLine
  rest<-get_pic (h-1) w
  return  (((take w) d):rest)

n_line_print::[[Char]]-> IO ()
n_line_print []=return ()
n_line_print (x:xs)=do
  putStr (x++"\n")
  n_line_print xs

main::IO()
main =do
  hwc<-getLine
  let h:w:[] = map read ( words hwc)::[Int]
  cll<-get_pic h w
  n_line_print (solver cll)


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

int main(){
	int n,m;
	char input;
	while(cin>>n,n){
		int situ=-1,cnt=-1,ans=0;
		cin>>m;
		for(int i=0;i<m;i++){
			cin>>input;
			AGAIN:
			if(situ!=0 && input=='I'){
				 cnt++;
				 situ=0;
			}
			else if(situ!=1 && input=='O'){
				situ=1;
			}
			else{
				if(cnt-n+1>0){
					ans+=cnt-n+1;
				}
				cnt=-1;
				situ=-1;
				goto AGAIN;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1144
#include <stdio.h>
#include <stdlib.h>

int main()
{
  int n,k,q,i,j,a;
  int *point;

  scanf("%d%d%d",&n,&k,&q );
  point = calloc(n,sizeof(int));
  for(i=0; i<n; i++)
    point[i]=0;

  for(i=0; i<q; i++){
    scanf("%d", &a);
    point[a-1]++;
  }

  for(i=0; i<n; i++)
  {
    if(point[i] > q-k)
      puts("Yes");
    else
      puts("No");
  }
  free(point);
  return 0;
}


Measured memory_bytes: 1708
//Even better better solutions q{^.^}p

#define ONLINE_JUDGE //in case i forget to uncomment this, sometimes the grader defines the macro ^.^
#ifdef ONLINE_JUDGE
#include <bits/stdc++.h>
#else
#include "stdc++.h"
#endif

#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#define MIN(x, y) (((x) < (y)) ? (x) : (y))

using namespace std;

signed main() {
#ifndef ONLINE_JUDGE
    freopen("/Users/kdkdk/Desktop/input.txt", "r", stdin);
    //freopen("/Users/kdkdk/Desktop/output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    if (n == 1) cout << "Hello World" << endl;
    else {
        int a, b;
        cin >> a >> b;
        cout << a+b << endl;
    }
    
    return 0;
}


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

using namespace std;

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

  int N;
  cin >> N;
  vector<int> X(N, 0);
  for (int i = 0; i < N; ++i) {
    cin >> X[i];
  }
  int res = 1e9;
  for (int x = 0; x <= 100; ++x) {
    int sum = 0;
    for (int j = 0; j < N; ++j) {
      sum += (X[j]-x) * (X[j]-x);
    }
    if (sum < res) res = sum;
  }
  cout << res << endl;

	return 0;
}



Measured memory_bytes: 256
N = int(input())
B = [[-1]*N for i in range(N)]

for i in range(N):
    tmpA = int(input())
    for j in range(tmpA):
        x,y = map(int,input().split())
        B[i][x-1] = y

zero1 = [0,1]
import itertools

ans = 0
for i in itertools.product(zero1,repeat=N):
    tmpans = sum(i)
    tmpshi = [-1]*N
    flag = 0
    for j in range(len(i)):
        if flag == 1:
            break
        if i[j]==1:
            for k in range(len(B[j])):
                if B[j][k] in [0,1]:
                    if B[j][k] == tmpshi[k] or tmpshi[k]==-1:
                        tmpshi[k]=B[j][k]
                    else:
                        flag = 1
                        break
    flag1 = 0
    if flag == 0:
        for j in range(N):
            if i[j]!=tmpshi[j] and tmpshi[j]!=-1:
                flag1 = 1
                break
        if flag1 == 0:
            ans = max(ans,tmpans)
print(ans)

Measured memory_bytes: 51180
n=int(input())
ab=[list(map(int,input().split())) for _ in range(n)]
ab.sort(key=lambda x:x[0])
a=[a for a,b in ab]
b=[b for a,b in ab]
a.sort()
b.sort()
l=0
if n%2==1:
  print(b[n//2]-a[n//2]+1)
  #print(b[n//2],a[n//2])
else:
  am=(a[n//2]+a[n//2-1])
  bm=(b[n//2]+b[n//2-1])
  print(bm-am+1)

Measured memory_bytes: 49052
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

struct Point {
  int x;
  int y;
};

int main() {
  int n;
  cin >> n;
  vector<Point> v;
  int x, y;
  while (cin >> x >> y) {
    v.push_back({x, y});
  }
  sort(v.begin(), v.end(), [](const Point &p, const Point &p2) {
    return p.x < p2.x or (p.x == p2.x and p.y < p2.y);
  });
  for (Point p : v)
    cout << p.x << " " << p.y << endl;
}


Measured memory_bytes: 3912
#include<stdio.h>
#include<string.h>
#define rep(i,n) for(i=0;i<n;i++)
int max(int a,int b){
    return a>b?a:b;
}

int main(void){
    int n,m,i,j,k,l,f;
    char s[50][51],t[50][51];
    while(scanf("%d",&n),n){
        l=0;
        rep(i,n){
            scanf("%s",s[i]);
            l=max(l,strlen(s[i]));
        }
        memset(t,0,sizeof(t));
        rep(k,l+1){
            rep(i,n){
                if(!k)continue;
                t[i][0]=s[i][0];
                j=1;
                m=0;
                while(s[i][m]&&j<k){
                    if(strchr("aiueo",s[i][m])!=NULL){
                        t[i][j++]=s[i][m+1];
                    }
                    m++;
                }
                t[i][j]=0;
            }
            f=1;
            rep(i,n){
                rep(j,n){
                    if(i!=j&&strcmp(t[i],t[j])==0){
                        f=0;
                    }
                }
            }
            if(f)break;
        }
        printf("%d\n",f?k:-1);
    }
    return 0;
}


Measured memory_bytes: 2056
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  string s;int k;cin>>s>>k;
  ll n=s.size();
  set<string> vs;
  rep(i,0,n){
    rep(j,1,k+1){
      string sij=s.substr(i,j);
      vs.insert(sij);
    }
  }
  auto ite=vs.begin();
  rep(i,0,k-1){ite++;}
  cout<<*ite<<endl;
}

Measured memory_bytes: 1664
use std::cmp::min;
use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let (n, x, y): (usize, usize, usize) = parse!(it, 3);
    let x = x - 1;
    let y = y - 1;
    let mut ret = vec![0; n];
    let diff = |x, y| if x > y { x - y } else { y - x };
    for i in 0..n {
        for j in (i + 1)..n {
            let l = min(
                diff(i, j),
                min(diff(i, x) + diff(j, y) + 1, diff(i, y) + diff(j, x) + 1),
            );
            ret[l] += 1;
        }
    }
    for &l in &ret[1..] {
        println!("{}", l);
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 4352
n=int(input())

t = list(map(int,input().split()))

mae = []
naka = [t[0]]
usiro = []

for i in range(1,n):
    if i%2==1:
        mae.append(t[i])
    else:
        usiro.append(t[i])

if n%2==0:
    mae.reverse()
    ans = mae+naka+usiro
else:
    usiro.reverse()
    ans = usiro+naka+mae
print(' '.join(map(str,ans)))

Measured memory_bytes: 118612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
typedef long long ll;

int main(){
    int a[3];
    int sum = 0;
    rep(i, 0, 3) cin >> a[i];
    rep(i,0,3) sum += a[i];
    if(sum >= 22) puts("bust");
    else puts("win");
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	int N, T; cin >> N >> T;
	vector<int> v(T + 1, 0);
	rep(i, 0, N) {
		int l, r; cin >> l >> r;
		v[l]++; v[r]--;
	}
	rep(i, 0, T)v[i + 1] += v[i];
	cout << *max_element(all(v)) << endl;
	return 0;
}

Measured memory_bytes: 3092
n = int(input())

#big+small*1000から出る辺の先
edge = [[] for _ in range(2*(10**6))]
#used -1:点なし else:入力本数
used = [-1]*(2*(10**6))

for i in range(1,n+1):
    a = tuple(map(int,input().split()))
    fr = None
    for e in a:
        go = max(i,e) + min(i,e)*1000

        if fr != None:
            if used[fr] < 0:
                used[fr] = 0
            if used[go] < 0:
                used[go] = 0
            edge[fr].append(go)
            used[go] += 1
        fr = go


res = 0
ctr = 0
tank = []
new = []
for i,e in enumerate(used):
    if e == 0:
        new.append(i)
        ctr += 1

while len(new) > 0:
    tank = []
    for p in new:
        for e in edge[p]:
            used[e] -= 1
            if used[e] == 0:
                tank.append(e)
                ctr += 1
    new = tank
    res += 1

if ctr < n*(n-1)//2:
    print(-1)
else:
    print(res)



Measured memory_bytes: 162472
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 4e3; int n;
char s[maxN + 1];
char letters[4] = "RGB";
int acc[3][maxN + 1];

int rem(int i, int j, int l)
{
  int m = j - i + j;
  if (m < n)
    return s[m] == letters[l];
  return 0;
}

int main()
{
  while (scanf("%d", &n) != EOF)
  {
    scanf(" %s", s);
    for (int l = 0; l < 3; l++)
      for (int i = 0; i < n; i++)
        acc[l][i + 1] = acc[l][i] + (s[i] == letters[l]);

    lli ans = 0;
    for (int i = 0; i < n; i++)
      for (int j = i + 1; j < n; j++)
        if (s[i] != s[j])
          for (int l = 0; l < 3; l++)
            if (s[i] != letters[l] && s[j] != letters[l])
            {
              DEBUG printf("\t%d %d %c - %d\n", i, j, letters[l], acc[l][n] - acc[l][j]);
              ans += max(0, acc[l][n] - acc[l][j] - rem(i, j, l));
            }

    printf("%lld\n", ans);
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
const int MAXN = 2e5 + 5;

int main() {
    int t;
    cin >> t;
    while (t--) {
        ll a, b;
        cin >> a >> b;
        ll c = a * b;
        ll ans = ((ll) sqrt(c) - 1) * 2;
        if ((ll) sqrt(c) * (ll) sqrt(c) == c && a != b)
            ans--;
        if ((ll) sqrt(c) * ((ll) sqrt(c) + 1) < c)
            ans++;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  string s;

  cin >> s;

  int ans = 0;
  int cc = 0;

  for(int i=0;i<s.size();i++){
    switch(s[i]){
    case 'A':
    case 'G':
    case 'C':
    case 'T':
      cc++;
      break;
    default:
      cc = 0;
    }
    ans = max(ans, cc);
  }

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


Measured memory_bytes: 256
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

n = inn()
x = 0
for a in range(1,n):
    x += (n-1)//a
print(x)


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

int H, W;
vector<string> S;

int bfs(int h, int w) {
    vector<vector<int>> dist(H, vector<int>(W, -1));
    queue<pair<int, int>> que;

    que.push({h, w});
    dist[h][w] = 0;
    while (!que.empty()) {
        pair<int, int> now = que.front();
        que.pop();

        for (pair<int, int> move : {make_pair(1, 0), make_pair(0, -1),
                                    make_pair(-1, 0), make_pair(0, 1)}) {
            if (now.first - move.first < 0 || now.first - move.first >= H ||
                now.second - move.second < 0 || now.second - move.second >= W) {
                continue;
            }
            if (S[now.first - move.first][now.second - move.second] == '.' &&
                dist[now.first - move.first][now.second - move.second] == -1) {
                que.push({now.first - move.first, now.second - move.second});
                dist[now.first - move.first][now.second - move.second] =
                    dist[now.first][now.second] + 1;
            }
        }
    }

    int mx = 0;
    for (vector<int> v : dist) {
        for (int i : v) {
            mx = max(i, mx);
        }
    }
    return mx;
}

int main() {
    cin >> H >> W;

    S.resize(H);
    int res = 0;
    for (int i = 0; i < H; i++) {
        cin >> S[i];
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S[i][j] == '.') {
                res = max(res, bfs(i, j));
            }
        }
    }

    cout << res;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#define MAXN 200100
typedef long long i64;
using namespace std;
int a[MAXN], n;
i64 f2abs(i64 k) {
	return k >= 0 ? k : -k;
}
i64 solve(void) {
	i64 ans = 0, s = 0, cur = 0, best = numeric_limits<i64>::max();
	for(int i = 0; i < n; i++) s += a[i];
	for(int i = 0; i < n - 1; i++)
		best = min(best, f2abs(2LL * (cur += a[i]) - s));
	return best;
}
int main(void) {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	printf("%lld\n", solve());
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
vector<int> dy={1,0,-1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main(){
    string s;
    cin>>s;
    int n=sz(s);
    
    int ans=INF;
    rep(i,n-2){
        string now="";
        now+=s[i];
        now+=s[i+1];
        now+=s[i+2];
        if(abs(753-stoi(now))<ans) ans=abs(753-stoi(now));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
n, m, x = map(int, input().split())
b = 10**18
tm = []
for i in range(n):
    tm.append(list(map(int, input().split())))
for i in range(2**n):
    c = [0 for i in range(m)]
    sum = 0
    for j in range(n):
        if (i >> j) & 1:
            sum += tm[j][0]
            for k in range(m):
                c[k] += tm[j][k+1]
    if min(c) >= x:
        b = min(b, sum)
if b == 10**18:
    print('-1')
else:
    print(b)

Measured memory_bytes: 9224