akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main()
{
	while (true)
	{
		int s, m = 0, e = 0, j = 0, sum[7];
		cin >> s;
		if (s == 0)break;
		for (int i = 0; i < s; i++)
		{
			cin >> m >> e >> j;
			if (m == 100 || e == 100 || j == 100)
			{
				cout << "A" << endl;
			}
			else
			{
				sum[0] = (m + e) / 2;
				if (sum[0] >= 90)
				{
					cout << "A" << endl;
				}
				else
				{
					sum[1] = (m + e + j) / 3;
					if (sum[1] >= 80)
					{
						cout << "A" << endl;
					}
					else
					{
						if (sum[1] >= 70)
						{
							cout << "B" << endl;
						}
						else
						{

							if (sum[1] >= 50 && m >= 80 || e >= 80)
							{
								cout << "B" << endl;
							}
							else cout << "C" << endl;
						}
					}
				}
			}
		}
	}
}

Measured memory_bytes: 1156
#include<iostream>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include<cmath>
#include <queue>
#include <numeric>

using lli = long long int;
int inf = 1000000007;
using namespace std;

int N, A, B;

lli nCr(lli n, lli r) {
	lli a = 1, b = 1;
	for (lli i = 0; i < r; i++) {
		a *= (n - i);
		b *= (i + 1);
		if (a % b == 0) { a /= b; b = 1; }
	}
	return a / b;
}

int main()
{
	cin >> N >> A >> B;
	vector<lli> v(N);
	for (int i = 0; i < N; i++)cin >> v[i];
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	lli sum = 0;
	for (int i = 0; i < A; i++)sum += v[i];
	lli ans = 0;
	lli n = count(v.begin(), v.end(), v[A - 1]);
	//全部同じときはA-B個ok
	if (v[0] == v[A - 1]) {
		for (lli i = A; i <= B && i <= n; i++) ans += nCr(n, i);
	}
	else {
		int c = 0;
		while (v[c] != v[A - 1])c++;
		ans = nCr(n, A - c);
	}
	printf("%f\n", sum / (A + .0));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def slove():
    import sys
    input = sys.stdin.readline
    s = str(input().rstrip('\n'))
    yy = int(s[:2])
    mm = int(s[2:])
    if 1 <= mm <= 12 and 1 <= yy <= 12:
        print("AMBIGUOUS")
    elif 1 <= mm <= 12:
        print("YYMM")
    elif 1 <= yy <= 12:
        print("MMYY")
    else:
        print("NA")


if __name__ == '__main__':
    slove()


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

using Graph=vector<vector<int>>;
using P=pair<int,int>;
const int INF=1e9;

int main()
{
   int N; cin>>N;
   Graph G(N);
   for(int i=0;i<N-1;i++){
      int a,b; cin>>a>>b;
      a--; b--;
      G[a].push_back(b);
      G[b].push_back(a);
   }
   int K; cin>>K;
   vector<int> num(N,-1);
   for(int i=0;i<K;i++){
      int v,p; cin>>v>>p;
      num[v-1]=p;
   }

   vector<int> dist(N,INF);
   priority_queue<P,vector<P>,greater<P>> Q;
   for(int i=0;i<N;i++) if(num[i]>=0){
      dist[i]=num[i];
      Q.push({dist[i],i});
   }
   while(!Q.empty()){
      int v=Q.top().second; Q.pop();
      for(int u:G[v]) if(dist[u]>dist[v]+1){
         dist[u]=dist[v]+1;
         Q.push({dist[u],u});
      }
   }

   bool ok=true;
   for(int i=0;i<N;i++){
      if(num[i]>=0 and dist[i]!=num[i]) ok=false;
      for(int j:G[i]) if(dist[i]==dist[j]) ok=false;
   }
   cout<<(ok? "Yes":"No")<<endl;
   if(ok) for(int i=0;i<N;i++) cout<<dist[i]<<endl;
   return 0;
}


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


int main(){
    int x,y;
    cin>>x>>y;

    vector<int> v1 = {1,3,5,7,8,10,12};
    vector<int> v2 = {4,6,9,11};

    if ( (find(v1.begin(), v1.end(), x)!=v1.end() && find(v1.begin(), v1.end(), y)!=v1.end() )
           || (find(v2.begin(), v2.end(), x)!=v2.end() && find(v2.begin(), v2.end(), y)!=v2.end() )) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b && b==c){
        cout << 1 << endl;
    }else if(a==b && b!=c){
        cout << 2 << endl;
    }else if(b==c && c!=a){
        cout << 2 << endl;
    }else if(c==a && a!=b){
        cout << 2 << endl;
    }else if(a!=b && b!=c){
        cout << 3 << endl;
    }
}




Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int sum = min(a, b);
  sum += min(max(a, b), c);
  cout << ((max(max(a, b), c) == sum) ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
<?php
//error_reporting(0);
//$S = trim(fgets(STDIN));
list($H,$W) = explode(" ",trim(fgets(STDIN)));
//$a = array_map('intval',explode(" ",trim(fgets(STDIN))));

//
$f = intdiv($W+1,2);
$s = intdiv($W,2);
$res = $f * intdiv($H,2);
$res += $s * intdiv($H,2);
if (($H % 2) == 1) {
  $res+=$f;
}
if ($H==1 ||$W ==1) {
  $res=1;
}
printf("%d\n",$res);


Measured memory_bytes: 4856
from collections import defaultdict
g = defaultdict(int)
h,w,m = map(int, input().split())
d = [0]*(3*10**5+1)
e = [0]*(3*10**5+1)
for i in range(m):
  h,w = map(int, input().split())
  g[h*(3*10**5+1)+w]+=1
  d[h]+=1
  e[w]+=1
h1=max(d)
w1=max(e)
ans=h1+w1
h = []
l = []
for i in range(3*10**5+1):
  if d[i] == h1:
    h.append(i)
  if e[i] == w1:
    l.append(i)
for i in h:
  for j in l:
    if g[i*(3*10**5+1)+j]==0:
      print(ans)
      exit()
print(ans-1)


Measured memory_bytes: 166368
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 1e6;

struct II {
    int v, num;
    bool operator < (const II &t) const {return v > t.v;}};
int n, m, a[N], cs[N];
II b[N];

int BiS(int v, int l, int r)
{
    if (v < a[l]) return -1;
    int res;
    while (l <= r) {
        int mid = (l + r) / 2;
        if (a[mid] > v) r = mid - 1;
        else l = mid + 1, res = mid;
    }
    return res;
}

void Create_CS()
{
    fill(cs, cs + N, 0);
    for (int i = 1; i <= m; ++i) {
        int tmp = BiS(b[i].v, cs[i-1] + 1, n);
        if (tmp == -1) break;
        int mx = cs[i-1] + b[i].num;
        if (tmp <= mx) {cs[i] = tmp; break;}
        cs[i] = mx;
    }
}

void Cal()
{
    int t = 0, mark = 0;
    long long res = 0;
    while (t < n) {
        ++mark;
        if (cs[mark] == 0) break;
        res += (long long) b[mark].v * (cs[mark] - t);
        t = cs[mark];
    }

    for (int i = t + 1; i <= n; ++i) res += a[i];
    cout << res;
}

int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 1; i <= m; ++i) cin >> b[i].num >> b[i].v;
    sort(a + 1, a + n + 1); sort(b + 1, b + m + 1);
    Create_CS();
    Cal();

    return 0;
}


