akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long int
#define fast  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            int t; cin>>t; while(t--)
const int MOD = 1000000007;
ll mod(ll x){
    return (x%MOD + MOD)%MOD;
}
ll mul(ll a , ll b){
    return mod(mod(a)*mod(b));
}
bool comp(pair<ll,ll>& a, pair<ll,ll>& b)
{
    if(a.second == b.second)
    return a.first > b.first;
    else
    return b.second < a.second;
}
static int rowNbr[] = { -1, -1, -1, 0, 0, 1, 1, 1 }; 
static int colNbr[] = { -1, 0, 1, -1, 1, -1, 0, 1 }; 
int main()
{
    fast
    ll n,d;
    cin>>n>>d;
    ll c=0;
    for(int i=0;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        ll p = (x*x) + (y*y);
        //ll s = sqrt(p);
        long double s= sqrt(p);
        if(s<=d)
        {
            c++;
        }
    }
    cout<<c<<endl;
    return 0;
}




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

struct Card
{
    string value;
    string suit;

    bool operator==(const Card &c) const
    {
        return (value == c.value &&
                suit == c.suit);
    }
};

void print_vector(vector<Card> A, int N)
{
    for (int i = 0; i < N; i++)
    {
        cout << A.at(i).suit << A.at(i).value;
        if (i != N - 1)
            cout << " ";
    }
    cout << endl;
}

vector<Card> bubble_sort(vector<Card> A, int N)
{
    int count = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = N - 1; j >= i + 1; j--)
        {
            if (A.at(j - 1).value > A.at(j).value)
            {
                count++;
                swap(A.at(j), A.at(j - 1));
            }
        }
    }
    return A;
}

vector<Card> selection_sort(vector<Card> A, int N)
{
    int count = 0;
    for (int i = 0; i < N - 1; i++)
    {
        int minj = i;
        for (int j = i + 1; j < N; j++)
        {
            if (A.at(minj).value > A.at(j).value)
            {
                minj = j;
            }
        }
        if (i != minj)
            count++;
        swap(A.at(i), A.at(minj));
    }
    return A;
}

bool is_stable(vector<Card> B, vector<Card> C, int N)
{
    for (int i = 0; i < N; i++)
    {
        if (B.at(i).suit != C.at(i).suit)
            return false;
    }
    return true;
}

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

    vector<Card> A(N);
    for (int i = 0; i < N; i++)
    {
        string s;
        cin >> s;
        A.at(i).value = s.at(1);
        A.at(i).suit = s.at(0);
    }

    vector<Card> B = bubble_sort(A, N);
    print_vector(B, N);
    cout << "Stable" << endl;

    vector<Card> C = selection_sort(A, N);
    print_vector(C, N);
    if (is_stable(B, C, N))
    {
        cout << "Stable" << endl;
    }
    else
    {
        cout << "Not stable" << endl;
    }
}


Measured memory_bytes: 3144
N,M = map(int,input().split())

ans = 0

if N >= 1 and M >= 1:
  ans = N*(N-1)//2 + M*(M-1)//2
elif N == 0 and M >= 1:
  ans = M*(M-1)//2
elif N >= 1 and M == 0:
  ans = N*(N-1)//2
  
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<limits>
#include<list>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0;i < (n); ++i)


