akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
using namespace std;

const int MAXN = 100000;

namespace FlowGraph{
	const int MAXV = 2*MAXN;
	const int MAXE = 10*MAXN;
	const int INF = (1 << 30);
	
	struct edge{
		int to, flow, cap;
		edge *nxt, *rev;
	}edges[MAXE + 5], *adj[MAXV + 5], *cur[MAXV + 5], *ecnt = edges;
	void addedge(int u, int v, int c) {
		edge *p = (++ecnt), *q = (++ecnt);
		p->to = v, p->cap = c, p->flow = 0;
		p->nxt = adj[u], adj[u] = p;
		q->to = u, q->cap = 0, q->flow = 0;
		q->nxt = adj[v], adj[v] = q;
		p->rev = q, q->rev = p;
	}
	int s, t;
	int fa[MAXV + 5], dis[MAXV + 5];
	int que[MAXV + 5], hd, tl;
	bool relabel() {
		for(int i=s;i<=t;i++)
			dis[i] = t + 5, cur[i] = adj[i];
		dis[que[hd = tl = 1] = t] = 0;
		while( hd <= tl ) {
			int x = que[hd++];
			for(edge *p=adj[x];p;p=p->nxt) {
				if( dis[p->to] > dis[x] + 1 && p->rev->cap > p->rev->flow )
					dis[p->to] = dis[x] + 1, fa[p->to] = x, que[++tl] = p->to;
			}
		}
		return !(dis[s] == t + 5);
	}
	int aug(int x, int tot) {
		if( x == t ) return tot;
		int sum = 0;
		for(edge *&p=cur[x];p;p=p->nxt) {
			if( p->cap > p->flow && dis[p->to] + 1 == dis[x] ) {
				int del = aug(p->to, min(tot - sum, p->cap - p->flow));
				p->flow += del, p->rev->flow -= del, sum += del;
				if( sum == tot ) break;
			}
		}
		return sum;
	}
	int max_flow(int _s, int _t) {
		int flow = 0; s = _s, t = _t;
		while( relabel() )
			flow += aug(s, INF);
		return flow;
	}
}

int a[MAXN + 5], b[MAXN + 5];
int main() {
	int N; scanf("%d", &N);
	for(int i=1;i<N;i++) {
		int c; scanf("%d", &c);
		for(int j=1;j<=c;j++) {
			int w; scanf("%d", &w);
			FlowGraph::addedge(N + i, w, 1);
		}
	}
	int s = 0, t = N + N - 1 + 1;
	for(int i=1;i<N;i++) FlowGraph::addedge(s, N + i, 1);
	for(int i=1;i<=N;i++) FlowGraph::addedge(i, t, 1);
	int f = FlowGraph::max_flow(s, t);
	if( f == N - 1 ) {
		FlowGraph::relabel();
		for(int i=1;i<t;i++)
			if( FlowGraph::dis[i] == t + 5 ) {
				puts("-1");
				return 0;
			}
		for(int i=1;i<N;i++) a[i] = FlowGraph::fa[N + i];
		for(int i=1;i<=N;i++) b[FlowGraph::fa[i] - N] = i;
		for(int i=1;i<N;i++) printf("%d %d\n", a[i], b[i]);
	}
	else puts("-1");
}

