akhauriyash/Code-Regression huggingface dataset:
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_7_A: Rooted Trees

#include <cstdio>

const int NIL = -1;

struct Node {
  // id is index of nodes
  int parent = NIL;
  int left_child = NIL;
  int right_sibling = NIL;
  unsigned int depth = 0;

  const char* type() const
  {
    auto type =
      parent == NIL ? "root" :
      left_child == NIL ? "leaf" :
      "internal node";
    return type;
  }    
};

class RootedTree {
  unsigned int n_;
  Node* nodes_;

public:
  RootedTree(unsigned int n) : n_(n), nodes_(new Node[n]) { }

  ~RootedTree() { delete[] nodes_; }

  Node& operator[](unsigned int id) { return nodes_[id]; }

  void set_depth()
  {
    set_depth_internal(root(), 0u);
  }

  void print_nodes() const
  {
    for (auto i = 0u; i < n_; ++i) {
      print_node(i);
    }
  }

private:
  int root() const
  {
    for (auto i = 0u; i < n_; ++i) {
      if (nodes_[i].parent == NIL) {
        return i;
      }
    }
    return NIL;
  }

  void set_depth_internal(unsigned int i, unsigned int depth)
  {
    nodes_[i].depth = depth;
    if (nodes_[i].right_sibling != NIL) {
      set_depth_internal(nodes_[i].right_sibling, depth);
    }
    if (nodes_[i].left_child != NIL) {
      set_depth_internal(nodes_[i].left_child, depth+1);
    }
  }

  void print_node(unsigned int i) const
  {
    auto node = nodes_[i];
    std::printf("node %u: parent = %d, depth = %u, ", i, node.parent, node.depth);
    std::printf("%s, [", node.type());
    int next_c = node.left_child;
    auto sep = "";
    while (next_c != NIL) {
      std::printf("%s%d", sep, next_c);
      sep = ", ";
      next_c = nodes_[next_c].right_sibling;
    }
    std::printf("]\n");
  }
};

int main()
{
  unsigned int n;
  std::scanf("%u", &n);
  RootedTree tree(n);

  for (auto i = 0u; i < n; ++i) {
    unsigned int id, k, c;
    std::scanf("%u %u", &id, &k);

    int* next_p = &tree[id].left_child;
    for (auto j = 0u; j < k; ++j) {
      std::scanf("%u", &c);
      tree[c].parent = id;
      *next_p = c;
      next_p = &tree[c].right_sibling;
    }
  }

  tree.set_depth();
  tree.print_nodes();
}

// eof

Measured memory_bytes: 5488
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define mst(a,b) memset((a),(b),sizeof(a))
#define PII pair<int,int>
using namespace std;
template<class T>inline void read(T &x) {
    x=0; int ch=getchar(),f=0;
    while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    if(f)x=-x;
}
const int inf=0x3f3f3f3f;
int n;
int main()
{
	cin>>n;
	if(n%2) cout<<(n/2)+1<<endl;
	else cout<<n/2<<endl;
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int64_t> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  int res = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      for (int k = j + 1; k < N; k++) {
        if (L[i] == L[j] || L[j] == L[k] || L[k] == L[i]) continue;
        if (L[i] < L[j] + L[k] && L[j] < L[i] + L[k] && L[k] < L[i] + L[j]) res++;
      }
    }
  }
  cout << res << '\n';
  return 0;
}


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

#define check cout<<"-----"<<endl

char getChar(char ch) {
    if ( ch == 'A') return '0';
    else if ( ch == 'C') return '1';
    else if ( ch == 'G') return '2';
    else if ( ch == 'T') return '3';
    return 0;
}

int getInt(char ch) {
    if ( ch == '0') return 0;
    else if ( ch == '1') return 1;
    else if ( ch == '2') return 2;
    else if ( ch == '3') return 3;
    return 0;
}

int change(char *v) {
    int sum = 0;
    int bai = 1;
    for(int i = 0; v[i] != 0; i++) {
        int c = getInt(v[i]);
        sum += c * bai;
        bai *= 4;
    }
    sum += bai*1;
    return sum;
}