int main(){
	int n;
	cin >> n;
	vector<string>s(n);
	rep(i, n) cin >> s[i];

	int ac = 0;
	int wa = 0;
	int tel = 0;
	int re = 0;
	rep(i, n) {
		if (s[i] == "AC")ac++;
		else if (s[i] == "WA")wa++;
		else if (s[i] == "TLE")tel++;
		else re++;
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tel << endl;
	cout<< "RE x " << re << endl;

	return 0;
}

Measured memory_bytes: 6356
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
int main()
{
    int n;
    cin >> n;
    map<int,int> mp;
    for(int i = 0;i < n - 1;i++)
    {
        int a;
        cin >> a;
        mp[a]++;
    }
    for(int i = 1;i <= n;i++)
    {
        cout << mp[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 13016
//Jai Shree Ram
//#include <iostream>
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define loopi(stop) for(int i=0; i<stop; i++)
#define loopj(stop2) for(int j=0; j<stop2; j++)
#define loopk(stop3) for(int k=0; k<stop3; k++)
#define loopi1(stop) for(int i=1; i<=stop; i++)
#define loopj1(stop2) for(int j=1; j<=stop2; j++)
#define loopk1(stop3) for(int k=1; k<=stop3; k++)
#define loopse(kt,sstart, eend) for(int kt = sstart; kt<eend; kt++)
#define faster_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define file_io_cf freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define p_b push_back
#define pii pair<int,int>
#define fi first
#define se second
#define prec_10 << fixed << setprecision(10)
#define DEB cout<<"DEBUG"<<'\n';
#define SRAND srand(time(0));

using namespace std;

int mod = 1000000007;

template <typename T>
void O(T x) {
    cout << x << '\n';
}

///////////////////////////////////CODE STARTS HERE///////////////////////////////////////////


int32_t main() {

    faster_io
    // file_io_cf

    int n; cin >> n;
    int ans = 0;

    loopi1(n) {
        if ((i % 3 != 0) && (i % 5 != 0)){
            ans+=i;
        }
        }

        O(ans);
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#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 all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
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, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if (s == u)
        cout << a - 1 << " " << b << endl;
    else
        cout << a << " " << b - 1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<int,int>
#define mod 1000000007
#define eps 0.000000001
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<" "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double PI = acos(-1.0);

void cp()
{
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double minutes = h * 60.0 + m * 1.0;
    // cout << minutes << endl;
    double theta_hour = 2 * PI / (12.0 * 60.0) * minutes;
    double theta_minute = 2 * PI / (60.0) * minutes;
    // cout << theta_hour << " " << theta_minute << endl;
    double x1 = a * 1.0 * cos(theta_hour);
    double y1 = a * 1.0 * sin(theta_hour);
    double x2 = b * 1.0 * cos(theta_minute);
    double y2 = b * 1.0 * sin(theta_minute);
    // cout << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
    double dist = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
    cout << setprecision(10) << dist;
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}

Measured memory_bytes: 4124
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define LL long long
#define fo(i,j,k) for(int i=j;i<=k;i++)
#define fd(i,j,k) for(int i=j;i>=k;i--)
#define fr(i,j) for(int i=beg[j];i;i=nex[i])
using namespace std;
int const mn=2e3+3,mo=1e9+7;
int n,m,K,f[mn*2][mn][2],g[mn];
int main(){
	scanf("%d%d%d",&n,&m,&K);
	m--;K--;
	int lim=(n+m)/K,ans=0;
	fo(j,0,K){
		f[1][j][j!=0]=1;
		if((!((j-n)%K))&&(!((K-j-m)%K))&&(K-j<=m))
			ans=(ans+f[1][j][1])%mo;
	}
	fo(i,2,lim){
		fo(j,0,n)g[j]=((j?g[j-1]:0)+1ll*f[i-1][j][0]+f[i-1][j][1])%mo;
		fo(j,0,n){
			f[i][j][0]=(f[i-1][j][0]+f[i-1][j][1])%mo;
			if(j)f[i][j][1]=(g[j-1]-((j-K-1>=0)?g[j-K-1]:0))%mo;
			if((!((j-n)%K))&&(!((K*i-j-m)%K))&&(K*i-j<=m))
				ans=(ans+f[i][j][1])%mo;
		}
	}
	printf("%d",(ans+mo)%mo);
	return 0;
}


Measured memory_bytes: 62720
import numpy as np

n = int(input())
A = list(map(int, input().split()))
d = [0]*(3200+1)

for a in A:
    if a > 3200:
        a = 3200
    d[a] += 1

cnt = 0
for i in range(0, 3200, 400):
    if np.count_nonzero(d[i:i+400]) > 0:
        cnt += 1
        
if d[3200] == 0:
    print(cnt, cnt)
else:
    if cnt == 0:
        print(1, d[3200])
    else:
        print(cnt, cnt+d[3200])

Measured memory_bytes: 22308
N = int(input())

dic = {}

for _ in range(N):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1

M = int(input())


for _ in range(M):
    s = input()
    if s in dic:
        dic[s] -= 1
    else:
        dic[s] = -1

print(max(max(dic.values()), 0))

Measured memory_bytes: 3060
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int a, b, c, d, e, f;
    double x, y;

    void run(){
	while(sc.hasNext()){
	    a = sc.nextInt();
	    b = sc.nextInt();
	    c = sc.nextInt();
	    d = sc.nextInt();
	    e = sc.nextInt();
	    f = sc.nextInt();

	    x = (double)(c*e-b*f)/(a*e-b*d);
	    y = (double)(a*f-c*d)/(a*e-b*d);
	    if(x==(-0.0)) x = Math.abs(x);
	    if(y==(-0.0)) y = Math.abs(y);
	    System.out.printf("%.3f %.3f\n", x, y);
	}
    }
}

Measured memory_bytes: 18192
#include<bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

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

    //グラフのデータ構造
    vector<int> G[100005];
    for(int i = 0;  i < M; ++i){
        int A, B;
        cin >> A >> B;
        A--; B--;
        //隣接するグラフの頂点を格納 G[A]という頂点に追加することで二次元配列になる。
        G[A].push_back(B);
        G[B].push_back(A);
    }  

    //BFSのためのデータ構造
    vector<int> dist(N, INF); //頂点が－1二なら未訪問
    queue<int> que;
    vector<int> pre(N, -1);

      //初期条件（頂点0を初期ノード
    dist[0] = 0;
    que.push(0);

    while(!que.empty()){
        int v = que.front(); //キューから先頭を取り出す
        que.pop();

        //頂点vから辿れる頂点を全て調べる
        for(int nv : G[v]){
            //訪問済みの頂点は探索しない。
            if(dist[nv] != INF) continue;

            //新たな頂点について距離情報を更新してキューを追加
            dist[nv] = dist[v] + 1;
            pre[nv] = v;
            que.push(nv);
        }
    }
    //出力結果（各頂点空の距離を見る）
    cout << "Yes" << endl;
    for (int i = 0; i < N; ++i){
        if(i == 0) continue;
        int ans = pre[i];
        ans++;
        cout << ans << endl;
    } 
  

    return 0;
}

Measured memory_bytes: 10664
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, n; cin >> h >> n;
  vector<ll> A(n), B(n); rep(i, n) cin >> A[i] >> B[i];
  ll mxh = h+10005;
  vector<ll> dp(mxh, longinf);
  dp[0] = 0;
  rep(i, mxh) {
    rep(j, n) {
      if(i+A[j] < mxh) chmin(dp[i+A[j]], dp[i]+B[j]);
    }
  }
  ll ans = longinf;
  REP(i, h, mxh) chmin(ans, dp[i]);
  cout << ans << endk;
  return 0;
}


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

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

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int m, d; cin >> m >> d;
  ll ans = 0;
  REP(i, 1, m+1) {
    REP(j, 1, d+1) {
      int d1 = j%10;
      int d10 = j/10;
      if(d1<2 || d10<2) continue;
      if(d1*d10==i) ans++;
    }
  }
  cout << ans << "\n";
  return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    const unsigned int i = K * pow(K-1, N-1);
    cout << i;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <string>
#include <stack>
 
using namespace std;
 
#define f(i,a,b) for(int i=a;i<b;i++)
#define fll(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define vvi vector<vector<int> >
#define ss second
#define ff first
#define ll long long
#define lld long double
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pq priority_queue< int >
#define pqll priority_queue< ll >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define INF 1000000000
#define NINF -1000000000
#define endl '\n'

void solve(){
    
    int x;
    cin >> x;
    int temp = x;
    int count = 1;
    while(1){
        if ((x )% 360 == 0){
            break;
        }    
        count++;
        x += temp;
    }
    cout << count;
}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
 
 

    int t = 1;
    // cin >> t;
    
    while(t--){
        
        solve();
        cout << endl;
    }
}

Measured memory_bytes: 3572
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main() {
	string s;
	cin>>s;
	ll flag = 1;
	rep(i,0,s.sz){
		if(i%2==0&&s[i]=='L')flag=0;
		if(i%2==1&&s[i]=='R')flag=0;
	}
	if(flag==1){
	    cout << "Yes" << endl;
	}
	else{
	    cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main()
{
	long long N,h,n,w,t,x,y;
	scanf("%lld",&N);
	for(h=1;h<=3500;h++)
	{
		for(w=1;w<=3500;w++)
			if(4*h*w-N*w-N*h>0 && N*h*w%(4*h*w-N*w-N*h)==0) break;
		if(4*h*w-N*w-N*h>0 && N*h*w%(4*h*w-N*w-N*h)==0) break;
	} 
	n=N*h*w/(4*h*w-N*w-N*h);
	printf("%lld %lld %lld\n",h,w,n);
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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

ll gcd(ll a, ll b){
	if(b == 0) return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b){
	return a * b / gcd(a, b);
}

int main(void){

	ll A, B; cin >> A >> B;

	ll ans = lcm(A, B);

	cout << ans << endl;

	return 0;

}


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

int main() {
	
	ll n, m, x; cin >> n >> m >> x;
	vector<ll> c(n);
	vector<vector<ll>> a(n, vector<ll>(m));
	for (ll i = 0; i < n; i++) {
		cin >> c[i];
		for (ll j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	ll ans = 1000000000;
	for (int bit = 0; bit < (1 << n); ++bit) {
		ll tmpAns = 0;
		vector<ll> u(m, 0);
		for (int i = 0; i < n; ++i) {
			if (bit & (1 << i)) {
				tmpAns += c[i];
				for (ll j = 0; j < m; j++) {
					u[j] += a[i][j];
				}
			}
		}
		bool can = true;
		for (ll j = 0; j < m; j++) {
			if (u[j] < x) can = false;			
		}
		if (can) ans = min(ans, tmpAns);
	}
	if (ans == 1000000000) cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}

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

int main() {

  int N, x;
  cin >> N >> x;

  vector<int> a(N);
  long long sum = 0;

  for (int i = 0; i < N; i++) {
    cin >> a[i];
    sum += a[i];
  }

  for (int i = 0; i < N - 1; i++) {
    if (x < a[i] + a[i+1]) {
      int d1_ = a[i] + a[i+1] - x;
      if (d1_ <= a[i+1]) {
        a[i+1] -= d1_;
      } else {
        a[i+1] = 0;  
      };
    }
    if (x < a[i] + a[i+1]) {
      int d2_ = a[i] + a[i+1] - x;
      if (d2_ <= a[i]) {
        a[i] -= d2_;
      } else {
        a[i] = 0;  
      };
    }
  }

  long long result = 0;
  for (int i = 0; i < N; i++) {
    result += a[i];
  }

  cout << sum - result << endl;
  
  return 0;

}

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

using namespace std;
#define X first
#define Y second
#define pb push_back
typedef double db;
typedef long long ll;
typedef pair<int,int> P;
const int MAXN=2e5+10;
vector<int> v[MAXN];
ll res[MAXN];
int n,a[MAXN],dsp[MAXN],tot;

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) 
        scanf("%d",&a[i]),dsp[++tot]=a[i];
    sort(dsp+1,dsp+n+1);tot=unique(dsp+1,dsp+n+1)-dsp-1;
    
    for(int i=1;i<=n;i++)
        a[i]=lower_bound(dsp+1,dsp+tot+1,a[i])-dsp,v[a[i]].pb(i);
    int now=0,mn=v[tot][0];
    for(int i=tot;i>=1;i--)
    {
        int d=dsp[i]-dsp[i-1];
        mn=min(mn,v[i][0]);
        now+=v[i].size();
        res[mn]+=1ll*now*d;
    }
    for(int i=1;i<=n;i++)
        printf("%lld\n",res[i]);
    return 0;
}

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

int main(){
	int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
	char s[N+1];
	for(int i=1; i<N+1; i++){
		cin >> s[i];
	}
	if(C > D){
		for(int i=A; i<C; i++){
			if(s[i] == '#' && s[i+1] == '#'){
				cout << "No" << endl;
				return 0;
			}
		}
		for(int i=B; i<=D; i++){
			if(s[i-1] == '.' && s[i] == '.' && s[i+1] == '.'){
				cout << "Yes" << endl;
				return 0;
			}
		}
		cout << "No" << endl;
		return 0;
	}else{
		for(int i=A; i<C; i++){
			if(s[i] == '#' && s[i+1] == '#'){
				cout << "No" << endl;
				return 0;
			}
		}
		for(int i=B; i<D; i++){
			if(s[i] == '#' && s[i+1] == '#'){
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
		return 0;
	}
	return 0;
}


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

int main() {
    string s;
    cin >> s;
    s.push_back('Z');
    int ans = 0;
    int ct = 0;
    rep(i,s.size()) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
            ct++;
        }
        else {
            ans = max(ct,ans);
            ct = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000

int A[MAX];
int n;

int partation(int p, int r) {
	int x, i, j, t;
	x = A[r];
	i = p - 1;
	for (j = p; j < r; j++) {
		if (A[j] <= x) {
			i++;
			t = A[i]; A[i] = A[j]; A[j] = t;
		}
	}
	t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
	return i + 1;
}

int main() {
	int i, q;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}

	q = partation(0, n - 1);

	for (i = 0; i < n; i++) {
		if (i)printf(" ");
		if (i == q)printf("[");
		printf("%d", A[i]);
		if (i == q)printf("]");
	}

	printf("\n");


	return 0;
	
}


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

void main()
{
    int c=0;
    foreach(s;stdin.byLine())
    {
        bool f=true;
        foreach(i;0..s.length/2+1)
            if(s[i]!=s[$-i-1])
            { f=false;break;}
        if(f) ++c;
    }
    writeln(c);
}

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

int N;
vector<int> A, B, C;

void input_init(void) {
	cin >> N;
	A.resize(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		--A[i];
	}
	B.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> B[i];
	C.resize(N - 1);
	for (int i = 0; i < N - 1; ++i)
		cin >> C[i];
}

int solve(void) {
	int val = B[A[0]];
	for (int i = 1; i <= N - 1; ++i) {
		val += B[A[i]];
		if (A[i] == A[i - 1] + 1)
			val += C[A[i - 1]];
	}
	return val;
}

int main(void) {
	input_init();
	int ans = solve();

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


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <utility>
#include <map>
#include <algorithm>
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
using namespace std;
bool is_prime(ll n)
{
    for (ll i = 2; i * i < n; ++i)
    {
        if (n % i == 0)
            return false;
    }
    return true;
}
vector<ll> soinsubunkai(long long N)
{
    vector<ll> tmp;
    ll num = N;
    for (ll i = 2; i * i <= N; ++i)
    {
        if (N % i == 0)
        {
            ll j = N / i;
            if (is_prime(i))
            {
                while (num % i == 0)
                {
                    tmp.push_back(i);
                    num /= i;
                }
            }
            if (is_prime(j))
            {
                while (num % j == 0)
                {
                    tmp.push_back(j);
                    num /= j;
                }
            }
        }
    }
    return tmp;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> vec;
    if (N == 1)
    {
        cout << 0 << endl;
        return 0;
    }
    vec = soinsubunkai(N);
    sort(vec.begin(), vec.end());
    if (vec.size() == 0)
    {
        cout << 1 << endl;
        return 0;
    }
    set<ll> st;
    for (auto i : vec)
        st.insert(i);
    vector<ll> sst;
    for (auto i : st)
        sst.push_back(count(vec.begin(), vec.end(), i));
    bool flag = true;
    ll counta = 1;
    ll ans = 0;
    while (flag)
    {
        for (ll i = 0; i < sst.size(); ++i)
        {
            if (sst[i] >= counta)
            {
                sst[i] -= counta;
                ans++;
            }
        }
        counta++;
        if (*max_element(sst.begin(), sst.end()) < counta)
            flag = false;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
//2020-05-16 14:22:00
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; ++i)

using namespace std;
using ll = long long;

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int n; cin >> n;
    queue<pair<string, int>> q;
    q.push(make_pair("", 0));
    vector<string> v;
    while (!q.empty())
    {
        string s = q.front().first;
        int var = q.front().second;
        q.pop();
        if (s.size() == n){
            v.push_back(s);
            continue;
        }
        rep(i, var+1){
            s.push_back('a'+i);
            if (i == var) q.push(make_pair(s, var+1));
            else q.push(make_pair(s, var));
            s.pop_back();
        }
    }
    for (auto &&i : v)
        cout << i << endl;
    
}

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

typedef struct{
  char suit,value;
}Card;

void Bubble(Card A[],int N){
  int i,j;
  Card f;
  for(i=0;i<=N-1;i++){
    for(j=N-1;j>i;j--){
      if(A[j].value<A[j-1].value){
          f = A[j];
          A[j]=A[j-1];
          A[j-1]=f;
        }
      }
    }
  }

void Selection(Card A[], int N){
  int i,j,minj,a,b;
  Card t;
  for(i=0;i<N;i++){
      minj=i;
      for(j=i;j<N;j++){
        if(A[j].value<A[minj].value){
          minj=j;
        }
      }
      t =A[i];A[i] = A[minj];A[minj]=t;
    }
  }

int isStable(Card C1[],Card C2[],int N){
  int i;
  for(i=0;i<N;i++){
    if(C1[i].suit!=C2[i].suit)return 0;
  }
  return 1;
}

int main(){
  int i,j,N;
  Card C1[100],C2[100];
  char as,s[3];
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%s",s);
    C1[i].suit=s[0];
    C1[i].value=s[1];
  }
  for(i=0;i<N;i++)C2[i]=C1[i];
  Bubble(C1,N);
  Selection(C2,N);
  for(i=0;i<N-1;i++){
    s[0]=C1[i].suit;
    s[1]=C1[i].value;
    printf("%s ",s);
  }
  s[0]=C1[i].suit;
  s[1]=C1[i].value;
  printf("%s\n",s);
  printf("Stable\n");
  for(i=0;i<N-1;i++){
    s[0]=C2[i].suit;
    s[1]=C2[i].value;
    printf("%s ",s);
  }
  s[0]=C2[i].suit;
  s[1]=C2[i].value;
  printf("%s\n",s);
  if(isStable(C1,C2,N)){
    printf("Stable\n");
  }
  else{
    printf("Not stable\n");
  }
  return 0;
}

Measured memory_bytes: 604
N,M=gets.chomp.split(' ').map{|n| n.to_i}
A = Array.new(M)
0.upto(M-1){|d|
	A[d]=gets.chomp.split(' ').map{|n| n.to_i}
}
A.sort!{|a,b| a[1] <=> b[1]}
# p A

left = -1
cnt = 0
for i in 0..(M-1)
	a = A[i][0]
	b = A[i][1]
	if(a <= left && left < b)
		next
	else
		# puts b-1
		left = b-1
		cnt += 1
	end
end
puts cnt


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

/* Main */
void calculateSquareMeasureAndPerimeter(void)
{
    /* The input/output value type was not specified. */
    /* AOJ judges the type of output string.          */
    /* So, I only considered the results.             */
    int widthLength   = -1;
    int heightLength  = -1;
    int squareMeasure = -1;
    int perimeter     = -1;
    
    while(1)
    {
        cin >> widthLength >> heightLength;
        /* input check */
        if( (1 <= widthLength) && (heightLength <= 100) )
        {
            break;
        }
    }
    
    squareMeasure = widthLength * heightLength;
    perimeter = 2*widthLength + 2*heightLength;
    
    cout << squareMeasure << " " << perimeter << endl;
    
    return;
}

/* Driver */
int main(void){
    calculateSquareMeasureAndPerimeter();
    return 0;
}

Measured memory_bytes: 3012
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")



void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll aa , bb;} fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->aa - ((fr*)q)->aa;}

int main(void){
    // char ;
    ll n;
    scanf("%lld",&n);
    ll x[n],l[n];
    rep(i,0,n){
        scanf("%lld%lld",&x[i],&l[i]);
    }
    fr a[n];
    rep(i,0,n){
        a[i].aa=x[i]+l[i];
        a[i].bb=i;
    }
    qsort(a,n,sizeof(fr),cmp1);
    ll now=x[a[0].bb]+l[a[0].bb],ans=n;
    rep(i,1,n){
        if( x[a[i].bb]-l[a[i].bb] >= now ){
            now = x[a[i].bb]+l[a[i].bb];
        }else{
            ans--;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


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

using ll = long long;
constexpr ll mod = 1e9 + 7;

int main() {
    string s;
    cin >> s;
    const int n = s.size();
    vector<ll> v(2);
    ll ans = 0, tot = 1;
    for(int i = 0; i < n; ++i) {
        if(s[i] == '?') {
            ans = (v[1] + ans * 3) % mod;
            v[1] = (v[1] * 3 + v[0]) % mod;
            v[0] = (tot + v[0] * 3) % mod;
            (tot *= 3) %= mod;
        } else if(s[i] == 'A') {
            (v[0] += tot) %= mod;
        } else if(s[i] == 'B') {
            (v[1] += v[0]) %= mod;
        } else {
            (ans += v[1]) %= mod;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <stdio.h>

int binarysearch(int *A, int key, int n)
{
    int left = 0;
    int right = n - 1;
    int mid;
    while (right >= left) {
		mid = (left + right)/2;
        if (A[mid] == key) return 1;
        if ( key < A[mid]) right = mid - 1;
        else left = mid + 1;
    }
    return 0;
}

int main(void)
{
    int q, i;
    int S[1000000];
    int T;
    int count = 0;
    int n = 15;

    scanf("%d", &n);
    for(i = 0; i < n; i++) scanf("%d", &S[i]);
    scanf("%d", &q);
    for(i = 0; i < q; i++) {
        scanf("%d", &T);
        count = count + binarysearch(S, T, n);
    }
    printf("%d\n", count);

    return 0;
}


Measured memory_bytes: 2112
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))



if sum(a)<sum(b):
    print(-1)
    exit(0)

dif=0
cnt=0
asis=0
#足りない項には足してあげる
for i in range(n):
    if a[i]<b[i]:
        dif-=(b[i]-a[i])
        a[i]=b[i]
        cnt+=1

if cnt==0:
    print(0)
    exit(0)

c=[]
for j in range(n):
    c.append(a[j]-b[j])

c=sorted(c,reverse=True)

#余裕があるところから引いていく
for k in range(n):
    if c[k]>=dif:
        dif+=c[k]
        cnt+=1

    if dif>=0:
        break

print(cnt)

Measured memory_bytes: 19068
#include <utility>
#include <bitset>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <ios>
#include <iomanip>
#include <sstream>
#include <climits>
#include <cmath>

using namespace std;

#ifdef USE_LOG
#define LOG(str)  cout << str << endl
#define DMP(var)  cout << #var << " = " << var << endl
#else
#define LOG(...)
#define DMP(...)
#endif

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

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

typedef long long           ll;
typedef unsigned long long  ull;

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

	int N;
	cin >> N;

	int M = 0;
	int A = 0;
	int R = 0;
	int C = 0;
	int H = 0;
	string name;

	REP (i, N)
	{
		cin >> name;

		if (name[0] == 'M') ++M;
		if (name[0] == 'A') ++A;
		if (name[0] == 'R') ++R;
		if (name[0] == 'C') ++C;
		if (name[0] == 'H') ++H;
	}

	int S[5] = {
		M,
		A,
		R,
		C,
		H
	};

	ull result = 0;
	FOR (i, 0, 3)
	FOR (j, i + 1, 4)
	FOR (k, j + 1, 5)
	{
		result += S[i] * S[j] * S[k];
	}

	cout << result << endl;
}

Measured memory_bytes: 888
// #include C/C++ {
#include <bits/stdc++.h>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef _DEBUG

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 3005
#define MAX_M 55
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////
int get_pow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = 1LL * res * a % MOD;
		a = 1LL * a * a % MOD;
		n >>= 1;
	}
	return res;
}
int fact[MAX_N];
void setup() {
	fact[0] = 1;
	for (int i = 1; i < MAX_N; i++) fact[i] = 1LL * fact[i - 1] * i % MOD;
}
int C(int n, int m) {
	if (n < m) return 0;
	return 1LL * fact[n] * get_pow(fact[m], MOD - 2) % MOD * get_pow(fact[n - m], MOD - 2) % MOD;
}
/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
	// WF("output.txt");
	DF("err.txt");
	
	setup();
	int N, K;
	scanf("%d %d", &N, &K);
	for (int i = 1; i <= K; i++) {
		printf("%lld\n", 1LL * C(N - K + 1, i) * C(K - 1, K - i) % MOD);
	}
	return 0;
}

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

int main(){
    int a,b;    cin>>a>>b;
    int ans=0;
    for(int i=a;i<=b;i++){
        int v=i%10,  w=i/10000 % 10,
            x=i/10 % 10,   y=i/1000 % 10;

            if(v==w && x==y)ans++;
            
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
N_hon, K_ko = map(int, input().split())
Height = list(int(input()) for i in range(N_hon))
Height.sort()
mini=float('inf')

for i in range(K_ko - 1, N_hon):
    mini = min(Height[i] - Height[i - (K_ko - 1)], mini)    
    
print(mini)

Measured memory_bytes: 7492
N = int(input())
A = int(input())

if N %500 == 0:
    print("Yes")

#もしNが９９９９だったら、５００円硬貨１９枚と１円硬貨が４９９枚数によって支払い可能。
#その４９９の算出方法は9999を５００で割った時の余り、つまりN％５００　
#この時、Aがもし４９９以上だったら支払い可能だが、４９８以下だったら不足しており支払い不可。
    
elif N %500 <= A:
    print("Yes")

else:
    print("No") 

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

#define f first
#define s second
#define ll long long
#define pb push_back
#define mp make_pair
#define inp(x) cin>>x
#define print(x) cout<<x
#define pii pair<int,int>
#define pll pair<ll,ll>
#define gcd(a,b) __gcd(a,b)
#define reset(d,val) memset(d,val,sizeof(d))
#define sort(v) sort(v.begin(),v.end())
#define sort_arr(arr,i,f) sort(arr+i,arr+f)
#define pq priority_queue<int,vector<int>,greater<int> >
#define pq1 priority_queue<pll,vector<pll>,greater<pll> >

const int mod = 1e9+7;

ll n,k;
std::vector<std::vector<ll> > v;

std::vector<std::vector<ll> >f1(std::vector<std::vector<ll> >v1,std::vector<std::vector<ll> > v2) {
	std::vector<std::vector<ll> >v3(n);
	for (int i = 0; i < n; ++i)
	{
		v3[i].resize(n);
	}
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			for (int k = 0; k < n; ++k)
			{
				v3[i][j] = (v3[i][j] + v1[i][k]*v2[k][j])%mod;
			}
		}
	}
	return v3;
}

std::vector<std::vector<ll> >f(std::vector<std::vector<ll> >a,ll b){
	if(b==1) return a;
	std::vector<std::vector<ll> > ans = f(a,b/2);
	if(b&1) {
		return f1(a,f1(ans,ans));
	}
	return f1(ans,ans);
}

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>k;
	v.resize(n);
	for (int i = 0; i < n; ++i)
	{
		v[i].resize(n);
		ll d;
		for (int j = 0; j < n; ++j)
		{
			cin>>v[i][j];
		}
	}
	ll cnt = 0;
	std::vector<std::vector<ll> >ans = f(v,k);
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			cnt = (cnt+ans[i][j])%mod;
		}
	}
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <iterator>
#include <utility>
#include <iomanip>
#include <stack>
#include<bitset>
#include <cmath>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
priority_queue<pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> > >pq;
vector<ll>adj[2005];
ll expo(ll b,ll n,ll m)
{
 ll r,p;
	p=1;
	 b=b%m;
	while(n>0)
	{ 
		r=n%2;
		if(r==1)
		   p=((p%m)*(b%m))%m;
		b=((b%m)*(b%m))%m; 
		n=n/2;		
	}
 return (p%m);
}
ll divide1(ll a,ll b,ll m)
	{ ll r,p,n;
			p=a%m;
				n=m-2;
				while(n>0){
						 r=n%2;
						if(r==1)
							p=((p%m)*(b%m))%m;
						b=((b%m)*(b%m))%m; 
						n=n/2;	
					}
	return (p%m); }
ll a[3002];
bool visited[2003][2002];
ll ans[2002];
void bfs(ll u)
{
	queue<pair<ll,ll> >q;
	q.push(mp(u,0));
	while(!q.empty())
	{
		ll vertex=q.front().ff;
		visited[vertex][u]=1;
		ll d=q.front().ss;
		ans[d++]++;
		for(auto v:adj[vertex])
		{
			if (!visited[v][u])
			{
				q.push(mp(v,d));
			}
		}
		while(!q.empty()&&visited[q.front().ff][u]==1)
		{
			q.pop();
		}
	}
}
int main(int argc, char const *argv[])
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);
	ll n,x,y;
	cin>>n;
	for (int i = 1; i < n; ++i)
	{
		adj[i].pb(i+1);
		adj[i+1].pb(i);	
	}
	cin>>x>>y;
	adj[x].pb(y);
	adj[y].pb(x);
	for (int i = 1; i <= n; ++i)
	{
		bfs(i);
	}
	for (int i = 1; i < n; ++i)
	{
		cout<<ans[i]/2<<"\n";
	}
	
	return 0;
}


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

