akhauriyash/Code-Regression huggingface dataset:
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,b,n) for(int i=b;i<n;i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int K;
int main(){
	while(cin>>K,K){
		if(K==0)break;
		int sum =0;
		int x;
		for(int i =0;2*i <K*(K-1);i++){
			cin>>x;
			sum +=x;
		}
		//cout <<sum<<endl;
		cout <<sum/(K-1)<<endl;
	}
	return 0;
}

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

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> isPair;
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
#define Pll pair<ll,ll>
#define vpll vector<pll>
#define sll set<ll>
#define mll map<ll,ll>

const ll inf=1e18;
const ll maxs = 100005;
const ll mod = 1e9+7;

#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define LB lower_bound
#define UB upper_bound
#define line cout<<endl;
#define fr(i,a,b) for(int i=a;i<=b;++i)
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fastio(); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mst(x,a) memset(x,a,sizeof(x))

ll n;
ll a[maxs];
isPair dp[3003][3003];

void solve()
{
    for(ll i=0;i<n;i++)
        dp[i][i] = mp(a[i],0);
    
    for(ll j=1;j<n;j++)
    {
        ll k = j;
        for(ll i=0;i<n-j;i++)
        {
            dp[i][k].ff = max( a[i] + dp[i+1][k].ss , a[k] + dp[i][k-1].ss );
            if(dp[i][k].ff==a[i]+dp[i+1][k].ss)
                dp[i][k].ss = dp[i+1][k].ff;
            else
                dp[i][k].ss = dp[i][k-1].ff;
            k++;
        }
    }
    
    /*for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<n;j++)
            cout<<"("<<dp[i][j].ff<<", "<<dp[i][j].ss<<")\t";
        line;    
    }*/
    cout<<dp[0][n-1].ff - dp[0][n-1].ss;
        
}

int main() {
    fastio();
    ll t=1;
    //cin>>t;
    while(t--){
        cin>>n;
        for(ll i=0;i<n;i++)
            cin>>a[i];
        solve();
    }
	return 0;
}

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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;


void solve(){
    int n, k, d, x;
    cin>>n>>k;
    map<int, bool> mp;
    fr(i, k) {
        cin>>d;
        fr(j, d){
            cin>>x;
            mp[x] = 1;
        }
    }

    cout<<n - mp.size();

}

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

    ll t = 1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}



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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	if ((n + 1) / 2 >= k)
		cout << "YES\n";
	else
		cout << "NO\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
   int N;
   scanf("%d",&N);

   if(N%10==2 ||N%10==4 ||N%10==5 ||N%10==7 ||N%10==9){
      printf("%s\n","hon");
   }else if(N%10==0 || N%10==1 ||N%10==6 ||N%10==8){
      printf("%s\n","pon");
   }else if(N%10==3){
      printf("%s\n","bon");
   }
   
   return 0;
}


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

int main(){
  long long F1,F2;
  long long A,B,N;
  cin >> A >> B >> N;
  long long MAX=0;
  long long x;
  if(B-1<=N){
    x = B-1;
    F1 = A*x/B;
    F2 = A*(x/B);
    MAX=F1-F2;
  }else{
    F1 = A*N/B;
 	F2 = A*(N/B);
    MAX=F1-F2;
  }
  cout << MAX << endl;
	return 0;
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int n = s.length() - 1;

        long ans = 0L;
        for(int i = 0;i<Math.pow(2,n);i++){
            StringBuilder sb = new StringBuilder(s);
            for(int j=n-1;j>=0;j--){
                if((1&i >> j) == 1){
                    sb.insert(j+1,"+");
                }
            }

            String[] ar = sb.toString().split("\\+",0);
            for(int j=0;j<ar.length;j++){
                ans += Long.parseLong(ar[j]);
            }
        }
        System.out.println(ans);
    }
}


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

static class Program
{
    static long Solve(long H)
    {
        return (H == 1) ? 1 : Solve(H / 2) * 2 + 1;
    }