int main() {
    
    int n;
    cin>>n;
    
    char cnd[12], str[13], ch, c, pass[13];
    int id;
    bool dic[33554431];
    
    for(int i = 0; i < n; i++) {
        cin>>cnd;
        id = 0;
        if(cnd[0] == 'i') {
            cin>>str;
            int j;
            for(j = 0; str[j] != 0; j++) {
                c = getChar(str[j]);
                pass[j] = c;
            }
            pass[j] = '\0';
            id = change(pass);
            dic[id] = true;
        } else {
            cin>>str;
            int j;
            for(j = 0; str[j] != 0; j++) {
                c = getChar(str[j]);
                pass[j] = c;
            }
            pass[j] = '\0';
            id = change(pass);
            if(dic[id]) cout<<"yes"<<endl;
            else cout<<"no"<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 4480
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
using namespace std;

#define fi first
#define se second
typedef long long LL;
typedef long double LD;

LL N,M,sz; LL v[100100]; bool bp;
vector<LL> g[100100];
LL cnt[4];

void dfs(int nod, int t){
    if (v[nod]){
        if (v[nod]!=t) bp=0;
        return;
    }

    v[nod]=t; sz++;
    for (int x : g[nod])
        dfs(x,3-t);
}


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

    int i,x,y;
    for (i=1; i<=M; i++){
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    for (i=1; i<=N; i++){
        if (v[i]) continue;
        sz=0,bp=1;
        dfs(i,1);
        if (sz==1) cnt[1]++;
        else if (bp) cnt[2]++;
        else cnt[3]++;
    }

    LL res=2*cnt[1]*(N-cnt[1])+cnt[1]*cnt[1];
    res+=2*cnt[2]+cnt[3];
    res+=2*cnt[2]*(cnt[2]-1)+cnt[3]*(cnt[3]-1);
    res+=2*cnt[2]*cnt[3];

    cout << res << "\n";
    return 0;

}


Measured memory_bytes: 11520
#include<cstdio>
#include<vector>
#include<complex>
#include<algorithm>

#define mp       make_pair
#define pb       push_back
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef complex<double> Point;

const double EPS=1e-9;

class Line:public vector<Point>{
public:
	Line(){}
	Line(const Point &a,const Point &b){ pb(a), pb(b); }
};

class Segment:public Line{
public:
	Segment(){}
	Segment(const Point &a,const Point &b):Line(a,b){}
};

double dot(const Point &a,const Point &b){
	return real(a)*real(b)+imag(a)*imag(b);
}

double cross(const Point &a,const Point &b){
	return real(a)*imag(b)-imag(a)*real(b);
}

enum {CCW=1,CW=-1,ON=0};
int ccw(const Point &a,Point b,Point c){
	b-=a,c-=a;
	double rotdir=cross(b,c);
	if(rotdir>EPS)  return CCW;
	if(rotdir<-EPS) return CW;
	return ON;
}

inline void calc_abc(const Line &l,double &a,double &b,double &c){
	a=imag(l[0])-imag(l[1]);
	b=real(l[1])-real(l[0]);
	c=cross(l[0],l[1]);
}

bool cover(const Segment &s,const Point &p){
	return dot(s[0]-p,s[1]-p)<EPS;
}

bool intersect(const Segment &s,const Segment &t,Point &p){
	bool flg;
	if(abs(cross(s[1]-s[0],t[1]-t[0]))<EPS && abs(cross(s[1]-s[0],t[0]-s[0]))<EPS){
		flg=(cover(s,t[0]) || cover(s,t[1]) || cover(t,s[0]) || cover(t,s[1]));
		if(!flg) return false;
	}

	if(flg || (ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1])<=0
			&& ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1])<=0)){
		double a1,b1,c1,a2,b2,c2;
		calc_abc(s,a1,b1,c1);
		calc_abc(t,a2,b2,c2);
		double det=a1*b2-a2*b1;
		if(abs(det)<EPS){
			Point q[3]={s[0],s[1],t[0]};
			rep(i,3){
				if(cover(s,q[i]) && cover(t,q[i])){
					p=q[i];
					break;
				}
			}
		}
		else p=Point(b1*c2-b2*c1,a2*c1-a1*c2)/det;
		return true;
	}
	return false;
}

int n;
Point A,B;
Segment AB,S[100];
bool own[100],loc[100];

int solve(){
	vector< pair<double,int> > pts;
	rep(i,n){
		Point Q;
		if(intersect(AB,S[i],Q)) pts.pb(mp(abs(A-Q),i));
	}
	if(pts.size()==0) return 0;

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

	int cnt=0,id=pts[0].second;
	bool now=(own[id]?loc[id]:!loc[id]);
	for(int i=1;i<pts.size();i++){
		id=pts[i].second;
		if(own[id]){
			if(now!=loc[id]){ cnt++; now=!now; }
		}
		else{
			if(now==loc[id]){ cnt++; now=!now; }
		}
	}
	return cnt;
}

int main(){
	int T; scanf("%d",&T);
	while(T--){
		int xa,ya,xb,yb; scanf("%d%d%d%d%d",&xa,&ya,&xb,&yb,&n);
		A=Point(xa,ya);
		B=Point(xb,yb);
		AB=Segment(A,B);
		rep(i,n){
			int x1,y1,x2,y2,o,l; scanf("%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&o,&l);
			S[i]=Segment(Point(x1,y1),Point(x2,y2));
			own[i]=o;
			loc[i]=l;
		}
		printf("%d\n",solve());
	}

	return 0;
}

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

using namespace std;

vector<vector<int> > G, R;
bool u[255], vi[255];

void f(int v) {
	u[v] = true;
	for (int a : R[v])
		if (!u[a]) f(a);
}

bool ok(int v) {
	bool ans = u[v];
	vi[v] = true;
	for (int a : G[v])
		if (!vi[a] && ans) ans = ok(a);
	return ans;
}

int main() {
    int m;
	while (cin >> m, m) {
	    int n; cin >> n;
		vector<int> d(n + 2);
		G.assign(n + 2, vector<int>()), R.assign(n + 2, vector<int>());
		for (int i = 0; i <= n + 1; ++i) G[i].clear(), R[i].clear(), vi[i] = u[i] = false;
		for (int i = 1; i <= n; ++i) cin >> d[i];
		for (int i = 0; i <= n; ++i) {
			for (int j = 1; j <= m && i + j <= n + 1; ++j) {
				int k = i + j + d[i + j];
				if (k > n + 1) k = n + 1;
				if (k < 0) k = 0;
				G[i].push_back(k);
				R[k].push_back(i);
			}
		}
		f(n + 1);
		cout << (ok(0) ? "OK" : "NG") << endl;
	}

	return 0;
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
#define FOR0(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(ll i=l;i<n;i++)
using namespace std;
#define pi pair<ll,ll>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e14
ll power(ll num,ll g,ll mod){
  if(g==0)return 1;
  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;
  return power((num*num)%mod,g/2,mod);
}
 
int main(){
	int n;
	cin>>n;
	vector< vector<int> > vec(n, vector<int> (3));
	FOR0(i, n) FOR0(j, 3) cin>>vec[i][j];

	vector< vector<int> > dp(n, vector<int> (3, 0));
	dp[0][0] = vec[0][0]; dp[0][1] = vec[0][1]; dp[0][2] = vec[0][2];
	FORl(i, 1, n)
		FOR0(j, 3)
			dp[i][j] = vec[i][j] + max(dp[i-1][(j+1) % 3], dp[i-1][(j+2) % 3]);

	cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
vector<int> dy={1,0,-1,0};
vector<int> dx={0,1,0,-1};
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...));
}
int main(){
    int n,k,q;
    cin>>n>>k>>q;
    vector<int> points(n,q);
    rep(i,q){
        int a;
        cin>>a;
        a--;
        points[a]--;
    }
    rep(i,n){
        cout<<(points[i]<k ? "Yes" : "No")<<endl;
    }
}


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

