akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

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

  vector<ll> dp(n + 1, 0);
  ll sum = a[0];
  for (int i = 2; i <= n; i++) {
    if (i % 2 == 0) {
      dp[i] = max(a[i - 1] + dp[i - 2], sum);
    } else {
      dp[i] = max(a[i - 1] + dp[i - 2], dp[i - 1]);
      sum += a[i - 1];
    }
  }
  cout << dp[n] << endl;
  return 0;
} 

Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
void Main()
{
    ll n;
    cin >> n;
    vector<ll> A(n);
    rep(i, n) cin >> A[i];

    ll Q;
    cin >> Q;
    vector<ll> B(Q), C(Q);
    rep(i, Q) cin >> B[i] >> C[i];
    
    vector<ll> x(100001);
    rep(i, n) x[A[i]]++;

    ll S = 0;
    rep(i, x.size()) S += x[i] * i;

    rep(i, Q) {
        ll b = B[i];
        ll c = C[i];
        ll cnt = x[b];
        x[b] = 0;
        x[c] += cnt;

        S -= b * cnt;
        S += c * cnt;
        put(S);
    }


}
signed main(){ Main();return 0;}

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

int f1[4];
vector<string> f2({"AC","WA","TLE","RE"});

int main()
{
    int n;
    cin>>n;
    while(n--)
    {
        string c;
        cin>>c;
        for(int i=0;i<4;i++)
        {
            if(c==f2[i])
                f1[i]++;
        }
    }
    for(int i=0;i<4;i++)
    {
        cout<<f2[i]<<" x "<<f1[i]<<endl;
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
  #define debug(...) printf(__VA_ARGS__)
#else
  #define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

char P(const string &S, int idx) {
  if (idx >= SZ(S))
    return '?';
  return S[idx];
}
bool match(char x, char y) {
  if (x == '?')
    return true;
  if (y == '?')
    return true;
  return x == y;
}
bool match(char x, char y, char z) {
  //debug("    ma %c %c %c\n", x, y, z);
  if (x == '?')
    return match(y, z);
  if (y == '?')
    return match(x, z);
  if (z == '?')
    return match(x, y);
  return (x == y) && (y == z);
}

int solve(const string &A, const string &B, const string &C, int cut) {
  if (cut == max(SZ(A), max(SZ(B), SZ(C))))
    return cut;
  //debug("%s %s %s\n", A.c_str(), B.c_str(), C.c_str());
  for (int dB = 0; dB <= SZ(A); dB++) {
    if (dB + SZ(B) >= cut)
      break;
    bool failed = false;
    for (int i = 0; i < SZ(B); i++) {
      if (!match(P(A, dB + i), P(B, i))) {
        failed = true;
        break;
      }
    }
    //debug(" dB %d  %d\n", dB, failed);
    if (failed)
      continue;

    for (int dC = 0; dC <= max(SZ(B), SZ(A) - dB); dC++) {
      if (dB + dC + SZ(C) >= cut)
        break;
      bool f_in = false;
      for (int i = 0; i < SZ(C); i++) {
        if (!match(P(A, dB + dC + i), P(B, dC + i), P(C, i))) {
          f_in = true;
          break;
        }
      }
      //debug("  dC %d  %d\n", dC, f_in);
      if (f_in)
        continue;
      cut = max(SZ(A), max(dB + SZ(B), dB + dC + SZ(C)));
    }
  }
  return cut;
}

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  int ans = SZ(a) + SZ(b) + SZ(c);
  ans = min(ans, solve(a, b, c, ans));
  ans = min(ans, solve(a, c, b, ans));
  ans = min(ans, solve(b, a, c, ans));
  ans = min(ans, solve(b, c, a, ans));
  ans = min(ans, solve(c, a, b, ans));
  ans = min(ans, solve(c, b, a, ans));
  cout << ans << endl;
  return 0;
}


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

using namespace std;
long long abc(int n){
    long long a = n;
    a *= n+1;
    a>>=1;
    return a;
}
int arr[1000000];
int arr2[1000000];
int main()
{
   int n;
   cin >> n;
   long long sum = 0;
   for(int i = 1; i <= n; i++){
    long long z = abc(n/i);
    z *= i;
    sum += z;
   }
   cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3608
import sys

def solve():
    input = sys.stdin.readline
    N, Z, W = map(int, input().split())
    A = [int(a) for a in input().split()]
    if N == 1: print(abs(W - A[0]))
    else: print(max(abs(W - A[N-1]), abs(A[N-2] - A[N-1])))

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3188
//	Totally unrelated and not AT ALL stolen from hohohaha's, generic_placeholder_name's or katoriyuu's template
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include <ext/rope>

using namespace std;

#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gcd __gcd
#define rep(i,s,end) for(int i = (s); i <  (end); ++i)
#define rep1(i, end) for(int i =   1; i <= (end); ++i)
#define lb lower_bound
#define ub upper_bound

#define vt vector
#define endl "\n"

#define fileopen(filename, in_type, out_type) if (fopen(filename in_type, "r")) {freopen(filename in_type, "r", stdin);freopen(filename out_type, "w", stdout);}
#define local_input(x) if (x && fopen("input.txt","r")) freopen("input.txt","r",stdin);
#define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

#define fscan(x)   scanf("%d",  &x)
#define fscandb(x) scanf("%lf", &x)
#define fscanll(x) scanf("%lld",&x)
//	Until next time, remember:
//			You are closer than you think.
//						_Dan Lok_

#define int ll
typedef double db;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define pi 3.1415926535897932	//faster than pi = acos(-1); but sometimes doesn't work?
//	srand(chrono::steady_clock::now().time_since_epoch().count());
//	freopen("input.txt","r",stdin);

#define mn 100001
#define mk 21
int n,tired,q;
int a[mn];
int s[mn][mk];

signed main()
{
	fastio;
	// fileopen("",".inp",".out");
	cin >> n; rep1(i,n){
		cin >> a[i];
	}
	cin >> tired >> q;
	rep1(i,n){
		s[i][0] = ub(a+1,a+1+n, a[i]+tired)-a-1;
	}
	rep(j,1,mk){
		rep1(i,n){
			s[i][j] = s[s[i][j-1]][j-1];
		}
	}
	while(q--){
		int l,r,ans = 0; cin >> l >> r; if(l > r) swap(l,r);
		for(int j = 20; j > -1; --j)
			if(s[l][j] < r) l = s[l][j], ans += 1 << j;
		cout << ans+1 << endl;
	}
	
	return 0;
}
// with the aura of Dora, AC!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Why is there a one in my row of exclamation marks?



Measured memory_bytes: 20804
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=5010,Mod=1e9+7;
int n,cnt,front[N],f[N][N][2],p[N][2],g[N],siz[N];
struct node{int to,nxt;}e[N<<1];
void Add(int u,int v){e[++cnt]=(node){v,front[u]};front[u]=cnt;}
void dfs(int u,int ff){
	siz[u]=1;f[u][1][0]=1;
	for(int i=front[u];i;i=e[i].nxt){
		int v=e[i].to;if(v==ff)continue;
		dfs(v,u);memset(p,0,sizeof(p));
		for(int j=1;j<=siz[u];j++)
			for(int k=1;k<=siz[v];k++){
				ll same=(1ll*f[u][j][0]*f[v][k][0]%Mod+1ll*f[u][j][1]*f[v][k][1]%Mod)%Mod;
				ll diff=(1ll*f[u][j][0]*f[v][k][1]%Mod+1ll*f[u][j][1]*f[v][k][0]%Mod)%Mod;
				p[j+k][0]=(p[j+k][0]+same)%Mod;
				p[j+k][1]=(p[j+k][1]+diff)%Mod;
				p[j][0]=(p[j][0]+1ll*g[k]*diff%Mod)%Mod;
				p[j][1]=(p[j][1]+1ll*g[k]*same%Mod)%Mod;
			}
		siz[u]+=siz[v];
		memcpy(f[u],p,sizeof(p));
	}
}
int main(){
	n=gi();
	for(int i=1;i<n;i++){
		int u=gi(),v=gi();
		Add(u,v);Add(v,u);
	}
	g[0]=1;
	for(int i=2;i<=n;i+=2)g[i]=1ll*g[i-2]*(i-1)%Mod;
	dfs(1,1);int ans=0;
	for(int i=2;i<=n;i+=2)
		ans=(ans+1ll*(f[1][i][0]-f[1][i][1]+Mod)%Mod*g[i]%Mod)%Mod;
	printf("%d\n",ans);
	return 0;
}


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

int solve();

int main()
{
	printf("%d\n", solve());

	return 0;
}

int solve()
{
	int N;
	scanf("%d", &N);
	std::vector<int64_t> a(N);
	for (auto& e: a) scanf("%lld", &e);

	int64_t all_xor{};
	for (auto& e: a) all_xor ^= e;

	bool exist[32]{};
	for (auto& e: a)
	{
		int digit{};
		while (~e >> digit & 1) digit++;
		exist[digit] = true;
	}

	int count{};
	for (int i{}; i < 32; i++)
	{
		if (((all_xor >> i) & 1) ^ ((all_xor >> (i + 1)) & 1) == 0)
			continue;
		if (!exist[i]) return -1;
		count++;
	}

	return count;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()

int N;
ll sum_a[200001];

ll calc_diff(int l, int c, int r) {
    return abs(sum_a[r] - 2 * sum_a[c] + sum_a[l]);
}

ll calc_score(int l, int c, int r) {
    ll max_s = max(sum_a[l] - sum_a[0], max(sum_a[c] - sum_a[l], max(sum_a[r] - sum_a[c], sum_a[N] - sum_a[r])));
    ll min_s = min(sum_a[l] - sum_a[0], min(sum_a[c] - sum_a[l], min(sum_a[r] - sum_a[c], sum_a[N] - sum_a[r]))); 
    return max_s - min_s;
}

int main() {
    cin >> N;
    REP(i, N) {
        cin >> sum_a[i + 1];
        sum_a[i + 1] += sum_a[i];
    }

    int c1 = 1, c2 = 2, c3 = 3;
    ll ans = calc_score(c1, c2, c3);
    while (c2 <= N - 2) {
        while (c1 + 1 < c2 && (calc_diff(0, c1 + 1, c2) < calc_diff(0, c1, c2)))
            c1++;
        if (c3 <= c2)
            c3 = c2 + 1;
        while (c3 + 1 < N && (calc_diff(c2, c3 + 1, N) < calc_diff(c2, c3, N)))
            c3++;

        ans = min(ans, calc_score(c1, c2, c3));
        c2++;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int n, m, cnt=0, cur=-1; cin >> n >> m;
    vector<pair<int, int>> ba;
    REP(i, m){
        int a, b; cin >> a >> b;
        ba.push_back(make_pair(b, a));
    }
    sort(ba.begin(), ba.end());
    REP(i, m){
        if(cur < ba[i].second){
            cur = ba[i].first -1;
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
typedef long long ll;
using namespace std;
int main()
{
    ll n, m;
    cin >> n >> m;
    ll a[n];
    cin >> a[0];
    FOR(i, 1, n)
    {
        cin >> a[i];
        a[i] += a[i - 1];
    }
    REP(i, n)
    a[i] %= m;
    sort(a, a + n);
    ll l = 1, ans = 0;
    REP(i, n)
    {
        if (i != n && a[i] == a[i + 1])
            l++;
        else
        {
            ans += l * (l - 1) / 2;
            if (a[i] == 0)
            {
                ans += l;
            }
            l = 1;
        }
    }
    cout << ans << endl;
    return 0;
}


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


typedef long long ll;

template <typename T,T INF,bool isMin>
struct ConvexHullTrick {
  using P = pair<T, T>;
  deque<P> L;
 
  inline T getY(const P &a,const T &x){
    return a.first*x+a.second; 
  }
 
  inline bool check(const P &a,const P &b,const P &c){
    return (b.first-a.first)*(c.second-b.second)
      >= (b.second-a.second)*(c.first-b.first);
  }
  
  void add(T a,T b){
    if(!isMin) a*=-1,b*=-1;
    P line(a,b);
    if(!L.empty()&&L.back().first==a){
      line.second=min(line.second,L.back().second);
      L.pop_back();
    }
    while(L.size()>=2&&check(L[L.size()-2],L[L.size()-1],line)) L.pop_back();
    L.emplace_back(line);    
  }
 
  T get(T x){
    if(L.empty()) return isMin?INF:-INF;
    ll low=-1,high=L.size()-1;
    while(low+1<high){
      ll mid=(low+high)>>1;
      if(getY(L[mid],x)>=getY(L[mid+1],x)) low=mid;
      else high=mid;
    }
    return (!isMin?-1:1)*getY(L[high],x);
  }
};

 
ll n,c;
ll h[200009];
ll dp[200009];

signed main(){
  cin>>n>>c;
  for(int i=0;i<n;i++) cin>>h[i];
  ConvexHullTrick< ll , (ll)1e18 ,true > C;

  for(int i=1;i<n;i++){
    C.add(-2*h[i-1],dp[i-1]+h[i-1]*h[i-1]);
    dp[i]=C.get(h[i])+h[i]*h[i]+c;
  }

  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 6656
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	vector<string> s(n);
	for(int i=0;i<n;i++) cin >> s[i];
	vector<int> marchnum(5);
	for(int i=0;i<n;i++){
		if(s[i][0]=='M') marchnum[0]++;
		if(s[i][0]=='A') marchnum[1]++;
		if(s[i][0]=='R') marchnum[2]++;
		if(s[i][0]=='C') marchnum[3]++;
		if(s[i][0]=='H') marchnum[4]++;
	}
	long long ans=0;
	for(int i=0;i<3;i++){	
		for(int j=i+1;j<4;j++){
			long long temp=0;
			for(int k=j+1;k<5;k++) temp+=marchnum[k];
			ans+=marchnum[i]*marchnum[j]*temp;
		}
	}
	cout << ans;
}

Measured memory_bytes: 6912
from collections import deque

n,k = map(int,input().split())
v_in = list(map(int,input().split()))
v = deque(v_in)
m = -10000001
for i in range(k+1):
    for j in range(k-i+1):
        vv = deque(v_in)
        a = []
        for x in range(i):
            try:
                a.append(vv.popleft())
            except:
                break
        for y in range(j):
            try:
                a.append(vv.pop())
            except:
                break
        a.sort(reverse=True)
        for z in range(k-i-j):
            try:
                if a[-1] < 0:
                    a.pop()
                else:
                    break
            except:
                break
        tmp = sum(a)
        if tmp > m:
            m = tmp
print(m)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i, a) for (ll i = 0; i < (a); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;

char f[102][102];
char c;

void dfs(int y, int x){
    if(f[y][x] != c)
        return;
    if(f[y][x] == '.')
        return;
    
    f[y][x] = '.';
    
    dfs(y-1, x);
    dfs(y, x+1);
    dfs(y+1, x);
    dfs(y, x-1);
}

int main(){
    while(1){
        int h,w;
        int cnt = 0;
        cin >> h >> w;
        if(h == 0 && w == 0){
            break;
        }
        for(int i = 1; i <= h; i++){
            for(int j = 1; j <= w; j++){
                cin >> f[i][j];
            }
        }
        for(int i = 1; i <= h; i++){
            for(int j = 1; j <= w; j++){
                if(f[i][j] != '.'){
                    c = f[i][j];
                    cnt++;
                    dfs(i, j);
                }
            }
        }
        cout << cnt << endl;
    }
}


Measured memory_bytes: 3472
//   Rishabh Agarwal
#include <bits/stdc++.h>
#define F first
#define S second
#define MAX 10000003
using namespace std;

typedef long long int ll;
const ll mod = 998244353;
long double PI=3.1415926;

ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    ll temp=power(a,b/2)%mod;
    if(b%2==0){
        return (temp*temp)%mod;
    }
    else{
        return ((a*temp)%mod*temp)%mod;
    }
}

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

//vector<ll>v;
//vector<ll>::iterator it;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t;
    //cin>>t;
    t=1;
    //ll c=1;
    while(t--){
        ll n;
        cin>>n;
        ll a[n];
        ll v[n];
        memset(v,0,sizeof(v));
        ll ans=1;
        for(ll x=0; x<n; x++){
            cin>>a[x];
            v[a[x]]++;
        }
        if(v[0]!=1){
            ans=0;
        }
        else if(v[0]==1&&a[0]!=0){
            ans=0;
        }
        else{
            ll k=n;
            for(ll x=n-1; x>=0; x--){
                if(v[x]==0){
                    k--;
                }
                else{
                    break;
                }
            }
            for(ll x=1; x<k; x++){
                ans=ans%mod;
                ans*=power(v[x-1],v[x])%mod;
                ans=ans%mod;
            }
        }
        cout<<ans<<"\n";
        //v.clear();
        //cout<<"Case #"<<c<<": "<<ans<<"\n";
        //c++;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main() {
	int N;
	int pt=0;
	int px=0,py=0;
	cin >> N;
	int t,x,y;
	for (int i=0;i<N;i++){
		cin >> t >> x >> y;
		int d=abs(x-px)+abs(y-py);
		if(d<=t-pt&&d%2==(t-pt)%2){
			px=x;
			py=y;
			pt=t;
		}
		else{
			//cout << t << ", " << pt << ", " << px << ", " << py << ", " << d << endl;
			//cout << (d>=t-pt) << ": " << (d%2 == (t-pt)%2) << endl;
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}



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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

template<class T,class F>
struct segtree{
  int n;
  T e;
  F f;
  std::vector<T> dat;

  segtree(){}
  segtree(T _e,F _f):e(_e),f(_f){}
  segtree(std::vector<T> const& v,T _e,F _f):e(_e),f(_f){
    build(v);
  }
  void build(std::vector<T> const& v){
    n = 1;
    int sz = v.size();
    while(n<=sz)n<<=1;
    dat.resize(2*n,e);
    for(int i=0;i<sz;++i){
      dat[i+n] = v[i];
    }
    for(int i=n-1;i>0;--i){
      dat[i] = f(dat[i<<1],dat[i<<1|1]);
    }
  }
  void modify(int p,T v){
    for(dat[p+=n]+=v;p>1;p>>=1){
      dat[p>>1] = f(dat[p],dat[p^1]);
    }
  }
  // [l,r)
  T query(int l,int r){
    T res = e;
    for(l+=n,r+=n;l<r;l>>=1,r>>=1){
      if(l&1){
        res = f(res,dat[l]);
        l++;
      }
      if(r&1){
        r--;
        res = f(res,dat[r]);
      }
    }
    return res;
  }
  T operator[](int k){
    return query(k,k+1);
  }
};

int main(){

  int n;
  cin>>n;
  vector<ll> h(n),a(n);
  cin>>h>>a;

  map<ll,ll> zatu;
  rep(i,n)zatu[h[i]]=i;
  int x=0;
  for(auto z:zatu){
    h[z.second] = x++;
  }

  auto f = [](auto a,auto b){return a<b?b:a;};
  segtree<ll,decltype(f)> seg(vector<ll>(2e5),0ll,f);

  rep(i,n){
    ll t = seg.query(0,h[i]);
    if(seg[h[i]]<t+a[i])seg.modify(h[i],t+a[i]);
  }

  cout<<(seg.query(0,2e5))<<endl;

}

Measured memory_bytes: 21504
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
ll power(ll a,int n){
	if(n==0)
	  return 1;
	if((n%2)==0)
	  return power(a*a,n/2);
	else
	  return a*power(a*a,n/2);    
}
int main(){
FASTIO
int n;
cin>>n;
vector<int> v;
while(n){
   v.pb(n%10);
   n=n/10;
}
bool is=false;
for(int i=0;i<3;i++){
	if(v[i]==7)
		is=true;
}
if(is)
   cout<<"Yes";
else
	cout<<"No";
return 0;
}


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

int a[1000005],n,t;

int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&t), a[t]++;
    int cnt = 0;
    for(int i=1;i<=100000;i++) if(a[i]>1) cnt+=a[i]-1;
    if(cnt&1) n-=cnt+1;
    else n-=cnt;
    cout<<n<<endl;
}


Measured memory_bytes: 640
// Addition and Subtraction Easy

#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>

using namespace std;

int main()
{
    int A,B;
    string op;
    cin >> A >> op >> B;

    int result = 0;
    if (op == "+") {
        result = A + B;
    }
    else {
        result = A - B;
    }

    cout << result << endl;

    return 0;
}

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

		// 整数の入力
		int n = sc.nextInt();
		int k = sc.nextInt();

		// 出力
		System.out.println(k==1?0:n-k);
	}
}

Measured memory_bytes: 23892
import qualified Data.ByteString.Char8 as B
import Data.List (unfoldr)
import Data.Char (isSpace)

main :: IO ()
main = B.interact
  $ B.pack
  . show
  . solve
  . unfoldr (B.readInt . B.dropWhile isSpace)

solve :: [Int] -> Int
solve (n:as) = sum as - n


Measured memory_bytes: 892
#include<stdio.h>
int main(){
  int x[6];
  int i,j;
  int n=0;
  
  for(i=0;i<6;i++){
    scanf("%d",&x[i]);
  }
  
  for(j=4;j>0;j--){
    if(x[j]-x[0]>x[5]) n++;
  }
  
  for(j=4;j>1;j--){
    if(x[j]-x[1]>x[5]) n++;
  }
  
  for(j=4;j>2;j--){
    if(x[j]-x[2]>x[5]) n++;
  }
  
  for (j=4;j>3;j--){
    if(x[j]-x[3]>x[5]) n++;
  }
  
  if(n==0) printf("Yay!\n");
  else printf(":(\n");
  return 0;
}
  
  


Measured memory_bytes: 128
a,b,c,x,y = map(int,input().split())
l = 0
flg = x
if x > y:
    l += (x - y) * a
    flg = y
elif x < y:
    l += (y - x) * b
else:
    pass
l += flg * 2 * c
n = max(x,y) * 2 * c
m = x * a + y * b
print(min(l,n,m))

Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i <= b; ++i)
const int N = 3001;

string s, t, ans; int f[N][N];

int main() {
	ios::sync_with_stdio(false);
	cin >> s >> t; int n = s.size(), m = t.size();
	rep(i, 1, n) rep(j, 1, m) {
		if (s[i - 1] == t[j - 1]) f[i][j] = f[i - 1][j - 1] + 1;
		f[i][j] = max(f[i][j], max(f[i][j - 1], f[i - 1][j]));
	} 
	while (n && m) {
		if (s[n - 1] == t[m - 1])
			ans += s[n - 1], n--, m--;
		else if(f[n][m - 1] > f[n - 1][m])
			m--;
		else
			n--;
	}
	reverse(ans.begin(), ans.end());
	
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;
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; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct UnionFind {
  vector<int> par; //par[i]:iの親の番号

  //最初は全てが根であるとする。-1のときに根である。
  UnionFind(int N) : par(N, -1){}

  // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
  int root(int x) {
    if(par[x] < 0) return x;
    else return par[x] = root(par[x]);
  }
  // データxが根かどうか
  bool cond_root(int x){
    if(par[x] < 0) return true;
    else return false;
  }
  //xとyが同じ集合に属するか
  bool issame(int x, int y) {
    return root(x) == root(y);
  }

  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if(x == y) return false;
    if(par[x] > par[y]) swap(x,y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }

  int size(int x) {
    return -par[root(x)];
  }
};


int main() {
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i, m){
    int a, b;
    cin >> a >> b;
    a--, b--;
    uf.merge(a, b);
  }
  int ans = 0;
  rep(i, n){
    ans = max(ans, uf.size(i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 4004
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#define MOD 1000000007
#define INF 1000000000
typedef long long ll;
using namespace std;
typedef pair<int,int> P;
struct data{
    ll a,b;
};
bool cmp(const data &p1,const data &p2){
    return p1.a<p2.a;
}
int main(void){
    ll n,k;
    cin>>n>>k;
    data p[100001];
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        p[i].a=x;
        p[i].b=y;
            }
    sort(p,p+n,cmp);
    /*for(int i=0;i<n;i++){
        printf("%d %d\n",p[i].a,p[i].b);
    }*/
    int i=0;
    while(k>0){
        k-=p[i].b;
        if(k<=0)break;
        i++;
    }
    printf("%lld\n",p[i].a);
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int a[1010];
int main() {
	int n, k;
	int ans = 0;
	int sum = 0;
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	sort(a + 1, a + 1 + n);
	if (n <= k) {
		cout << sum << endl;
	}
	else {
		for (int i = 1; i <= k; i++) {
			ans += a[i];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
 
int main(){
  int N, M;
  int s[5], c[5];
  int num[3]={-1,-1,-1};
  scanf("%d %d", &N, &M);
  for(int i=0; i<M; i++){
    scanf("%d %d", &s[i], &c[i]);
  }
  
  for(int i=0; i<M; i++){
    if(s[i]==1&&c[i]==0&&N!=1){
      printf("-1");
      return 0;
    }
    if((N-s[i])>=0){
      if(num[(2-N)+s[i]]==(-1)){
        num[(2-N)+s[i]] = c[i];
      }else{
        if(num[(2-N)+s[i]]!=c[i]){
          printf("-1");
          return 0;
        }
      }
    }else{
      printf("-1");
      return 0;
    }
  }
 
  if(N==3){
    if(num[0]==(-1)){
      printf("1");
    }else{
      printf("%d", num[0]);
    }
    if(num[1]==(-1)){
      printf("0");
    }else{
      printf("%d", num[1]);
    }
    if(num[2]==(-1)){
      printf("0");
    }else{
      printf("%d", num[2]);
    }
  }else if(N==2){
    if(num[1]==(-1)){
      printf("1");
    }else{
      printf("%d", num[1]);
    }
    if(num[2]==(-1)){
      printf("0");
    }else{
      printf("%d", num[2]);
    }
  }else if(N==1){
    if(num[2]==(-1)){
      printf("0");
    }else{
      printf("%d", num[2]);
    }
  }
  return 0;
}

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

ctr = [1] * (N + 1)
for i in range(2, N + 1):
    for j in range(i, N + 1, i):
        ctr[j] += 1
        
ans = 0
for i in range(1, N + 1):
    ans += i * ctr[i]
print(ans)


Measured memory_bytes: 145876
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cmath>

using namespace std;
typedef pair<int, int> P;
typedef pair<P, int> PI;


void solve()
{
	int N;
	cin >> N;
	vector<long long int> A(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i];
		A[i] -= i + 1;
	}
	sort(A.begin(), A.end());
	int median = 0;
	long long int ans = 0;
	if(N % 2 == 0)
	{
		median = A[N / 2];
		for (int i = 0; i < N; ++i)
		{
			ans += abs(median - A[i]);
		}
	}
	else
	{
		median = A[N / 2];
		for (int i = 0; i < N; ++i)
		{
			ans += abs(median - A[i]);
		}
		median = A[N / 2 - 1];
		long long ansTemp = 0;
		for (int i = 0; i < N; ++i)
		{
			ansTemp += abs(median - A[i]);
		}
		ans = min(ans, ansTemp);
	}
	cout << ans << endl;
}

int main()
{
	solve();
	return(0);
}

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

int main(){
    int n;
    cin >> n;
    int d = n%10;
    string s;
    if(d == 3) s = "bon";
    else if(d == 0 || d == 1 || d == 6 || d == 8) s = "pon";
    else s = "hon";
    cout << s << endl;
    return 0;
}

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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  int n;
  cin >> n;
  VLL a(n),b(n);
  ll anext=0,bnext = 0;
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n){
    int x = a[i] - b[i];
    if(x == 0) continue;
    //aの方が大きい
    if(x > 0){
      bnext -= x;
      anext += x;
    }
    //b の方が大きい
    if(x < 0){
      x = -x;
      if(x % 2 == 1){
        anext++;
        bnext--;
        x++;
      }
      bnext += x/2;
      anext -= x/2;
    }
  }
  if(anext <= bnext){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


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

int main(){
    int H,N;
    cin >> H >> N;
    int cnt = 0;
    for (int i = 0;i < N; i++){
        int a;
        cin >> a;
        cnt += a;
    }
    if(cnt >= H){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()

#define N 10
#define M 3

int
main(int argc, char** argv)
{
	int top[M];
	int x;
	int s;
	int i, j;

	for (i = 0; i < M; ++i)
		top[i] = 0;

	for (i = 0; i < N; ++i)
	{
		scanf("%d", &x);
		for (s = 0; s < M; ++s)
		{
			if (x > top[s])
				break;
		}

		for (j = 1; j >= s; --j)
			top[j + 1] = top[j];

		if (s < M)
			top[s] = x;
	}

	for (i = 0; i < M; ++i)
		printf("%d\n", top[i]);

	return 0;
}

Measured memory_bytes: 600
def s():
 def b(M,x,y,n=0):
  if M[x][y]==0:return n
  M[x][y]=0
  a=max(b(M,x-1,y,n+1),b(M,x,y-1,n+1),b(M,x+1,y,n+1),b(M,x,y+1,n+1))
  M[x][y]=1
  return a
 for e in iter(input,'0'):
  n,m=int(e),int(input())
  P=[[0]*(n+2)for _ in[0]*(m+2)]
  for i in range(m):P[i+1][1:-1]=map(int,input().split())
  print(max(b(P,i,j)for i in range(1,m+1)for j in range(1,n+1)))
if'__main__'==__name__:s()


Measured memory_bytes: 5720
import numpy as np

A1=np.array(input().split(" "),dtype=np.int32)
A2=np.array(input().split(" "),dtype=np.int32)
A3=np.array(input().split(" "),dtype=np.int32)

A=[A1,A2,A3]

N=int(input())

B=[]
for i in range(N):
    B.append(int(input()))

T=np.zeros((3,3),dtype=np.int32)

for n in range(N):
    value=B[n]
    for i in range(3):
        for j in range(3):
            if(value==A[i][j]):
                T[i][j]=1

# horizontal
flag=False
for i in range(3):
    cnt=0
    for j in range(3):
        if(T[i][j]==0):
            break
        else:
            cnt+=1
    if(cnt==3):
        flag=True

# vertical
for i in range(3):
    cnt=0
    for j in range(3):
        if(T[j][i]==0):
            break
        else:
            cnt+=1
    if(cnt==3):
        flag=True

if(T[0][0]==1 and T[1][1]==1 and T[2][2]==1):
    flag=True
elif(T[0][2]==1 and T[1][1]==1 and T[2][0]==1):
    flag=True

if(flag):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 12500
import java.util.Scanner;

public class Main {
    
    static Node[] tree;
    static StringBuilder sb;
    static final int NIL = -1;

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        tree = new Node[n];
        for(int i = 0; i < n; i++){
            tree[i] = new Node();
        }
        for(int i = 0; i < n; i++){
            int id = Integer.parseInt(sc.next());
            int left = Integer.parseInt(sc.next());
            int right = Integer.parseInt(sc.next());
            tree[id].left = left;
            tree[id].right = right;
            if(left != NIL) tree[left].parent = id;
            if(right != NIL) tree[right].parent = id;
        }
        sb = new StringBuilder();
        
        int u = 0;
        while(tree[u].parent != NIL){
            u = tree[u].parent;
        }
        sb.append("Preorder").append(System.lineSeparator());
        prePerse(u);
        sb.append(System.lineSeparator());
        sb.append("Inorder").append(System.lineSeparator());
        inPerse(u);
        sb.append(System.lineSeparator());
        sb.append("Postorder").append(System.lineSeparator());
        postParse(u);
        
        System.out.println(sb);
    }
    
    static void prePerse(int u){
        
        if(u == NIL) return;
        sb.append(" ").append(u);
        prePerse(tree[u].left);
        prePerse(tree[u].right);
    }
    
    static void inPerse(int u){
        
        if(u == NIL) return;
        inPerse(tree[u].left);
        sb.append(" ").append(u);
        inPerse(tree[u].right);
    }
    
    static void postParse(int u){
        
        if(u == NIL) return;
        postParse(tree[u].left);
        postParse(tree[u].right);
        sb.append(" ").append(u);
    }
    
    static class Node {
        int parent, left, right;

        public Node() {
            parent = NIL;
            left = NIL;
            right = NIL;
        }
    }
}


Measured memory_bytes: 26324
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;cin>>s;
    if(count(s.begin(),s.end(),'a')&&count(s.begin(),s.end(),'b')&&count(s.begin(),s.end(),'c')) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);
    static int mod = 1000000007;

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int k = scanner.nextInt();

        long[][] ncr = new long[2001][2001];
        ncr[0][0] = 1;
        for (int i = 1; i <= 2000; i++) {
            ncr[i][0] = 1;
            for (int j = 1; j <= i; j++) {
                ncr[i][j] = (ncr[i - 1][j - 1] + ncr[i - 1][j]) % mod;
            }
        }

        for (int i = 1; i <= k; i++) {
            int m = n - k - i + 1;
            System.out.println(ncr[m + i][i] * ncr[k - 1][i - 1] % mod);
        }
    }
}

Measured memory_bytes: 82004
A, B, C = map(int, input().split())
aa = []
now = A
T = True
while T:
  if now % B == C:
    print("YES")
    T = False
    quit()
  else:
    if (now % B) not in aa:
      aa.append(now % B)
      now += A
      #print(aa)
    else:
      print("NO")
      quit()

Measured memory_bytes: 9084
#!/usr/bin/python3
# -*- coding: utf-8 -*-
a = int(input())
b = int(input())

if (a == 1 and b == 2) or (a == 2 and b == 1):
  print(3)
if (a == 1 and b == 3) or (a == 3 and b == 1):
  print(2)
if (a == 3 and b == 2) or (a == 2 and b == 3):
  print(1)

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

int main(){
  while(true){
    int n;
    cin >> n;
    if(n == 0) break;
    int ans = 0;
    string s[151];

    for(int i = 0 ; i < n ; i++) cin >> s[i];
    
    for(int i = 1 ; i < n ; i++){
      if((s[i] == "lu" && s[i - 1] == "ru") || (s[i] == "ru" && s[i - 1] == "lu")){
	ans++;
      }
      if((s[i] == "ld" && s[i - 1] == "rd") || (s[i] == "rd" && s[i - 1] == "ld")){
	ans++;
      }
    }
    cout << ans << '\n';
  }
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        ans+=min(a*2, (k-a)*2);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
h,w = map(int,input().split())
 
table = [[0]*(w+1) for i in range(h+1)]
 
for row in range(h):
    work = list(map(int,input().split()))
    for col in range(w):
        table[row][col] = work[col]
 
 
for row in range(h):
    for col in range(0,w):
        table[row][w] += table[row][col]
 
 
for col in range(0,w+1):
    for row in range(0,h):
        table[h][col] += table[row][col]
 
 
for row in range(0,h+1):
    print("%d"%(table[row][0]),end="")
    for col in range(1,w+1):
        print(" %d"%(table[row][col]),end = "")
    print()


Measured memory_bytes: 6200
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  string S;
  cin >> S;
  
  if(S[0] == 'S' && S[1] == 'A'){
    cout << '1' << endl;
  }
  else if(S[0] == 'F'){
    cout << '2' << endl;
  }
  else if(S[0] == 'T' && S[1] == 'H'){
    cout << '3' << endl;
  }
  else if(S[0] == 'W'){
    cout << '4' << endl;
  }
  else if(S[0] == 'T' && S[1] == 'U'){
    cout << '5' << endl;
  }
  else if(S[0] == 'M'){
    cout << '6' << endl;
  }
  else if(S[0] == 'S' && S[1] == 'U'){
    cout << '7' << endl;
  }
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000

using namespace std;

int main(){
  int n,m;cin>>n>>m;
  vector<pi> ab(m);
  vector<vector<pi>> g(n, vector<pi>());
  rep(i, m){
    int a,b;cin>>a>>b; a--; b--;
    g[a].push_back( {1, b} );
    g[b].push_back( {1, a} );
  }

  priority_queue< pi, vector<pi>, greater<pi> > q;
  q.push({0,0});

  int nex[100001];
  rep(i, 100001)nex[i]=-1;
  ll d[100001];
  rep(i, n)d[i]=INF;
  d[0]=0;

  while(!q.empty()){
    auto p = q.top();q.pop();
    int from = p.second;
    int from_cost = p.first;

    if(d[from] < from_cost)continue;

    for(auto np: g[from]){
      int to = np.second;
      int cost = np.first;
      if(d[to] > d[from] + cost ){
        d[to] = d[from] + cost;
        q.push({d[to], to});
        nex[to] = from;
      }
    }
  }
  cout<<"Yes"<<endl;
//  rep1(i, n-1)cout<<i+1<<' '<<nex[i]+1<<endl;
  rep1(i, n-1)cout<<nex[i]+1<<endl;

  return 0;
}

Measured memory_bytes: 15564
n,m=map(int,input().split())
x=[0 for i in range(n)]
a=[0 for i in range(m)]
b=[0 for i in range(m)]
for i in range(m):
  a[i],b[i]=map(int,input().split())
  x[a[i]-1]+=1
  x[b[i]-1]+=1
for i in range(n):
  print(x[i])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#include<string.h>
#define inf 1000000000000000000
#define maxn 1000001
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
#define endl '\n'
#define mapint_iterator map<int,int> :: iterator
#define mapll_iterator map<ll,ll> :: iterator
#define setint_iterator set<int> :: iterator
#define setll_iterator set<ll> :: iterator
#define setpint_iterator set<pint> :: iterator
#define setpll_iterator set<pll> :: iterator
#define trace(x) cout<<#x<<": "<<x<<" "<<endl
#define trace2(x,y) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x,y,z) cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a,b,c,d) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define cout1(a) cout<<a<<endl
#define cout2(a,b) cout<<a<<" "<<b<<endl
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define cout4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define vcout(v,i) cout<<v[i].fi<<" "<<v[i].se<<endl
typedef priority_queue<ll,vector<ll>,greater<ll> > pqset;
typedef priority_queue<pint,vector<pint>,greater<pint> > pqset_ll;
#define pb push_back
#define fi first
#define se second
#include<ext/pb_ds/assoc_container.hpp>
ll dxk[]={0,0,1,-1,1,1,-1,-1};
ll dyk[]={1,-1,0,0,1,-1,1,-1};
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> os_pair;
#define mp make_pair
#define acc (ios::sync_with_stdio(false),cin.tie(0))
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>0;i--)
#define repeat(i,start,n) for(ll i=start;i<n;i++)
#define print(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" ";}
ll ll_max(ll a,ll b,ll c){return max(a,max(b,c));}
int int_max(int a,int b,int c){return max(a,max(b,c));}
ll ll_min(ll a,ll b,ll c){return min(a,min(b,c));}
int int_min(int a,int b,int c){return min(a,min(b,c));}
ll max(int a,ll b){ return max((ll)a,b);}
ll min(int a,ll b){ return min((ll)a,b);} 
ll min(ll a,int b){ return min(a,(ll)b);}
ll max(ll a,int b){ return max(a,(ll)b);}
//ifstream cin("b_read_on.txt"); ofstream cout("output3.txt");
//Chronology: Binary Search,Greedy,dp,dfs and similar
//Use (<<) for multiplication
//Use (>>) for division
// In dp, first try top-down,then bottom-up
//ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed;cerr.tie(NULL);cout.precision(10);
void solve(int countu){
	ll n;
	cin>>n;
	cout.precision(10);
	double dp[n][n+1];
	double p[n];
	rep(i,n)	
		cin>>p[i];
	dp[0][0]=1-p[0];
	dp[0][1]=p[0];
	repeat(i,1,n){
		dp[i][0]=dp[i-1][0]*(1-p[i]);
		repeat(j,1,i+2)
			dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
	}
	double tot=0;
	repeat(i,n/2+1,n+1)
		tot+=dp[n-1][i];
	cout1(tot);
}
int main(){
    int t=1;
	//cin>>t;
	int countu=1;
    while(t--){
    	solve(countu);
    	countu++;
    }
}

Measured memory_bytes: 70016
#include <iostream>
#include <vector>
#include <iomanip>

double dp[3003][3003];

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

	std::vector<double> p(n);
	for(int i = 0; i < n; ++i) {
		std::cin >> p[i];
	}

	dp[0][0] = 1;
	for(int omote = 0; omote <= n; ++omote) {
		for(int ura = 0; ura <= n; ++ura) {
			int usedCoin = omote + ura;
			if(usedCoin >= n) break;

			dp[omote + 1][ura] += dp[omote][ura] * p[usedCoin];
			dp[omote][ura + 1] += dp[omote][ura] * (1 - p[usedCoin]);
		}
	}

	double ans = 0;

	for(int omote = n / 2 + 1; omote <= n; ++omote) {
		int ura = n - omote;
		ans += dp[omote][ura];
	}

	std::cout << std::fixed << std::setprecision(12) << ans << std::endl;
}

Measured memory_bytes: 70016
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
int main()
{
    ll a,b,k;
    a=read(),b=read(),k=read();
    if(a>=k)a-=k;
    else
    {
        k-=a;a=0;
        if(b>=k)b-=k;
        else b=0,k=0;
    }
    cout<<a<<" "<<b<<"\n";
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> h(n+1);
  for (int i = 1; i <= n; i++)
  {
    cin >> h[i];
  }

  vector<int> dp(n+1);
  dp[2] = abs(h[2]-h[1]);
  for (int i = 3; i <= n; i++)
  {
    dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]));
  }
  cout << dp[n] << endl;  
}

Measured memory_bytes: 1024
N, K = map(int,input().split())
p = list(map(int,input().split()))
a = []
for e in p:
    a.append((e*(e+1)/2)/e)
ans = sum(a[:K])
temp = ans
for i in range(N-K):
    temp -= a[i]
    temp += a[i+K]
    ans = max(ans,temp)
print(ans)


Measured memory_bytes: 77448
#pragma gcc optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i=(ll)(r);i<(ll)(n);++i)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define pb(n) push_back(n)
#define endl '\n'
#define P(x) cout << #x << " = " << (x) << endl
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c
#define VIN(V) for(int ii = 0; ii < (V).size(); ii++) {cin >> (V).at(ii);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(ii,(V).size()){cout << (V)[ii] << " ";} cout<<endl;
#define VOUT2(V) REP(jj,(V).size()){VOUT(V[jj])}
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<vi > vvi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
ll n, m, k, ans, sum, cnt = 0; string s; char c;

int main(){
  cin.tie(0);ios::sync_with_stdio(false);
  IN(n);
  FOR(i,0,100) {
    FOR(j,0,100) {
      if (n == i*4 + j * 7) {
        OUT("Yes");
        return 0;
      }
    }
  }
  OUT("No");
}


Measured memory_bytes: 256