    static void Main(string[] args)
    {
        long H = long.Parse(Console.ReadLine());
        Console.WriteLine(Solve(H));
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<queue>
using namespace std;
int main(){
    int h,w,cnt=0,d[5]={0,1,0,-1,0},ans=0;
    cin>>h>>w;
    char a[h][w];
    int dis[h][w];

    queue<pair<int,int>>q;
    bool visited[h][w]={};

    for(int i=0;i<h*w;i++)dis[i/w][i%w]=100000;
    for(int i=0;i<h*w;i++){
        cin>>a[i/w][i%w];
        if(a[i/w][i%w]=='#'){
            q.push(make_pair(i/w,i%w));
            dis[i/w][i%w]=0;
            visited[i/w][i%w]=true;
        }
    }
            while(!q.empty()){
                pair<int,int>p=q.front();q.pop();
                for(int j=0;j<4;j++){
                    if(a[p.first+d[j]][p.second+d[j+1]]=='#')continue;
                    if(p.first+d[j]>=0&&p.first+d[j]<h&&p.second+d[j+1]>=0&&p.second+d[j+1]<w&&visited[p.first+d[j]][p.second+d[j+1]]==false){
                        visited[p.first+d[j]][p.second+d[j+1]]=true;
                        if(dis[p.first][p.second]+1<dis[p.first+d[j]][p.second+d[j+1]])q.push(make_pair(p.first+d[j],p.second+d[j+1]));
                        dis[p.first+d[j]][p.second+d[j+1]]=min(dis[p.first][p.second]+1,dis[p.first+d[j]][p.second+d[j+1]]);
                        
                    }
                    //for(int j=0;j<h*w;j++)cout<<dis[j/w][j%w]<<(j%w==w-1?"\n":"");

                    //cout<<endl<<endl;
                }
            }
    for(int i=0;i<h*w;i++)if(dis[i/w][i%w])ans=max(ans,dis[i/w][i%w]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 14352
#include <bits/stdc++.h>
using namespace std;
#define int long long   // aaaaaaaaaaaaaaaaaa
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define in(s,x) s.find(x) != s.end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE(buff) (sizeof(buff)/sizeof(buff[0]))
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<pair<int,int>> VPII;
const ll mod=1000000007;
const ll INF= 1LL<<60-1;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
template<typename T, typename U>ostream& operator << (ostream& os, pair<T, U>& pair_var)
{os << "(" << pair_var.first << ", " << pair_var.second << ")";return os;}

// head


int m,n,k,res,tmp,tmp2,tmp3,h,w,x,y;
VI a;
deque<PII> que;
string s;
//VI b;
vector<PII> g[100600];
int b[210000];
int c[210000] = {};
int dp[100050] = {};



signed main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  rep(i,0,n)cin>>b[i];
  a.pb(INF);
  int max1 = 0;
  rep(i,0,n){
    int ba = lower_bound(all(a),b[i]) - a.begin();
//    cout << ba << '\n';
    if (ba >max1){
      a.pb(b[i]);
      max1 += 1;
      dp[i] = max1;
    }
    else{
      dp[i] = ba;
      a[ba] = b[i];
    }

  }
  int ans;
  ans = 0;
  rep(i,0,n){
    ans = max(ans,dp[i]+1);
  }
  cout << ans << '\n';
}



Measured memory_bytes: 7672
#include<bits/stdc++.h>
using namespace std;
int main(){
  while(1){
        int m,n1,n2,ans,max=0,s,p;
        int a[10000];
        cin >> m >> n1 >> n2;
        if(m==0 && n1==0 && n2==0) break;
        for(int i=0; i<m; i++){
          cin >> p;
          a[i] = p;
        }
        for(int i=n1; i<=n2; i++){
          s = a[i-1] - a[i];
          if(s >= max) {
                ans = i;
                max = s;
          }
        }
        cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3080
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#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 fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;


int main(void) {

    ll n,k;
    cin>>n>>k;
    if(k%2==1){
        cout<<(n/k)*(n/k)*(n/k)<<endl;
    } else {
        ll x = (n/k);
        ll y = (n + (k/2)) / k;
        cout<<x*x*x+y*y*y<<endl;
    }

}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int K;
    cin >> K;
    string S;
    cin >> S;

    if (S.length() <= K) {
        cout << S << endl;
        return 0;
    }

    S = S.substr(0, K) + "...";
    cout << S << endl;
}


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

#define fi first
#define se second
#define sz(v) (int)((v).size())
#define pb push_back

typedef long long ll;

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

	int n; cin >> n;
	vector<int> v(n);
	string s; cin >> s;
	for (int i=0; i<4; i++){
		v[0] = i%2;
		v[1] = i/2;
		for (int j = 2; j < n; j++) {
			v[j] = (s[j-1]=='o')^v[j-2]^v[j-1];
		}

		if( ( (v[0]^v[1]^(s[0]=='o')) == v[n-1]) && ( ((v[n-2]^v[n-1]^(s[n-1]=='o'))&1) == v[0]) ){
			for (int i = 0; i < n; i++) {
				cout << "WS"[v[i]];
			}
			cout << "\n";
			//cout << ( (v[0]^v[1]^(s[0]=='o')) == v[n-1]) <<" "<< ( (v[n-2]^v[n-1]^(s[n-1]=='o')) == v[0]) << "\n";
			return 0;
		}
	}
	cout << "-1\n";
}


Measured memory_bytes: 976
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll v[200005];
int main()
{
 ll n,m,c=0,x;
 cin>>n;
 for(int i=1;i<n;i++)
 {
     cin>>x;
     v[x]++;
 }
 for(int i=1;i<=n;i++)
 {
     cout<<v[i]<<endl;
 }
return 0;
}


Measured memory_bytes: 5160
object Main extends App {
  import scala.io.StdIn._
  val n = readInt()
  val monsters = readLine().trim.split(' ').map(_.toInt)
  val heros = readLine().trim.split(' ').map(_.toInt)
  var result = 0L
  for (i <- heros.indices) {
    val a = math.min(heros(i), monsters(i))
    val b = math.min(heros(i) - a, monsters(i + 1))
    result += a + b
    monsters(i + 1) -= b
  }
  println(result)
}

Measured memory_bytes: 75016
#include <stdio.h>          // printf(), getchar()
#include <stdbool.h>

const char NUL = '\0';

bool
ope_line()
{
	char oline[101];
	const char letter[6][5] = {"abcde", "fghij", "klmno", "pqrst", "uvwxy", "z.?! "};

	int c = getchar();
	if (c == EOF)
		return false;

	if (c == '\n')
		return true;

	bool b_na = false;
	int ix = 0;
	while (c != '\n' && c != EOF)
	{
		int s = c - '1';

		c = getchar();
		if (c == '\n' || c == EOF)
		{
			b_na = true;
			break;
		}

		int t = c - '1';
		if (0 <= s && s <= 5 && 0 <= t && t <= 4)
			oline[ix++] = letter[s][t];
		else
			b_na = true;

		c = getchar();
	}

	oline[ix] = NUL;
	if (b_na)
		printf("NA\n");
	else
		printf("%s\n", oline);

	if (c == EOF)
		return false;

	return true;
}

int
main(int argc, char **argv)
{
	while (true)
	{
		if (!ope_line())
			break;
	}

	return 0;
}

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

using namespace std;

#define MAX_STR_LEN 1001

int mat[MAX_STR_LEN][MAX_STR_LEN];

int lcs(string x, string y)
{
    int xlen = x.length();
    int ylen = y.length();
    for (int i = 1; i <= xlen; i++)
    {
        for (int j = 1; j <= ylen; j++)
        {
            if (i != 0 && j != 0)
            {
                mat[i][j] = (x[i - 1] == y[j - 1]) ? mat[i - 1][j - 1] + 1 : max(mat[i - 1][j], mat[i][j - 1]);
            }
            else
            {
                mat[i][j] = 0;
            }
        }
    }

    return mat[xlen][ylen];
}

int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        string x, y;
        cin >> x >> y;
        printf("%d\n", lcs(x, y));
    }

    return 0;
}



Measured memory_bytes: 7240
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))