using namespace std;

typedef long long LL;

const int N = 1010;

int n;
char last;
map<string, bool> h;

int main()
{
    cin >> n;

    bool flag = true;
    for(int i = 0; i < n; i++)
    {
        string t;
        cin >> t;

        if(!i)
        {
            h[t] = true;
            last = t.back();
            continue;
        }

        if(!h.count(t) && t[0] == last)
        {
            last = t.back();
            h[t] = true;
        }
        else flag = false;
    }

    if(flag) puts("Yes");
    else puts("No");

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define N 5000005
void Read(int &p)
{
	p = 0;
	char c = getchar();
	for (; c < '0' || c > '9'; c = getchar());
	for (; c >= '0' && c <= '9'; c = getchar())p = p * 10 + c - '0';
}
int n, m, rot, cnt, val[N], ans[N];
char T[N];
struct Node{int ch[3], rv, tg;}S[N];
void Build(int &q, int d, int s)
{
	q = ++cnt;
	if (d == n)
	{
		S[q].tg = s;
		return;
	}
	Build(S[q].ch[0], d + 1, s);
	Build(S[q].ch[1], d + 1, s + val[d]);
	Build(S[q].ch[2], d + 1, s + val[d] * 2);
}
void Pushdown(int q)
{
	if (S[q].rv)
	{
		swap(S[q].ch[1], S[q].ch[2]);
		S[S[q].ch[0]].rv ^= 1;
		S[S[q].ch[1]].rv ^= 1;
		S[S[q].ch[2]].rv ^= 1;
		S[q].rv = 0;
	}
}
void Insert(int q, int d)
{
	if (d == n)
		return;
	Pushdown(q);
	int a = S[q].ch[0];
	int b = S[q].ch[1];
	int c = S[q].ch[2];
	S[q].ch[1] = a;
	S[q].ch[2] = b;
	S[q].ch[0] = c;
	Insert(S[q].ch[0], d + 1);
}
void Getans(int q, int d, int s)
{
	if (d == n)
	{
		ans[S[q].tg] = s;
		return;
	}
	Pushdown(q);
	Getans(S[q].ch[0], d + 1, s);
	Getans(S[q].ch[1], d + 1, s + val[d]);
	Getans(S[q].ch[2], d + 1, s + val[d] * 2);
}
int main()
{
	Read(n);
	val[0] = 1;
	for (int i = 1; i <= n; i++)
		val[i] = val[i - 1] * 3;
	Build(rot, 0, 0);
	scanf("%s", T + 1);
	m = strlen(T + 1);
	for (int i = 1; i <= m; i++)
		if (T[i] == 'S')
			S[rot].rv ^= 1;
		else
			Insert(rot, 0);
	Getans(rot, 0, 0);
	for (int i = 0; i < val[n]; i++)
		printf("%d%c", ans[i], i == val[n] - 1 ? 10 : 32);
}


Measured memory_bytes: 21876
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);++i)
#define fi first
#define se second
typedef long long ll;
const ll MOD = 1000000007;
 
inline ll add(ll x, ll y) {return (x+y)%MOD;}
inline ll mul(ll x, ll y) {return (x*y)%MOD;}
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    int K; cin >> K;
    map<ll,ll> mp; // mp[i] i*j <= N, (i+1)*j > N となるN以下の自然数jの個数
    for(ll i=1; i*i<=N; ++i) {
        if(i*i==N) {
            mp[N/i]++;
        }
        else {
            mp[N/i]++;
            mp[i] = N/i - (N+i+1)/(i+1) + 1; 
        }
    }
    vector<ll> v;
    for(auto it = --mp.end();; --it) {
        v.push_back((*it).se);
        if(it == mp.begin()) break;
    }
    ll M = v.size();
    ll dp[105][65000];
    memset(dp,0,sizeof(dp));
    REP(j,M) dp[0][j] = 1;
    REP(i,K) {
        REP(j,M) dp[i+1][j] = mul(dp[i][M-1-j], v[j]);
        REP(j,M-1) dp[i+1][j+1] = add(dp[i+1][j+1], dp[i+1][j]); 
    }
    cout << dp[K][M-1] << endl;
    return 0;
}

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