#define LL long long
#define pa pair<int,int>
using namespace std;
const int inf = 2147483647;
const int mod = 1e9 + 7;
const int N = 1000001;

int _max(int x, int y) {return x > y ? x : y;}
int _min(int x, int y) {return x < y ? x : y;}
inline int read() {
    int x = 0, f = 1; char ch = getchar();
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
    return x * f;
}
void put(int x) {
	if(x < 0) putchar('-'), x = -x;
	if(x >= 10) put(x / 10);
	putchar(x % 10 + '0');
}

int jc[N], iv[N], inv[N], f[N];

int add(int x, int y) {
	x += y;
	return x >= mod ? x -= mod : x;
}

int C(int n, int m) {return (LL)jc[n] * inv[m] % mod * inv[n - m] % mod;}

int pow_mod(int a, int k) {
	LL ans = 1;
	while(k) {
		if(k & 1) ans = (LL)ans * a % mod;
		a = (LL)a * a % mod, k /= 2;
	} return ans;
}

int main() {
	int n = read();
	if(n == 2) {puts("138888890"); return 0;}
	jc[0] = 1; for(int i = 1; i <= n; i++) jc[i] = (LL)jc[i - 1] * i % mod;
	iv[0] = iv[1] = 1; for(int i = 2; i <= n; i++) iv[i] = (LL)(mod - mod / i) * iv[mod % i] % mod;
	inv[n] = pow_mod(jc[n], mod - 2);
	for(int i = n; i >= 1; i--) inv[i - 1] = (LL)inv[i] * i % mod;
	f[0] = 0; int tot = pow_mod(iv[3], n - 1), ans = 0;
	for(int i = 1; i <= n; i++) {
		if(i == 1) f[i] = 1;
		else f[i] = add(f[i - 1], add(f[i - 2], f[i - 2]));
		int ff = (LL)f[i] * C(n, i) % mod * tot % mod;
		int gg = (LL)iv[3] * iv[i] % mod * iv[n] % mod;
		ans = add(ans, (LL)gg * ff % mod);
	} put(ans), puts("");
	return 0;
}