Measured memory_bytes: 7168
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int y,m,d;
	scanf("%d/%d/%d",&y,&m,&d);
	if(y<2019 || y==2019 && m<=4)	printf("Heisei\n");
	else printf("TBD\n");
	return 0;
}

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

int main(){

int num;

cin>>num;

if(num%10==3){
    cout<<"bon"<<endl;

}else if(num%10==0 || num%10==1 || num%10==6 || num%10==8){
    cout<<"pon"<<endl;
}else{
    cout<<"hon"<<endl;
}


    return 0;
}

Measured memory_bytes: 3636
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int n,l,r,ans;
inline void read(int &x)
{
	int data=0,w=1;
	char ch=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(ch>='0'&&ch<='9')data=(data<<3)+(data<<1)+(ch^'0'),ch=getchar();
	x=data*w;
}
int main()
{
	read(n);
	while(n--)
	{
		read(l);read(r);
		ans+=(r-l+1);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <sstream>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <iostream>
#include <fstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <iterator>
#include <iomanip>
#include <unordered_map>

using namespace std;

#define ll long long int
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    double l;
    cin>>l;
    cout<<fixed<<setprecision(10)<<(l/3)*(l/3)*(l/3);

 }


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

int main(){
    ll l,r,d,counter=0;
    cin >> l >> r >> d;
    rep(i,r-l+1){
        int num = l+i;
        if(num%d==0){
            counter++;
        }
    }
    cout << counter << endl;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
const int N = 110;
const double pi = acos(-1);
const double eps = 1e-7;
const double sn = sin(0.6), cs = cos(0.6);
int n, m, top;
double ans[N];
struct P{
	int id;
	double x, y, t;
	P(double x = 0, double y = 0):x(x), y(y){}
}p[N], sta[N];
inline int Sgn(double x) { return fabs(x) < eps ? 0 : x > 0 ? 1 : -1; }
inline P operator-(P u, P v) { return P(u.x - v.x, u.y - v.y); }
inline int Cross(P u, P v) { return Sgn(u.x * v.y - u.y * v.x); }
inline double Length(P u) { return u.x * u.x + u.y * u.y; }
inline double Ang(P u, P v) { return acos((double)(u.x * v.x + u.y * v.y) / sqrt(Length(u)) / sqrt(Length(v))); }
inline bool Cmp(P u, P v) {
	if (fabs(u.t - v.t) > eps) return u.t < v.t;
	return Length(u - p[1]) > Length(v - p[1]);
}
inline void Rot(P &u) {
	u = P(u.x * cs - u.y * sn, u.y * cs + u.x * sn);
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%lf%lf", &p[i].x, &p[i].y); Rot(p[i]); p[i].id = i;
		if (p[i].x < p[1].x || (p[i].x == p[1].x && p[i].y < p[1].y)) swap(p[i], p[1]);
	}
	for (int i = 2; i <= n; ++i) {
		P tmp = p[i] - p[1];
		p[i].t = atan2(tmp.y, tmp.x);
	}
	sort(p + 2, p + n + 1, Cmp);
	m = 2; for (int i = 3; i <= n; ++i) if (fabs(p[i].t - p[m].t) > eps) p[++m] = p[i];
	for (int i = 1; i <= m; ++i) {
		while (top > 1 && Cross(p[i] - sta[top - 1], sta[top] - sta[top - 1]) > 0) --top;
		sta[++top] = p[i];
	}
	sta[top + 1] = sta[1]; sta[0] = sta[top];
	for (int i = 1; i <= top; ++i) ans[sta[i].id] = pi - Ang(sta[i - 1] - sta[i], sta[i + 1] - sta[i]);
	for (int i = 1; i <= n; ++i) printf("%.10lf\n", ans[i] / pi / 2);
	return 0;
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(0);
  	cin.tie(0);
  	string n,m;
  	cin >> n >> m;
  	int count = 0;
  	for(int i = 0;i<int(m.size());++i) {
		if(n[i] != m[i])
          count++;
    }
  	cout << count;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
const int N = 1e5 + 5;
int n, mod;
int dp[N], sol[N];
deque<int> g[N], pre[N], suf[N];
 
int add(int a, int b)
{
	a = (a + mod) % mod;
	b = (b + mod) % mod;
	return (a + b) % mod;
}
 
int mul(int a, int b)
{
	return (1ll * a * b) % mod;
}
 
void dfs(int node, int parent)
{
	int cur = 1;
	for(int i = 0; i < g[node].size(); i++)
	{
		int child = g[node][i];
		if(child != parent){
			dfs(child, node);
			cur = mul(cur, dp[child]);
		}
		pre[node].push_back(cur);
	}
	cur = 1;
	for(int i = (int)g[node].size() - 1; i >= 0; i--)
	{
		int child = g[node][i];
		if(child != parent){
			cur = mul(cur, dp[child]);
		}
		suf[node].push_front(cur);
	}
	dp[node] = add(1, cur);
}
 
void dfs2(int node, int parent, int val_parent)
{
	dp[node] = add(dp[node], -1);
	dp[node] = mul(dp[node], val_parent);
	dp[node] = add(dp[node], 1);
	sol[node] = dp[node];
	for(int i = 0; i < g[node].size(); i++)
	{
		int child = g[node][i];
		if(child != parent){
			int p = 1, s = 1;
			if(i)
				p = pre[node][i - 1];
			if(i + 1 < g[node].size())
				s = suf[node][i + 1];
			dfs2(child, node, add(1, mul(mul(p, s), val_parent)));
		}
	}
}
 
int main()
{
//	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef ONLINE_JUDGE
	// freopen("", "r", stdin);
	// freopen("", "w", stdout);
#endif
	cin >> n >> mod;
	for(int i = 0; i < n - 1; i++)
	{
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1, 1);
	dfs2(1, 1, 1);
	for(int i = 1; i <= n; i++)
		cout << add(sol[i], -1) << '\n';
	return 0;
}

Measured memory_bytes: 262144
'use strict';
(function(stdin) {
  var inputs = stdin.toString().trim().split('\n');
  var params = inputs[0].split(' ').map(Number);

  (function(a, b, c) {
    // ????????????????????????
    if(a<b && b<c)
    	console.log('Yes');
    else
    	console.log('No');

  }(params[0], params[1], params[2]));

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15672
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int s1 = sc.nextInt();
   int s2 = sc.nextInt();
   int s3 = sc.nextInt();
   if((10*s2+s3)%4==0)System.out.println("YES");
   else System.out.println("NO");
 }
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector> 
#include <cmath>
#include <algorithm>
#include <functional>
#define debug printf("****\n")
#define Mod 1000000007
#define pi (acos(-1))
#define INF 0x3f3f3f3f
#define esp (1e-6)
#define maxn 400005
using namespace std;
typedef long long ll;

struct Edge{
	int to;
	int next;
	int w;
}e[maxn];
struct Node{
	int p;
	int ds;
	bool operator < (const Node&n)const{
		return ds>n.ds;
	}
};
int head[maxn],cnt = 1;
int dis[maxn];
int fa[maxn];
void add(int x,int y,int w){
	e[cnt] = {y,head[x],w};
	head[x] = cnt++;
}
void dijkstra(int s){
	memset(dis,INF,sizeof(dis));
	priority_queue<Node> q;
	dis[s] = 0;
    q.push({s,0});
	while(!q.empty()){
		int pp = q.top().p;
		int dds = q.top().ds;
		q.pop(); 
        if( dds != dis[pp] ) continue;
		for(int i = head[pp];i != 0;i = e[i].next){
			int to = e[i].to;
			int w = e[i].w;
			if(dis[to] > dds + w){
				dis[to] = dds + w;
				fa[to]=pp;
				q.push({to,dis[to]}); 
			}
		}
	}
}
void init(int n){
	for(int i = 1 ; i <= n ; i ++ )
	fa[i]=i;
} 
int main(){
	int n,m,fr,to;
	scanf("%d%d",&n,&m);
	init(n);
	while(m--){
		scanf("%d%d",&fr,&to);
		add(fr,to,1);
		add(to,fr,1);
	}
	dijkstra(1);
	for(int i = 2 ; i <= n ; i ++ ){
		if(fa[i]==i){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	for(int i = 2 ; i <= n ; i ++ ) printf("%d\n",fa[i]);
	return 0;
}

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

int H,W;
vector<string> S(512);
vector<vector<bool>> ansr(512,vector<bool>(512,false));
vector<vector<bool>> ansb(512,vector<bool>(512,false));

void search(int x,int y){
  if(x<0||x>=W||y<0||y>=H) return;
  if(ansr.at(y).at(x)==true && S.at(y).at(x)=='.') return;//trueは#の証、Sも#なら紫でセーフ
  if(ansb.at(y).at(x)) return;
  
  ansb.at(y).at(x)=true;
  
  search(x+1,y);
  search(x,y+1);
  search(x-1,y);
  search(x,y-1);
}

int main(){
  cin >> H >> W;
  for(int i=0;i<H;i++){
    cin >> S.at(i);
  }
  
  for(int i=1;i<H-1;i++){
    ansr.at(i).at(1)=true;
    if(i%2){
      for(int j=1;j<W-1;j++)
      ansr.at(i).at(j)=true;
      continue;
    }
    for(int j=1;j<W-1;j++){
      if(S.at(i).at(j)=='#'){
        ansr.at(i).at(j)=true;
      }
    }
  }
  //ここまでで赤が出来上がり
  //深さ優先探索
  search(0,0);
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(ansr.at(i).at(j))
        cout << '#';
      else
        cout << '.';
    }
    cout << endl;
  }
  cout << endl;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(ansb.at(i).at(j))
        cout << '#';
      else
        cout << '.';
    }
    cout << endl;
  }
}

Measured memory_bytes: 28416
#include <bits/stdc++.h>
#define int long long
using namespace std;

int a[5][5],b[5],c[5];

signed main()
{
	for (int i=1;i<=3;i++)
	{
		for (int j=1;j<=3;j++)  cin>>a[i][j];
	}
	for (b[1]=0;b[1]<=100;b[1]++)
	{
		for (b[2]=0;b[2]<=100;b[2]++)
		{
			for (b[3]=0;b[3]<=100;b[3]++)
			{
				int flag=1;
				for (int i=1;i<=3;i++)  c[i]=a[1][i]-b[1];
				for (int i=2;i<=3;i++)
				{
					for (int j=1;j<=3;j++)
					{
						if (a[i][j]!=b[i]+c[j])
						{
							flag=0;
							break;
						}
					}
					if (flag==0)  break;
				}
				if (flag==1)  return cout<<"Yes"<<endl,0;
			}
		}
	}
	cout<<"No"<<endl;
	
	return 0;
}

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

int n,a[100005],b[100005],c[100005];
int64_t res=0;

int Binary1(int x)
{
    int rs=-1,l=1,r=n;
    while(l<=r)
    {
        int mid=(l+r)/2;
        if(a[mid]<x)
        {
            rs=mid;
            l=mid+1;
        }
        else
            r=mid-1;
    }
    return rs;
}

int Binary2(int x)
{
    int rs=-1,l=1,r=n;
    while(l<=r)
    {
        int mid=(l+r)/2;
        if(c[mid]>x)
        {
            rs=mid;
            l=mid+1;
        }
        else
            r=mid-1;
    }
    return rs;
}

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++)
        cin>>b[i];
    for(int i=1;i<=n;i++)
        cin>>c[i];
    sort(a+1,a+n+1);
    sort(c+1,c+n+1,greater<int>());
    for(int i=1;i<=n;i++)
    {
        int64_t t1=Binary1(b[i]);
        int64_t t2=Binary2(b[i]);
        if(t1!=-1&&t2!=-1)
            res+=t1*t2;
    }
    cout<<res;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;