#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define all(x) (x).begin(), (x).end()

#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
const int MOD = 1000000007;

int main() {
    IOS;
    int n;
    cin >> n;
    std::vector<int> a(n), b(n), c(n);

    for(int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];
    std::vector<std::vector<int> > dp(n, std::vector<int>(3));

    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for(int i = 1; i < n; i++) {
        dp[i][0] = MAX(dp[i - 1][1], dp[i - 1][2]) + a[i];
        dp[i][1] = MAX(dp[i - 1][0], dp[i - 1][2]) + b[i];
        dp[i][2] = MAX(dp[i - 1][0], dp[i - 1][1]) + c[i];
    }

    cout << MAX(dp[n - 1][0], MAX(dp[n - 1][1], dp[n - 1][2]));

    return 0;
}

Measured memory_bytes: 6912
X,Y,Z,K=map(int,input().split())
A=[int(x) for x in input().split()]
A.sort(reverse=True)
B=[int(x) for x in input().split()]
B.sort(reverse=True)
C=[int(x) for x in input().split()]
C.sort(reverse=True)
D=[a+b for a in A for b in B]
D.sort(reverse=True)
D=D[:3000]
E=[ab+c for ab in D for c in C]
E.sort(reverse=True)
for i in range(K):
  print(E[i])


Measured memory_bytes: 161072
#include <stdio.h>

int main(void)
{
	int a,b,i;
	int c=0;
	
	scanf("%d %d",&a,&b);
	
	for(i = 0;i<b-a;i++){
		c = c+i+1;
	}
		printf("%d\n",c-b);
		
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef complex<double> P;
#define ld double
const double eps=1e-10;
double cross(const P& a, const P& b) {return imag(conj(a)*b);}
double dot(const P& a, const P& b) {return real(conj(a)*b);}

pair<ld, P> smallest_enclosing_disc(vector<P> ps){
  auto c3 = [](const P &a, const P &b, const P &c){
              ld aa = norm(b - c);
              ld bb = norm(c - a);
              ld cc = norm(a - b);
              ld S = abs(cross(b - a, c - a));
              P p = (aa*(bb+cc-aa)*a + bb*(cc+aa-bb)*b + cc*(aa+bb-cc)*c) / (4*S*S);
              ld r = abs(p - a);
              return make_pair(r, p);
            };
  auto c2 = [](const P &a, const P &b){
              P c = (a + b) / (ld)2;
              ld r = abs(a - c);
              return make_pair(r, c);
            };
  auto in_circle = [](const P &a, const pair<ld, P> &c){
                     return norm(a - c.S) <= c.F*c.F + eps;
                   };
  int n = ps.size();
  random_shuffle(ps.begin(), ps.end());
  pair<ld, P> c = c2(ps[0], ps[1]);
  for(int i = 2; i < n; ++i){
    if(!in_circle(ps[i], c)){
      c = c2(ps[0], ps[i]);
      for(int j = 1; j < i; ++j){
        if(!in_circle(ps[j], c)){
          c = c2(ps[j], ps[i]);
          for(int k = 0; k < j; ++k){
            if(!in_circle(ps[k], c)){
              c = c3(ps[i], ps[j], ps[k]);
            }
          }
        }
      }
    }
  }
  return c;
}

void Main() {
  int n;
  R n;
  vector<P> a(n);
  rep(i,n) {
    double x,y;
    cin >> x >> y;
    a[i]=P(x,y);
  }
  pair<ld, P> p=smallest_enclosing_disc(a);
  pd(p.F);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

int popcount(int x) {
    int ret = 0;
    while (x) {
        ret += x & 1;
        x >>= 1;
    }
    return ret;
}

vector<int> solve(int n, int a, int b) {
    vector<int> ret;
    if (n == 1) {
        ret.push_back(a);
        ret.push_back(b);
        return ret;
    }
    if ((a & 1) != (b & 1)) {
        int x;
        for (int i = 0; i < (1 << n - 1); ++i) {
            if (i != (a >> 1) && i != (b >> 1) && (popcount(i ^ (a >> 1)) & 1) == 1) {
                x = i;
                break;
            }
        }
        vector<int> A = solve(n - 1, a >> 1, x);
        vector<int> B = solve(n - 1, x, b >> 1);
        for (int i : A) ret.push_back(i << 1 | (a & 1));
        for (int i : B) ret.push_back(i << 1 | (b & 1));
        return ret;
    }
    else {
        int x;
        vector<int> A = solve(n - 1, a >> 1, b >> 1);
        A.pop_back();
        vector<int> B = solve(n - 1, A.back(), b >> 1);
        for (int i : A) ret.push_back(i << 1 | (a & 1));
        for (int i : B) ret.push_back(i << 1 | ((a & 1) ^ 1));
        ret.push_back(b);
        return ret;
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    if ((popcount(a) + popcount(b) & 1) == 0) {
        printf("NO\n");
        return 0;
    }
    vector<int> ans = solve(n, a, b);
    printf("YES\n");
    for (int i : ans) printf("%d ", i);
    return 0;
}

Measured memory_bytes: 1628
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] maze = new char[h][w];
		int[][] distance = new int[h][w];
		Boolean[][] flag = new Boolean[h][w];
		int whiteCount = 0;
		
		for (int i = 0; i < h; i++) {
			String line = sc.next(); 
			for (int j = 0; j < w; j++) {
				char c = line.charAt(j);
				maze[i][j] = c;
				if (c == '.') {
					whiteCount++;
				}
			}
		}
	
		for (int i = 0; i < h; i++) {
			Arrays.fill(distance[i], Integer.MAX_VALUE);
		}
		
		for (int i = 0; i < h; i++) {
			Arrays.fill(flag[i], false);
		}
		
		Deque<Point> queue = new ArrayDeque<>();
		Point start = new Point(0, 0);
		flag[start.y][start.x] = true;
		distance[0][0] = 1;
		queue.addLast(start);
		int dx[] = {1, 0, -1, 0};
		int dy[] = {0, 1, 0, -1};
		
		while (!queue.isEmpty()) {
			Point p = queue.removeFirst();
			
			for (int i = 0; i < 4; i++) {
				int tmpX = p.x + dx[i];
				int tmpY = p.y + dy[i];
				if (tmpX >= 0 && tmpX < w && tmpY >= 0 && tmpY < h && flag[tmpY][tmpX] == false && maze[tmpY][tmpX] == '.') {
					flag[tmpY][tmpX] = true;
					queue.addLast(new Point(tmpX, tmpY));
					if (distance[tmpY][tmpX] > distance[p.y][p.x] + 1) {
						distance[tmpY][tmpX] = distance[p.y][p.x] + 1;
					}
				}
			}
		}
		if (flag[h - 1][w - 1]) {
			System.out.println(whiteCount - distance[h - 1][w - 1]);
		} else {
			System.out.println(-1);
		}
		
		/*
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				System.out.print(distance[i][j] + " ");
			}
			System.out.println();
		}
		*/
	}
}