Measured memory_bytes: 15872
using System;
using System.Linq; 

namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
	string[] str=Console.ReadLine().Split(' ');
      int K=int.Parse(Console.ReadLine());
      int A=int.Parse(str[0]);
      int B=int.Parse(str[1]);
      int C=int.Parse(str[2]);
      int flg=0;
      for(int i=1;i<=K;i++){
        if(A>=B){
          B=2*B;
        }else if((B>=C)||(A>=C)){
          C=2*C;
        }
        if((A<B)&&(B<C)){
          flg=1;
          break;
        }
      }if(flg==1){
        Console.WriteLine("Yes");
      }else{
        Console.WriteLine("No");
      }
      
    }
    
  }

}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using Graph = vector<vector<pair<int, int>>>;

constexpr int MOD = 1000000007;

vi bfs(const Graph& G) {
    int n = G.size();

    // Initialize cost.
    vi cost(n, -1);
    cost[0] = 0;

    queue<int> q;
    q.push(0);

    // Seen or not.
    vb seen(n, false);
    seen[0] = true;

    while (!q.empty()) {
        int curr = q.front();
        q.pop();

        for (pair<int, int> p : G[curr]) {
            int next = p.first;
            int edge = p.second;

            if (seen[next]) { continue; }
            seen[next] = true;

            cost[next] = (cost[curr] + edge) % 2;
            q.push(next);
        }
    }
    return cost;
}

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

    int n;
    cin >> n;

    Graph G(n);
    rep(_, 0, n - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        G[u - 1].emplace_back(v - 1, w % 2);
        G[v - 1].emplace_back(u - 1, w % 2);
    }

    vi cost = bfs(G);
    rep(i, 0, n) { cout << cost[i] % 2 << endl; }

    return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 
 
 int main(){
   int H,W ; cin>>H>>W ;
   int h, w ; cin>>h>>w ;
   if(H%h==0&&W%w==0) cout<<"No"<<endl ;
   else{
     cout<<"Yes"<<endl ;
     if(H%h!=0){
       ll a= H%h ; ll b= h-a ;
       ll c= -(a*1000+1) ;
       rep(i,H){
         rep(j,W){
           ll ans ;
           ll p= i%h ;
           if(p<a) ans=1000 ;
           else if(p==h-1) ans = c ;
           else ans =0 ;
           if(j==W-1) cout<<ans<<endl ;
           else cout<<ans<<" " ;
         }
       }

     }

     else{
       ll a= W%w ; ll b= w- a ;
       ll c= -(a*1000+1) ;
       rep(i,H){
         rep(j,W){
           int ans  ;
           ll p = j%w ;
          if(p<a) ans = 1000 ;
          else if(p==w-1) ans = c ;
          else ans=0 ;
          if(j==W-1) cout<<ans<<endl ;
          else cout<<ans<<" " ;
         }
       }
     }
   }
   return 0 ;
 }



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

