akhauriyash/Code-Regression huggingface dataset:
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int n, m;
vector<int> Graph[1010], rGraph[1010];
int d[1010];
int main(){
    cin >> n >> m;
    REP(i, m){
        int a, b;
        cin >> a >> b;
        a--, b--;
        Graph[a].emplace_back(b);
        rGraph[b].emplace_back(a);
    }
    vector<int> ans(1010, -1);
    REP(root, n){
        REP(i, 1010)d[i] = HINF<int>();
        d[root] = 0;
        queue<int> q;
        q.push(root);
        int flg = -1;
        while(!q.empty()){
            int p = q.front();
            q.pop();
            for(auto to : Graph[p]){
                if(to == root){
                    flg = p;
                    break;
                }
                if(d[to] != HINF<int>())continue;
                d[to] = d[p] + 1;
                q.push(to);
            }
            if(flg != -1)break;
        }
        if(flg != -1){
            vector<int> vec;
            int cur = flg;
            while(cur != root){
                vec.emplace_back(cur);
                for(auto to : rGraph[cur]){
                    if(d[to] == d[cur] - 1){
                        cur = to;
                        break;
                    }
                }
            }
            vec.emplace_back(root);
            if((int)vec.size() < (int)ans.size()){
                ans = vec;
            }
        }
    }
    if(ans[0] == -1){
        cout << -1 << endl;
        return 0;
    }
    cout << (int)ans.size() << endl;
    REP(i, (int)ans.size()){
        cout << ans[i] + 1 << endl;
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
using namespace std;


int main ()
{

int a,b;
cin >> a >>b;

if(a<b)
{
	 while(b-->0)
	 {
		  cout << a;
	 }
}
else
{
	  while(a-->0)
	  {
			cout << b;
	  }
}

	return 0;
}











Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cout << #v "=" << (v) << endl;
#define ppa(v) cout << "----\n"; rep(i,v.size()) cout << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;

int main() {
  int n,k;cin>>n>>k;
  int ans = 1;
  rep(i,n) {
    ans = min(ans+k,ans*2);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int s[12][12];
void solve(int x,int y){
  if(y-1>=0&&s[y-1][x]==1){
    s[y-1][x]=0;
    solve(x,y-1);
  }
  if(y+1<12&&s[y+1][x]==1){
    s[y+1][x]=0;
    solve(x,y+1);
  }
  if(x-1>=0&&s[y][x-1]==1){
    s[y][x-1]=0;
    solve(x-1,y);
  }
  if(x+1<12&&s[y][x+1]==1){
    s[y][x+1]=0;
    solve(x+1,y);
  }
}
int main(void){
  int i,j,ans;
  while(1){
    for(i=0;i<12;i++){
      for(j=0;j<12;j++)
	if(scanf("%1d",&s[i][j])==EOF)
	  return 0;
    }
    ans=0;
    for(i=0;i<12;i++){
      for(j=0;j<12;j++){
	if(s[i][j]==1){
	  ans++;
	  solve(j,i);
	}
      }
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define eb emplace_back 
#define lb lower_bound 
#define fi first
#define se second

#define rep(i, a, b) for (auto i = (a); i < (b); ++i) // [a, b)
#define trav(e, x) for (auto &e : x)

#define getchar getchar_unlocked
#define putchar putchar_unlocked

inline int in() {
	int n, c, flag = 1;
	while ((c = getchar()) < '0') if (c == EOF) return -1; else flag = -1;
	n = c - '0';
	while ((c = getchar()) >= '0') n = n * 10 + c - '0';
	return n * flag;
}

inline void out(int n) {
	int res[10], i = 0;
	do { res[i++] = n % 10, n /= 10; } while (n);
	while (i) putchar(res[--i] + '0');
	putchar('\n');
}

signed main() {
	int n = in();
	vector<pii> p(n); trav(q, p) q.fi = in(), q.se = in();
	vector<int> x(n); rep(i, 0, n) x[i] = p[i].fi;
	sort(all(x)); x.erase(unique(all(x)), end(x));
	vector<vector<pii>> y(sz(x));
	rep(i, 0, n) {
		int j = lb(all(x), p[i].fi) - begin(x);
		y[j].eb(p[i].se, i);
	}
	trav(v, y) sort(all(v));
	int t = in();
	while (t--) {
		vi ans;
		int sx = in(), tx = in(), sy = in(), ty = in();
		int l = lb(all(x), sx) - begin(x);
		rep(i, l, sz(x)) {
			if (x[i] > tx) break;
			int a = lb(all(y[i]), pii(sy, 0)) - begin(y[i]);
			rep(j, a, sz(y[i])) {
				if (y[i][j].fi > ty) break;
				ans.eb(y[i][j].se);
			}
		}
		sort(all(ans)); trav(x, ans) out(x); putchar('\n');
	}
}


Measured memory_bytes: 29408
s=input()
be=s[:2]
af=s[2:]

if s=="0000":
  print("NA")

elif int(be)<=12 and int(af)<=12 and be!="00" and af!="00":
  print("AMBIGUOUS")

elif int(af)<=12 and af!="00":
    print("YYMM")
    
elif int(be)<=12 and be!="00":
    print("MMYY")
  
else:
  print("NA")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

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

ll add(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a+b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll mul(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a*b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

int x;

int main(){
	ri(x);
	int ans = (x / 500) * 1000 + ((x % 500) / 5) * 5;
	printf("%d\n",ans);
	return 0;
}


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

int main(){
    int H, W;
    
    while(true){
        cin >> H >> W;
        if(H==0 && W==0) break;
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                if( (i+j) % 2 == 0){
                    cout << "#";
                }else{
                    cout << ".";
                }
            }
            cout << "\n";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,l;
  cin>>n>>l;
  vector<string> v;
  for(int i=0;i<n;++i){
    string s;
    cin>>s;
    v.push_back(s);
  }
  sort(v.begin(),v.end());
  string res ="";
  for(auto e:v) res = res+e;
  cout<<res<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  int n; cin >> n;
  vector<int> nums(n);
  rep_i(i, n){
    cin >> nums[i];
  }

  int q; cin >> q;
  int tmp;
  rep_i(i, q){
    cin >> tmp;
    if(binary_search(nums.begin(), nums.end(), tmp)){
      say(1);
    }else{
      say(0);
    }
  }
}


Measured memory_bytes: 3120
import sys, math
from fractions import Fraction as F
for line in sys.stdin:
    t = F(line.rstrip()) / F(98, 10)
    y = F(49, 10) * t * t
    #print int(math.ceil(y/5 + 1))
    for n in xrange(1, 1000):
        if 5 * n - 5 >= y:
            print n
            break

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N, M;
    cin >> N >> M;

    if (N >= M) {
        cout << '0' << "\n";
        return 0;
    }

    vector<int> points;
    REP(i, M) {
        int p;
        cin >> p;
        points.push_back(p);
    }

    sort(points.begin(), points.end());

    vector<ll> D;
    REP(i, (int)(points.size() - 1)) {
        ll d = points[i+1] - points[i]; // 差分
        D.push_back(d);
    }

    sort(D.begin(), D.end());

    int result = 0;
    REP(i, M - N) {
        result += D[i];
    };
    cout << result << "\n";
} 

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define INF 1000000000000000000
#define all(x) x.begin(), x.end()
#define PI 3.141592653589793

int main() {
    int N;
    cin >> N;
    vector<double> P(N);
    rep(i, N) { cin >> P[i]; }

    vector<vector<double>> dp(N + 1, vector<double>(N + 1));
    dp[0][0] = 1;
    rep(i, N) { dp[i + 1][0] = dp[i][0] * (1 - P[i]); }
    // i枚投げてj枚表がでる確率
    for (int i = 0; i < N; i++) {
        for (int j = 1; j <= N; j++) {
            dp[i + 1][j] = dp[i][j - 1] * P[i] + dp[i][j] * (1 - P[i]);
        }
    }

    double res = 0.0;
    rep(i, N + 1) {
        if (i > N / 2)
            res += dp[N][i];
    }

    cout << fixed << setprecision(10) << res << endl;
}

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

typedef pair<int,int> ii;

#define fi first
#define se second

const int MAXN = 2005;
const int INF = 1e9;

int N, K, dist[MAXN];
vector<int> adjList[MAXN];
vector<ii> edgeList;

int main() {

    scanf("%d%d", &N, &K);
    for (int i = 1, u, v; i < N; i++) {
        scanf("%d%d", &u, &v);

        adjList[u].push_back(v);
        adjList[v].push_back(u);
        edgeList.push_back(ii(u, v));
    }

    int D = K / 2;

    int ans = INF;

    if (K % 2 == 0) {
        for (int i = 1; i <= N; i++) {
            memset(dist, -1, sizeof(dist)); dist[i] = 0;
            queue<int> q; q.push(i);

            int tmp = 0;
            while (!q.empty()) {
                int node = q.front(); q.pop();

                //cout << node << " " << dist[node] << endl;

                if (dist[node] > D) tmp++;

                for (int j = 0; j < adjList[node].size(); j++) {
                    int neighbor = adjList[node][j];

                    if (dist[neighbor] == -1) {
                        dist[neighbor] = dist[node] + 1;
                        q.push(neighbor);
                    }
                }
            }

            ans = min(ans, tmp);
        }
    } else {
        for (int i = 0; i < edgeList.size(); i++) {
            memset(dist, -1, sizeof(dist)); dist[edgeList[i].fi] = dist[edgeList[i].se] = 0;
            queue<int> q; q.push(edgeList[i].fi); q.push(edgeList[i].se);

            int tmp = 0;
            while (!q.empty()) {
                int node = q.front(); q.pop();

                //cout << node << " " << dist[node] << endl;

                if (dist[node] > D) tmp++;

                for (int j = 0; j < adjList[node].size(); j++) {
                    int neighbor = adjList[node][j];

                    if (dist[neighbor] == -1) {
                        dist[neighbor] = dist[node] + 1;
                        q.push(neighbor);
                    }
                }
            }

            ans = min(ans, tmp);
        }
    }

    printf("%d\n", ans);
    
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

class Main{
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		for(int i = 1; i < 11111; i++) {
			int x = scanner.nextInt();
			if (x == 0) break;
		    //System.out.print(x);
		    //String trimmed = str.trim();
			System.out.printf("Case %d: %d\n", i, x);

		}

	}
}


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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> L(M),R(M);
  for(int i=0;i<M;i++){
    cin >> L.at(i) >> R.at(i);
  }
  sort(L.rbegin(),L.rend());
  sort(R.begin(),R.end());
  cout << max(R.at(0)-L.at(0)+1,0) << endl;
}
  

Measured memory_bytes: 3980
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define pb(a) push_back(a)

typedef long long ll;
using namespace std;

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 dy[] = { 0, 0, 1, -1 };
//const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);

vector<ll> a,b;
vector<ll> ans;

map<ll,ll> m;


int main()
{
	ll n,k,q;
	ll tmp;

	cin >> n >> k >> q;

	for (int i = 0; i < q; i++) {
		cin >> tmp;
		a.push_back(tmp);
	}

	for (int i = 0; i < n; i++) {
		ans.push_back(k);
		b.push_back(0);
	}

	for (int i = 0; i < q; i++) {
		b[a[i]-1]++;
	}

	for (int i = 0; i < n; i++) {
		int tmp = ans[i] - q + b[i];
		if (tmp > 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}

	return 0;
}





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

int main(void){
  int y,m,d;
  string s;
  cin >> s;
  y = stoi(s.substr(0,4));
  m = stoi(s.substr(5,7));
  d = stoi(s.substr(8,10));
  if(y>=2019 && (m>=5 || (m==4 && d==31))) cout << "TBD" << endl;
  else cout << "Heisei" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n,k,ans=0;cin>>n>>k;
  V<ll> v(n);rep(i,0,n)cin>>v[i];
  sort(all(v));
  reverse(all(v));
  rep(i,0,n){
    if(i<k)continue;
    else ans+=v[i];

  }
  cout<<ans<<ENDL;


}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007

int main()
{
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;++i)	cin>>a[i];
	ll p[n];
	p[n-1] = 0;
	for(ll i=n-2;i>=0;--i)	p[i] = (p[i+1] + a[i+1])%mod;
	ll ans=0;
	for(ll i=0;i<n;++i)
	{
		ans = (ans%mod + ((a[i]%mod)*(p[i]%mod))%mod)%mod;
	}

	cout<<ans<<endl;
}	

Measured memory_bytes: 6740
#include<bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define MOD (int)1e9+(int)7
typedef long long ll;
//dark power
//#define int ll
//define Error、大抵は、セミコロン忘れとか、Defineは関係ない
/*
vector<int> d(100000);
vector<int> b(100000);
class UnionFind{
	public:
	UnionFind(signed n){rep(i,n){d[i]=i;b[i]=0;}}
	signed find(signed x){
		if(d[x]==x){
			return x;
		}else{
			return d[x]=find(d[x]);
		}
	}
	UnionFind(signed n){rep(i,n){d[i]=i;b[i]=0;}}
	void unite(signed x,signed y){
		x=find(x);
		y=find(y);
		if(x==y)return;
		if(b[x]<b[y]){
			d[x]=y;
		}else{
			d[y]=x;
			if(b[x]==b[y])b[x]++;
		}
	}
	bool same(signed x,signed y){return (find(x)==find(y));}
};
*/
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string str;
	cin>>str;
	int n;
	n=1;
	while(1){
		if(str.substr(0,(int(str.size())-2*n)/2)==str.substr((int(str.size())-2*n)/2,(int(str.size())-2*n)/2))break;
		n++;
	}
	cout<<int(str.size())-n*2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e4+5;
const ll INF=999999999999;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
ll dp[MAXN];
int main()
{
    ll h,n;
    cin>>h>>n;
    int cnt=0;
    for(int i=0;i<=h;i++)dp[i]=INF;
    dp[0]=0;
    for(int i=1;i<=n;i++)
    {
        int w,v;cin>>w>>v;
        for(int j=1;j<=h;j++)
        {
            dp[j]=min(dp[j],dp[max(j-w,0)]+v);
        }
    }
    cout<<dp[h]<<endl;
    return 0;
}

Measured memory_bytes: 384
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
  int n,x;
  cin >> n;
  int o[n/2+1],e[n/2];
  for(int i = 0; i < n; i++){
    cin >> x;
    if(i%2==0) o[i/2] = x;
    else e[i/2] = x;
  }

  if(n%2==0){
    reverse(e,e+n/2);

    for(int i = 0; i < n/2; i++){
      printf("%d ",e[i]);
    }
    for(int i = 0; i < n/2; i++){
      printf("%d ",o[i]);
    }
  }else{
    reverse(o,o+n/2+1);

    for(int i = 0; i < n/2+1; i++){
      printf("%d ",o[i]);
    }

    for(int i = 0; i < n/2; i++){
      printf("%d ",e[i]);
    }

  }
  return 0;
}


Measured memory_bytes: 3072
#include <cstdio>
#include <vector>
#include <map>
using namespace std;

int main() {
        int n;
        scanf("%d", &n);
        vector<long long> a(n);
        for (int i = 0; i < n; i ++) scanf("%lld", &a[i]);
        map<long long, int> cnt;
        for (int i = 0; i < n; i ++) cnt[a[i]] ++;
        long long ans = 0;
        for (auto it : cnt) ans += it.second + (it.first > it.second ? 0 : -it.first);
        printf("%lld\n", ans);
        return 0;
}


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

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

int n, m, s, c;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    int res[n] = {0};

    bool ok = true, f = false;
    for (int i = 0; i < m; ++i) {
      cin >> s >> c;
      if (s == 1 && c == 0 && n > 1) {
        ok = false;
        break;
      }
      if (res[s - 1] != 0 && res[s - 1] != c) {
        ok = false;
        break;
      }
      res[s - 1] = c;
    }
    if (n > 1 && res[0] == 0) {
      res[0] = 1;
    }

    if (ok) {
      int ans = 0;
      for (int i = 0; i < n; ++i) {
        ans = ans * 10 + res[i];
      }
      cout << ans << endl;
    } else
      cout << -1 << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

class Main{
    Main(){
        Scanner SC = new Scanner(System.in);
        StringBuffer SB = new StringBuffer(SC.next());

        int Q = Integer.parseInt(SC.next());

        StringBuilder head = new StringBuilder(Q);
        StringBuilder tail = new StringBuilder(Q);

        boolean isReverse = false;
        int T, F;
        char C;
        for(int i=0;i<Q;i++){
            T = Integer.parseInt(SC.next());
            if(T==1){
                isReverse = !isReverse;
            } else {
                F = Integer.parseInt(SC.next());
                C = SC.next().charAt(0);

                if(F == 1){
                    if(isReverse){
                        tail.append(C);
                    } else {
                        head.append(C);
                    }
                } else {
                    if(isReverse){
                        head.append(C);
                    } else {
                        tail.append(C);
                    }
                }
            }
        }

        if(isReverse){
            System.out.print(tail.reverse().toString());
            System.out.print(SB.reverse().toString());
            System.out.println(head.toString());
        } else {
            System.out.print(head.reverse().toString());
            System.out.print(SB.toString());
            System.out.println(tail.toString());
        }
    }

    public static void main(String[] args){
        Main main = new Main();
    }
}


Measured memory_bytes: 82236
/*

    author : s@if

*/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			1e18
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> new_data_set;

//*find_by_order(k)  gives the kth element;
//order_of_key(item)   gives the index(number of element strictly less than item) of item;


inline int in() {int x; scanf("%d", &x); return x; }
bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};    // King's move
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hx[]={-2,-2,-1,+1,+2,+2,-1,+1};    // Knight's move
int hy[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)2e5+9;


int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    ll i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    cin>>n>>m>>x;
    ll a[n+9][m+9];

    for(i=0; i<n; i++)
    {
        for(j=0; j<=m; j++)
            cin>>a[i][j];
    }

    ll ans = INF;

    for(i=0; i<(1<<n); i++)
    {
        vector<int>vv;
        for(j=0; j<n; j++)
        {
            if(Check(i,j)==true){
                vv.push_back(j);
              //  cout<<j<<" ";
            }
        }
      //  cout<<endl;

        ll sum1 = 0, sum2 = 0;

        ll tmp[m+9] = {0};
        for(j=0; j<vv.size(); j++)
        {
            p = vv[j];
            for(k=1; k<=m; k++)
                tmp[k]+=a[p][k];
            sum1+=a[p][0];
          //  cout<<sum1<<endl;
        }

        bool flag  = true;
        for(j=1; j<=m; j++)
        {
            if(tmp[j]<x) flag = false;
        }

        if(flag) ans = min(ans, sum1);
    }

    if(ans==INF) ans = -1;

    cout<<ans<<endl;

  //  main();

    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


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

int main(){
  int N;
  cin >> N;

  if( N / 100 == 7 ){
    cout << "Yes" << endl;
    return 0;
  }

  N %= 100;
  if( N / 10 == 7 ){
    cout << "Yes" << endl;
    return 0;
  }

  N %= 10;
  if( N == 7 ){
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>


using namespace std;
using ll = long long;


int main()
{
    string s;
    ll K;
    cin >> s;
    cin >> K;
    set<string> substrs;
    for (ll j = 1; j <= K && j <= s.length(); j++) {
        for (auto i = 0; i <= s.length() - j; i++) {
            string sub = s.substr(i, j);
            substrs.insert(sub);
        }
    }
    vector<string> tmp;
    for (auto t : substrs) {
        tmp.push_back(t);
    }

    sort(tmp.begin(), tmp.end());
    cout << tmp[K - 1] << endl;
}


Measured memory_bytes: 1920
#include<map>
#include<queue>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<vector>
#include<cstring>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
const int N=1e5+10;

template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

ll n,m,ans;

int main() {
	qr(n); qr(m);
	if(n==1||m==1) puts("1");
	else pr2((n*m+1)>>1);
	return 0;
}



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

int main()
{    
    int r;
    cin >> r;
    cout << r*r << endl;    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f first 
#define s second
int32_t main(){
     char c;
     cin>>c;
     if(c-'a'>= 0 && c-'a'<=25){
         cout<<"a"<<endl;
         return 0;
     }
     cout<<"A"<<endl;
}

Measured memory_bytes: 3592
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BeginnerContest053
{
    class Program
    {
        static void Main(string[] args)
        {
            //var input = Console.ReadLine();                                                   

            //Console.WriteLine(int.Parse(input) < 1200 ? "ABC" : "ARC");

            var input = Console.ReadLine();

            var first  = input.IndexOf("A");
            var last = input.LastIndexOf("Z");
            Console.WriteLine(last - first +1);

        }
    }
}


Measured memory_bytes: 3928
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,M; cin>>N>>M;
    if(N>=M){
        cout<<0;
        return 0;
    }

    vector<int> X(M,0);
    for(int i=0;i<M;i++){
        cin>>X[i];
    }
    sort(X.begin(),X.end());
    vector<int> sa(M-1,0);
    for(int i=0;i<M-1;i++){
        sa[i]=X[i+1]-X[i];
    }
    sort(sa.begin(),sa.end());
    int ans=0;
    for(int i=0;i<M-N;i++){
        ans=ans+sa[i];
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
	  Scanner sc=new Scanner(System.in);
	  for(;;) {
		  int y=sc.nextInt();
		int  x=sc.nextInt();
		if(x == 0&&y == 0)break;
		else if(x>y) {
			System.out.println(y +" " + x);
		}else {
			System.out.println(x+ " "+ y);
		}

	  }
	  sc.close();
  }
}


Measured memory_bytes: 37288
#include<stdio.h>
int main(){
	int str[512];
	int count=0;
	int buff=0;
	while((buff=getchar())!='\n'){
		if('a'<=buff&&buff<='z')str[count]=buff-32;
		else str[count]=buff;
		count++;
		printf("%c",str[count-1]);
	}
	printf("\n");
	return 0;
	
}

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

int32_t main() {

    int n; cin >> n;
    vector<int> d1(n);
    vector<int> d2(n);
    for(int i = 0; i < n; i++) {
        cin >> d1[i];
        cin >> d2[i];
    }
    int cnt = 0; bool T = true;
    for(int i = 0; i < n; i++) {
        
        
        if(d1[i] == d2[i]) {
            cnt++;
            T = false;
            if(cnt == 3) {
                cout << "Yes";
                return 0;
            }
        }
        else if(cnt != 0 && !T) {
            cnt = 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  double N;
  cin >> N;
  for (int i=1; i<=3500; i++) {
    bool loop = true;
    for (int j=1; j<=3500; j++) {
      double h=i, n=j;
      if (4*h*n-N*(n+h)==0) break;
      else {
        double w = N*h*n/(4*h*n-N*(n+h));
        if (ceil(w)==floor(w)&&w>0) {
          ll w0 = w;
          cout << h << " " << n << " ";
          cout << w0 << endl;
          loop = false;
          break;
        }
      }
    }
    if (!loop) break;
  }
}

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

void _memset();
void _cin();
void check1();
int _check();

#define MAX_N 8000

int n;
char x[MAX_N][MAX_N];
string tate[MAX_N], yoko[MAX_N], naname1[MAX_N * 10], naname2[MAX_N * 10];

void _memset() {
	memset(x, '0', sizeof(x));
	for (int i = 0; i < MAX_N; i++) {
		tate[i] = "";
	}
	for (int i = 0; i < MAX_N; i++) {
		yoko[i] = "";
	}
	for (int i = 0; i < MAX_N * 10; i++) {
		naname1[i] = "";
	}
	for (int i = 0; i < MAX_N * 10; i++) {
		naname2[i] = "";
	}
}

void _cin(int p) {
	for (int i = 0; i < p; i++) {
		for (int j = 0; j < p; j++) {
			cin >> x[i][j];
		}
	}
}

void check1(int p) {
	for (int i = 0; i < p; i++) {
		for (int j = 0; j < p; j++) {
			tate[i] += x[i][j];
			yoko[j] += x[i][j];
			naname1[i + j] += x[i][j];
			naname2[p + i - j] += x[i][j];
		}
	}
}

int maxn;

int _check(int p) {
	maxn = 0;

	//tate.
	int chain = 0;
	for (int i = 0; i < p; i++) {
		chain = 0;
		for (int j = 0; j < tate[i].size(); j++) {
			if (tate[i][j] == '1') {
				chain++;
			}
			else {
				maxn = max(chain, maxn);
				chain = 0;
			}
		}

		maxn = max(chain, maxn);

	}

	//yoko.
	for (int i = 0; i < p; i++) {
		chain = 0;
		for (int j = 0; j < yoko[i].size(); j++) {
			if (yoko[i][j] == '1') {
				chain++;
			}
			else {
				maxn = max(chain, maxn);
				chain = 0;
			}
		}

		maxn = max(chain, maxn);

	}

	//naname1.
	for (int i = 0; i < p * 10; i++) {
		chain = 0;
		for (int j = 0; j < naname1[i].size(); j++) {
			if (naname1[i][j] == '1') {
				chain++;
			}
			else {
				maxn = max(chain, maxn);
				chain = 0;
			}
		}
		
		maxn = max(maxn, chain);

	}

	//naname2.
	for (int i = 0; i < p * 10; i++) {
		chain = 0;
		for (int j = 0; j < naname2[i].size(); j++) {
			if (naname2[i][j] == '1') {
				chain++;
			}
			else {
				maxn = max(chain, maxn);
				chain = 0;
			}
		}

		maxn = max(chain, maxn);

	}

	_memset();

	return maxn;
}

int main() {
	while (true) {
		cin >> n;
		if (n == 0) {
			break;
		}
		_cin(n);
		check1(n);
		cout << _check(n) << endl;
	}
	return 0;
}

Measured memory_bytes: 65488
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>
#include<queue>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;

template<class T>
struct Edge {
    int to;
    T cost;
    Edge() {};
    Edge(int to, T cost) : to(to), cost(cost) {};
};

template<class T>
class Graph {
    int n;
    bool directed;
    vector<vector<Edge<T>>> edges;
public:

    Graph(int n, bool directed) :n(n), directed(directed), edges(vector<vector<Edge<T>>>(n)){};
    Graph() {};

    void add(int to, T cost) {
        emplace_back(to, cost);
    }

    int size() {
        return n;
    }
};


int main() {

    int N,K;

    cin >> N >> K;

    vi H(N);

    REP(i,N)cin >> H[i];

    sort(ALL(H),greater<int>());

    long long ans = 0;

    REP(i,N){
        if(i<K)continue;

        ans += H[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (1e9)

typedef struct { string name; int time; } process;

queue<process> que;
int elapsed = 0;

int main() {
  int n, q;
  process tmp;
  cin >> n >> q;
  for(int i = 0; i < n; i++) {
    cin >> tmp.name >> tmp.time;
    que.push(tmp);
  }

  while(!que.empty()) {
    tmp = que.front();
    tmp.time -= q;
    que.pop();
    if(tmp.time > 0) {
      elapsed += q;
      que.push(tmp);
    } else {
      elapsed += q + tmp.time;
      cout << tmp.name << " " << elapsed << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 6168
#include <iostream>
#include <string>
#include <algorithm> 
using namespace std;
 
int main()
{
	std::ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int begin = (int)'a';
	int end = (int)'z';
	int s = end-begin+1;
	int a[s] = {0};
	int b[s] = {0};
	int ans[s] = {0};
    int j = 1;
	
	
		string t;
		cin>>t;
		int ts = t.size();
		for(int i = 0 ; i < ts ; i++)
		{
			a[(int)(t[i] - 'a')]++;
		}
    
        if(n==1)
        {
            for(int i = 0 ; i < s ; i++)
	{
		while(a[i]--)
		{
			cout<<(char)(i+(int)'a');
		}
	}
            return 0;
        }
    
		string tb;
		cin>>tb;
		int tbs = tb.size();
		for(int i = 0 ; i < tbs ; i++)
		{
			b[(int)(tb[i] - 'a')]++;
		}
	for(int i = 0 ; i < s ; i++)
		{
			ans[i] = min(a[i],b[i]);
           a[i] = 0;
            b[i] = 0;
		}
    
    n = n-2;
    while(n--)
    {
        string t;
		cin>>t;
		int ts = t.size();
		for(int i = 0 ; i < ts ; i++)
		{
			a[(int)(t[i] - 'a')]++;
		}
        for(int i = 0 ; i < s ; i++)
		{
			ans[i] = min(a[i],ans[i]);
            a[i]=0;
		}
        
    }
	for(int i = 0 ; i < s ; i++)
	{
		while(ans[i]--)
		{
			cout<<(char)(i+(int)'a');
		}
	}
	cout<<'\n';
	return 0;
}

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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

int main()
{
    canhazfast();

    int a, b, x;
    double d, v, ans;

    cin >> a >> b >> x;
    if (2*x >= a*a*b) {
        d = b-(double)x/(a*a);
        v = 2.0*d/a;
    } else {
        d = 2.0*x/(a*b);
        v = b/d;
    }
    ans = atan(v)*180.0/M_PI;
    cout << setprecision(8) << ans << '\n';

    return 0;
}


Measured memory_bytes: 512
import math
def fact(n):
    ans = 1
    for i in range(2, n+1):
        ans*= i
    return ans
def comb(n, c):
    return fact(n)//(fact(n-c)*c)

n,m=map(int, input().split())
a = list(map(int, input().split()))
day= sum(a)
if(n-day< 0):
    print(-1)
else:
    print(n-day)


Measured memory_bytes: 68020
#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;
    vvi edges(n);
    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    int root = -1;
    for (int i = 0; i < n; ++i) {
        if (edges[i].size() >= 3) {
            root = i;
            break;
        }
    }
    if (root == -1) {
        cout << 1 << "\n";
        return 0;
    }
    vector<bool> subtree_has_anntena(n, 0);
    vector<int> a(n, 0);
    function<int(int, int)> dfs = [&](int c, int p) {
        int childs = edges[c].size();
        if (p != -1)
            childs -= 1;
        int cnt = 0;
        int tot = 0;
        for (auto &v : edges[c]) {
            if (v == p)
                continue;
            tot += dfs(v, c);
            if (subtree_has_anntena[v])
                cnt++;
        }
        if (cnt > 0)
            subtree_has_anntena[c] = true;
        if (cnt >= childs - 1)
            return a[c] = tot;
        else {
            subtree_has_anntena[c] = true;
            return a[c] = tot + (childs - 1 - cnt);
        }
    };
    cout << dfs(root, -1) << endl;
    return 0;
}

Measured memory_bytes: 11136
#include <sstream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <string>
#include <queue>
#include <bitset>
#define int long long
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; --i)
#define REP(i, a) for (int i = 0, _a = (a); i < _a; ++i)

#define DEBUG(X) { cerr << #X << " = " << (X) << endl; }
#define PR(A, n) { cerr << #A << " = "; FOR(_, 1, n) cerr << A[_] << ' '; cerr << endl; }
#define PR0(A, n) { cerr << #A << " = "; REP(_, n) cerr << A[_] << ' '; cerr << endl; }

#define sqr(x) ((x) * (x))
#define ll long long
#define __builtin_popcount __builtin_popcountll
#define SZ(x) ((int)(x).size())
using namespace std;

double safe_sqrt(double x) { return sqrt(max((double)0.0, x)); }
int GI(int& x) { return scanf("%lld", &x); }

const int MOD = 1e9 + 7;

int f[1011][1011], C[1011][1011], gt[1011], inv_gt[1011];
void add(int& f, int val) {
    f += val;
    if (f >= MOD) f -= MOD;
}

int power(int x, int k) {
    int res = 1;
    while (k > 0) {
        if (k & 1) res = res * x % MOD;
        k >>= 1;
        x = x * x % MOD;
    }
    return res;
}

int inverse(int x) {
    return power(x, MOD  - 2);
}

#undef int
int main() {
#define int long long
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout << (fixed) << setprecision(9);

    gt[0] = 1;
    FOR(i,1,1000) gt[i] = gt[i-1] * i % MOD;
    FOR(i,0,1000) inv_gt[i] = inverse(gt[i]);

    int n, a, b, c, d;
    C[0][0] = 1;
    FOR(i,1,1000) {
        C[i][0] = 1;
        FOR(j,1,i) C[i][j] = (C[i-1][j-1] + C[i-1][j]) % MOD;
    }

    while (GI(n) == 1) {
        GI(a); GI(b); GI(c); GI(d);
        memset(f, 0, sizeof f);

        f[0][a-1] = 1;
        FOR(i,0,n) FOR(t,a-1,b-1) {
            int cur = f[i][t];
            if (!cur) continue;

            // do not use t+1
            add(f[i][t+1], cur);

            // use t+1
            int mul = 1;
            for(int j = i+t+1, g = 1; j <= n && g <= d; g++, j += t+1) {
                mul = mul * C[n-(j-t-1)][t+1] % MOD;
                if (g >= c) {
                    add(f[j][t+1], cur * mul % MOD * inv_gt[g] % MOD);
                }
            }
        }
        /*
        FOR(i,1,n) FOR(t,a,b) {
            // do not use t
            add(f[i][t], f[i][t-1]);
            // use some t
            for(int mul=c, j=i-c*t; j >= 0 && mul <= d; mul++, j -= t) {
                add(f[i][t], f[j][t-1]);
            }
        }
        */
        cout << f[n][b] << endl;
    }
}


Measured memory_bytes: 15232
#include<bits/stdc++.h>
using namespace std;
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define pa pair<int,int>
#define mod 998244353
#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define cl(x) memset(x,0,sizeof x)
#ifdef Devil_Gary
#define bug(x) cout<<(#x)<<" "<<(x)<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define bug(x)
#define debug(...)
#endif

const int INF = 0x7fffffff;
const int N=5e3+5;
/*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=(TT=but)+fread(but,1,1<<15,stdin),TT==mo))?-1:*TT++)//*/
inline int read(){
    int x=0,rev=0,ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')rev=1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
    return rev?-x:x;
}/*
struct Edge{
	int nxt,v;
//	int w;
//	int id;
}e[N<<1];
void add(int u,int v){
	e[++tot].v=v,e[tot].nxt=head[u],head[u]=tot;
	e[++tot].v=u,e[tot].nxt=head[v],head[v]=tot;
}*/
ll f[N][N][4];
int n,m,k;
ll c[N][N];
int main(){
#ifdef Devil_Gary
    freopen("in.txt","r",stdin);
//  freopen("out.txt","w",stdout);
#endif
	n=read(),m=read(),k=read();
	for(int i=1;i<=k;i++){
		ll x,y,z;
		cin>>x>>y>>z;
		c[x][y]=z;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			for(int k=0;k<=3;k++){
				if(k!=0) f[i][j][k]=c[i][j]+max(f[i][j-1][k-1],max(max(f[i-1][j][0],f[i-1][j][1]),max(f[i-1][j][2],f[i-1][j][3])));
				f[i][j][k]=max(f[i][j][k],max(f[i][j-1][k],max(max(f[i-1][j][0],f[i-1][j][1]),max(f[i-1][j][2],f[i-1][j][3]))));
			} 
		}
	}
	cout<<max(max(f[n][m][0],f[n][m][1]),max(f[n][m][2],f[n][m][3])); 
	return 0;
}


Measured memory_bytes: 376472
//#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <iostream>


using namespace std;

int main() {

    int A, B, C;
    cin >> A >> B >> C;
    
    int a = A - B; // 容器1に入れられる量

    int result = 0;
    if (a >= C) {
        result = 0;
    } else if (a < C) {
        result = C - a;
    }

    cout << result;

    return 0;
}

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

int main(){
	int N, i, l = 0, r = 0;
	scanf("%d", &N);
	char *s = (char *)malloc(sizeof(char) * (N + 1));
	scanf("%s", s);
	for(i = N - 1; i >= 0; i--){
		if(s[i] == ')'){
			l++;
		}
		else if(l > 0){
			l--;
		}
	}
	for(i = 0; i < N; i++){
		if(s[i] == '('){
			r++;
		}
		else if(r > 0){
			r--;
		}
	}
	for(i = 0; i < l; i++){
		printf("%c", '(');
	}
	for(i = 0; i < N; i++){
		printf("%c", s[i]);
	}
	for(i = 0; i < r; i++){
		printf("%c", ')');
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<iomanip>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF long long int(1e18+1)
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

int main() 
{
	int n, m;
	cin >> n >> m;
	if (n == m)cout << "Yes" << endl;
	else cout << " No" << endl;
}




Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
struct unionFind{
  vector<int>par;

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

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

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

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

};



int main(){
  int n,m;
  cin >> n >> m;
  vector<int>a(m);
  vector<int>b(m);
  int i;
  for(i=0;i<m;i++){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }

  int ans = 0;

  for(i=0;i<m;i++){
    unionFind unif(n);
    for(int j=0;j<m;j++){
      if(i!=j)unif.unite(a[j],b[j]);
    }
    bool chk = false;
    for(int j=1;j<n;j++){
      if(!unif.same(0,j)){
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;




}


Measured memory_bytes: 256