class Point {
	public int x, y;
	
	public Point(int x, int y) {
		this.x = x;
		this.y = y;
	}
}

Measured memory_bytes: 21844
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	ll a, v, b, w, t;
	cin>>a>>v>>b>>w>>t;
	ll d=abs(a-b);
	if(v<=w){
		cout<<"NO"<<endl;
		return 0;
	}
	if(d<=t*(v-w)){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define    ll      long long int
#define    Fori(a,b) for (ll i = a ; i<b ;i++ )
#define    Forj(a,b) for (ll j = a ; j<b ;j++ )
#define    Fork(a,b) for (ll k = a ; k<b ;k++ )
#define    W       while
#define    pb      push_back
#define    nl      cout<<endl
#define    mod     1000000007
#define    I       cin>>
#define    Out     cout<<
#define    DOD(i)  cout<<setprecision(i)<<fixed<<
#define    XXX     return 0
#define    Fast    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;
ll nCr(ll n, ll r) 
{ 
    long long p = 1, k = 1;
    if (n - r < r) 
        r = n - r; 
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            long long m = __gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        }
    } 
    else
        p = 1; 
  
    return p;
} 
int main()
{
   Fast;
   ll n;I n;
  ll a[n],M=0;
  Fori(0,n){
    I a[i];
    if(M<a[i]) M=a[i];
  }
  ll freq[M+1]={0};
  Fori(0,n){
    freq[a[i]]++;
  }
  ll sum=0;
  for(int i=0;i<=M;i++){
      if(freq[i]>1){
          sum+=nCr(freq[i],2);
      }
  }
  for(int i=0;i<=M;i++){
  	if(freq[i]>2){
  	    //cout<<sum<<endl;
    	freq[i]=sum+nCr(freq[i]-1,2)-nCr(freq[i],2);
    }else if(freq[i]==2){
        freq[i]=sum-1;
    }else if(freq[i]<=1){
      	freq[i]=sum;
    }
  }
   for(int i=0;i<n;i++){
     cout<<freq[a[i]]<<endl;
   }
   
   XXX;
}




Measured memory_bytes: 5632
#include<stdio.h>
#include<math.h>

int main(void){

    int n,d;

    scanf("%d %d",&n,&d);
    float x[n][d];

    for(int j=0;j<n;j++){
        for(int i=0;i<d;i++){
            // printf("x[%d][%d]=",i,j);
            scanf("%f",&x[j][i]);
        };
    };

    int count=0;

    float sum = 0;

    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            sum = 0;
            for(int k=0;k<d;k++){
                sum = sum + pow(x[i][k]-x[j][k],2);
                // printf("sum[%d]=%f\n",k,sum);
            };
            // if(ceil(sqrt(sum)) != floor(sqrt(sum)) ){
            if(sqrt(sum) -(int)sqrt(sum) ==0){
                count = count+1;
            };
        };
    };
  
    printf("%d\n",count);

    return 0;
}

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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

const ll MAX_N=202020;
ll now_id;
map<P,ll> mp;//{色c=i,頂点id=j}を根とする部分木のサイズ
ll c[MAX_N];
ll dp[MAX_N];//色cの補集合
ll con[MAX_N];//頂点数
ll id[MAX_N];//頂点id