int main(){
  string s;
  cin >> s;
  int f = s.size(); int b = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A') f = min(f, i);
    if (s[i] == 'Z') b = max(b, i);
  }
  cout << b - f + 1 << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>

int main() {

        std::string s;
        std::cin >> s;

        auto ret = 0;
        for (auto c : s) {
                if (c == '+') {
                        ++ret;
                }
                else if (c == '-') {
                        --ret;
                }
        }

        std::cout << ret << std::endl;

        return 0;
}

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

int main(){
   int N;
   cin >> N;
   vector<int> A(N - 1);
   vector<int> cou(200050,0);
   for (int i = 0; i < (N - 1); i++){
       cin >> A.at(i);
       cou.at(A.at(i))++;
   }
   for (int i = 1; i <= N; i++){
       cout << cou.at(i) <<  endl;
   }
}


Measured memory_bytes: 4844
from collections import deque

S = input()
Q = int(input())

cur = 1
d = deque([S])

for _ in range(Q):
    ins = input().split()
    if len(ins) == 1:
        cur = 2 if cur == 1 else 1
    else:
        _, f, c = ins
        f = int(f)
        if cur == f == 1 or cur == f == 2:
            d.appendleft(c)
        else:
            d.append(c)

if cur == 1:
    print("".join(d))
else:
    temp = "".join(d)
    print(temp[::-1])


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

int main(){
	int w, n, i, a, b;
	cin >> w;
	int ans[w];
	for (i = 0; i < w; i++) {
		ans[i] = i+1;
	}
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf("%d,%d", &a, &b);
		swap(ans[a-1], ans[b-1]);
	}

	for (i = 0; i < w; i++) {
		cout << ans[i] << endl;
	}


	return 0;
}

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

int main() {
	string s;
	int n,cnt=0;
	cin >> n >> s;
	for (int i = 0;i < n;i++) {
		if (s[i] == 'A'&& s[i + 1] == 'B'&&s[i+2] == 'C') {
			cnt++;
			i += 2;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256