hw=[[0 for i in range(w)] for i in range(h)]

k=0#今どこ見ているか
for i in range(h):
    if i%2==0:
        for j in range(w):
            if a[k]==0:
                k+=1
            hw[i][j]=k+1
            a[k]-=1
    else:
        for j in range(w-1,-1,-1):
            if a[k]==0:
                k+=1
            hw[i][j]=k+1
            a[k]-=1
for i in range(h):
    print(" ".join(map(str,hw[i])))


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    int h[n];
  	ll dp[n];  
  	for(int i=0;i<n;i++){
        cin>>h[i];
    	dp[i]=INT_MAX;
    }
    dp[0]=0;    
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<30;

long long f(long long n, long long x) {
  if(n == -1) return 0;
  else return n/x+1;
}

int main() {
  long long a, b, x; cin >> a >> b >> x;
  long long ans = f(b, x) - f(a-1, x);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
import math
def distance(x, y, i, j):
    return abs(x - i) + abs(y - j)

N, M = map(int, input().split())
student = []
for i in range(N):
    student.append(list(map(int, input().split())))
checkpoint = []
for i in range(M):
    checkpoint.append(list(map(int, input().split())))

for i in student:
    mini = 1000000000000
    minicp = 0
    for k in range(M):
        j = checkpoint[k]
        if distance(i[0], i[1], j[0], j[1]) < mini:
            mini = distance(i[0], i[1], j[0], j[1])
            minicp = k + 1
    print(minicp)


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


int main(){

    int N, A[200000];
    cin >> N;
    for( int i = 0; i < N; i++ ) cin >> A[i];


    for( int i = 0; i < N; i++ ) A[i] -= i+1;

    sort( A, A+N );
    
    long sum = 0, b;

    if( N % 2 == 0 ) b = ( A[N/2-1] + A[N/2] )/2; 
    else b = A[N/2];
    for( int i = 0; i < N; i++ ) sum += abs( A[i] - b );
    
    cout << sum << endl;

    return 0;

}

Measured memory_bytes: 1024
N = int(input())
S = input()

mod = 10 ** 9 + 7
hash = [0]
pow = [1]
for s in S :
    hash.append((hash[-1] * 26 + ord(s) - 97) % mod)
    pow.append(pow[-1] * 26 % mod)

M = 0
for i in range(N + 1) :
    for j in range(i + 1, N + 1) :
        for k in range(M + 1, N - j + 1) :
            if i + k > j :
                break
            if (hash[j+k] - hash[j] * (pow[k])) % mod == (hash[i+k] - hash[i] *  pow[k]) % mod :
                M += 1
            else :
                break
                
print(M)

Measured memory_bytes: 44204
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define lundi ios_base::sync_with_stdio(false); cin.tie(NULL);

const int M = 1e9 + 7;

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

struct Node{
    int rank;
    Node* parent;
    int val;
    Node(int value) {
        rank = 1;
        val = value;
        parent = nullptr;
    }
};

struct dsu{

    unordered_map<int, Node*> hashmp;

    dsu(){
        hashmp.clear();
    }

    void add(int x){
        if(hashmp.find(x) != hashmp.end()) 
            return;
        Node* nn = new Node(x);
        hashmp[x] = nn;
    }

    int repr(int x){
        if(hashmp.find(x) == hashmp.end()){
            add(x);
        }
        auto cur = hashmp[x];
        while(cur->parent){
            cur = cur->parent;
        }
        return cur->val;
    }

    int unite(int x, int y){
        // printf("uniting %lld, %lld", x,y); cout<<endl;
        if(repr(x) == repr(y)){
            // cout<<"already united"<<endl;
            return repr(x);
        }
        Node* rx = hashmp[repr(x)];
        Node* ry = hashmp[repr(y)];

        if(rx->rank < ry->rank){
            rx->parent = ry;
            ry->rank += rx->rank;
            // printf("united %lld, %lld", x, y); cout<<endl;
            return ry->val;
        } else {
            ry->parent = rx;
            rx->rank += ry->rank;
            // printf("united %lld, %lld", x, y); cout<<endl;
            return rx->val;
        }
    }

};

void solve(){
    int n, m;
    dsu grps;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        grps.add(i);
    }
    int ans = 1;
    for(int i=0;i<m;i++){
        int a, b;
        cin>>a>>b;
        // cout<<"a = "<<a<<" b = "<<b<<endl;
        grps.unite(a, b);
    }
    for(int i=1;i<=n;i++){
        ans = max(ans, grps.hashmp[i]->rank);
    }
    cout<<ans<<endl;
}

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