int main()
{
	long N, Q, K;
	vector<long> QQ;
	cin >> N >> K >> Q;
	vector<long> NN(100000, K-Q);
	for (long i = 0; i < Q; i++)
	{
		long t;
		cin >> t;
		QQ.push_back(t);
	}
	for (long i = 0; i < Q; i++)
	{
		NN[QQ[i]-1]++;
	}
	for (long i = 0; i < N; i++)
	{
		if(NN[i]>0)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 2292
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)
int main(){
    int N,M;
    cin>>N>>M;
    int S[2000],T[2000];
    rep(i,N) cin>>S[i];
    rep(i,M) cin>>T[i];
    ll dp[2000][2000];
    ll row[2000];
    rep(i,M) row[i]=0;
    ll sum,pre;;
    for(int i=N-1;i>-1;i--){
        sum=0;
        for(int j=M-1;j>-1;j--){
            if(S[i]!=T[j]) {
                sum=(sum+row[j])%mod;
                continue;
            }
            pre=row[j];
            row[j]=(row[j]+1+sum)%mod;
            sum=(sum+pre)%mod;
            // cout<<i<<" "<<j<<" "<<sum<<endl;
            // cout<<row[j]<<" ";
        }
        // cout<<endl;
    }
    sum=1;
    rep(i,M){
        sum=(sum+row[i])%mod;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""

import queue

def main():
    N, M = map(int, input().split())

    connedted_room_list = [ [] for i in range(N)] # ここでNとMを書き間違えていた。
    for i in range(M):
        A, B = map(int, input().split())
        connedted_room_list[A-1].append(B-1)
        connedted_room_list[B-1].append(A-1)

    answer_list = [ -1 for i in range(N)]
    answer_list[0] = 0

    next_rooms_queue = queue.Queue()
    next_rooms_queue.put(0)
    now_room = int()
    while not next_rooms_queue.empty():
        now_room = next_rooms_queue.get()
        for i in connedted_room_list[now_room]:
            if answer_list[i] == -1:
                answer_list[i] = now_room
                next_rooms_queue.put(i)

    
    is_escapable = True
    for i in range(1, N):
        if answer_list[i] == -1:
            is_escapable = False
            break

    if is_escapable:
        print("Yes")
        for i in range(1, N):
            print(answer_list[i]+1)
    else:
        print("No")

if __name__ == "__main__":
    main()




Measured memory_bytes: 34528
from itertools import*
s,k=open(0)
k=int(k)
g=[len(list(v))for _,v in groupby(s)]
print(sum(c//2for c in g)*k+((s[0]==s[-2])*g[0]%2&g[-2]%2)*(k//2*(-len(s)==~g[0])or k-1))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	int n;
	cin>>n;
	if(n>=30)cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}



Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int K = in.nextInt();

            int count = 1;
            for (int i = 0; i < N; i++) {
                if (i == 0) {
                    count *= K;
                } else {
                    count *= K - 1;
                }
            }

            System.out.println(count);
        }
    }
}


Measured memory_bytes: 26868
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long N, std::vector<long long> a){
    ll cnt = 0;
    rep(i, N){
        if(a[a[i]]== i)
            cnt ++;
    }
    cout << cnt /2 << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
        a[i]--;
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 1024
import collections
import time
def bfs(G,l):
    l.append([1,1])
    visited = [[0] * len(G[0]) for i in range(len(G))]
    chk = 0
    G[1][1] = 0
    while(len(l)):
        [n0,n1] = l.popleft()
        if visited[n0][n1] == 1:
            continue
        else:
            visited[n0][n1] = 1
        if [n0,n1] == [len(G)-2,len(G[0])-2]:
            chk = 1
            break
        if G[n0][n1+1] != "#" and visited[n0][n1+1] == 0:
            l.append([n0,n1+1])
            G[n0][n1+1] = min(G[n0][n1] + 1,G[n0][n1+1])

        if G[n0][n1-1] != "#" and visited[n0][n1-1] == 0:
            l.append([n0,n1-1])
            G[n0][n1-1] = min(G[n0][n1] + 1,G[n0][n1-1])

        if G[n0+1][n1] != "#" and visited[n0+1][n1] == 0:
            l.append([n0+1,n1])
            G[n0+1][n1] = min(G[n0][n1]+1,G[n0+1][n1])

        if G[n0-1][n1] != "#" and visited[n0-1][n1] == 0:
            l.append([n0-1,n1])
            G[n0-1][n1] = min(G[n0][n1]+1,G[n0-1][n1])
        #print(n0,n1)
    return chk

[h,w] = [int(i) for i in input().split()]
st = time.time()
s = [["#"] * (w+2)]
whites = 0
for i in range(h):
    ls = ["#"]
    tmp = input()
    for j in range(len(tmp)):
        if tmp[j] == ".":
            ls.append(200)
        else:
            ls.append(tmp[j])
    ls.append("#")
    whites += tmp.count(".")
    s.append(ls)
s.append(["#"] * (w+2))
l = collections.deque()
#print(time.time() - st)
if bfs(s,l):
    print(whites - s[h][w]-1)

else:
    print(-1)
#print(time.time() - st)


Measured memory_bytes: 40812
N, K = map(int, input().split())
S = input()

l = []
now = 1 # 今見ている数(1から見る配列を作りたいので1で初期化)
cnt = 0

# lには(1の個数),(0の個数),(1の個数),(0の個数),...(1の個数)という感じのリストを入れたい(両端が0から始まるとしても1が0こあるとしてカウントしたい)
for i in range(N):
    if int(S[i]) == now:
        cnt += 1
    else:
        l.append(cnt)
        cnt = 1
        now = 1 - now # 0と1を切り替える(now ^= 1でも良い)
if cnt != 0:
    l.append(cnt)
if len(l) % 2 == 0: # (1の個数),(0の個数),(1の個数),(0の個数),...(0の個数)となってしまっていたら最後に0を入れておく
    l.append(0)
# print(l)

ans = 0
width = 2 * K + 1

left = 0
right = 0
tmp = 0 # [left, right)の総和
for i in range(0, len(l), 2):
    nextleft = i # 0,2,4,...
    nextright = min(i + width, len(l)) # 0+width,2+width,...
    while nextleft > left:
        tmp -= l[left]
        left += 1
    while nextright > right:
        tmp += l[right]
        right += 1
    ans = max(ans, tmp)

"""
# 愚直に足し算を繰り返すとTLE
for i in range(0, len(l), 2): # ここを2ごとにすることで1の個数を数えられる
    tmp = 0
    left = i
    right = min(i + width, len(l))
    for j in range(left, right): # leftからright-1まで
        tmp += l[j]
    ans = max(ans, tmp)
"""

print(ans)


Measured memory_bytes: 4212
X,Y=map(int, input().split())

import math

def combination(n, x, mod=10**9+7):
    factorial = [1] * (n+1)
    t = 1
    for i in range(1, n+1):
        t = (t * i) % mod
        factorial[i] = t
    tmp = factorial[n]
    tmp = (tmp * pow(factorial[x], mod-2, mod)) % mod
    tmp = (tmp * pow(factorial[n-x], mod-2, mod)) % mod
    return tmp

if 2*Y-X<0 or 2*X-Y<0:
	print(0)
elif (2*Y-X)%3!=0 or (2*X-Y)%3!=0:
	print(0)
else:
	a=(2*Y-X)//3
	b=(2*X-Y)//3
	print(combination(a+b,a,mod=10**9+7))


Measured memory_bytes: 29300
#include <bits/stdc++.h>
     
#define pll pair <long long,long long>
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define vll vector <ll>
#define NFS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl '\n'
#define M 1000000007   
using namespace std;
 
int main()
{
    NFS
 	int n,r;
 	cin>>n>>r;
 	cout<<(int)(floor( log(n)/log(r)) + 1);
    return 0;
}

Measured memory_bytes: 512
package main

import (
	"fmt"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}
func main() {
	var N int
	fmt.Scanf("%d\n", &N)
	A := make([]int, N)
	B := make([]int, N)
	C := make([]int, N)
	for i := 0; i < N; i++ {
		var a int
		fmt.Scan(&a)
		A[i] = a
	}
	sum := 0
	for i := 0; i < N; i++ {
		var a int
		fmt.Scan(&a)
		B[i] = a
		sum += a
	}
	for i := 0; i < N-1; i++ {
		var a int
		fmt.Scan(&a)
		C[i] = a
	}
	for i := 0; i < N-1; i++ {
		n := A[i]
		n1 := A[i+1]
		if n1-n != 1 {
			continue
		}
		sum += C[n-1]
	}
	fmt.Println(sum)

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N, K;
  string S;
  cin >> N >> K >> S;
  vector<pair<long, long>> data;
  int count = 1;
  for(int i = 1; i < S.size(); i++){
    if(S.at(i - 1) == S.at(i)){
      count++;
    } else {
      data.push_back(make_pair(count, S.at(i - 1) - '0'));
      count = 1;
    }
  }
  data.push_back(make_pair(count, S.at(N - 1) - '0'));
  int ans = -1, front = 0, back = 0, zeroc = 0;
  count = 0;
  while(front < data.size()){
    if(data.at(front).second != 0){
      count += data.at(front).first;
      front++;
    } else {
      count += data.at(front).first;
      front++;
      zeroc++;
    }
    while(zeroc > K){
      if(data.at(back).second != 0){
        count -= data.at(back).first;
        back++;
      } else {
        count -= data.at(back).first;
        back++;
        zeroc--;
      }
    }
    ans = max(ans, count);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2548
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"sort"
	"strconv"
)

func main() {
	log.SetFlags(log.Lshortfile)
	N := nextInt()
	a := nextInt()
	b := nextInt()
	p := nextInts(N)
	sort.Ints(p)
	cnts := make([]int, 3)
	for i := 0; i < N; i++ {
		if p[i] <= a {
			cnts[0]++
		} else if p[i] <= b {
			cnts[1]++
		} else {
			cnts[2]++
		}
	}
	fmt.Println(intMin(cnts...))
}

func intPow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func intMax(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func intMin(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func intSum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func intAbs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	return p[i].b < p[j].b
}

var nextReader func() string

func init() {
	nextReader = newScanner()
}

func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 640
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;

int main(void){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++){
        cin >> v.at(i);
    }
    
    vector<pair<int, int>> vOdd(100010);
    vector<pair<int, int>> vEven(100010);
    for(int i = 0; i < 100010; i++){
        vOdd.at(i).first = 0;
        vOdd.at(i).second = i;
        vEven.at(i).first = 0;
        vEven.at(i).second = i;
    }
    for(int i = 0; i < n; i++){
        if(i % 2 == 1){
            vOdd.at(v.at(i)).first++;
        }else{
            vEven.at(v.at(i)).first++;
        }
    }
    sort(vOdd.begin(), vOdd.end());
    reverse(vOdd.begin(), vOdd.end());
    sort(vEven.begin(), vEven.end());
    reverse(vEven.begin(), vEven.end());
    
    if(vOdd.at(0).second != vEven.at(0).second){
        cout << n - vOdd.at(0).first - vEven.at(0).first << endl;
    }else{
        cout << min(n - vOdd.at(0).first - vEven.at(1).first, n - vOdd.at(1).first - vEven.at(0).first) << endl;
    }
}


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

int main()
{
    ll n, m;
    cin >> n >> m;
    map<ll, ll> stores;
    for (ll i = 0; i < n; i++)
    {
        ll x, y;
        cin >> x >> y;
        if (stores[x] > 0)
        {
            stores[x] += y;
        }
        else
        {
            stores[x] = y;
        }
    }
    ll c = 0;
    ll sum = 0;
    for (auto &&x : stores)
    {
        if ((c + x.second) <= m)
        {
            sum += x.first * x.second;
            c += x.second;
        }
        else
        {
            sum += x.first * (m - c);
            break;
        }
    }
    cout << sum << "\n";
}

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

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

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

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 1e5 + 13;
const int M = 1e6 + 123;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

ll dp[N];

int main(){
    #ifdef KAZAKH
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, W;
    cin >> n >> W;
    for (int i = 1; i <= n; i++){
        int w, v;
        cin >> w >> v;
        for (int j = W; j - w >= 0; j--){
            dp[j] = max(dp[j], dp[j-w]+v);
        }
    }
    cout << dp[W];
    return 0;
}


Measured memory_bytes: 1024
n=int(input())
a=[int(i) for i in input().split()]
d={}
for i in a:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
ans=chk=0
for i in d:
    ans+=[d[i],d[i]-i][d[i]>=i] 
print(ans)

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

int main(){
    v a(5);
    int r=10;
    int ans = 0;
    rep(i,5){
        cin>>a[i];
        if(a[i]%10) r = min(r, a[i]%10);
        a[i] += 10-1;
        a[i] /= 10;
        a[i] *= 10;
        ans += a[i];
    }
    
    cout << ans -10 + r << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[300000];
int main()
{

    int k,l,b;
    cin>>k;

    map<int,int>s;
    for(int i = 0; i < k; i++)
    {
        cin>>a[i];
        s[a[i]] = i;
        //s[b]++;


    }
    for(int i = 1; i <= k; i++)
    {
        cout<<s[i]+1<<" ";
    }
}





Measured memory_bytes: 5888
import std.stdio;
import std.algorithm;
import std.conv;
import std.range;
import std.string;

int gcd(int m, int n) {
	int a = max(m,n);
	int b = min(m,n);
	if (b == 0) return a;
	return gcd(b, a % b);
}

void main() {
	int n = readln.chomp.to!int;
	int[] as = readln.chomp.split(' ').map!(s => s.to!int).array;
	int all_in = as[0];
	int ex = as[0];
	foreach(a; as[1..$]) {
		ex = max(gcd(ex, a), all_in);
		all_in = gcd(all_in, a);
	}
	int ex1 = ex;
	int tmp = as[0];
	as[0] = as[1];
	as[1] = tmp;
	all_in = as[0];
	ex = as[0];
	foreach(a; as[1..$]) {
		ex = max(gcd(ex, a), all_in);
		all_in = gcd(all_in, a);
	}
	writeln(max(ex, ex1));
}


Measured memory_bytes: 4348
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;
    static int N;
    static Dictionary<int, bool> dict = new Dictionary<int, bool>();
    static void input()
    {
        cin = new Scanner();
        N = cin.nextInt();
    }
    static void solve()
    {
        input();
        for(int i = 0; i < N; i++)
        {
            int a = cin.nextInt();
            if (!dict.ContainsKey(a))
                dict.Add(a, true);
            else
                dict[a] = !dict[a];
        }
        int ans = 0;
        foreach(var pair in dict)
        {
            if (pair.Value)
                ans++;
        }
        WriteLine(ans);
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,k; cin>>n>>k; string s; cin>>s; k--;
	s[k]=tolower(s[k]);
	cout<<s<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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; }

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = int(s.size());
  for (int i = 0; i < n; i+=2) {
    if(s[i] != 'h' || s[i+1] != 'i'){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
const int mo=1000000007;
const int N=32800;
int b[20],bit[N];
int f[N],n,m;
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		b[x]|=1<<(y-1);
	}
	for (int i=1;i<1<<n;i++)
		bit[i]=(i&1?bit[i>>1]*2+1:bit[i>>1]);
	f[0]=1;
	for (int i=1;i<1<<n;i++)
		if ((i&3)==3||(i&3)==0)
			for (int j=i;j;j=(j-1)&i){
				if ((j&3)!=0&&(j&3)!=3) continue;
				int tmp=1;
				for (int k=0;k<n;k++)
					if (i&(1<<k)){
						if (!(j&(1<<k)))
							tmp=1ll*tmp*bit[b[k+1]&j]%mo;
						else tmp=1ll*tmp*(bit[b[k+1]&(i^j)]+1)%mo;
					}
				f[i]=(f[i]+1ll*f[i^j]*tmp)%mo;
			}
	int ans=1;
	for (int i=1;i<=m;i++)
		ans=2*ans%mo;
	printf("%d",(ans+mo-f[(1<<n)-1])%mo);
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
string s;
int l;
int main()
{
    cin>>s;
    l=s.size();
    for(register int i=0;i<l;i++)
    {
        if(s[i]=='C')
        {
            for(register int j=i+1;j<l;j++)
            {
                if(s[j]=='F')
                {
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout<<"No";
    return 0;
}

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

int main(void) {
	string s;
	cin >> s;

	for (int i = 0; i < s.length(); i++) {
		if (i % 2 == 0) printf("%c", s[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 3576
import sys
readline = sys.stdin.readline
class Node:
    __slots__ = ['value', 'left', 'right']
    def __init__(self, value = None, left = None, right = None):
        self.value = value
        self.left = left
        self.right = right
class BinTree:
    def __init__(self):
        self._tree = None
    def insert(self, value):
        p = None
        c = self._tree
        while c is not None:
            p = c
            if value < c.value:
                c = c.left
            else:
                c = c.right
        if p is None:
            self._tree = Node(value)
        elif value < p.value:
            p.left = Node(value)
        else:
            p.right = Node(value)
    def find(self, value):
        c = self._tree
        while c is not None:
            if value == c.value:
                return True
            elif value < c.value:
                c = c.left
            else:
                c = c.right
        return False
    def preoder_walk(self):
        self.result = []
        def preoder(node):
            if node is not None:
                self.result.append(node.value)
                preoder(node.left)
                preoder(node.right)
        preoder(self._tree)
        print(" " + " ".join(map(str, self.result)))
    def inorder_walk(self):
        self.result = []
        def inorder(node):
            if node is not None:
                inorder(node.left)
                self.result.append(node.value)
                inorder(node.right)
        inorder(self._tree)
        print(" " + " ".join(map(str, self.result)))
n = int(input())
tree = BinTree()
for _ in range(n):
    com = readline().split()
    if com[0] == "insert":
        tree.insert(int(com[1]))
    elif com[0] == "find":
        print("yes" if tree.find(int(com[1])) else "no")
    else:
        tree.inorder_walk()
        tree.preoder_walk()



Measured memory_bytes: 77180
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  int p,q,r;
  cin >> p >> q >> r;
  cout << p+q+r-max(p,max(q,r)) << endl;
  return 0;
}


Measured memory_bytes: 256
var s:ansistring;
var r:array['a'..'z'] of boolean;
var i:longint;
var r1:boolean;
var c:char;
begin
  readln(s);
  for i:=1 to length(s) do r[s[i]]:=true;
  for c:='a' to 'z' do if not r[c] then begin writeln(c);r1:=true;break;end;
  if not r1 then writeln('None');
end.

Measured memory_bytes: 256
mod=10**9+7
def A001792(n):
  if n>1:
    return (n+1)*pow(2,n-2,mod)
  else:
    return 1

nn=int(input())
C=list(map(int, input().split()))
C.sort(reverse=True)
mod=10**9+7
ans=0
for i in range(nn):
  ans+=pow(2,nn-i-1,mod)*A001792(i+1)*C[i]
  ans %=mod
ans = ans*pow(2,nn,mod)
ans %=mod
print(ans)

Measured memory_bytes: 31564
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>

using namespace std;

int main() {
	int a[4]; for (int i = 0; i < 4; i++) { cin >> a[i]; }

	sort(a, a + 4);

	int tmp = a[3];
	int ttt = a[2];

	a[3] = a[1];
	a[1] = tmp;

	if (a[0] == 1 && a[1] == 9 && a[2] == 7 && a[3] == 4) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }

	

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

int const MOD = 1e9+7;
int const MAXLL = 1e5+2;
std::string L;

int n, p3;

int calc_p3(int x) {
  for(; n < x; ++n) {
    int t = (p3 + p3)%MOD;
    (p3 += t) %= MOD;
  }
  return p3;
}

int main() {
  n = 0; p3 = 1;
  std::cin >> L;
  int ans = 1, l = L.size(), d = 0;
  while(--l >= 0) {
    if(L[l] == '1') {
      int t = (ans + calc_p3(d))%MOD;
      (ans += t) %= MOD;
    }
    ++d;
  }
  std::cout << ans << std::endl;
  return 0;
}


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

    void solve() {
        string s;
        cin >> s;
        vector<ll> v[30];
        ll n = s.length();
        for(ll i = 0; i < n; i++) v[s[i] - 'a'].push_back(i);
        for(ll i = 0; i < 30; i++) sort(v[i].begin(), v[i].end());
        for(ll i = 0; i < 30; i++) {
            if(v[i].size() < 2) continue;
            for(ll j = 1; j < v[i].size(); j++) if(v[i][j] - v[i][j-1] < 3){
                cout << v[i][j-1] + 1 << " " << v[i][j] + 1 << endl;
                return;
            }
        }
        cout << -1 << " " << -1 << endl;
    }

    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      //ll ti;   cin >> ti;  while(ti--)
      solve();
      return 0;
    }


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

int main(){
int n;
cin>>n;
vector<int>a(n);
for(int i=0;i<n;i++){
  cin>>a.at(i);
  }
sort(a.begin(),a.end());
cout<<a.at(n-1)-a.at(0)<<endl;
return 0;
}
 

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

int main()
{
  int x1, y1, x2, y2;
  int res=0;
  cin >> x1 >> y1 >> x2 >> y2;

  int x = x2;
  int y = y2;
  int dx = x2 - x1;
  int dy = y2 - y1;

  rep(i,2){
    int tmp;
    tmp = dx;
    dx = -dy;
    dy = tmp;

    x = x+dx;
    y = y+dy;
    cout << x << " " << y << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
	char s[101];
	int i,j,len,flg;
	scanf("%s",s);
	len=strlen(s);
	flg=0;
	for(i=0;i<len;i++){
		if(i%2==0){
			if(!(s[i]=='R'||s[i]=='U'||s[i]=='D')){
				flg=1;
				break;
			}
		}
		else{
			if(!(s[i]=='L'||s[i]=='U'||s[i]=='D')){
				flg=1;
				break;
			}
		}
	}
	if(flg==0)	printf("Yes\n");
	else	printf("No\n");
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main() {
  long a, b, k, tmp;
  scanf("%ld", &a);
  scanf("%ld", &b);
  scanf("%ld", &k);

  tmp = a - k;
  if(tmp >= 0) {
    printf("%ld %ld\n", tmp, b);
    return 0;
  }
  tmp = b + tmp;
  if(tmp >= 0) {
    printf("%d %ld\n", 0, tmp);
    return 0;
  }
  printf("0 0\n");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <set>
using namespace std;

int main() {
    long long n, max = -1, sum = 0;
    cin >> n;
    vector <int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        if (a[i] >= max) {
            max = a[i];
        }
        if (a[i] < max) {
            sum = sum + (max - a[i]);
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 4044