void dfs(Graph& g, int v, int p){
    now_id++;
    id[v]=now_id;
    for(auto e:g[v]){
        if(e.to==p) continue;
        dfs(g,e.to,v);

        con[v]+=con[e.to];
        ll now_con=con[e.to];

        auto s=mp.lower_bound({c[v],id[v]});
        auto t=mp.lower_bound({c[v]+1,-1});
        while(s!=t){
            now_con -= s->second;//c[v]を根とする部分木の頂点数分ひく
            s=mp.erase(s);
        }

        dp[c[v]]+=now_con*(now_con+1)/2;
    }
    con[v]++;
    mp[{c[v],id[v]}]=con[v];
}

void solve(){
    ll n;
    cin>>n;
    REP(i,n) cin>>c[i];
    Graph g(n);
    REP(i,n-1){
        ll a,b;
        cin>>a>>b;
        a--;b--;
        add_edge(g,a,b,1,true,1);
    }

    dfs(g,0,-1);
    rep(i,1,n+1) {
        ll ans = n*(n+1)/2;

        //根からの分を引く
        ll now_con = n;
        auto s=mp.lower_bound({i,-1});
        auto t=mp.lower_bound({i+1,-1});
        while(s!=t){
            now_con -= s->second;//c[v]を根とする部分木の頂点数分ひく
            s=mp.erase(s);
        }
        dp[i] += now_con*(now_con+1)/2;
        ans-=dp[i];
        cout<<ans<<en;
    }

}

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

    solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 56532
field = [[0]*3 for _ in range(3)]

for x in range(3):
    for y in range(3):
        field[x][y] = 0

def is_bingo(f):
    fl_v = [0 for _ in range(3)]
    fl_h = [0 for _ in range(3)]
    for i in range(3):
        for j in range(3):
            if f[i][j] == 1:
                fl_v[j]+=1
    if max(fl_v)==3:
        return True
    for i in range(3):
        for j in range(3):
            if f[i][j] == 1:
                fl_h[i]+=1
    if max(fl_h)==3:
        return True

    if f[0][0] == 1 and f[1][1] == 1 and f[2][2] == 1:
        return True

    if f[0][2] == 1 and f[1][1] == 1 and f[2][0] == 1:
        return True

    return False

bingo_num = [(-1,-1) for _ in range(101)]

for x in range(3):
    ax = list(map(int,input().split()))
    for y in range(3):
        bingo_num[ax[y]] = (x,y)

n = int(input())

for x in range(n):
    bn = bingo_num[int(input())]
    field[bn[0]][bn[1]] = 1

if is_bingo(field):
    print('Yes')
else:
    print('No')



Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
G = [[] for i in range(n)]
for i in range(n-1):
  a,b = map(int,input().split())
  a-=1;b-=1
  G[a].append(b)
  G[b].append(a)
C = list(map(int,input().split()))
C.sort(reverse = True)
ans = [0]*n
ans[0] = C[0]
que = collections.deque([0])
i = 1
M = 0
while que:
  node = que.popleft()
  for vi in G[node]:
    if ans[vi] == 0:
      ans[vi] = C[i]
      i += 1
      que.append(vi)
      M += min(ans[vi],ans[node])
print(M)
print(*ans)

Measured memory_bytes: 6260
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<int>;


class Arrow
{
public:
	ll x=0, y=0;
	bool operator<(const Arrow& another)const
	{
		return atan2(y, x) < atan2(another.y, another.x);
	}
};


int main()
{
	int N;
	cin >> N;
	
	vector<Arrow> ary(N);

	for (int i = 0; i < N; ++i)
	{
		cin >> ary[i].x >> ary[i].y;
	}

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


	double ans = 0;

	for (int i = 0; i < N; ++i)
	{
		for (int j = i; ; )
		{
			Arrow arw;
			for (int k = i;; k = (k + 1) % N)
			{
				arw.x += ary[k].x;
				arw.y += ary[k].y;
				if (k == j)break;
			}
			
			ans = max(ans, sqrt(arw.x*arw.x + arw.y*arw.y));
			

			j = (j + 1) % N;
			if (j == i)break;
		}
	}
	
	printf("%.10f\n", ans);

	return 0;
}

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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  if (K <= A) return cout << K << "\n", 0;
  if (K <= A + B) return cout << A << "\n", 0;
  cout << A - (K - A - B) << "\n";
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int A,B;
  cin>>A>>B;
  int p = 0;
  if(A>=13)p=B;
  else if(A>=6)p=B/2;
  else p=0;
  cout<<p<<endl;


  return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,m=LI()
  l=[True for _ in range(n+1)]
  for _ in range(m):
    l[I()]=False

  dp=[0 for _ in range(n+1)]
  dp[0]=1
  for i in range(n):
    for j in range(1,3):
      if i+j<=n and l[i]:
        dp[i+j]+=dp[i]

  # print(dp)
  return dp[n]%mod

# main()
print(main())