Measured memory_bytes: 17800
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
d = [INT() for _ in range(N)]

print(len(set(d)))

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



int main() {


	int n, w1, w2, cnt = 0, nm = 0, st = 0, tmp;


	cin >> n >> nm;



	for (int i = n;i >= 0;i--) {

		w1 = nm - i;
		w1 = min(w1, n);
		for (int k = w1; k >= 0; k--) {

			w2 = nm - i - k;

			if (w2 <= n) {
				cnt++;
			}

		}
	}

	cout << cnt << endl;

	return 0;
}


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

int main(){
    int n,i;
    long long int res = 0;

    cin >> n;

    for( i = 1; i <= n; i++){
        if( ( i % 3 ) != 0 &&
            ( i % 5 ) != 0
        ){
            res += i;
        }
    }
    cout << res << "\n";
}

Measured memory_bytes: 3672
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
#include <fstream>
#include <cstdio>
#include <stdio.h>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <array>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

template <typename T>
void printArr(const T * arr, int s, int fn) {
    for (int i = s; i <= fn; ++ i) cout << arr[i] << " ";
    cout << '\n';
}

template <typename T>
long long minArr(const T * arr, int s, int fn) {
    ll res = 1e16 + 1;
    for (int i = s; i <= fn; ++ i) {
        res = min(res, arr[i]);
    }
    return res;
}

