akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define N 200010
#define mod 1000000007
using namespace std;

inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
inline int qpow(int bas,int pw)
{
	int res=1; for(;pw;pw>>=1,bas=1ll*bas*bas%mod)
		if(pw&1) res=1ll*res*bas%mod; return res;
}
inline void add(int &x,int y)
{
	x+=y; if(x>=mod) x-=mod;
	if(x<0) x+=mod;
}
int n,fac[N],pre[N],sum;
inline int deal(int x)
{
	return (1ll*pre[x]+1ll*pre[n-x+1]-1ll+mod)%mod;
}
int main()
{
	fac[0]=1; for(int i=1;i<N;i++)
		fac[i]=1ll*fac[i-1]*i%mod;
	pre[0]=pre[1]=1;
	for(int i=2;i<N;i++) 
		pre[i]=(1ll*pre[i-1]+qpow(i,mod-2))%mod;
	cin >> n;
	// for(int i=1;i<=n;i++) printf("%d ",fac[i]); puts("");
	// for(int i=1;i<=n;i++) printf("%d ",pre[i]); puts("");
	for(int i=1;i<=n;i++)
	{
		int x; cin >> x;
		add(sum,1ll*x*deal(i)%mod);
	}
	cout << 1ll*sum*fac[n]%mod << endl;
	return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define pb push_back
int main(){
    int n;
    int y;
    cin >> n >> y;
    rep(i,n+1){
        rep(j,n+1){
            int k = n - i - j;
            if(k<0){
                continue;
            }
            if(10000*i+5000*j+1000*k==y){
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i] >>y[i];
typedef long long int ll;
using namespace std;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }

int main(){
	int n,m,x; cin >>n>>m;
	vector <pair<ll,ll> >a(n);
	vector<ll> b(m),c(m);
	for(int i=0;i<n;i++){
		cin>>x;
		a[i]=make_pair(x,1);
	}
	cinf(m,b,c);
	for(int i=0;i<m;i++){
		a.push_back(make_pair(c[i],b[i]));
	}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	ll cnt=0;
	for(int i=0;;i++){
		if(n<=a[i].second){
			cnt+=n*a[i].first;
			cout << cnt << endl;
			return 0;
		}
		else{
			cnt+=a[i].second*a[i].first;
			n-=a[i].second;
		}
	}
}

Measured memory_bytes: 8544
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    sort(ALL(a));
    pair<int,int> ans = {a[n-1],0};
    int diff = INT_MAX;
    REP(i,n-1) {
        int tmp = abs(2*a[i] - ans.first);
        if(diff>tmp) {
            diff = tmp;
            ans.second = a[i];
        }
    }
    cout << ans.first << ' ' << ans.second << endl;
    return 0;
}

Measured memory_bytes: 640
package main

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

const inf = 1 << 60

func main() {
	n := getInt()
	as := make([]int, n)
	for i := range as {
		as[i] = inf
	}
	bs := getIntSlice(n - 1)

	for i, b := range bs {
		as[i] = min(as[i], b)
		as[i+1] = min(as[i+1], b)
	}

	ans := sum(as...)
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func sum(ns ...int) int {
	var sum int
	for _, n := range ns {
		sum += n
	}
	return sum
}

// -----------------------------------------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
    double a, b, c, d, e, f;

    while(scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF)
    {
        double g = -1 * e / b;
        double h = -1 * d / a;

        printf("%.3lf %.3lf\n", (g * c + f) / (g * a + d) + 0.0004, (h * c + f) / (h * b + e) + 0.0004);
    }

    return 0;
}

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

int main(){
    string S;
    int ans = 0;
    cin >> S;

    if(S.at(0) == 'R'){
        ans++;
        if(S.at(1) == 'R'){
            ans++;
            if(S.at(2) == 'R'){
                ans++;
            }
        }
    } else if(S.at(1) == 'R'){
        ans++;
        if(S.at(2) == 'R'){
            ans++;
        }
    } else if(S.at(2) == 'R'){
        ans++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<stdlib.h>

#define MIN(a,b) ((a)<(b)?(a):(b))

#define POS(i,j) ((i)*(h+1)+(j))

void run(void){
  int h,w;
  scanf("%d%d",&h,&w);
  char *s=(char *)calloc(h*w+1,sizeof(char));
  int i,j,k;
  for(i=0;i<h;i++) scanf("%s",s+i*w);
  char *x=(char *)calloc(h,sizeof(char));
  char *y=(char *)calloc(h,sizeof(char));
  int *cost=(int *)calloc((h+1)*(h+1),sizeof(int));
  int *dp=(int *)calloc((h+1)*(h+1),sizeof(int));
  int ans=0;
  for(i=0;i+1<w;i++){
    for(j=0;j<h;j++){
      x[j]=s[j*w+i];
      y[j]=s[j*w+i+1];
    }
    for(j=1;j<=h;j++){
      for(k=1;k<=h;k++){
	cost[POS(j,k)]=cost[POS(j-1,k-1)]+(x[j-1]==y[k-1]?1:0);
	dp[POS(j,k)]=MIN(dp[POS(j-1,k)],dp[POS(j,k-1)])+cost[POS(j,k)];
      }
    }
    ans+=dp[POS(h,h)];
  }
  printf("%d\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize(-O3)
#pragma GCC optimize(0fast)
#pragma GCC optimize("unroll-loops")

#define fi first
#define se second
#define sqr(x) (x) * (x)
#define p_b push_back
#define m_p make_pair
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()
#define pw(x) (1ll << x)

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
const ll MAXN = 1123456;
const ll N = 1e6;
const ll MOD = 1e9 + 7;

template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename T> void vout(T s){cout << s << endl; exit(0);}


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

    string s;
    cin >> s;

    for(int i = 1; i < 4; i++)if(s[i] == s[i - 1])vout("Bad");
    vout("Good");

    return 0;
}


Measured memory_bytes: 256
/*
    Author : DemonStar
*/

#pragma GCC optimize("Ofast")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define loop(i, n) for(ll i = 0; i < n; i++)
#define pl pair<ll, ll>
#define vl vector<ll>
#define endl '\n'
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

template <typename T, typename TT>
ostream &operator<<(ostream &os, const pair<T, TT> &t) {
    return os << t.first << " " << t.second;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &t) {
    for (auto &i : t) os << i << " ";
    return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &t : v) is >> t;
    return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, vector<pair<T1, T2>> &v) {
    for (pair<T1, T2> &t : v) is >> t.first >> t.second;
    return is;
}

const ll mod = 1e9 + 7;

int main()
{

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    fast;
    ll l, r, d;
    cin >> l >> r >> d;
    ll ans = 0;
    for (int i = d; i <= r; i += d) if (l <= i and i <= r) ans++;
    cout << ans << endl;




#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s";
#endif

    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double dd;
const int N = 1e5+5;
const dd eps = 1e-8;
const int mod = 998244353;

int n,s,dp[3005],a[3005],now,ans;

int main(){
  ios::sync_with_stdio(false);
  // freopen("input.txt","r",stdin);
  cin>>n>>s;
  while(n--){
    cin>>now;
    dp[0]++;
    for(int i = s-now;i >= 0;i--){
      dp[i+now] = (dp[i+now]+dp[i])%mod;
    }
    ans = (ans+dp[s])%mod;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R


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

	int ans = 0;
	cin >> H >> W >> K;
	vector<string>v(H);
	for (auto &i : v)cin >> i;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			vector<vector<int>>w(W);
			for (int k = H - 1; k >= 0; k--) {
				for (int l = 0; l < W; l++) {
					if (i == k && j == l)continue;
					w[l].push_back(v[k][l] - '0');
				}
			}
			int box = 0;
			for (int k = 0; k < H; k++) {
				for (int l = H - 1; l >= 0; l--) {
					int st = W;
					for (int m = 0; m < W; m++) {
						if (w[m].size() > l) {
							st = m;
							break;
						}
					}
					for (int m = st + 1; m < W; m++) {
						if (w[m].size() <= l) {
							if (m - st >= K) {
								box += ((m - st)*w[st][l]) << k;
								for (int n = st; n < m; n++) {
									w[n].erase(w[n].begin() + l);
								}
							}
							st = m + 1;
							continue;
						}
						if (w[st][l] != w[m][l]) {
							if (m - st >= K) {
								box += ((m - st)*w[st][l]) << k;
								for (int n = st; n < m; n++) {
									w[n].erase(w[n].begin() + l);
								}
							}
							st = m;
							continue;
						}
					}
					if (W - st >= K) {
						box += ((W - st)*w[st][l]) << k;
						for (int n = st; n < W; n++) {
							auto it = w[n];
							w[n].erase(w[n].begin() + l);
						}
					}
				}
			}
			ans = max(ans, box);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trv(a) cerr<<#a<<":\n";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define mod 1000000007
#define inf 9999999999999999ll

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	map <string,ll> m;
	ll an=0;
	for(ll i=0;i<n;i++)
	{
		string s;
		cin>>s;
		m[s]++;
		an=max(an,m[s]);
	}
	set <string> ans;
	for(auto &i:m)
	{
		if(i.S==an)
		{
			ans.insert(i.F);
		}
	}
	for(auto &i:ans)
	{
		cout<<i<<"\n";
	}
}


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

int main()
{
    int a, b, c;
    map<int, int> m;
    cin >> a >> b >> c;
    m[a]++, m[b]++, m[c]++;
    if(m[5] == 2 && m[7] == 1)  cout << "YES" << endl;
    else                        cout << "NO" << endl;
    return 0;
}


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

int main() {

    int n, a;
    std::cin >> n;

    int         min = INT_MAX;
    int         max = INT_MIN;
    long long   sum = 0;

    for ( int i = 0; i < n; i++ ) {

        std::cin >> a;

        if ( a < min )  min  = a;
        if ( a > max )  max  = a;
                        sum += a;
    }

    std::cout << min << " ";
    std::cout << max << " ";
    std::cout << sum << std::endl;

    return 0;
}



Measured memory_bytes: 3104
n = int(input())
s = []
t = []
for _ in range(n):
    si, ti = input().split()
    s.append(si)
    t.append(int(ti))
x = input()
ans = sum(t)
for i in range(n):
    ans -= t[i]
    if s[i] == x:
        break
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
#define test cout<<"test"<<endl;
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
void debug(vector<vector<ll>>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j]<<" ";cout<<endl;}};
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}
//m.emplace(x,0).fi->second++;
 
int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n),b(n);
  for(i=0;i<n;i++){
    cin>>a[i];
    b[i]=a[i];
    
  }
  sort(ALLR(b));
  for(i=0;i<n;i++){
    if(a[i]==b[0])cout<<b[1]<<endl;
    else cout<<b[0]<<endl;
  }
 
 
  return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <tuple>
#include <stdbool.h>
#include <bitset>
#include <string>
#include <boost/multiprecision/cpp_int.hpp>

namespace mp = boost::multiprecision;
using namespace std;

int mizuyari(vector<int> h) {
    // 0が含まれない区間で分割統治する
    // for(const auto& x : h) {
    //     cout << x << ", ";
    // }
    // cout << endl;

    int count = 0;
    for(int i = 0 ; i < h.size() ; ) {
        if (!h[i]) {
            i++;
            continue;
        }
        vector<int> sub; // 分割統治するvector
        int j;
        for(j = i ; j < h.size() ; ++j ) {
            if(!h[j]) {
                break;
            } else {
                sub.push_back(h[j] - 1); // 水やりする
            }
        }
        // (i, j]区間でいける
        count++; // 今回の水やり分
        count += mizuyari(sub); // 水をやった後の残りはまかした
        // 後処理
        i = j;
    }
    return count;
}

int main(void) {
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0 ; i < n ; ++i) {
        cin >> h[i];
    }
    auto ans = mizuyari(h);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
#include <bitset>
#include <string>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)


ll modpow(ll x, ll n) {
    if (n == 0) {
        return 1;
    } else if (n % 2 == 0) {
        ll h = modpow(x, n / 2);
        return h * h % MOD;
    } else {
        return x * modpow(x, n - 1) % MOD;
    }
}

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

int main() {
    int A, B; cin >> A >> B;
    string ans = "No";
    if(A*B%2) ans = "Yes";

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    if (n % 2 != 0) {
        cout << "No" << "\n";
    } else {
        bool ok = true;
        for (int i = 0; i < n/2; ++i) {
            if (s[i] != s[i+n/2])
                ok = false;
        }
        if (ok)
            cout << "Yes" << "\n";
        else
            cout << "No" << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
'use strict';
const p = s => console.log(s);
// let a,b,c,d;
// [a,b,c,d] = input[0].trim().split(" ").map(i => parseInt(i));

function main(input) {
  let A = input[0].trim().split(" ")[0];
  let B = input[0].trim().split(" ")[1];

  p(A * B);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));


Measured memory_bytes: 29636
fn main() {
    let nk = read_vec::<usize>();
    let mut p = read_vec::<usize>();
    p.sort();
    let mut ret = 0;
    for i in 0..nk[1] {
        ret += p[i];
    }
    println!("{}", ret);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

using namespace std;

int main() {
    int w, h;
    cin >> w >> h;
    int x, y, r;
    cin >> x >> y >> r;
    if (x + r <= w && x - r >= 0 && y + r <= h && y - r >= 0) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }
}


Measured memory_bytes: 3072
// clang-format off

#include <bits/stdc++.h>

#define int long long

#define main signed main()

// #define main int main()

#define loop(i, a, n) for (int i = (a); i < (n); i++)

#define rep(i, n) loop(i, 0, n)

#define all(v) (v).begin(), (v).end()

#define rall(v) (v).rbegin(), (v).rend()

#define prec(n) fixed << setprecision(n)

#define stlice(from, to) substr(from, (to) - (from) + 1)

#define pb push_back

#define mp make_pair

#define mt make_tuple

#define fi first

#define se second

using namespace std;

typedef pair<int, int> pii;

typedef vector<int> vi;

typedef vector<double> vd;

typedef vector<char> vc;

typedef vector<bool> vb;

typedef vector<string> vs;

typedef vector<pii> vpii;

typedef vector<vi> vvi;

typedef vector<vb> vvb;

typedef vector<vpii> vvpii;

const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;

const int MOD = 1000000007;

const double PI = acos(-1);

template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }

template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }

bool odd(const int &n) { return n & 1; }

bool even(const int &n) { return !odd(n); }

void solve();

main { solve(); return 0; }

// clang-format on



void solve() {

  int n, m;

  cin >> n >> m;

  vi e(m);

  rep(i, m) cin >> e[i];

  reverse(all(e));

  vi used(n + 1);

  queue<int> oq;

  for (int &x : e) {

    if (used[x]) continue;

    used[x] = true;

    oq.emplace(x);

  }

  loop(i, 1, n + 1) if (!used[i]) oq.emplace(i);

  while (oq.size()) cout << oq.front() << endl, oq.pop();

}

Measured memory_bytes: 6764
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define per(i,r,l) for(int i=r;i>=l;i--)
#define IMAX 0x3f3f3f3f
#define LLMAX 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef double db;
inline int read() {
  int x=0,f=1;
  char c=getchar();
  while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
  while(isdigit(c)){x=x*10+c-'0';c=getchar();}
  return x*f;
}
int n;
ll sum;
signed main() {
  n=read();
  rep(i,1,n){
    if(i%3!=0&&i%5!=0){
      sum+=i;
    }
  }
  printf("%lld\n",sum);
  return 0;
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3") 
#pragma GCC optimization ("unroll-loops")
 
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
// const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// gp_hash_table<int, int> table;
 
#define ll  long long
#define vii vector< ll >
#define pb push_back
#define pii pair<ll,ll>
#define ppi pair<pii,ll>
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define ins insert
#define ld long double
#define lp(l,r) for(i=l;i<=r;++i)
 
#define lpj(l,r) for(j=l;j<=r;++j)
#define lpr(l,r) for(i=r;i>=l;--i)
#define lprj(l,r) for(j=r;j>=l;--j)
 
#define swap(a,b){ auto _t=a;a=b,b=_t;}
#define flush() cout.flush()
#define popcount __builtin_popcount
#define die() return 0;
#define sz() size() 


 
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define MD          1000000007
#define M 			200011
#define LN             14
#define fftmod      998244353
#define EPS         (double)1e-10
 
long long  md=MD;
ll inf=1e18;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
 
 
inline ll exp(ll a,ll b){if(a==0&&b==0)return 1ll;if(a==0)return 0ll;ll r=1LL;while(b>0){if(b&1){r=(r%md)*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;if(a==0)return b;return gcd(b,a%b);}
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (ll)r;}
 
using cd=complex<double>;
const double PI=acos(-1);
 
inline ll rand(ll l,ll r){
    return l+rng()%(r-l+1);
}


int main(){
 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
 
   // ifstream fin("input.txt");ofstream fout("outut.txt");
    ll t,i,j,m,n,s,z,k,p;string s1,s2;ll q;ll x,y;
    cin>>n;
    vector<ld> v;
    lp(1,n){
    	ld c;cin>>c;v.pb(c);
    }
    sort(all(v));
    ld d=0.5;
    ld ans=0;
    while(v.size()){
    	ans+=v.back()*d;
    	v.pop_back();
    	if(v.sz()>=2)d*=0.5;
    }
    cout<<setprecision(14)<<ans<<"\n";


    





    	






    

}



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

int main() {
	int N,Z,W;
	cin >> N >> Z >> W;
	vector<int> a(N);

	rep(i,N)
		cin >> a.at(i);

	if(N == 1)
		cout << abs(a.at(0)-W);
	else
		cout << max(abs(a.at(N-1)-W), abs(a.at(N-2)-a.at(N-1)));
	cout << endl;
}

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

int main() {
    int a, b, c;
    cin >> a;
    cin >> b;
    cin >> c;
    if (a == b && a != c) {
        cout << "Yes" << endl;
    }
    else if (a != b && a == c) {
        cout << "Yes" << endl;
    }
    else if (b == c && a != b) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

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

using namespace std;

int main(){
	int n; cin>>n;
	int d=0,t=n;
	while(t>0) d+=t%10, t/=10;
	cout<<(n%d==0?"Yes":"No")<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
typedef pair<int, int> pi;
vector<bool> use;
int main(void) {
    int k; cin >> k;
    use.resize(k, false);
    deque<pi> q;
    q.push_back(make_pair(1, 1));
    while(!q.empty()) {
        pi p = q.front(); q.pop_front();
        if (p.first == 0) {
            cout << p.second << endl;
            return 0;
        }
        if (use[p.first]) continue;
        use[p.first] = true;
        q.push_front(make_pair(p.first * 10 % k, p.second));
        q.push_back(make_pair((p.first + 1) % k, p.second + 1));
    }
    return 0;
}





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

int main(){
	ll n,k;
	cin >> n >> k;
	vector<ll> v(n);
	rep(i,n){
		cin >> v[i];
	}
	
	ll ans = 0;
	
	for (int A = 0; A <= min(n,k) ; ++A) {
		for (int B = 0; B <= min(n,k) - A ; ++B) {
			vector<ll> temp;
			rep(i,A){
				temp.push_back(v[i]);
			}
			rep(i,B){
				temp.push_back(v[n-1-i]);
			}
			sort(temp.begin(),temp.end());
			ll trash = k - A - B;
			ll value = 0;
			ll l = temp.size();
			rep(i,l){
				value += temp[i];
			}
			rep(i,min(l, trash)){
				if(temp[i] < 0){
					value -= temp[i];
				}
			}
			ans = max(ans, value);
		}
	}
	
	cout << ans << endl;
	
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long n,v,ans=0;
    map <long long,long long> b;
    cin>>n>>v;
    long long a[4][n];
    f(i,0,4){
        f(j,0,n){
            cin>>a[i][j];
        }
    }
    f(i,0,n){
        f(j,0,n){
            b[a[0][i]+a[1][j]]++;
        }
    }
    f(i,0,n){
        f(j,0,n){
            ans+=b[v-a[2][i]-a[3][j]];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 128076
#include <iostream>
#include <string>
using namespace std;
int main (){
    int A,B,i;
    cin >> A >> B;
    string S;
    cin >> S;
    int C;
    int No=0;
    if(S[A]!='-'){
        No = 1;
    }
    while(S[i]){
        i++;
    }
    if(i != A+B+1){
        
        No=10;
    }
        for (i = 0 ;i < A;i++){
            C = int(S[i]-'0');
            if (C > 9 || C < 0){
                No=2;
        }
            
        }
            for ( i = 0 ;i < B;i++){
                C = int(S[i+A+1]-'0');
                if (C > 9 || C < 0){
                    No=5;
                }
    }
            
            if(No == 0){
                cout << "Yes";
            }else{
                cout << "No";
            }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int ans = 0;
    string S;
    cin >> S;
    for (int i = 0; i < 4; i++) {
        if (S[i] == '+') {
            ans++;
        } else if (S[i] == '-') {
            ans--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <chrono>
#include <numeric>

using namespace std;


int main(){
  string s;
  cin >> s;
  for (int i=0;i<s.length()-1;i++) {
    if (s[i] == 'A' && s[i+1] == 'C') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String A=sc.next();
		String B=sc.next();
		String C=sc.next();
		int[] stats=new int[3];
		char next='a';
		int[] max=new int[3];
		max[0]=A.length();
		max[1]=B.length();
		max[2]=C.length();
		for(int i=0; i<3; i++) {
			stats[i]=0;
		}
		next=A.charAt(0);
		stats[0]++;
		while(true) {
			char old=next;
			if(next=='a') {
				if(stats[0]<max[0]) {
					next=A.charAt(stats[0]);
					stats[0]++;
				}
				else {
					System.out.println("A");
					System.exit(0);
				}
			}
			else if(next=='b') {
				if(stats[1]<max[1]) {
					next=B.charAt(stats[1]);
					stats[1]++;
				}
				else {
					System.out.println("B");
					System.exit(0);
				}
			}
			else if(next=='c') {
				if(stats[2]<max[2]) {
					next=C.charAt(stats[2]);
					stats[2]++;
				}
				else {
					System.out.println("C");
					System.exit(0);
				}
			}
		}
	}
}

Measured memory_bytes: 23764
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include <initializer_list>
#include<unordered_set>
#include<map>
#include<cmath>
#include <iterator>
#include<stack>
#include<queue>
#include <iomanip>
#include<math.h>
#include <limits.h>
#include <numeric>
#include <functional>
#include<fstream>
using namespace std;

#define mod  
#define ll  long long
#define endl "\n"
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int x, mx = 0, c = 0;
	cin >> x;
	int* y = new int[x];
	int* q = new int[x];
	for (int i = 0; i < x; i++) {
		cin >> y[i];
		q[i] = y[i];
		if (mx < y[i])
		{
			mx = y[i];
			c = 0;
		}
		if (mx == y[i])
			c++;
	}
	sort(q, q + x);
	for (int i = 0; i < x; i++) {
		if (y[i] != mx)
			cout << mx << endl;
		else if (c == 1)
			cout << q[x - 2] << endl;
		else
			cout << mx << endl;
	}
	return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define RREP(i, a, n) for(int i=n-1; i>=a; i--)
#define INF 100000000
#define ll long long

int main()
{
	int cat_flag = false;
	string S;
	cin >> S;

	if (S == "") cat_flag = true;
	else if (S.size() % 3 == 0) {
		bool flag = true;

		while (flag) {
			flag = false;
			
			int x = S.find("mew", 1);
			if (x != -1) {
				if (x < S.size() - 3) {
					S.replace(x, 3, "");
					flag = true;
				}
			}
		}
		if (S == "mew") cat_flag = true;
	}

	if (cat_flag) cout << "Cat" << endl;
	else cout << "Rabbit" << endl;
	return 0;
}

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

int main(){
    string s1,s2,s3,x;
    cin >> s1 >> s2 >> s3;
    x += toupper(s1[0]);
    x += toupper(s2[0]);
    x += toupper(s3[0]);
    
    cout << x << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define oo 1000000010
#define mod 1000000007
const int N = 1010;
int n , m , a , b;
char grid[N][N];

int cur[N];

int needed[N];

void make(int a,int b,int c,int d){
	for(int i = 0 ;i < c;i++)
		needed[i] = d;
	for(int i = c;i < m;i++)
		needed[i] = (n - d);
	int cur;
	for(int i = 0 ;i < n;i++){
		cur = (i < a ? b : m - b);
		for(int j = 0 ;j < m && cur > 0;j++){
			if(needed[j] > 0){
				needed[j]--;
				grid[i][j] = '1';
				cur--;
			}
		}
	}
	for(int i = 0 ;i < n;i++)
		puts(grid[i]);
	exit(0);
	
}

int main(){
	cin >> n >> m >> a >> b;
	for(int i =0 ;i < n;i++){
		for(int j = 0 ;j < m;j++) grid[i][j] = '0';
		grid[i][m] = '\0';
	}
	int z , z2 , o , o2;
	for(int i = 0 ;i <= n;i++){
		for(int j = 0;j <= m;j++){
			z = a * i + (m - a) * (n - i);
			z2 = b * j + (n - b) * (m - j);
			if(z == z2){
				make(i , a , j , b);
			}
		}
	}
	puts("-1");
    return 0;
}

Measured memory_bytes: 2176
#include<stdio.h>

int main(){
 
  int n,x,t;//n全部のたこ焼き x焼けるたこ焼き
  int i,a,ans=0;
  
  scanf("%d%d%d",&n,&x,&t);
  
  for(i = 0; i < 10000; i++){
    
    n = n - x;
    ans += t;
    
    //printf("n = %d t = %d\n",n,t);   
    if(n <= 0){
       
      printf("%d\n",ans);
      return 0;
    }
    
  }
  
  
  
  return 0;
  
}



Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
void manager_no(){
    int A[200010]={};
    int ans[200010]={};
    int n; cin >> n;
    int a;
    for(int i=2;i<=n;i++){
        cin >> A[i];
        ans[A[i]]++;
    }
    /*for(int i=1;i<=n;i++){
        ans[A[i]]++;
    }*/
    for(int i=1;i<=n;i++){
        cout << ans[i] << endl;
    }
}

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

Measured memory_bytes: 5136
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 3e5+10;
const ll mod =   1e9+7;
#define pi 3.14159265358979323846264338327950L

int main()
{  fast

int a,b,h,m;
cin>>a>>b>>h>>m;
long double rad=pi*2*((long double)h/12.0+((long double)m/60.0)/12.0-
(long double)m/60.0);
long double rs=(long double)(a*a+b*b)-(long double)(2*a*b)*cosl(rad);
cout<<fixed<<setprecision(20)<<sqrtl(rs);



}

Measured memory_bytes: 4176
#include <stdio.h>
#include <stdlib.h>

int compare_ints(const void* a, const void* b)
{
    int arg1 = *(const int*)a;
    int arg2 = *(const int*)b;
 
    if (arg1 < arg2) return -1;
    if (arg1 > arg2) return 1;
    return 0;
}

int	main(void)
{
  	int	n;
  	int k;
  	int	p[1001];
  	int	i;
  	int	sum;
  
  	scanf("%d %d\n", &n, &k);
  	for(i=0;i<n;i++)
    {
      	scanf("%d", &p[i]);
    }
  
  	qsort(p, n, sizeof(int), compare_ints);
  
  	sum = 0;
  	for(i=0; i<k; i++)
    {
      	sum += p[i];
    }
  	printf("%d", sum);
  	return (0);
}

Measured memory_bytes: 1748
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int L,A,B,C,D;
	scanf("%d %d %d %d %d",&L,&A,&B,&C,&D);
	if(A%C==0)
	{
		A/=C;
	}
	else
	{
		A=A/C+1;
	}
	if(B%D==0)
	{
		B/=D;
	}
	else
	{
		B=B/D+1;
	}
	C=max(A,B);
	printf("%d\n",L-C);
	return 0;
}


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

void main(){
  int num = to!int(chomp(readln()));
  int[] result = new int[num];
  for(int i = 0; i < num; ++i){
    string[] input = split(readln());
    int[] sides = new int[3];
    for(int j = 0; j < 3;j++){
      sides[j] = to!int(input[j]);
    }
    sort(sides);
    if(sides[2]*sides[2] == sides[1]*sides[1] + sides[0]*sides[0]){
      writeln("YES");
    } else{
      writeln("NO");
    }
  }
}

Measured memory_bytes: 2384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int ans=0;
    int l,r,n;
	cin>>l>>r>>n;
	for(int i=l;i<=r;i++){
        if(i%n==0) ans++;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3632
import calendar as C
j=0
while 1:
    a,b=map(int, input().split())
    if a==0:break
    if j:print()
    j=1
    if sum([1 for i in range(a,b+1) if C.isleap(i)])==0:
        print("NA")
    else:
        for i in range(a,b+1):
            if C.isleap(i):print(i)

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
int main(){
  int r,g,b,k;
  cin>>r>>g>>b>>k;
  string s = "No";
  for(int i=0; i<k+1; i++){
    if(b>g && g>r){
    	s="Yes";
      	break;
    }
    
  	else if(b>=r && r>=g){
    	g*=2;
    }
    else if(g>=b && b>=r){
    	b*=2;
    }
    else if(r>=b && b>=g){
    	b*=2;
    }
    else if(r>=g && g>=b){
    	b*=2;
    }
    else if(g>=r && r>=b){
    	b*=2;
    }
  }
  cout<<s;
  
return 0;}

Measured memory_bytes: 3588
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<cstring>
#define ll long long
using namespace std;
const int N=100005;

int n,k,a[N],ans=1<<30,p,K;

inline int Get(int x){
	return x/K+(x%K?1:0);
}

inline void solve(){ 
	for(int i=max(1,p-k+1),j=i+k-1;j<=n;i++,j++){
		ans=min(ans,1+Get(i-1)+Get(n-j));
	}
}

int main(){
	scanf("%d%d",&n,&k),K=k-1;
	for(int i=1;i<=n;i++){
	    scanf("%d",a+i);
	    if(a[i]==1) p=i;
	}
	
	solve();
	
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
/*
	Karya anak bangsa yang paling agung
	Author : Yohandi or... bukan..
*/

#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define endl "\n"

#define all(a) a.begin(),a.end()
#define lb(a,x) (lower_bound(all(a),x)-a.begin())
#define ub(a,x) (upper_bound(all(a),x)-a.begin())

#define rep(a,x,y) for(int a=(int)x;a<=(int)y;++a)
#define repd(a,x,y,d) for(int a=(int)x;a<=(int)y;a+=d)
#define res(a,x,y) for(int a=(int)x;a>=(int)y;--a)
#define resd(a,x,y,d) for(int a=(int)x;a>=(int)y;a-=d)

// Ordered Set, Ordered Multiset
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define o_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define o_multiset tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
// .order_of_key(x) -> Number of elements less than x
// * .find_by_order(k) -> Kth smallest element (0-based)
// .erase(x) -> Remove all elements equal to x

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

using namespace std;
using lint=long long;

mt19937 rng(time(NULL));

lint Power(lint A,lint B,lint C){
	if(!B) return 1LL;
	lint tmp=Power(A,B>>1,C);
	return tmp*tmp%C*(B&1?A:1)%C;
}

int T;

int main(){
//	ios_base::sync_with_stdio(0);
//	cin.tie(0); cout.tie(0);
	T=1;
//	cin>>T;
	rep(t,1,T){
        int N,M;
        cin>>N>>M;
        vector<int> Edg[N+1];
        for(int i=1;i<=M;++i){
            int A,B;
            cin>>A>>B;
            if(B!=1) Edg[A].pb(B);
            if(A!=1) Edg[B].pb(A);
        }
        int Par[N+1];
        for(int i=1;i<=N;++i) Par[i]=i;
        queue<int> Bfs;
        Bfs.push(1);
        while(!Bfs.empty()){
            for(auto i:Edg[Bfs.front()]){
                if(Par[i]==i){
                    Par[i]=Bfs.front();
                    Bfs.push(i);
                }
            }
            Bfs.pop();
        }
        bool Ok=1;
        for(int i=2;i<=N&&Ok;++i){
            if(Par[i]==i) Ok=0;
        }
        if(Ok){
            cout<<"Yes\n";
            for(int i=2;i<=N;++i) cout<<Par[i]<<"\n";
        } else {
            cout<<"No\n";
        }
	}
	return 0;
}




Measured memory_bytes: 10352
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, const char * argv[]) {
    int N = 0;
    cin >> N;

    vector<int> ps(N, 0);
    for(int i = 0; i < N; i++) {
        cin >> ps[i];
    }

    for(int i = 0; i < N; i++) {
        if(ps[i] == i+1) {
            continue;
        }

        // 以下で ps[i] と ps[ps[i]-1] を入れ替える
        int swp_i1 = i;
        int swp_i2 = ps[i] - 1;

        swap(ps[swp_i1], ps[swp_i2]);
        if(ps[swp_i1] != swp_i1+1) {
            cout << "NO" << endl;
            return 0;
        }
        if(ps[swp_i2] != swp_i2+1) {
            cout << "NO" << endl;
            return 0;
        }

        break;
    }

    for(int i = 0; i < N; i++) {
        if(ps[i] != i+1) {
            cout << "NO" << endl;
            return 0;
        }
    }
    /*
     vector<bool> done(N, false);
    for(int i = 0; i < N; i++) {
        if(ps[i] == i+1) {
            continue;
        }

        // 以下で ps[i] と ps[ps[i]-1] を入れ替える
        int swp_i1 = i;
        int swp_i2 = ps[i] - 1;

        if(done[swp_i1] || done[swp_i2]) {
            cout << "NO" << endl;
            return 0;
        }

        swap(ps[swp_i1], ps[swp_i2]);
        if(ps[swp_i1] != swp_i1+1) {
            cout << "NO" << endl;
            return 0;
        }
        if(ps[swp_i2] != swp_i2+1) {
            cout << "NO" << endl;
            return 0;
        }

        done[swp_i1] = true;
        done[swp_i2] = true;
        if(replaced) {
            cout << "NO" << endl;
        }
    }*/
    cout << "YES" << endl;
    return 0;
}

/**
 cheat sheet

 vector<int> v{ 1, 5, 8, 9, 6, 7, 3, 4, 2, 0 };
 sort(v.begin(), v.end());
 => 0 1 2 3 4 5 6 7 8 9

 vector<int> v{ 1, 5, 8, 9, 6, 7, 3, 4, 2, 0 };
 sort(v.begin(), v.end(), greater<int>());
 => 9 8 7 6 5 4 3 2 1 0

 struct A { int x, y; };
 bool comp(A i1, A i2) { return (i1.y < i2.y); }
 vector<A> v { { 6, 8 }, { 1, 9 }, { 2, 4 }, { 4, 7 } };
 sort(v.begin(), v.end(), comp);
 => [1, 9] [2, 4] [4, 7] [6, 8]

 */


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

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

int main(){
    int n;
    int ans = 0;
    cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                int t;
                if(j>k){
                    t = gcd(j,k);
                    if(t>i){
                        ans+=gcd(t,i);
                    }
                    else{
                        ans+=gcd(i,t);
                    }
                }
                else {
                    t = gcd(k,j);
                    if(t>i){
                        ans+=gcd(t,i);
                    }
                    else{
                        ans+=gcd(i,t);
                    }
                }
            }
        }
    }
    cout<<ans;
    return 0;
}


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

const int INF = 1e9 + 10;

int X, N;


int main() {
    cin >> X >> N;
    vector<int> p(N);
    rep(i,N) cin >> p[i];
    auto it = find(p.begin(), p.end(), X);
    if (it == p.end()) {
        cout << X << endl;
        return 0;
    }
    int diff = 1005;
    int res = 1005;
    rep(i,102) {
        it = find(p.begin(), p.end(), i);
        if (it == p.end() && abs(X - i) < diff) {
            diff = abs(X - i);
            res = i;
        }
    }
    cout << res << endl;
}

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

int main(){
	string a, b;
	cin >>a >> b;
	
	int zh(string x);
	int c;
	a+=b;
	c=zh(a);
	
	if(int(sqrt(c))==sqrt(c))  cout<<"Yes";
	  else  cout<<"No";
	
	return 0;
}

int zh(string x){
	int c=0,i;
	for(int i=0;i<x.size();i++)  c=c*10+(x[i]-'0');
	return c;
}

Measured memory_bytes: 256
local _i={}
for i=1,1 do
    local a=io.read()
    _i[i]={}
    for s in string.gmatch(a,"%S+")do
        _i[i][#_i[i]+1]=s
    end
end

local s=tonumber(_i[1][1])
if(s==1 or s==2)then
  print(4)
  return
end
local i=1
while true do
  if(s==4)then
  	print(i+3)
  	return
  elseif(s%2==0)then
  	s=s*.5
  else
  	s=3*s+1
  end
  i=i+1
end

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

int main() {
  int N, D, X;
  cin >> N >> D >> X;
  int ans = N + X;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    ans += (D-1) / a;
  }
  cout << ans << endl;
}


Measured memory_bytes: 632
#include <stdio.h>
#include <stdlib.h>
#define MAX 100000
 
 
 
int partition(int *A, int p, int r){
  int x,j,tmp1,tmp2,i;
 x = A[r]; 
 i = p-1;
 for( j = p; j < r ; j++){
   if (A[j] <= x){
     i = i+1;
     tmp1 = A[i];
     A[i] = A[j];
     A[j] = tmp1;
   }
 }
   tmp2 = A[i+1];
   A[i+1] = A[r];
   A[r] = tmp2;
   return i+1;
 
 }
 
    
 int main(){
   int i,n,*A,q;
 
   A = (int*)malloc(sizeof(int)*MAX);
 
   scanf("%d",&n);
 
   for( i = 0; i < n; i++){
     scanf("%d",&A[i]);
   }
 
   
q =    partition(A,0,n-1);
 
 
     for(i = 0;i < n;i++){
       if( i == q)
	 printf("[%d]",A[i]);
       else printf("%d",A[i]);
       if (i < n-1) printf(" ");
     }
     printf("\n");
     free(A);
   return 0;
 }

Measured memory_bytes: 892
#include <cstdio>

const int MN = 200005;

int N, p[MN], q[MN];
int t[MN], f[MN];

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i) scanf("%d", &p[i]), q[p[i]] = i;
	t[N] = 0;
	for (int i = N - 1; i >= 1; --i) {
		if (t[i + 1] == 0) {
			if (q[i] > q[i + 1]) t[i] = 1, f[i] = i + 1;
			else t[i] = 0;
		} else {
			if ( /* 1. */ (q[i] < q[i + 1] && q[i + 1] < q[f[i + 1]]) ||
			/*      2. */ (q[i + 1] < q[f[i + 1]] && q[f[i + 1]] < q[i]) ||
			/*      3. */ (q[f[i + 1]] < q[i] && q[i] < q[i + 1]))
				t[i] = t[i + 1], f[i] = f[i + 1];
			else t[i] = t[i + 1] + 1, f[i] = i + 1;
		}
	}
	printf("%d\n", t[1]);
	return 0;
}

Measured memory_bytes: 4844