Measured memory_bytes: 465916
#include <iostream>
using namespace std;
//f
int main(void){
   long long n;
   cin >> n;
   long long ans = n;
   for(long long i = 1;i * i <= n;i++){
       if(n % i == 0){
           ans = min(ans,i - 1 + n / i - 1);
       }
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>
#include <cmath>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define absl(v) labs((v))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
#define downint greater<int>()
#define downchar greater<char>()
#define downstring greater<string>()
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
  
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,flag=0;
  int a[LIMIT2]={0},x[20][20]={0},y[20][20]={0};
  char s[LIMIT1];
  
  cin >> n;
  rep(i,n){
    cin >> a[i];
    rep(j,a[i]){
      cin >> x[i][j] >> y[i][j];
      x[i][j]--;
    }
  }
  
  rep(i,(1<<n)){
    flag=1;
	rep(j,n){
      if((i>>j)%2 == 1){
        rep(k,a[j]){
          m = (i>>x[j][k])%2;
          if(m != y[j][k]){
            flag=0;
            break;
          }
        }
      }
      if(flag==0) break;
    }
    if(flag==1){
      flag=0;
      m = i;
      while(m>0){
        if(m%2 == 1) flag++;
        m /= 2;
      }
      result = max(result,flag);
    }
  }
  cout << result << endl;
  
  return 0;
}

Measured memory_bytes: 2176
import sys

def solve(n, m):
    l = []
    for i in range(n):
        d, v = map(int, input().split())
        l.append((d, v))

    l.sort(reverse=True)

    now = -1
    count = 0
    for i in l:
        if now == i[0]:
            continue
        else:
            count += i[1]
            now = i[0]

    print(count)


while True:
    n, m = map(int, input().split())
    if n == m == 0:
        break
    solve(n, m)



Measured memory_bytes: 5612
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <numeric>
#include <climits>
#include <functional>
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++)
using ll = unsigned long long;
const ll mod = 1000000007;
const int M_MAX = 10000;
string al = "abcdefghijklmnopqrstuvwxyz";
//bool less_sec(const pair<int, int>&a, const pair<int, int>&b) {
//	return a.second > b.second;
//}
int M;

int main() {
	
	cin.tie(0);
	ios::sync_with_stdio(false);
    string str; cin >> str;
    int sum=700;
    for(int i=0; i<3; ++i){
        if(str[i]=='o') sum+=100;
    }
    cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR (int x) {
	if (x ==1)
		return false;
	if (x == 2)
		return true;
	if (x%2==0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}

using namespace std;
#pragma endregion
signed main() {
	int H, W;
	string s;
	cin >> H >> W;
	rep(i, H) {
		cin >> s;
		cout << s << endl << s << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) throws Exception {
	    Scanner sc = new Scanner(System.in);   
	    
	    int X = sc.nextInt();
	    int Y = sc.nextInt();
	    
	    System.out.println(X + (Y / 2));
	}    
}	

Measured memory_bytes: 21332
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,a[100005];
int32_t main(){
cin>>n;
for(ll i=0;i<n;i++)
cin>>a[i];
for(ll i=0;i<n-1;i++)
if(a[i]>a[i+1]){
a[i]--;
i++;
}else if(i==0){
a[i]--;
}else if(a[i]-1>=a[i-1]){
a[i]--;
}
for(ll i=0;i<n-1;i++)
if(a[i]>a[i+1]){
rc("No");
}
cout<<"Yes"<<endl;
}


Measured memory_bytes: 1024
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]
x,y = map(int,input().split())
if x in a and y in a:
    print("Yes")
elif x in b and y in b:
    print("Yes")
elif x in c and y in c:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#![allow(unused)]

use std::{cell, cmp, collections, convert, fmt, io, iter, ops, str};

use cell::{Cell, RefCell};
use cmp::Ordering::{Equal, Greater, Less};
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use io::{Read, Write};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($($args: tt)*) => { eprint!($($args)*) };
}