template <typename T>
void printVec(const T * arr) {
    for (int i = 0; i < sz(arr); ++ i) cout << arr[i] << " ";
    cout << '\n';
}

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

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

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const int N = 4e6 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const ll P = 53;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

int main () {
    to_pray();
    
    int n;
    cin >> n;
    
    double ans1 = (n / 2 + n % 2), ans2 = n;
    
    cout << fixed << setprecision(7) << ans1 / ans2;
    
    //eprintf("%.18lf seconds\n", (double)clock() / CLOCKS_PER_SEC);

    return 0;
}


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

int A, B;
int ans = 0;

int main() {
	cin >> A >> B;
	for (int num = A; num <= B; num++) {
		string Snum = to_string(num);
		bool palindrome = true;
		for (int i = 0; i < Snum.size() - i; i++) {
			if (Snum[i] != Snum[Snum.size() - 1 - i]) {
				palindrome = false;
			}
		}

		if (palindrome) ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int min(int a,int b){return a<b?a:b;}
int a[205],f[205];
int main(){
	int n,x,ans=0x3fffffff;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		while(x%2==0) f[i]++,x/=2;
	}
	for(int i=1;i<=n;i++) ans=min(ans,f[i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  string s;
  int i,n;
  long long int ans=0,j,dp[2025][3];
  cin >> s;
  for(i=0;i<2019;i++){
    for(j=0;j<2;j++){
      dp[i][j]=0;
    }
  }
  n=s.size();
  for(i=0;i<n;i++){
    if(s[i]!='0'){
      dp[0][0]++;
    }
    for(j=0;j<2019;j++){
      dp[(j*10+(s[i]-'0'))%2019][1]+=dp[j][0];
    }
    for(j=0;j<2019;j++){
      dp[j][0]=dp[j][1];
      dp[j][1]=0;
    }
    ans+=dp[0][0];
  }
  printf("%lld\n",ans);
  return 0;
}

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

int main(void){

int n;
int i,j;
int max;
int tmp;
scanf("%d",&n );
int p[n];
int ans=0;
int min;

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

for(i=1;i<n-1;i++){
  max=p[i-1];
  min=p[i+1];
  if(max<min){
    tmp=max;
    max=min;
    min=tmp;
  }
  if(p[i]>=min&&p[i]<max)
  ans++;
}
printf("%d",ans);
return 0;

}


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




int N, utmp, vtmp, wtmp;
vector<vector<pair<int,int>>> G;
vector<int> color;
vector<bool> seen;


//dfs
void dfs(int v){

  //cout << "dfs: v=" << v+1 << endl;

  seen[v] = true;

  for(auto next : G.at(v)){
    int vnext = next.first;
    int dist = next.second;
    //頂点nextが滞在済なら無視
    if(seen[vnext] == true) continue;
    else{
      //頂点nextが滞在済みでなければ、まずnextに色をつける
      if((dist % 2) == 0) color[vnext] = color[v]; //vからnexttまでの距離が偶数ならvと同じ色
      else color[vnext] = (-1) * color[v] + 1; //距離が奇数ならvと違う色
    }
    dfs(vnext);
  }

}

int main(){


  //入力を受け取ってグラフを構成
  cin >> N;
  G.resize(N);
  for(int i=0; i<N-1; i++){
    cin >> utmp >> vtmp >> wtmp;
    utmp--;vtmp--;
    //Gに(vtmp,wtmp)要素を追加
    G.at(utmp).push_back(make_pair(vtmp,wtmp));
    G.at(vtmp).push_back(make_pair(utmp,wtmp));
  }

  //for(int i=0;i<N;i++){
  //  cout << "v=" << i << ":" << endl;
  //  for(auto v : G.at(i))
  //    cout << "(vnext,w)=(" << v.first << "," << v.second << ")" << endl;
  //}

  //訪れたかどうかのフラグ、初期設定
  seen.resize(N);
  for(int i=0;i<N;i++) seen[i]= false;

  //色初期設定
  color.resize(N);
  for(int i=0;i<N;i++) color[i]=0;

  //dfsしながら色塗り、最初は頂点0を色1としてからdfs呼び出し
  //グラフは連結と仮定
  color[0]=0;
  dfs(0);

  //output
  for(int i=0; i<N; i++)
    cout << color[i] << endl;
}


Measured memory_bytes: 10904
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.S;
		var t=sc.S;
		for(int i = 0;i<s.Length;i++) {
			if(s[i]!=t[i]){
				Console.WriteLine("No");
				return;
			}
		}
		Console.WriteLine("Yes");
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 25908
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define strall(v) (v).cbegin(),(v).cend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

ll choose(ll n){
  return n*(n-1)/2;
}
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> cnt(n);//番号ごとに集計
  rep(i,n) cin >> a[i];
  rep(i,n) a[i]--;
  rep(i,n) cnt[a[i]]++;
  ll tot = 0; 
  rep(i,n) tot+=choose(cnt[i]);
  rep(i,n){
    ll ans = tot;
    ans -= choose(cnt[a[i]]);
    ans += choose(cnt[a[i]]-1);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
typedef long long ll;
const ll INF = 1e+18;

int main(){
    int N,M;
    cin >>N>>M;
    vector<ll> x(N),y(N),z(N);
    vector<ll> sum;
    rep(i,N) cin >> x[i] >> y[i] >> z[i];
    ll ans=0;

    rep(l,2){
        rep(m,2){
            rep(n,2){
                priority_queue<ll> sum;
                ll tmp=0;
                rep(i,N){
                    sum.push(pow(-1,l)*x[i]+pow(-1,m)*y[i]+pow(-1,n)*z[i]);
                }

                rep(i,M){
                    tmp+=sum.top();
                    sum.pop();
                }
                ans=max(ans,tmp);
            }
        }      
    }
    cout << ans << endl;
    
    
}


Measured memory_bytes: 256
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( iter = $ iter : ident , $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut $ iter = s . split_whitespace ( ) ; input_inner ! { $ iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , mut $ var : usize $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , $ var : usize $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , { chars : $ base : expr } ) => { read_value ! ( $ iter , String ) . chars ( ) . map ( | c | ( c as u8 - $ base as u8 ) as usize ) . collect ::< Vec < usize >> ( ) } ; ( $ iter : expr , { char : $ base : expr } ) => { read_value ! ( $ iter , { chars : $ base } ) [ 0 ] } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , char ) => { read_value ! ( $ iter , chars ) [ 0 ] } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
fn main() {
    input! { n, ab: [(i64,i64); n] };
    let s = ab.iter().map(|&(a, _b)| a).sum();
    let ans = s
        - (0..n)
            .filter_map(|i| {
                if ab[i].0 > ab[i].1 {
                    Some(ab[i].1)
                } else {
                    None
                }
            })
            .min()
            .unwrap_or(s);
    println!("{}", ans);
}


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

using namespace std;

int D;
vector<int> c(30, 0);
vector<vector<int>> s(400, vector<int>(30, 0));
vector<vector<int>> last(400, vector<int>(30, 0));
vector<int> t(400, 0), ans_B(400, 0);

void input() {
	cin >> D;
	for (int i = 1; i <= 26; ++i) { cin >> c[i]; }
	for (int i = 1; i <= D; ++i) {
		for (int j = 1; j <= 26; ++j) { cin >> s[i][j]; }
	}
	for (int i = 1; i <= D; ++i) { cin >> t[i]; }
}

void calc_score() {
	for (int d = 1; d <= D; ++d) {
		for (int i = 1; i <= 26; ++i) { last[d][i] = last[d - 1][i]; }
		last[d][t[d]] = d;

		ans_B[d] = s[d][t[d]] + ans_B[d - 1];
		for (int i = 1; i <= 26; ++i) {
			ans_B[d] -= c[i] * (d - last[d][i]);
		}
	}
}

int main() {
	input();
	calc_score();
	for (int i = 1; i <= D; ++i) {
		cout << ans_B[i] << endl;
	}

	return 0;
}


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

    int main (){
        int n;
        cin >> n;
        vector<int> a(n);

        rep(i,n){
            cin >> a[i];
        }
        int ma=a[0];
        int mi=inf;
        int ans = 1;
        rep(i,n){
            if(mi>=a[i] && i!=0){
                ans++;
               // cout << a[i] << endl;
            }
    mi=min(mi,a[i]);
        }   
        cout << ans << endl;

    }

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

int main() {
  int N,x;
  cin >> N >> x;
  vector<int> a(N);  
  for(int i=0;i<N;++i){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  
  int sum=0;
  int ans=0;
  for(int i=0;i<N;++i){ 
    if(sum<=x){
      sum+=a[i];
      ans = i;
    }
    if(sum==x){
      ans = N;
    }        
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#define int long long
using namespace std;

int n,p[100],cost[100];
vector<int> recipe[100];

int dfs(int v){
	int sum = 0;
	if(cost[v] != -1) return cost[v];
	if(recipe[v].size() == 0) return cost[v] = p[v];
	for(int i = 0;i < recipe[v].size();i++){
		sum += dfs(recipe[v][i]);
	}
	return cost[v] = min(p[v],sum);
}

signed main(){
	int m;
	string t;
	while(cin >> n,n){
		for(int i = 0;i < 100;i++) {
			recipe[i].clear();
			cost[i] = -1;
		}
		map<string,int> mp;
		for(int i = 0;i < n;i++){
			string s;
			cin >> s >> p[i];
			mp[s] = i;
		}
		cin >> m;
		for(int i = 0;i < m;i++){
			int k;
			string s,q;
			cin >> s >> k;
			for(int j = 0;j < k;j++){
				cin >> q;
				recipe[mp[s]].push_back(mp[q]);
			}
		}
		cin >> t;
		cout << dfs(mp[t]) << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
 
typedef long long ll;
typedef unsigned short int unsi;
typedef unsigned int uni;
typedef unsigned long int unli;
 
using namespace std;
 
int main(){
	int A_1, A_2, A_3;
	cin >> A_1 >> A_2 >> A_3;
	
    if (A_1 + A_2 + A_3 >= 22) {
		cout << "bust" << endl;
	} else {
		cout << "win" << endl;
	}
}

Measured memory_bytes: 256
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 200005
vector<ll> v[MAX];
ll par[MAX];
bitset<MAX> vis;
void dfs()
{
    par[1]=1;
    deque<ll> dq;
    dq.push_back(1);
    vis[1]=1;
    while(!dq.empty())
    {
        int node =dq[0];
        dq.pop_front();
        for(int i=0;i<v[node].size();i++){
            if(vis[v[node][i]]) continue;
            vis[v[node][i]]=1;
            par[v[node][i]]=node;
            dq.push_back(v[node][i]);
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,m; cin>>n>>m;
    for(int i=1;i<=m;i++){
        ll a, b; cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    ll cnt=0;
    for(int i=1;i<=n;i++){
        if(vis[i]==0) {
            dfs();
            cnt++;
        }
        if(cnt>1) { cout<<"No"<<endl; return 0 ;} 
        
    }
    
    
         cout<<"Yes"<<endl;
        for(int i=2;i<=n;i++) cout<<par[i]<<endl;
        cout<<endl;
}

Measured memory_bytes: 15388
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
 
// ------------------------------------------------------------------------------------------------

ll n, m, ans;
vpll v;
auto comp = [](const auto &l, const auto &r) -> bool {
    return l.second < r.second;
};
priority_queue<pll, vpll, decltype(comp)> pq(comp);

void func() {
    cin >> n >> m;
    for (ll i = 0, a, b; i < n; i++) {
        cin >> a >> b;
        v.emplace_back(a, b);
    }
    sort(v.begin(), v.end(), [&](const auto &l, const auto &r) -> bool {
        return l.first < r.first;
    });
    ans = 0;
    for (ll i = 1, j = 0; i <= m; i++) {
        while (j < n && v[j].first <= i) {
            pq.push(v[j]);
            j++;
        }
        if (!pq.empty()) {
            ans += pq.top().second; pq.pop();
        }
    }
    cout << ans << endl;
}

int main() {
    fast_io; cout_precision;
    ll t = 1; // cin >> t;
    for (ll i = 0; i < t; i++) {
        func();
    }
}

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

struct edge{
	int to,from;
};

int main(){
	int n;
	cin >> n;
	vector<edge> edges;
	for(int i =0;i<n-1;i++){
		int u,v;
		cin >> u >> v;
		edges.push_back({u,v});
	}
	long long ans = 0;
	for(long long i =1;i<=n;i++){
		ans += (i*(n-i+1));
	}

	for(auto e:edges){
		long long u = min(e.to,e.from);
		long long v= max(e.to,e.from);
		ans-= (u*(n-v+1));
	}
	cout << ans << endl;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, x);
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

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

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

int main(void) {
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

int main(){
    ll n;
    ll ans=0;
    cin >> n;
    rep(i,n){
        ll a;;
        cin >> a;
        ans+=a;
    }
    cout << ans-n << endl;
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<list>
#define LL long long
#define FF(i,a,b) for(int i=a;i<=b;++i)
#define RR(i,a,b) for(int i=a;i>=b;--i)
#define SC(x) scanf("%d",&x)
#define SCC(x,y) scanf("%d%d",&x,&y)
#define SCCC(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define SS(x) scanf("%s",x)
#define PR(x) printf("%d\n",x)
#define CL(a,b) memset(a,b,sizeof(a))
#define ll rt<<1
#define rr rt<<1|1
#define mid int m=(x+((y-x)>>1))
#define lson x,m,rt<<1
#define rson m+1,y,rt<<1|1
#define lowbit(x) (x&-x)
#define PB push_back
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
#define fi freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
using namespace std;

const int N = 1e5 + 10;
const int inf = 1e9;

int a, b, c;
int main()
{


    SCCC(a, b, c);
    int ans = 0;
    if(a == b && b == c && a % 2 == 0){
        puts("-1"); return 0;
    }
    while((a%2==0 && b%2==0 && c%2==0))
    {
        int na = (b+c)/2, nb = (a+c)/2, nc = (a+b)/2;
        a = na; b = nb; c = nc;
        ++ans;
    }
    PR(ans);
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    int value[n], cost[n];
    ll res = 0;
    for (int i = 0; i < n; i++) cin >> value[i];
    for (int i = 0; i < n; i++) {
        cin >> cost[i];
        if (value[i] - cost[i] >= 0) res += value[i] - cost[i];
    }

    cout << res << endl;
}


Measured memory_bytes: 256
isprime = [True] * 100201

def seive(n): 
  isprime[0] = isprime[1] = False
  p = 2
  while (p*p <= n):
    if isprime[p]:
      for i in range(p*p, n+1, p):
        isprime[i] = False   
    p += 1
      
  prime = [j for j in range(n) if isprime[j]]
  return prime

		
def program():
  x = int(input())
  N = 100200
  prime = seive(N) 
    
  for i in range(len(prime)):
    if prime[i] >= x:
      return prime[i]
      break
		
print(program())


Measured memory_bytes: 10148
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  ll ans = 0;
  ans = (n/(a+b))*a;
  ll memo = n%(a+b);
  if(memo >= a) ans += a;
  else ans += memo;
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    pair<int,int> p[2*n];
    rep(i,2*n){
        cin>>p[i].first;
        p[i].second=(i<n);
    }
    sort(p,p+2*n);
    ll ans = 1;
    ll cur = 0;
    rep(i,2*n){
        if(p[i].second){
            if(cur>0)ans*=cur;
            --cur;
        }
        else {
            if(cur<0)ans*=-cur;
            ++cur;
        }
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int K,S,ans=0;
int main(){
  cin >> K >> S;
  for(int X=0;X<=K;X++){
    for(int Y=0;Y<=K;Y++){
      int Z=S-X-Y;
      if(Z>=0 && Z<=K) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
data = int(input())
e = [0] * (data+1)
for i in range(2, data+1):
    cur = i
    for j in range(2, i+1):
        while cur % j == 0:
            e[j] += 1
            cur //= j


def num(m):
    return len(list(filter(lambda x: x >= m-1, e)))

print(num(75) + num(25)*(num(3)-1) + num(15)*(num(5)-1)+num(5)*(num(5)-1)*(num(3)-2)//2)

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

#define pb push_back
#define ff first
#define ss second

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

const int MAXN = 2 * 1000 + 17;

int n, k, ans = 1e9 + 17;
vector<int> adj[MAXN];
vector<pii> ed;

int bfs(int x, int y) {
	queue<int> q;
	int lev[MAXN] = {};
	fill(lev, lev + MAXN, 1e9);
	lev[x] = 0;
	lev[y] = 0;
	if (y != 0)
		q.push(y);
	q.push(x);
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		//cerr << u << endl;
		for (auto v : adj[u])
			if (lev[v] == 1e9) {
				lev[v] = lev[u] + 1;
				q.push(v);
			}
	}
	int res = 0;
	for (int i = 1; i <= n; i++)
		if (lev[i] > (k / 2))
			res++;
	return res;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	for (int i = 1; i < n; i++) {
		int v, u;
		cin >> v >> u;
		ed.pb({v, u});
		adj[v].pb(u);
		adj[u].pb(v);
	}
	if (k % 2 == 0)
		for (int i = 1; i <= n; i++)
			ans = min(ans, bfs(i, 0));
	else
		for (auto i : ed)
			ans = min(ans, bfs(i.ff, i.ss));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
n = int(input())
a = []
for i in range(n):
    x, y = map(int, input().split())
    a.append([y, x])
a.sort()
r = 0
for i, j in enumerate(a):
    r += j[1]
    if r > j[0]:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 35620