akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int kansu(int i){
    if(i==25964)
    return 0;
    else return i;
}
struct Card{
  char suit;
  char value;
};

void bubble(struct Card A[], int n){
  int i, j;
  struct Card t;
  for ( i = 0; i < n; i++ ){
    for ( j = n-1; j >= i+1; j-- ){
      if ( A[j].value < A[j-1].value ){
	t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(struct Card A[], int n){
  int i, j, mini;
  struct Card t;
  for ( i = 0; i < n; i++ ){
    mini = i;
    for ( j = i; j < n; j++ ){
      if ( A[j].value < A[mini].value ) mini = j;
    }
    t = A[i]; A[i] = A[mini]; A[mini] = t;
  }
}

void print(struct Card A[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( i ) printf(" ");
    printf("%c%c", A[i].suit, A[i].value);
  }
  printf("\n");
}

int isStable(struct Card C1[], struct 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(){
  struct Card C1[101], C2[101];
  int n, i;
  char ch;

  scanf("%d\n", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%c%c ", &C1[i].suit, &C1[i].value);
  }

  for ( i = 0; i < n; i++ ) C2[i] = C1[i];

  bubble(C1, n);
  selection(C2, n);

  print(C1, n);
  printf("Stable\n");
  print(C2, n);
  if ( isStable(C1, C2, n) ){
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}


Measured memory_bytes: 2052
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
    int h, w, N;
    cin >> h >> w >> N;
    int mx = max(h, w);

    cout << (N + mx - 1) / mx << endl;
    return 0;
}


Measured memory_bytes: 256
/*
Original problem: https://atcoder.jp/contests/dp/tasks/dp_y
Author: sammochen
*/

#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define REP(x, l, u) for (ll x = l; x < u; x++)
#define RREP(x, l, u) for (ll x = l; x >= u; x--)

#define PII pair<int, int>
#define PLL pair<ll, ll>

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef vector<ll> VLL;
typedef vector<int> VI;

const ll mod = 1e9 + 7;
namespace SOLVE {
	struct block {
		ll i, j, odd, even;
		block(ll a, ll b) {
			i = a, j = b;
		}
	};

	struct sortblock {
		bool operator()(block a, block b) {
			if (a.i == b.i) {
				return a.j < b.j;
			}
			return a.i < b.i;
		}
	};

	VLL F(200010);
	vector < block > blocks;

	void initF() {
		F[0] = 1;
		REP(i,1,F.size()) {
			F[i] = F[i-1] * i % mod;
		}
	}

	// recursive, log(b) time
	ll pow(ll a, ll b) {
		if (b == 0) {
			return 1;
		}
		ll half = pow(a, b / 2);
		ll ans = half * half % mod;
		ans = b % 2 == 1 ? ans * a % mod : ans;
		return ans;
	}

	ll inverse(ll a) {
		return pow(a, mod - 2);
	}

	// n! / (n - r)! * r!
	ll ncr(ll n, ll r) {
		ll top = F[n];
		ll bot = F[n-r] * F[r] % mod;
		return top * inverse(bot) % mod;
	}

	ll paths(ll a, ll b) {
		return ncr(a + b, a);
	}

	void parity(int ind) {
		blocks[ind].even = 0;
		blocks[ind].odd = 0;
		// for every other block
		REP(i,0,ind) {
			block b = blocks[i];
			ll di = blocks[ind].i - b.i;
			ll dj = blocks[ind].j - b.j;
			if (di >= 0 && dj >= 0) {
				ll p = paths(di, dj);
				blocks[ind].even += p * b.odd;
				blocks[ind].even %= mod;

				blocks[ind].odd += p * b.even;
				blocks[ind].odd %= mod;
			}
		}
	}

	void main() {
		int H, W, N, a, b;
		cin >> H >> W >> N;
		initF();
		// final answer is combination to the final point - odd parity + even parity
		// i will work out all the odd/even parities of each block using dp

		// i will 'pretend' there is a block at 1,1 and H,W
		blocks.push_back(block(1,1));
		blocks[0].even = 1;
		blocks[0].odd = 0;

		blocks.push_back(block(H,W));

		REP(i, 0, N) {
			cin >> a >> b;
			blocks.push_back(block(a, b));
		}

		// the blocks are in an order such that if i work with a block, all blocks smaller are considered
		sort(blocks.begin(), blocks.end(), sortblock());

		REP(i, 1, blocks.size()) {
			// work out its odd/even parities
			parity(i);
		}

		ll o = blocks[blocks.size() - 1].odd;
		ll e = blocks[blocks.size() - 1].even;
		ll ans = (o - e + mod) % mod;
		cout << ans << endl;
	}
} // namespace SOLVE

signed main() {
	int t;
	t = 1;
	// cin >> t;
	while (t--) {
		SOLVE::main();
	}

	return 0;
}

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

#define P(s) cout<<(s)<<"\n"
#define R(v) v.begin(),v.end()

int main() {
    int32_t n, x;
    cin >> n >> x;

    int32_t mi = 10000;
    for (auto i = 0; i < n; ++i) {
        int32_t m;
        cin >> m;
        x -= m;
        mi = min(mi, m);
    }
    
    P(n + x / mi);
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>
using namespace std;

//#include<bits/stdc++.h>

int main() {
	
	int n;
	cin >> n;
	int d = 0, z = 0;
	vector<string>a, b,c;
	for (int i = 0; i < n; i++) {
		string x;
		cin >> x;
		a.push_back(x);
	
	}
	string t;
	cin >> t;
	for (int i = 0; i < n; i++) {
		string x = a[i];
		string h = x, w = x;
		for (int j = 0; j < x.size(); j++) {
			if (x[j] == '?') {
				//		cout << "#";
				h[j] = 'a';
				w[j] = 'z';
			}
		}
		//	cout << w << endl;
		if (h <= t)d++;
		if (w >= t)z++;
	
	}
	bool f = 1;
	
	for (int i =n- z; i <= d; i++) {
		if (f)cout << i + 1;
		else cout << " "<<i+1 ;
		f = 0;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 896
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 1000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  string s; cin >> s;
  REP(i, 3){
    if(s[i] == s[i+1]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int, input().split()))
B=[A[i]-i-1 for i in range(N)]
B.sort()
if N%2==1:
  print(sum([abs(B[i]-B[N//2]) for i in range(N)]))
else:
  temp=(B[N//2-1]+B[N//2])//2
  ms=[temp+i for i in range(-2, 3, 1)]
  temp=[sum([abs(B[i]-ms[j]) for i in range(N)]) for j in range(5)]
  print(min(temp))

Measured memory_bytes: 27844
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define N 1000005
using namespace std;

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

int n, a[N];
multiset < int > s;

int main() {
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    scanf("%d",&n);
    for(int i = 1; i <= n; i++){
      scanf("%d",a + i);
      s.insert(a[i]);
    }

    for(int i = 1; i <= n; i++){
      s.erase(s.find(a[i]));

      printf("%d\n", *s.rbegin());

      s.insert(a[i]);
    }
    return 0;
}


Measured memory_bytes: 11776
#include<bits/stdc++.h>
using namespace std;
const int N =2e5,OO=0x3f3f3f3f;
int n,l;
vector<string>v;

int main()
{
    cin>>n>>l;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        v.push_back(s);
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++)cout<<v[i];
    cout<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

n, m = map(int, input().split())
A = [input() for _ in range(n)]
B = [input() for _ in range(m)]
for i in range(n-m+1):
    for j in range(n-m+1):
        include = True
        for k in range(m):
            for l in range(m):
                if A[i+k][j+l] != B[k][l]:
                    include = False
        if include:
            print('Yes')
            exit()
print('No')


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

using namespace std;

const long long MN = -1e17;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    map<pair<int, int>, long long> mem;
    function<long long(int, int)> dp;
    dp = [&] (int i, int need) {
        int mx = (i+2)/2;
        if (need < 0 || need > mx) {
            return MN;
        }
        pair<int, int> pr(i, need);
        if (mem.count(pr) == 0) {
            mem[pr] = i < 0
                ? 0
                : max(dp(i-1, need), dp(i-2, need-1) + a[i]);
        }
        return mem[pr];
    };
    cout << dp(n-1, n/2) << endl;
}



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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    string X;
    cin >> X;
    int s = 0, del = 0;
    rep(i, X.size()) {
        if (X[i] == 'S') s++;
        else if (X[i] == 'T') {
            if (s > 0) {
                s--;
                del += 2;
            }
        }
    }
    cout << X.size() - del << endl;
}


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

using namespace std;

int main()
{   string s;
    int i ;
    string news="";
    cin>>s;
    for (i=0;i<19;i++){
        if (s[i]== ','){
            s[i]=' ';
            news=news+s[i];}
        else{
            news=news+s[i];
        }}
        cout<<news;


    return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        var N = long.Parse(Console.ReadLine());

        var result = Calc26Base(N);

        var sb = new StringBuilder();
        foreach (var item in result)
        {
            char chr = (char)(item + 'a');
            sb.Append(chr);
        }

        Console.WriteLine(sb.ToString());
    }

    private static List<long> Calc26Base(long n)
    {
        var result = new List<long>();
        while (n != 0)
        {
            n--;
            result.Add(n % 26);
            n = n / 26;
        }

        result.Reverse();
        return result;
    }
}


Measured memory_bytes: 27780
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<int> v(N);
  int max1=0,max2=0;
  rep(i,N){
    cin >> v[i];
    if(v[i]>max1){
      swap(max1,max2);
      max1 = v[i];
    }else if(v[i] > max2) max2 = v[i];
  }
  rep(i,N){
    if(v[i] == max1) cout << max2 << endl;
    else cout << max1 << endl;
  }
  return 0;
}


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

typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;

using Graph = vector<vector<int> >;

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}

int N,Q;
const int MAXN = 200000;
const int MAXQ = 200000;
int counter[MAXN+1] = {0};
bool checker[MAXN+1] = {false};


void search(Graph &G, int current_node, int value) {
    for(int nxt : G[current_node]) {
        if(!checker[nxt]){
            checker[nxt] = true;
            counter[nxt] += value;
            search(G,nxt,counter[nxt]);
        }
    }
}



int main() {
    cin >> N >> Q;
    Graph G(N+1);
    rep(i,N-1){
        int a,b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i,Q){
        int p,x;
        cin >> p >> x;
        counter[p] += x;
    }
    checker[1] = true;
    search(G, 1, counter[1]);
    Rep(i,N)cout << counter[i] << " ";
    cout << endl;



    return 0;
}

Measured memory_bytes: 27520
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e3+10;
int n,m;
int A[maxn];
vector<pair<int,int>> C;
int main()
{
    cin>>n;
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        cin>>A[i];
        if(A[i]!=i)
        {
            cnt++;
            C.push_back({i,A[i]});
        }
    }
    if(cnt==2)
    {
        if(C[0].first==C[1].second&&C[0].second==C[1].first)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    else if(cnt==0)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char a[220];
int main(){
	scanf("%s",a);
	int s=strlen(a),head,end,sum,i,ans=0,j,mid;
	mid=s/2-1;
	for(i=0;;){
		if(mid==0)
			break;
		if(a[i]==a[mid]){
			head=i,end=mid;
			while(a[head]==a[end]&&head<mid){
				head++;end++;
			}
			if(head==mid){
				printf("%d\n",mid*2);
				return 0;
			}
			else
				mid--;
		}
		else
			mid--;	
	}
	printf("-1\n");
	return 0;
}

Measured memory_bytes: 128
s = input()
s = [int(i) for i in s]
k = int(input())
if max(s) == 1:
	print(1)
	exit()
c = 0
for i in s:
	if i == 1: c += 1
	else: break
if k <= c:
	print(1)
else:
	for i in s:
		if i > 1:
			print(i)
			exit()

Measured memory_bytes: 3064
N, M = map(int, input().split())
Ai = [list(map(int, input().split())) for _ in range(M)]
 
groups = [-1 for i in range(N + 1)] #0番目は使わない
sizes = [1 for _ in range(N + 1)]
Ai.reverse()
 
value = N * (N - 1) // 2
answers = []
answers.append(value)
 
def parent(n):
    if groups[n] < 0:
        return n
    return parent(groups[n])
 
for a in Ai:
    if value <= 0:
        answers.append(0)
        continue
    p1 = parent(a[0])
    p2 = parent(a[1])
    if p1 == p2:
        answers.append(value)
        continue
 
    value -= sizes[p1] * sizes[p2]
    if p1 > p2:
        sizes[p2] += sizes[p1]
        groups[p1] = p2
    else:
        sizes[p1] += sizes[p2]
        groups[p2] = p1
    answers.append(value)
 
answers.reverse()
answers = answers[1:]
for a in answers:
    print(a)

Measured memory_bytes: 34220
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL<<60LL)
typedef long long ll;

using namespace std;

int main() {
	vector<ll> v(3);
	rep(i, 3) cin >> v[i];
	sort(all(v));
	if (v[0] + v[1] == v[2]) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000000
#define MAX 200001
#define MOD 1000000007

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

vector<long long> fact, fact_inv, inv;

void init_nCk(int SIZE) {
    fact.resize(SIZE + 5);
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        fact[i] = fact[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
}
 
/*  nCk :MODでの二項係数を求める(前処理 int_nCk が必要)
    計算量:O(1)
*/
long long nCk(int n, int k) {
    return fact[n] * (fact_inv[k] * fact_inv[n - k] % MOD) % MOD;
}

int main(){
    init_nCk(1000000);
    int N;cin >> N;
    int c = 0;
    vector<int> A(N, -1);
    for(int i = 0; i < N+1; i++){
        int a;cin >> a;
        a--;
        if(A[a] != -1) c += A[a] + N - i;
        else A[a] = i;
    }
    for(int i = 1; i <= N+1; i++){
        if(i == 1) cout << N << endl;
        else{
            int r = i-1;
            if(c < r){
                cout << nCk(N+1, i) << endl;
            }
            else{
                int ans = nCk(N+1, i) - nCk(c, r);
                if(ans < 0) ans += MOD;
                ans %= MOD;
                cout << ans << endl;
            }
        }
    }
}


Measured memory_bytes: 26968
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
map<ll,ll>mp;
ll ar[3][3];
int main()
{
    long long int a,b,j,c,m,sum,i;
    for(i=1; i<=3; i++)
    {
        for(j=1; j<=3; j++)
            cin>>ar[i][j];
    }

    cin>>a;
    for(i=1; i<=a; i++)
    {
        cin>>b;
        mp[b]=1;
    }
    if(mp[ar[1][1]]*mp[ar[1][2]]*mp[ar[1][3]]==1||mp[ar[2][1]]*mp[ar[2][2]]*mp[ar[2][3]]==1||mp[ar[3][1]]*mp[ar[3][2]]*mp[ar[3][3]]==1)
        cout<<"Yes"<<endl;
    else if(mp[ar[1][1]]*mp[ar[2][1]]*mp[ar[3][1]]==1||mp[ar[1][2]]*mp[ar[2][2]]*mp[ar[3][2]]==1||mp[ar[1][3]]*mp[ar[2][3]]*mp[ar[3][3]]==1)
        cout<<"Yes"<<endl;
    else if(mp[ar[1][1]]*mp[ar[2][2]]*mp[ar[3][3]]==1)
        cout<<"Yes"<<endl;
        else if(mp[ar[3][1]]*mp[ar[2][2]]*mp[ar[1][3]]==1)
        cout<<"Yes"<<endl;
        
    else
        cout<<"No"<<endl;





}


Measured memory_bytes: 256
package main
import (
	"fmt"
)

type Dice struct{
	/*
	こういう感じ
  		 ___
	____|_1_|_______
	|_4_|_2_|_3_|_5_|
		|_6_|
	*/
	Surface []int
}

func (d *Dice)Move(dir string, n int){
	n%=4
	switch dir{
	case "W":
		for i:=0; i<n; i++{
			d.Surface[0], d.Surface[2], d.Surface[5], d.Surface[3] = d.Surface[2], d.Surface[5], d.Surface[3], d.Surface[0]
		}
	case "E":
		for i:=0; i<n; i++{
			d.Surface[0], d.Surface[2], d.Surface[5], d.Surface[3] = d.Surface[3], d.Surface[0], d.Surface[2], d.Surface[5]
		}
	case "N":
		for i:=0; i<n; i++{
			d.Surface[0], d.Surface[4], d.Surface[5], d.Surface[1] = d.Surface[1], d.Surface[0],d.Surface[4], d.Surface[5]
		}
	case "S":
		for i:=0; i<n; i++{
			d.Surface[5], d.Surface[1], d.Surface[0], d.Surface[4] = d.Surface[1], d.Surface[0],d.Surface[4], d.Surface[5]	
		}
	}
}

func (d *Dice)Roll(dir string, n int){
	n%=4	// べつにいらんけど一周したら元にもどるので
	switch dir{
	case "R":
		for i:=0; i<n; i++{
			d.Surface[3], d.Surface[1], d.Surface[2], d.Surface[4] = d.Surface[1], d.Surface[2], d.Surface[4], d.Surface[3]
		}	
	case "L":
		for i:=0; i<n; i++{
			d.Surface[3], d.Surface[1], d.Surface[2], d.Surface[4] = d.Surface[4], d.Surface[3], d.Surface[1], d.Surface[2]
		}
	}
}

func (d *Dice)GetStatus(){
	doc := `              ____
 	 ____|_%02d_|_________
	|_%02d_|_%02d_|_%02d_|_%02d_|
	     |_%02d_|`
	fmt.Printf(doc, d.Surface[0], d.Surface[3], d.Surface[1], d.Surface[2], d.Surface[4], d.Surface[5])
	fmt.Println()
}

func (d *Dice)IsEqual(other_d Dice)(ret bool){
	if len(d.Surface) != len(other_d.Surface){
		return false
	}
	for i, v := range d.Surface{
		if v!=other_d.Surface[i]{
			return false
		}
	}
	return true
}

func main(){
	var n int
	fmt.Scan(&n)

	Dices := make([]Dice, n)
	for i:=0; i<n; i++{
		d := Dice{}
		for x:=0; x<6; x++{
			var f int
			fmt.Scan(&f)
			d.Surface = append(d.Surface, f)
		}
		Dices[i] = d
	}

	roll_order := []string{"R", "L"}
	direction_order := []string{"N", "W", "E", "S"}
	ans := true

	CHECK:
		for x:=0; x<n; x++{
			x_d := Dice{}
			x_d.Surface = append([]int{}, Dices[x].Surface...)
			for y:=x+1; y<n; y++{
				for i:=0; i<=2; i++{
					for j:=0; j<=2; j++{
						for _, d := range direction_order{
							for _, r := range roll_order{
								y_d := Dice{}
								y_d.Surface = append([]int{}, Dices[y].Surface...)
								y_d.Move(d, i)
								y_d.Roll(r, j)
								if y_d.IsEqual(x_d){
									ans = false
									break CHECK
								}
							}
						}
					}
				}
		
			}
		}
	if ans{
		fmt.Println("Yes")
	}else{
		fmt.Println("No")
	}
}

func getIndex(ns []int, key int)(id int){
	for idx, v := range ns{
		if v==key{
			id = idx
			break
		}
	}
	return
}


Measured memory_bytes: 6020
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;


struct UnionFind {
    vector<int> par; 

    UnionFind(int N) : par(N) { 
        for(int i = 0; i < N; i++) par[i] = i;
    }

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

    void unite(int x, int y) { 
        int rx = root(x); 
        int ry = root(y); 
        if (rx == ry) return; 
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    map<int,int> unions(int n) {
      map<int,int> mp;
      rep(i,n){
        int p = root(i);
        mp[p]+=1;
      }
      return mp;
    }
};



int main() {
  int n,m,k;
  cin  >> n >> m >> k;
  UnionFind tree(n);
  vector<vi> G(n);
  vector<vi> B(n);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;b--;
    tree.unite(a, b);
    G[a].push_back(b);
    G[b].push_back(a);
  }

  UnionFind btree(n);
  rep(i,k){
    int c,d;
    cin >> c >> d;
    c--;d--;
    B[c].push_back(d);
    B[d].push_back(c);
  }

  auto u1 = tree.unions(n);
  rep(i,n){
    int ans = u1[tree.root(i)]-sz(G[i]) -1 ;
    for(auto u: B[i])if(u != i) ans -=tree.same(i,u);
    cout << ans <<" ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 13184
import sys
input = sys.stdin.readline
import math


def read():
    X, K, D = map(int, input().strip().split())
    return X, K, D


def solve(X, K, D):
    m = (-X + K*D) / (2*D)
    mc = min(max(0, math.ceil(m)), K)
    mf = min(max(0, math.floor(m)), K)
    ans = min(abs(X - K*D + 2 * mc * D), abs(X - K*D + 2 * mf * D))
    return ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 9184
#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <ctime>
#include <iterator>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;


int main()
{
    int n;
    while(cin>>n)
    {
        int res = 0;
        for(int c=0;c<=9;c++)
        {
            for(int c2=0;c2<=9;c2++)
            {
                for(int c3=0;c3<=9;c3++)
                {
                    int c4 = n - c3 -c2 - c;
                    if(c4 >= 0 && c4 <= 9)
                        res++;
                }
            }
        }
        cout<<res<<endl;
    }
}

Measured memory_bytes: 1160
def main():
    n, c = map(int, input().split())
    xv = [list(map(int, input().split())) for _ in range(n)]
    v, left_max, right_max = 0, 0, 0
    gl = [None]*n
    gr = [None]*n
    _2oas = [None]*(n+1)
    _2obs = [None]*(n+1)
    _2oas[0], _2obs[0] = 0, 0
    ans = 0
    for i, (xi, vi) in enumerate(xv, 1):
        v += vi
        left = v - xi
        if left_max < left:
            left_max = left
        gl[n-i] = left_max
        _2oas[i] = v - 2*xi
    v = 0
    for i, (xi, vi) in enumerate(xv[::-1], 1):
        v += vi
        right = v - c + xi
        if right_max < right:
            right_max = right
        gr[n-i] = right_max
        _2obs[i] = v - 2*(c - xi)
    for oa, _2ob, ob, _2oa in zip(gl, _2obs[:n], gr, _2oas[:n]):
        ans = max(ans, _2oa+ob, _2ob+oa)
    print(ans)
        
if __name__ == "__main__":
    main()

Measured memory_bytes: 44772
#include<iostream>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
#define pb push_back
 const ll mod = 1000000007;

int main() {
	int n;
	cin >> n;
	int p0, p1, p2;

	cin >> p1 >> p2;
	int count = 0;

	for (int i = 2; i < n; i++) {
		p0 = p1;
		p1 = p2;
		cin >> p2;

		if (min({ p0, p1, p2 }) != p1 && max({ p0, p1, p2 }) != p1) {
			count++;
		}
	}
	cout << count << endl;

	return 0;
}

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

int dx[]={1,-1,0,0};
int dy[]={0,0,-1,1};

li n=1000001;
    
void bfs(string a[],li h,li w,li x1,li y1,li k,li x2,li y2)
{
    int vis[h][w];
    li dis[h][w];
    for(li i=0;i<h;i++)
    {
        for(li j=0;j<w;j++)
        vis[i][j]=0,dis[i][j]=0;
    }
   // cout<<x1<<" "<<y2;
    vis[x1][y1]=1;
    dis[x1][y1]=0;
    queue<pair<li,li>>q;
    q.push({x1,y1});
    while(q.size())
    {
        pair<li,li>p=q.front();
        q.pop();
        for(li i=0;i<4;i++)
        {
            for(li j=1;j<=k;j++)
            {
                li nx=p.first+dx[i]*j;
                li ny=p.second+dy[i]*j;
                if(nx<0 || ny<0 || nx>=h || ny>=w)
                {
                    break;
                }
                if(a[nx][ny]=='@')
                break;
                if(vis[nx][ny] && dis[p.first][p.second]+1>dis[nx][ny])
                break;
                dis[nx][ny]=1+dis[p.first][p.second];
                if(!vis[nx][ny])
                q.push({nx,ny});
                vis[nx][ny]=1;
                
                
            }
        }
        
    }
    if(vis[x2][y2]==0)
    cout<<-1;
    else
    cout<<dis[x2][y2];
}
int main()
{
    li h,w,k;
    cin>>h>>w>>k;
    li x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    x1--,y1--,x2--,y2--;
    string a[h];
    for(li i=0;i<h;i++)
    {
        cin>>a[i];
    }
    
    
  
    bfs(a,h,w,x1,y1,k,x2,y2);
    
}

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find algo with array
// Find()
int findpar(int curr, int arr[])
{
  while(arr[curr] != curr) curr = arr[curr];
  return curr;
}
// Union()
void Union(int b, int spa, int arr[])
{
  while(arr[b] != b)
  {
    int c = arr[b];
    arr[b] = spa;
    b = c;
  }
  arr[b] = spa;
}

// Main Code


int main()
{
  ll x;
  cin>>x;
  ll aa = x / 11;
  ll bb = x % 11;
  aa = aa*2;
  if(bb != 0)
  {
    bb = bb - 6;
    if(bb <= 0)   cout<<aa+1<<endl;
    else cout<<aa+2<<endl;
    return 0;
  }
  cout<<aa<<endl;
  return 0;
}


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

#define ll long long
#define ld long double
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll q,h,s,d;
    cin >> q >> h >> s >> d;
    h = min(h,q*2);
    s = min(min(s,q*4),h*2);
    d = min(min(d,s*2),min(q*8,h*4));
    ll answ = 0;
    ll n;
    cin >> n;
    answ = d*(n / 2);
    if (n % 2 != 0){
        answ += s;
    }
    cout << answ << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  int N; cin>>N;
  vector<int> lines(N);
  int sum = 0;
  for(int i=0; i<N; i++) {
    int l; cin>>l;
    lines[i] = l;
    sum += l;
  }
  sort(lines.begin(), lines.end());
  int max_l = lines[N-1];
  sum -= max_l;

  string ans = "No";
  if(max_l < sum) ans = "Yes";
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long ,long long> ii; 	
//typedef complex<long double> com;
 
const ll mod = 1e9+7;
 
void setIO(string name) {
    ios_base::sync_with_stdio(0); cin.tie(0);
    freopen((name+".in").c_str(),"r",stdin);
    freopen((name+".out").c_str(),"w",stdout);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >> s;
	char first = s[0];
	bool ok = true;
	for (int z=1;z<3 && ok;z++){
		if (s[z] != first) ok = false;
	}
	if (ok) cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define x             first
#define y             second
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define PI            3.14159265358979
#define N             200005

int solve(){
    int a,b; cin>>a>>b;
    cout<<a*b;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <cassert>
#include <cstdio>
using namespace std;
#define MAX 41
#define TEST 0

typedef long long int ll;

int n;
map<string,int> names;
int b[MAX],c[MAX];
string ds[MAX][MAX];
int graph[MAX][MAX];


int rmax;
ll rmaxs;
void rec(ll bits,int sum){//gradually elim-ing vertices
    if(TEST)
        printf("bits=%llx,sum=%d\n",bits,sum);
    if(sum<=rmax){
        return;
    }
    if((bits&1)==0){//vertex 0 is not in the set
        return;
    }
    int mini=90000;
    int minv=-1;
    for(int i=0;i<n;i++){
        if((bits&(1LL<<i))==0){
            continue;
        }
        int ind=b[i];
        for(int j=0;j<n;j++){
            if((bits&(1LL<<j))==0||i==j){
                continue;
            }
            if(graph[i][j]){
                ind+=b[j];
            }
        }
        if(ind<mini){
            mini=ind;
            minv=i;
        }
    }
    if(mini==sum){//clique
        rmax=sum;
        rmaxs=bits;
        return;
    }
    //minv:minimum
    ll set=1LL<<minv;
    int w=b[minv];
    for(int i=0;i<n;i++){
        if((bits&(1LL<<i))&&graph[minv][i]){
            set|=1LL<<i;
            w+=b[i];
        }
    }
    if(TEST)
    printf("minv=%d,set=%llx,w=%d\n",minv,set,w);
    rec(set,w);
    rec(bits&~(1LL<<minv),sum-b[minv]);
    return;
}


int main(void){
    while(cin>>n&&n){
        names.clear();
        int sum=0;
        for(int i=0;i<n;i++){
            fill_n(graph[i],n,1);
        }
        for(int i=0;i<n;i++){
            string a;
            cin>>a>>b[i]>>c[i];
            names.insert(pair<string,int>(a,i));
            for(int j=0;j<c[i];j++){
                string t;
                cin>>t;
                ds[i][j]=t;
            }
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<c[i];j++){
                int d=names[ds[i][j]];
                graph[i][d]=0;
            }
            graph[i][i]=0;
        }
        ll bits=1;
        sum=b[0];
        for(int i=1;i<n;i++){
            if(graph[0][i]){
                bits|=1LL<<i;
                sum+=b[i];
            }
        }
        rmax=0;
        rmaxs=0;
        rec(bits,sum);
        cout<<rmax<<endl;
        if(TEST){
            cout<<"rmaxs"<<hex<<rmaxs<<dec<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1344
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;

const int maxn = 2005;
vector<int>g[maxn],dis(maxn);
int n;
void spfa(int s){
	fill(dis.begin(),dis.end(),1e6);
	vector<int>inq(n+1);
	queue<int>q;
	dis[s]=0;
	q.push(s);
	inq[s]=1;
	while( q.size() ){
		int u = q.front(); q.pop(); inq[u]=0;
		for(auto v:g[u]){
			if( dis[v] > dis[u] + 1 ){
				dis[v] = dis[u] + 1;
				if( !inq[v] ){
					inq[v] = 1;
					q.push(v);
				}
			}
		}
	}
}
int32_t main(){
	IOS
	int x,y;cin>>n>>x>>y;
	for(int i=1;i<n;i++){
		g[i].push_back(i+1);
		g[i+1].push_back(i);
	}
	g[x].push_back(y);
	g[y].push_back(x);
	
	vector<int>ans(n+1);
	for(int i=1;i<=n;i++){
		spfa(i);
		for(int j=1;j<=n;j++){
			ans[ dis[j] ]++;
			//bug3(i,j,dis[j]);
		}
	}
	for(int i=1;i<n;i++){
		cout << ans[i] /2 <<" ";
	}
	cout<< endl;
	

}
/*
 * long long or int?
 * index out of bound? 
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


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

using namespace std;
#define ll long long int
#define f(i,n) for(auto i=0;i<n;i++)
#define fs(i,a,b,c) for(auto i=a;i!=b;i+=c)
#define fl(i,x) for(auto i : x)
#define nl cout<<"\n";
#define vi vector<int>
#define pb push_back
#define pr pair<ll, ll>

class triplet{
    ll f,s,t;
};

int main(){
    ll N;
    cin>>N;
    string S,T;
    vector<char> v;
    cin>>S>>T;
    f(i,N)
    v.pb(S.at(i)), v.pb(T.at(i));

    fl(i, v)
    cout<<i;
}

Measured memory_bytes: 3636
#include <vector>
#include <iostream>

using namespace std;

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

	if (a > b) { return gcd(b, a % b); }

	return gcd(a, b % a);
}

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

vector<int> G; // i --> G[i] Graph

vector<bool> visited;

vector<vector<int> > cycles;

void rec(int p)
{
	visited[p] = true;

	cycles.back().push_back(p);

	if (!visited[G[p]])
	{
		rec(G[p]);
	}
}

int extgcd(int a, int b, int &x, int &y)
{
	int d = a;

	if (b != 0)
	{
		d = extgcd(b, a % b, y, x);

		y -= (a / b) * x;
	}
	else
	{
		x = 1; y = 0;
	}

	return d;
}

int modinv(int a)
{
	int x, y;

	extgcd(a, 1000000007, x, y);

	return (1000000007 + x % 1000000007) % 1000000007;
}

int main()
{
	int V, Q;

	scanf("%d", &V);
	scanf("%d", &Q);

	G = vector<int>(V);

	for (int i = 0; i < V; i++)
	{
		scanf("%d", &G[i]); G[i]--; // 1 -> 0 indexed
	}

	visited = vector<bool>(V, false);

	for (int i = 0; i < V; i++)
	{
		if (!visited[i])
		{
			cycles.push_back(vector<int>());

			rec(i);
		}
	}

	vector<int> val(V, 0), num(V, 0);

	for (int i = 0; i < cycles.size(); i++)
	{
		int sum = 0;

		for (int j = 0; j < cycles[i].size(); j++)
		{
			sum += cycles[i][j] + 1;
		}

		for (int j = 0; j < cycles[i].size(); j++)
		{
			val[cycles[i][j]] = sum;

			num[cycles[i][j]] = cycles[i].size();
		}
	}

	vector<vector<int> > sum(V, vector<int>(41));

	sum[0][num[0]] = 1;

	for (int i = 1; i < V; i++)
	{
		sum[i][num[i]] = 1;

		for (int j = 2; j <= 40; j++)
		{
			sum[i][j] += sum[i - 1][j];
		}
	}

	vector<int> sum2(V);

	sum2[0] = (1LL * modinv(num[0]) * val[0]) % 1000000007;

	for (int i = 1; i < V; i++)
	{
		sum2[i] = (sum2[i - 1] + 1LL * modinv(num[i]) * val[i]) % 1000000007;
	}

	int l, r;

	for (int i = 0; i < Q; i++)
	{
		scanf("%d", &l); l--; // 1 -> 0 indexed
		scanf("%d", &r); r--;

		long long rep = 1; int c;

		for (int i = 2; i <= 40; i++)
		{
			c = sum[r][i];

			if (l != 0)
			{
				c -= sum[l - 1][i];
			}

			if (c != 0)
			{
				rep = lcm(rep, i);
			}
		}

		int ret = sum2[r] + 1000000007;

		if (l != 0)
		{
			ret -= sum2[l - 1];
		}

		ret %= 1000000007;

		ret = 1LL * rep % 1000000007 * ret % 1000000007;

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

	return 0;
}

Measured memory_bytes: 24732
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<29;

int main(){
  char C; cin >> C;
  C++;
  cout << C << endl;
}


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

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i,n)  for(ll i=0; i<n; i++)
#define loop1(i,n)  for(ll i=1; i<=n; i++)

#define all(a)      (a).begin(),(a).end()
#define exist(s,e)  (s.find(e)!=s.end())
#define dbg(x)  cout << #x << " = " << x << endl
#define pt(x) cout<<x<<"\n"
#define pts(x) cout<<x<<" "

#define mp make_pair
#define pb push_back
#define F first
#define S second


#define inf (int)1e9
#define infll 1e18
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007


#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test   int t; cin>>t; while(t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll,ll> mll;
typedef set<ll> sl;


int dirx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int diry[] = { -1, 0, 1, -1, 1, -1, 0, 1 };



//===========================DEBUG======================//
#define XOX 1
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

//================================================================//



//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt=1e5+5;


int main(){
 //    #ifndef ONLINE_JUDGE
 //    freopen("../../input.txt", "r", stdin);
 //    freopen("../../output.txt", "w", stdout);
	// #endif
    fast

    ll n; cin>>n;
    string s; cin>>s;
    ll r=0,g=0,b=0;
    loop(i,n){
    	if(s[i]=='R')r++;
    	else if(s[i]=='G')g++;
    	else b++;
    }
    ll ans=r*g*b;
    // debug(ans);
    loop(i,n){
    	int j,k;
    	for(j=i-1,k=i+1; j>=0 && k<n; j--,k++){
    		if(s[i]!=s[j] && s[i]!=s[k] && s[j]!=s[k])ans--;
    	}
    }
    pt(ans);
}


/*



*/





Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;
using P = pair<Int, Int>;

int main() {
	Int N, M;
	cin >> N >> M;
	vector<Int> A(N), B(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i] >> B[i];
	}

	priority_queue<P> que;
	for (int i = 0; i < N; ++i) {
		que.emplace(M - A[i], B[i]);
	}
	priority_queue<Int> que2;
	Int ans = 0;
	for (Int day = M; day >= 0; --day) {
		while (!que.empty() && que.top().first >= day) {
			que2.push(que.top().second);
			que.pop();
		}
		if (!que2.empty()) {
			ans += que2.top();
			que2.pop();
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 5232
#include <bits/stdc++.h> 
using namespace std;
#define ll long long
#define db double
const int N=1e6,P=998244353;

#define C getchar()-48
ll read()
{
  ll s=0,t=1,k=C;
  for (;k<0||9<k;k=C) if (k==-3) t=-1;
  for (;0<=k&&k<=9;k=C) s=(s<<1)+(s<<3)+k;
  return s*t;
}

  struct rec
    {
      ll v;
      db t;
    }s[N];
  ll sum,l=1,r,prod,i,de;

  ll n,L;
	ll t[N],v[N];
void in()
{
  cin>>n>>L;
  for (int i=0;++i<=n;)
	  t[i]=read(),v[i]=read();
}

void sol()
{
  for (int i=0;++i<=n;)
    {
        while (sum+v[i]>L)
        {
            de=min(s[l].v,sum+v[i]-L);
            s[l].v-=de;
            sum-=de;
            prod-=de*s[l].t;
            if (!s[l].v) l++;
        }
        s[++r]={v[i],t[i]};
        prod+=v[i]*t[i];
        sum+=v[i];
        while (l<r&&s[r].t<s[r-1].t)
        {
            s[r-1].t=(s[r-1].t*s[r-1].v+s[r].t*s[r].v)/(s[r-1].v+s[r].v);
            s[r-1].v+=s[r].v;
            r--;
        }
        printf("%lf\n",(db)prod/L);
    }
}

int main()
{
  in();
	sol(); 
  exit(0);
}

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



int main(){
    int N;
    cin >> N;
    if(N <= 111){
        cout << "111" << endl;
    }
    else if(N > 111 && N <= 222){
        cout << "222" << endl;
    }
    else if(N > 222 && N <= 333){
        cout << "333" << endl;
    }
    else if(N > 333 && N <= 444){
        cout << "444" << endl;
    }
    else if(N > 444 && N <= 555){
        cout << "555" << endl;
    }
    else if(N > 555 && N <= 666){
        cout << "666" << endl;
    }
    else if(N > 666 && N <= 777){
        cout << "777" << endl;
    }
    else if(N > 777 && N <= 888){
        cout << "888" << endl;
    }
    else if(N > 888 && N <= 999){
        cout << "999" << endl;
    }
    
}

Measured memory_bytes: 256