#[cfg(feature = "debug")]
macro_rules! debugln {
    ($($args: tt)*) => { eprintln!($($args)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($($args:tt)*) => {};
}

#[cfg(not(feature = "debug"))]
macro_rules! debugln {
    ($($args:tt)*) => {};
}

macro_rules! vmax {
    ($x: expr, $y: expr) => { cmp::max($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::max($x, vmax!($($args),*)) };
}

macro_rules! vmin {
    ($x: expr, $y: expr) => { cmp::min($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::min($x, vmin!($($args),*)) };
}

fn main() {
    let s = read_line();
    let t = read_line();

    let s = s.chars().cycle();
    let len = t.len();

    for rot in 0..len {
        let s = s.clone().skip(rot);
        if s.zip(t.chars()).all(|(s, t)| s == t) {
            println!("Yes");
            return;
        }
    }

    println!("No");
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if !buf.is_empty() {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}

fn next_prime(x: i32) -> i32 {
    for i in (x + 1).. {
        if is_prime(i) {
            return i;
        }
    }

    panic!("attempt to add with overflow");
}

fn is_prime(x: i32) -> bool {
    let ceil = f64::from(x).sqrt().ceil() as i32;
    x == 2 || (2..(ceil + 1)).all(|i| x % i != 0)
}

fn bit_high(bits: u64, pos: u64) -> bool {
    bits & (1 << pos) != 0
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  int a = x2-x1;
  int b = y2-y1;
  int x3 = x2 - b;
  int y3 = y2 + a;
  int x4 = x3 - a;
  int y4 = y3 - b;
  cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
  return 0;
}

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

const int N = 1e3 + 10, mod = 1e9 + 7;

int n, m;
char s[11][N];
int dp[N][1 << 9], pref[11][N];

void build() {
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            pref[i][j] = pref[i][j - 1] + (s[i - 1][j - 1] == '1');
        }
    }
    for(int j = 1; j <= m; j++) {
        for(int i = 1; i <= n; i++) pref[i][j] += pref[i - 1][j];
    }
}

int query(int i1, int j1, int i2, int j2) {
    return pref[i2 + 1][j2 + 1] - pref[i2 + 1][j1] - pref[i1][j2 + 1] + pref[i1][j1];
}

int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    for(int j = 0; j < N; j++) {
        for(int mask = 0; mask < (1 << 9); mask++) dp[j][mask] = (1 << 20);
    }
    int tc = 1; 
    //scanf("%d", &tc);
    while(tc--) {
        int k; scanf("%d%d%d", &n, &m, &k);
        for(int i = 0; i < n; i++) scanf("%s", &s[i]);
        for(int mask = 0; mask < (1 << (n - 1)); mask++) {
            int cur = 0;
            dp[0][mask] = 1;
            for(int i = 0; i < n; i++) {
                cur += (s[i][0] == '1');
                if((mask >> i) & 1 || i == n - 1) {
                    dp[0][mask] &= (cur <= k);
                    cur = 0;
                }
            }
            if(dp[0][mask]) dp[0][mask] = 0;
            else dp[0][mask] = (1 << 20);
        }
        build();
        for(int j = 1; j < m; j++) {
            for(int mask = 0; mask < (1 << (n - 1)); mask++) {
                int l = 0, r = j, res = -1;
                while(l <= r) {
                    int mid = (l + r) >> 1;
                    bool ok = 1;
                    int i1 = 0;
                    for(int i = 0; i < n; i++) {
                        if(i == n - 1 || ((mask >> i) & 1)) {
                            ok &= (query(i1, mid, i, j) <= k);
                            i1 = i + 1;
                        }
                    }
                    if(ok) {
                        res = mid;
                        r = mid - 1;
                    }
                    else l = mid + 1;
                }
                if(res < 0) continue;
                dp[j][mask] = (res ? dp[res - 1][mask] + 1 : 0);
            }
        }
        int ans = (1 << 20);
        for(int mask = 0; mask < (1 << (n - 1)); mask++) {
            int cnt = __builtin_popcount(mask);
            ans = min(ans, cnt + dp[m - 1][mask]);
        }
        printf("%d\n", ans);
    }    
    return 0;
}

Measured memory_bytes: 2432
import sys
A, B, C, D, E, F = map(int, input().split())


def concentration(water, suger):
    if water * E/100 < suger or water + suger == 0:
        return 0
    return (100 * suger/(water + suger))

lst_w = []
limit_w = (F+A*100-1)//(A*100)
for i in range(limit_w):
    for j in range(limit_w):
        if 100 * (A * i + B * j) <= F:
            lst_w += [100 * (A * i + B * j)]

lst_s = []
limit_s = (F+C-1)//C
for i in range(limit_s):
    for j in range(limit_s):
        if C* i + D * j <= F:
            lst_s += [C * i + D * j]

# print (lst_w)
# print (lst_s)
set_w = set(lst_w)
set_s = set(lst_s)

# print (set_w)
# print (set_s)

ans = 0
ans_total = 0
ans_suger = 0
for water in set_w:
    for suger in set_s:
        if water + suger <= F:
            a = concentration(water, suger)
            if ans < a:
                ans = a
                ans_total = water + suger
                ans_suger = suger
            if ans == 50:
                print (ans_total, ans_suger)
                sys.exit()

if ans == 0:
    print (A * 100, 0)
else:
    print (ans_total, ans_suger)

# print (ans)


Measured memory_bytes: 54200
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()

#define FOR(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)

//関数定義
//最大公約数
ll gcd(ll a, ll b);

//最小公倍数
ll lcm(ll a, ll b);

int main() {
  // ========================================================
  int n;
  double inp, ans;
  cin >> n;
  REP(i, n) {
    cin >> inp;
    ans += 1 / inp;
  }
  cout << 1 / ans << endl;
}

//最大公約数
ll gcd(ll a, ll b) {
  if (!b) return a;
  return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

Measured memory_bytes: 256
import sys
n=int(input())
a=list(map(int,input().split()))
if len(a)==1:
  print("Yes")
  sys.exit()
if len(a)==2 and a[0]<=a[1]:
  print("Yes")
  sys.exit()
elif len(a)==2:
  print("No")
  sys.exit()
  
for i in range(1,n-1):
  if a[i+1]>=a[i]-1 and a[i]-1>=a[i-1]:
    a[i]=a[i]-1
    continue

  if a[i+1] >= a[i] and a[i] >=a [i-1]:
    continue
  else:
    print("No")
    sys.exit()
print("Yes")

Measured memory_bytes: 14704
def is_kaibun(s):
    n = len(s)
    end = n // 2
    for i in range(end):
        if s[i] != s[n-1-i]:
            return False
    return True

s = input()
n = len(s)

pivot = (n - 1) //2
pre = s[:pivot]
post = s[pivot+1:]

if pre == post and is_kaibun(pre) and is_kaibun(post):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064