Measured memory_bytes: 34432
#include<bits/stdc++.h>
using namespace std;
int main(){
  int s,k, ans=0;
  cin>>k>>s;
  for(int i=k; i>=0; i--){
  	for(int j=k; j>=0; j--){
    	int lala = s-i-j;  
    	if(lala<=k and lala>=0) ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> C(H, vector<char>(W));
    vector<int> x;
    vector<int> y;
    REP(int,i,0,H) REP(int,j,0,W) cin >> C.at(i).at(j);
    REP(int,i,0,H){
        bool Flag = false;
        REP(int,j,0,W) if ( C.at(i).at(j) == '#') Flag = true;
        if ( Flag ) y.push_back(i);
    }
    //REP(int,i,0,x.size()) cout << x.at(i) << endl;
    REP(int,j,0,W){
        bool Flag = false;
        REP(int,i,0,H) if ( C.at(i).at(j) == '#') Flag = true;
        if ( Flag ) x.push_back(j);
    }
    //REP(int,i,0,x.size()) cout << y.at(i) << endl;
    for ( auto i : y ){
        for ( auto j : x ) cout << C.at(i).at(j);
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(){
	int n,i,k,j;
	scanf("%d %d",&n ,&k);
	int h[n];
	int conpara[k];
	int cost[n];	
	for(i=0;i<n;i++){
		scanf("%d",&h[i]);
	}
	int Sconpara;
	cost[0]=0;
	
	for(i=1;i<n;i++){
		j=i-1;
		cost[i]=cost[j]+abs(h[j]-h[i]);
		j--;
		while(j >=0 && i-j <=k){
			conpara[j]=cost[j]+abs(h[j]-h[i]);
			if (cost[i] >conpara[j]){
				cost[i]=conpara[j];
			}
			j--;
		}
		//printf("%d; %d\n",i,cost[i]);
	}
		
	
	printf("%d\n",cost[n-1]);
	

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr ll INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[N],B[N];
    priority_queue<pair<ll,ll>> que;
    REP(i,N) cin >> A[i];
    REP(i,N){
        cin >> B[i];
        if(A[i] != B[i]) que.push({B[i],i});
    }
    ll ans = 0,cnt = 0;
    while(!que.empty()){
        pair<ll,ll> p = que.top();que.pop();
        ll i = p.second -1,j = p.second +1;
        if(j == N) j = 0;if(i == -1) i = N-1;
        ll mid = p.second;
        if(B[mid] <= B[i]+B[j]){cout << -1 << endl;return 0;}
        else if(B[mid] - A[mid] >= B[i] + B[j]){
            B[mid] -= A[mid];
            ans += B[mid] / (B[i]+B[j]);
            B[mid] %= (B[i] + B[j]);
          	B[mid] += A[mid];
            if(B[mid] != A[mid]) que.push({B[mid],mid});
        }
    }
    cout << ans << endl;
}


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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;

template<i64 M>
struct modint {
    i64 x;

    constexpr modint(const i64 y = 0) noexcept : x(y >= 0 ? y % M : (M - (-y) % M) % M) {}

    constexpr modint operator-() const noexcept { return modint(-x); }
    constexpr modint operator+(const modint &rhs) const noexcept { return modint(*this) += rhs; }
    constexpr modint operator-(const modint &rhs) const noexcept { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint &rhs) const noexcept { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint &rhs) const noexcept { return modint(*this) /= rhs; }

    constexpr modint &operator+=(const modint &rhs) noexcept {
        x += rhs.x;
        if (x >= M) x -= M;
        return *this;
    }

    constexpr modint &operator-=(const modint &rhs) noexcept {
        if (x < rhs.x) x += M;
        x -= rhs.x;
        return *this;
    }

    constexpr modint &operator*=(const modint &rhs) noexcept {
        x = x * rhs.x % M;
        return *this;
    }

    constexpr modint &operator/=(const modint &rhs) noexcept {
        i64 a = rhs.x, b = M, u = 1, v = 0;
        while (b > 0) {
            i64 t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        *this *= u;
        return *this;
    }

    friend ostream &operator<<(ostream &os, const modint &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, modint &a) {
        i64 t;
        is >> t;
        a = modint(t);
        return is;
    }
};

constexpr i64 MOD = 1 ? 1'000'000'007 : 998'244'353;
using m64 = modint<MOD>;
constexpr m64 operator"" _m(unsigned long long n) { return m64(n); }

void solve() {
    i64 n, k;
    cin >> n >> k;

    vector<vector<m64>> a(n, vector<m64>(n));
    for (auto& e : a) for (auto& f : e) cin >> f;

    vector<vector<m64>> sum(n, vector<m64>(n));
    for (i64 i = 0; i < n; i++) sum[i][i] = 1;
    for (; k > 0; k >>= 1) {
        if (k & 1) {
            vector<vector<m64>> tmp1(n, vector<m64>(n));
            for (i64 x = 0; x < n; x++) {
                for (i64 y = 0; y < n; y++) {
                    for (i64 z = 0; z < n; z++) {
                        tmp1[x][y] += sum[x][z] * a[z][y];
                    }
                }
            }
            sum = move(tmp1);
        }

        vector<vector<m64>> tmp2(n, vector<m64>(n));
        for (i64 x = 0; x < n; x++) {
            for (i64 y = 0; y < n; y++) {
                for (i64 z = 0; z < n; z++) {
                    tmp2[x][y] += a[x][z] * a[z][y];
                }
            }
        }
        a = move(tmp2);
    }

    m64 ans = 0;
    for (i64 i = 0; i < n; i++) {
        for (i64 j = 0; j < n; j++) ans += sum[i][j];
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 3728
#include<algorithm>
#include<iostream>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  long int a,b,c;
  cin>>a>>b>>c;
  if(a%2==0 or b%2==0 or c%2==0)
    cout<<0<<endl;
  else{
    if(a>=b and a>=c)
     cout<<b*c<<endl;
    else if(b>a and b>c)
      cout<<a*c<<endl;
    else if(c>a and c>b)
      cout<<a*b<<endl;
  }
}

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

int main() {
  string S, T;
  cin >> S >> T;
  if(S.size()+1 == T.size()){
    int a = S.size();
    int i;
    for(i = 0; i < a; i++){
      if(S[i] != T[i]){
        break;
      }
    }
    if(i == a){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

constexpr ll LNF = 1ll<<60;

constexpr int INF = 1e9+7;

vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

int solve(){
    ll n,a,b,c,d; cin >> n >> a >> b >> c >> d;
    map<ll,ll> m;
    auto dfs = [&](ll here, auto &dfs)->ll{
        if(m[here]!=0) return m[here];
        if(here<=0) return 0;
        if(here==1) return d;
        ll t = LNF;
        if(here<LNF/d) t = here*d;
        chmin(t,a+d*(here%2ll)+dfs(here/2ll,dfs));
        if(here%2==1){
            chmin(t,a+d+dfs((here+1ll)/2ll,dfs));
        }
        chmin(t,b+d*(here%3ll)+dfs(here/3ll,dfs));
        if(here%3!=0){
            chmin(t,b+d*(3ll-here%3ll)+dfs((here+2ll)/3ll,dfs));
        }
        chmin(t,c+d*(here%5ll)+dfs(here/5ll,dfs));
        if(here%5!=0){
            chmin(t,c+d*(5ll-here%5ll)+dfs((here+4ll)/5ll,dfs));
        }
        m[here] = t;
        return t;
    };
    cout << dfs(n,dfs) << endl;
    return 0;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int t; cin >> t;
    rep(_,0,t){
        solve();
    }
}

Measured memory_bytes: 4484
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;
vector<int> G[100010];
int other = 0;
int used[100010] = {0};
int p;
void dfs(int s){
    if(used[s] == 1)return;
    if(s != p && G[s].size() == 4){
        other++;
        return;
    }
    used[s] = 1;
    for(auto x:G[s]){
        dfs(x);
    }
    return;
}
signed main(){
    int n,m;
    cin >> n >> m;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        G[a-1].pb(b-1);
        G[b-1].pb(a-1);
    }
    int cnt = 0;
    
    rep(i,n){
        if(G[i].size()%2 == 1){
            cout << "No" << endl;
            return 0;
        }
        if(G[i].size() == 4){
            cnt++;
            p = i;
        }
        if(G[i].size() >= 6)cnt += 3;
    }
    if(cnt >= 3){
        cout << "Yes" << endl;
        return 0;
    }else if(cnt  <= 1){
        cout << "No" << endl;
        return 0;
    }

    dfs(p);
    if(other == 4){
        cout << "No" << endl;
    }else cout << "Yes" << endl;
    


    
    
    return 0; 
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_d
// rm -r -f test;oj dl http://abc122.contest.atcoder.jp/tasks/abc122_a

Measured memory_bytes: 7296
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int X;
    cin >> X;
    X-=400;
    cout << 8-X/200 << endl;
}

Measured memory_bytes: 3620
import java.util.*;

class Main{       
    
    private static int MOD = 1000000007;
    
   public static void main(String[] args){
     
       Scanner sc = new Scanner(System.in);                                            
              
       String S = sc.next();
       
       if(S.contains("AC")){
           System.out.println("Yes");
           return;
       }else{
           System.out.println("No");
           return;
       }
       
       
   }
}
        

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<vector>

int main() {
	char alpha;
	std::cin >> alpha;
	std::string moji = "abcdefghijklmnopqrstuvwxyz";
	std::string ans = "A";

	for (int i = 0; i < 26; i++) {
		if (moji.at(i) == alpha) {
			ans = "a";
			break;
		}
	}
	
	std::cout << ans << std::endl;
}

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

#define ll unsigned long long

ll gcd(ll a, ll b) {
    if(a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

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

int main() {
    ll A, B;
    cin >> A >> B;
    cout << lcm(A, B) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int a[100],count[101];
int main()
{
	int max=-1,i=0,j=0,k;
	while(scanf("%d",&a[i]) != EOF)
	{
		i++;
		j++;
	}
	for(i=0;i<j;i++)
	{
		for(k=0;k<101;k++)
		{
			if(a[i] == k)
			{
				count[k] ++;
			}
		}
	}
	for(i=0;i<101;i++)
	{
		if(count[i]>max)max = count[i];
	}
	for(i=0;i<101;i++)
	{
		if(count[i] == max)printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;
typedef long long ll;

#define INF (long long)(10e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)

int main(void)
{
    int n, a[110];
    int asum = 0;
    cin >> n;
    REP(i, n) cin >> a[i];
    sort(a,a+n,greater<int>());
    REP(i, n) {
        if(i%2==0) {
            asum+=a[i];
        } else {
            asum -=a[i];
        }
    }
    cout << asum << endl;
}


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

int main()
{
	int a, b, c, x; cin >> a >> b >> c >> x;

	int ans = 0;
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			int tmp = x / 50 - 10 * i - 2 * j;
			if (0 <= tmp && tmp <= c) ans++;
		}
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, m, l, r, d, a[210000];
const ll INF = 1000000000000000000;
vector<P> vec[210000];
bool ans = true;

void dfs(ll x) {
    for (ll i = 0; i < vec[x].size(); i++) {
        P p = vec[x][i];
        if (a[p.first] == INF) {
            a[p.first] = a[x] + p.second;
            dfs(p.first);
        } else {
            if (a[p.first] != a[x] + p.second) ans = false;
        }
    }
}

int main(void){
    // Your code here!
    cin >> n >> m;
    for (ll i = 0; i < m; i++) {
        cin >> l >> r >> d;
        vec[l].push_back(P(r, d));
        vec[r].push_back(P(l, d * -1));
    }
    for (ll i = 1; i <= n; i++) a[i] = INF;
    for (ll i = 1; i <= n; i++) {
        if (a[i] != INF) continue;
        
        a[i] = 0;
        dfs(i);
    }
    cout << (ans ? "Yes" : "No");
}


Measured memory_bytes: 19456
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int n,x;
    cin >> n >>x;
    int a = max(x,n-x);
    int b = min(x,n-x);
    int r;
    while(b !=0){
        r = a%b;
        a = b;
        b = r;
    }
    cout << 3* (n - a);


    
    return 0;
    
}

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

int main() {
    int n;
    set<int> D;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int d;
        cin >> d;
        D.insert(d);
    }

    cout << D.size() << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const ll MOD=1000000007,INF=1ll<<60;
int dx[]={0,0,1,-1},dy[]={-1,1,0,0};

int N,Q;
vector<char>s,t,q,d;

int f(int now){
    if(now>=N)return true;
    rep(i,0,Q){
        if(d[i]=='R'){
            if(s[now]==q[i])now++;
        }else{
            if(s[now]==q[i])now--;
        }
        if(now>=N)return true;
        if(now<0)return false;
    }
    return false;
}

int ff(int now){
    if(now>=N)return true;
    rep(i,0,Q){
        if(d[i]=='L'){
            if(t[now]==q[i])now++;
        }else{
            if(t[now]==q[i])now--;
        }
        if(now>=N)return true;
        if(now<0)return false;
    }
    return false;
}

signed main() {
    IOS();
    cin>>N>>Q;
    s.resize(N);
    t.resize(N);
    rep(i,0,N){
        char c;
        cin>>c;
        s[i]=c;
        t[N-i-1]=c;
    }
    q.resize(Q);
    d.resize(Q);
    rep(i,0,Q){
        char a,b;
        cin>>a>>b;
        q[i]=a;
        d[i]=b;
    }
    
    int ans=0;
    int l = -1, r = N + 10;
    while(r - l > 1){
        int c = (l + r) / 2;
        if(f(c)) r = c;
        else l = c;
    }
    ans+=N-r;
    l = -1, r = N + 10;
    while(r - l > 1){
        int c = (l + r) / 2;
        if(ff(c)) r = c;
        else l = c;
    }
    ans+=N-r;
    cout<<N-ans<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    sc.nextLine()
    val cards: Array[Int] = sc.nextLine.split(" ").map(_.toInt).sorted.reverse
    val (alice, bob) = cards.zipWithIndex.partition(item => item._2 % 2 == 0)
    println(alice.map(_._1).sum - bob.map(_._1).sum)
  }

}


Measured memory_bytes: 27728
#include<stdio.h>

int main(void) {
  long int N;
  scanf("%d", &N);
  int f;
  f = N%10 + (N/10)%10 + (N/100)%10 + (N/1000)%10 + (N/10000)%10 + (N/100000)%10
  + (N/1000000)%10 + (N/10000000)%10 + N/100000000;
  
  if (N%f == 0) printf("Yes");
  else printf("No");
  
  return 0;
  
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <tuple>
#include <cmath>
using namespace std;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;

int main(){
    int N;
    cin>>N;
    string S;
    cin>>S;
    int L=0,R=0;
    int level=0;
    for(int i=0;i<N;i++){
        if(S[i]=='('){
            level++;
        }else{
            if(!level)L++;
            else level--;
        }
    }
    R=level;
    cout<<string(L,'(')+S+string(R,')')<<endl;

    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<int> A(N), flag(N, 0), ans;
    rep(0, i, N)
    {
        cin >> A.at(i);
        A.at(i)--;
    }

    if (K < 1000000)
    {
        int tmp = 0;
        rep(0, i, K)
        {
            tmp = A.at(tmp);
        }
        cout << tmp + 1 << endl;
        return 0;
    }
    int now = 0;
    int tmp;
    int count = 0;
    int amari = 0;
    while (1)
    {
        now = A.at(now);
        amari++;
        if (flag.at(now))
        {
            tmp = now;
            int i = now;
            do
            {
                ans.push_back(i);
                i = A.at(i);
                count++;
            } while (i != tmp);
        }
        else
        {
            flag.at(now)++;
        }
        if (count != 0)
        {
            break;
        }
    }
    ll loop = (K - (amari - count)) % count;
    rep(0, i, loop)
    {
        tmp = A.at(tmp);
    }
    cout << tmp + 1 << endl;
}

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

// #include <atcoder/all>

// #LIB#

using namespace std;
// using namespace atcoder;
using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#ifdef ONLINE_JUDGE
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');
#endif

int main() {
  ll n, k;
  cin >> n >> k;
  vector<pair<ll, ll>> v(n);
  rep(i, n) cin >> v[i].second >> v[i].first;
  sort(v.begin(), v.end(), greater<pair<ll, ll>>());
  vector<bool> vt(n + 1);
  vector<ll> s1, s2, s3;
  ll tn = 0;
  rep(i, n) {
    auto [d, t] = v[i];
    if (i < k) {
      if (vt[t]) {
        s2.push_back(d);
      } else {
        s1.push_back(d);
        vt[t] = true;
        ++tn;
      }
    } else {
      if (!vt[t]) {
        s3.push_back(d);
        vt[t] = true;
      }
    }
  }
  ll s2len = s2.size(), s3len = s3.size();
  sort(s2.begin(), s2.end(), greater<ll>());
  sort(s3.begin(), s3.end(), greater<ll>());
  rep(i, s3len) s3[i] += (tn + i + 1) * (tn + i + 1) - (tn + i) * (tn + i);
  vector<ll> s2sum(s2len + 1), s3sum(s3len + 1);
  rep(i, s2len) s2sum[i + 1] = s2sum[i] + s2[i];
  rep(i, s3len) s3sum[i + 1] = s3sum[i] + s3[i];
  ll score = 0;
  repr(i, max(0ll, s2len - s3len), s2len + 1) updatemax(score, s2sum[i] + s3sum[s2len - i]);
  score += tn * tn;
  itr(x, s1) score += x;
  cout << score << endl;
}


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

int main()
{
	int point[20000], width = 0, top = 0
		, volume[10000] = { }, count = 0, sum = 0
		, tmp = 0, height = 0, volumer[10000], rcount = 0;
	char c;
	for (int i = 0; cin >> c; i++)
	{
		width++;
		switch (c)
		{
		case '_':
			point[i] = 0;
			break;
		case '/':
			point[i] = 1;
			height++;
			break;
		case '\\':
			point[i] = -1;
			height--;
			break;
		}
		if (height > 0)
		{
		    top = i;
		    height = 0;
		}
	}
	height = 0;
	for (int i = 0; i <= top; i++)
	{
	    switch(point[i])
	    {
        case 0:
            tmp += height * 2;
            break;
        case 1:
            if (height > 1)
            {
                tmp += height * 2 - 1;
                height--;
            }
            else if (height == 1)
            {
                height = 0;
                tmp++;
                volume[count] = tmp / 2;
                count++;
                tmp = 0;
            }
            break;
        case -1:
            tmp += height * 2 + 1;
            height++;
            break;
	    }
	}
	height = tmp = 0;
	for (int i = width - 1; i >= top; i--)
	{
		switch (point[i])
		{
		case 0:
			tmp += height * 2;
			break;
		case 1:
			tmp += height * 2 + 1;
			height++;
			break;
		case -1:
			if (height > 1)
			{
				tmp += height * 2 - 1;
				height--;
			}
			else if (height == 1)
			{
				height = 0;
				tmp++;
				volumer[rcount] = tmp / 2;
				rcount++;
				tmp = 0;
			}
			break;
		}
	}

	for (int i = 0; i < count; i++)
		sum += volume[i];
	for (int i = 0; i < rcount; i++)
	    sum += volumer[i];
	cout << sum << endl;
	cout << count + rcount;
	for (int i = 0; i < count; i++)
		cout << " " << volume[i];
	for (int i = rcount - 1; i >= 0; i--)
	    cout << " " << volumer[i];
	cout << endl;

	return 0;
}


Measured memory_bytes: 3248
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return int64(a)
}

func scanFloat() float64 {
	sc.Scan()
	a, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		fmt.Println(err)
	}
	return a
}

func scanTextSlice(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = scanText()
	}
	return a
}

func scanSlice(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanFloatSlice(n int) []float64 {
	a := make([]float64, n)
	for i := 0; i < n; i++ {
		a[i] = scanFloat()
	}
	return a
}

func scanInt64Slice(n int64) []int64 {
	a := make([]int64, n)
	for i := int64(0); i < n; i++ {
		a[i] = scanInt64()
	}
	return a
}

// var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	input := scanSlice(2)
	a := input[0]
	b := input[1]

	// maze := make([]string, 0)

	// for i := 0; i < n; i++ {
	// 	maze[i] = make([]string, m)
	// }
	c := ""
	d := ""
	for i := 0; i < a; i++ {
		c += strconv.Itoa(b)
	}
	for i := 0; i < b; i++ {
		d += strconv.Itoa(a)

	}

	if a > b {
		fmt.Println(c)

	} else {
		fmt.Println(d)

	}

}

type position struct {
	x        int
	y        int
	distanse int
}

func binarySearch(arr []int, number int) int {

	l := -1
	r := len(arr)
	index := 0
	for {
		mid := l + (r-l)/2
		tmp := arr[mid]

		if r-l <= 1 || tmp == number {
			index = mid
			break
		} else if tmp < number {
			l = mid
		} else {
			r = mid
		}
	}
	return index
}

func factorial(n int) int64 {
	sum := int64(1)
	for i := 2; i <= n; i++ {
		sum *= int64(i)
	}
	return sum
}

func deleteNumOfArray(arr []int, position int) []int {
	left := arr[:position]
	r := arr[position+1:]
	appendArr := append(left, r...)
	return appendArr
}


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

int prime(int x){
  int i=3;
  if(x==2)return 1;
  else if(x<2 || x%2==0)return 0;
  for(i; i<=sqrt(x); i+=2)if(x%i==0)return 0;

  return 1;
}

int main(){
  int i,n,x,count=0;
  cin>>n;
  for(i=0; i<n; i++){
  cin>>x;
  count+=prime(x);
  }
  cout<<count<<endl;
return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a%2==1){
    cout<<"0"<<endl;
    return 0;
    }
  int x=b-a,y=c-b,z=a-c,cnt=0;
  if(x==0&&y==0&&z==0){
    cout<<"-1"<<endl;
    return 0;
    }
  while(x%2==0&&y%2==0&&z%2==0){
    x/=2;
    y/=2;
    z/=2;
    cnt++;
    }
  cout<<cnt<<endl;
  return 0;
  }


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 100000000

#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

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

static const double EPS = 1e-8;

void dfs(map<char,int>& co,map<char,int>::iterator it,map<char,bool>& pre,int visited,int sum,map<int, vector<int> >& result){

	if(it==co.end()){
		result[sum].push_back(visited);
		return;
	}

	for(int i=0;i<=9;i++){		
		if(visited & (1<<i)) continue;
		if(i==0 && pre[it->first]) continue;

		sum += it->second * i;
		it++;
		visited |= (1<<i);
		dfs(co,it,pre,visited,sum,result);
		visited &= ~(1<<i);
		it--;
		sum -= it->second * i;
	}
}

int main(){
	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;
		int count = 0;
		map<char,int> coefficient;
		map<char,bool> prefix; // prefix or not
		for(int i=0;i<n;i++){
			string str;
			cin >> str;
			if(str.size() > 1) prefix[str[0]] = true;
			for(int j=str.size()-1,k=1;j>=0;j--,k*=10){
				if(i!=n-1) coefficient[str[j]] += k;
				else coefficient[str[j]] -= k;
			}
		}
	
		map<char,int> co_front;
		map<char,int> co_rear;

		int ub=0;
		map<char,int>::iterator cit;
		for(cit = coefficient.begin(); cit != coefficient.end();cit++){
			if(ub >= coefficient.size()/2) break;
			co_front[cit->first] = cit->second;
			ub++;
		}

		for(; cit != coefficient.end();cit++){
			co_rear[cit->first] = cit->second;
		}

		map<int,vector<int> > result_front;
		map<int,vector<int> > result_rear;

		dfs(co_front,co_front.begin(),prefix,0,0,result_front);
		dfs(co_rear,co_rear.begin(),prefix,0,0,result_rear);

		int res=0;
		for(map<int,vector<int> >::iterator it = result_front.begin(); it != result_front.end(); it++){
			
			map<int,vector<int> >::iterator it2;

			if((it2 = result_rear.find(-(it->first))) != result_rear.end()){
				for(vector<int>::iterator sit = it->second.begin(); sit != it->second.end(); sit++){
					for(vector<int>::iterator sit2 = it2->second.begin(); sit2 != it2->second.end(); sit2++){
						if(!(*sit & *sit2)) res++;
					}
				}
			}
		}


		printf("%d\n",res);
	}
}

Measured memory_bytes: 3832
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust )
import           Control.Applicative

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

output :: [Int] -> String
output [a, b] | a > b     =  "a > b"
              | a < b     =  "a < b"
              | otherwise =  "a == b"

main :: IO ()
main = readInts >>= putStrLn <$> output



Measured memory_bytes: 3504
ans = 0
A,B,C,X = int(input()),int(input()),int(input()),int(input())
for i in range(A+1):
        for j in range(B+1):
                for k in range(C+1):
                        if 500*i+100*j+50*k == X:
                                ans += 1
print(ans)

Measured memory_bytes: 2940
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long
#define pii pair<int,int>
#define pb(x) push_back(x)
#define lbound lower_bound
#define ubound upper_bound
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcountll(x)
#define heap_min priority_queue<int,vector<int>,greater<int>>
#define heap_max priority_queue<int>
#define precision(x) cout << setprecision(x) << fixed;
#define printv(v) for(auto p : v) cout << p << " ";
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout << a[i] << " "; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int32_t main()
{
   fast;
   #ifndef ONLINE_JUDGE
   freopen("goodluckin.txt","r",stdin);
   freopen("goodluckout.txt","w",stdout);
   #endif

   int x;
   cin >> x;
   cout << 1-x;
}


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

int main () {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll t=1;
    while (t--) {
        int n;
        cin >> n;
        int ans=0;
        for(int i=1; i<n; ++i) {
            int temp=n-i;
            int cnt=0;
            for(int j=1; j*j<=temp; ++j) {
                if(temp%j==0){
                    if(temp/j != j) {
                        cnt+=2;
                    } else {
                        cnt+=1;
                    }
                }
            }
            ans += cnt;
        }        
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 3652
#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=(a);i>=(b);--i)
#define MP make_pair
#define PB push_back
#define PII pair<int, int>
typedef long long LL;
const LL P = 1e9+7;
const int N = 2e5+5;
const double pi = acos(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,a[N];

int main(){
	scanf("%d\n",&n);
	int cnt = 0;
	LL ans = 1;
	rep(i,1,n*2){
		char x;
		scanf("%c",&x);
		if(x=='W' && cnt%2==0 || x=='B' && cnt%2==1){
			ans = ans * cnt % P;
			cnt--;
			if(cnt<0){
				printf("0");
				return 0;
			}
		}else{
			cnt++;
		}
	}
	if(cnt!=0){
		printf("0");
		return 0;
	}
	rep(i,1,n) ans = ans * i % P;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
/* SPDX-License-Identifier: X11
 *
 * Copyright 2020 Elias Yuan <a@jthv.ai>, MIT/X11 License
 *   https://jthv.ai/LICENSE/X11.txt
 *
 * ANU-CPC Complexity Workshop - A: Two Integers
 *   2020-04-13
 *
 * Amended at Cormac's suggestion.
 */

#include <stdio.h>

int main(void)
{
  unsigned long x,y;
  scanf("%lu %lu",&x,&y);

  if (x % y) printf("%lu\n",x);
  else       printf("-1\n");

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
using namespace std;
int r[10000],parent[10000];
int find(int x){
    if(x==parent[x]){
        return x;
    }else{
        return parent[x]=find(parent[x]);
    }
}
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y){
        return;
    }
    if(r[x]<r[y]){
        parent[x]=y;
    }else{
        parent[y]=x;
        if(r[x] == r[y])r[x]++;
    }
    
}
int same(int x,int y){
    if(find(x)==find(y)){
        return 1;
    }else{
        return 0;
    }
}
int main(void){
   int n,q;
   cin >> n>>q;
   for(int i=0;i<n;i++){
       r[i]=0;
       parent[i]=i;
   }
   for(int i=0;i<q;i++){
       int com;
       cin >> com;
       int x,y;
       cin >> x>>y;
       if(com==0){
           if(same(x,y))continue;
           unite(x,y);
       }else{
            if(same(x,y)){
                 cout << 1<<endl;
           }else {
               cout<< 0<<endl;
           }
       }
       
   }
    
}



Measured memory_bytes: 3164
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = 0;
        int notMul10Num = 101;
        for(int i = 0; i < n; i++) {
            int num = sc.nextInt();
            sum += num;
            if(num % 10 != 0) {
                notMul10Num = Math.min(notMul10Num, num);
            }
        }
        if(sum % 10 != 0) {
            System.out.println(sum);
        } else if (notMul10Num != 101) {
            System.out.println(sum - notMul10Num);
        } else {
            System.out.println(0);
        }
    }
}


Measured memory_bytes: 21332
def main():
    n, m = [int(s) for s in input().strip().split()]
    S, C = [], []
    for _ in range(m):
        s, c = [int(s) for s in input().strip().split()]
        S.append(s)
        C.append(str(c))
    
    for x in range(1000):
        x = str(x)
        if len(x) == n and all(x[s - 1] == c for s, c in zip(S, C)):
            print(x)
            return
    print(-1)


main()


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
map<long long int,long long int> mp;
int main(){
    int n;
    long long int m;
    cin >> n >> m;
    long long int a[n];
    long long int sum =0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum += a[i];
        sum %= m;
        mp[sum]++;
    }
    long long int ans=0;
    for(auto u:mp){
        if(u.first==0LL)ans += u.second;
        ans += u.second*(u.second-1)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define i64 unsigned long long
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll mod = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
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;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}


int pow(ll x, ll y, ll mod){
    ll ret=1;
    for(;y;y>>=1,x=1ll*x*x%mod){
        if(y&1) ret=1ll*ret*x%mod;
    }
    return ret;
}
void kill()
{
    cout << "No" << endl;
    exit(0);
}

int main() {
    sonic();
    int a, b, c, k;
    R a >> b >> c >> k;
    co(a + b + c + (max({a, b, c}) << k) - max({a, b, c}));

}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  ll n;
  cin>>n;
  ll data[n][2];
  for(int i=0;i<n;i++){
  	cin>>data[i][0]>>data[i][1];
  }
  ll tot = 0;
  for(int i=n-1;i>=0;i--){
  	ll a=data[i][0],b=data[i][1];
  	a+=tot;
  	if((a%b)!=0){
  		tot+=b-(a%b);
  	}
  }
  cout<<tot<<endl;
}
//b-(a%b)





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

vector<int> adj[2005];
int d[2005][2005];

int n;
void bfs(int s) {
    for (int i = 1; i <= n; i++) {
        d[s][i] = -1;
    }
    d[s][s] = 0;

    queue<int> q;
    q.push(s);
    while (q.size()) {
        int u = q.front();
        q.pop();
        for (auto i: adj[u]) {
            if (d[s][i] == -1) {
                d[s][i] = d[s][u] + 1;
                q.push(i);
            }
        }
    }
}

int main() {
   // freopen("input.txt", "r", stdin);

    int x, y;
    cin >> n >> x >> y;

    for (int i = 1; i <= n - 1; i++) {
        adj[i].push_back(i + 1);
        adj[i + 1].push_back(i);
    }
    adj[x].push_back(y);
    adj[y].push_back(x);

    vector<int> res(n + 1);
    for (int i = 1; i <= n; i++) {
        bfs(i);
        for (int j = i + 1; j <= n; j++) {
            res[d[i][j]]++;
        }
    }

    for (int i = 1; i <= n - 1; i++) {
        cout << res[i] << "\n";
    }
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pii > vii;
typedef vector<pair<int, pair<int, int> > > viii;
typedef pair<ll,ll> pll;
typedef vector<string> vs;
typedef vector<vii> vvii;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define MEM(a,b) memset(a,(b),sizeof(a))
#define all(a) a.begin(),a.end()
#define loop(x,a,b) for(int (x) = (a);(x)<(b);(x)++)
#define rep(x,n)   for(int (x)=0;(x)<(n);(x)++)
#define tr(c,it) for(typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ain(a,n) int ((a)[(n)]); for(int i=0; i<(n); i++) cin>>((a)[i])  
#define md 1000000007
#define MAXN 200005

int main()
{   
    ios::sync_with_stdio(false);

    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    ans += min(k, a);
    k -= min(k,a);
    if (k > 0) {
    	k -= min(k, b);
    }
    if (k > 0) {
    	ans -= min(k,c);
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3664
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

using namespace std;

int main() {
  string S, T;
  int A, B;
  string U;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;

  if (U == S) {
    A--;
  } else {
    B--;
  }

  cout << A <<  " " << B << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    string S;
    int Q;
    cin >> S >> Q;
    deque<char> ans(S.size());
    for (int i = 0; i < S.size(); i++) {
        ans[i] = S[i];
    }
    int rev = 1;
    for (int i = 0; i < Q; i++) {
        int a;
        cin >> a;
        if (a == 1) {
            rev = 3 - rev;
        }
        else {
            int b;
            char c;
            cin >> b >> c;
            if ((b + rev) % 2 == 0) {
                ans.push_front(c);
            }
            else {
                ans.push_back(c);
            }
        }
    }
    int N = ans.size();
    if (rev == 1) {
        for (int i = 0; i < N; i++) {
            cout << ans[i];
        }
    }
    else {
        for (int i = N - 1; i > -1; i--) {
            cout << ans[i];
        }
    }
    cout << endl;
}


Measured memory_bytes: 3944
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long a, b, c;
  cin >> a >> b >> c;
  if (a <= c and c <= b) puts("Yes");
  else puts("No");
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

const int INF = 1e9+7;


ll n,m;
vector<vector<ll> > g(100,vector<ll> (100, 0));

int main(void){
  cin >> n >> m;
  vector<ll> a(m);
  vector<ll> b(m);
  vector<ll> c(m);
  for(ll i = 0;i < m;i++){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
  }
  for(ll i = 0;i < n; i++){
    for(ll j = 0;j < n; j++){
      if(i != j){
        g[i][j] = INF;
      }
    }
  }
  for(ll i = 0;i < m; i++){
    g[a[i]][b[i]] = min(g[a[i]][b[i]], c[i]);
    g[b[i]][a[i]] = min(g[b[i]][a[i]], c[i]);
  }

  for(ll d = 0;d < n; d++){
    for(ll i = 0;i < n; i++){
      for(ll j = 0;j < n; j++){
        g[i][j] = min(g[i][j], g[i][d] + g[d][j]);
      }
    }
  }
  ll ans = m;
  bool isShortest = false;
  for(ll i = 0;i < m; i++){
    isShortest = false;
    for(ll j = 0;j < n; j++){
      if (g[j][a[i]] + c[i] == g[j][b[i]]){
        isShortest = true;
      }
    }
    if(isShortest){
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;


int main(int argc, char *argv[])
{
	int n;
	cin >> n;
	vector<int> p(n);

	int P=0;
	for (int i=0;i<n;i++) cin>>p[i];
	do {
		P++;
	} while(next_permutation(p.begin(),p.end()));
	for (int i=0;i<n;i++) cin>>p[i];
	do {
		P--;
	} while(next_permutation(p.begin(),p.end()));
	if (P<0) P=-P;

	cout<<P<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
int n,a[202020],b[202020];
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>n;
	fo(i,0,n)cin>>a[i];
	fo(i,0,n)cin>>b[i];
	if(n<=190000){
		fo(i,0,n){
			bool q=1;
			fo(j,i,i+n) if(a[j-i]==b[j%n]){
				q=0;
				break;
			}
			if(q){
				cout<<"Yes\n";
				fo(j,i,i+n-1)cout<<b[j%n]<<' ';
				cout<<b[(i+n-1)%n]<<endl;
				return 0;
			}
		}
		cout<<"No\n";
		return 0;
	} 
	fo(i,0,n) if(a[0]!=b[i]){
		fo(j,i,i+n){
			while(a[j-i]==b[j%n]){
				i++;
				j++;
			}
			if(i>=n){
				cout<<"No\n";
				return 0;
			}
		}
		fo(j,i,i+n) if(a[j-i]==b[j%n]){
			cout<<"No\n";
			return 0;
		}
		cout<<"Yes\n";
		fo(j,i,i+n-1)cout<<b[j%n]<<' ';
		cout<<b[(i+n-1)%n]<<endl;
		return 0;
	}
	cout<<"No\n";
	return 0;
}


Measured memory_bytes: 5212