akhauriyash/Code-Regression huggingface dataset:
ref = ["= ****","=* ***","=** **","=*** *","=**** "]
n = raw_input()
while 1:
	try:
		n = "0"*(5-len(n)) + n
		abacus = ["" for i in range(5)]
		for i in range(4,-1,-1):
			abacus[i] += "* " if int(n[i]) < 5 else " *"
			abacus[i] += ref[int(n[i])%5]
		for i in range(8):
			a = ""
			for j in range(5):
				a += abacus[j][i]
			print a
		n = raw_input()
		print
	except:
		break

Measured memory_bytes: 4224
import math
n,k=map(int,input().split())
def prob(n,k):
	if(n>=k):
		return 1
	else:
		return(0.5**(math.ceil(math.log(k/n,2))))
i=1
s=0
while(i<=n):
	s+=prob(i,k)
	i+=1

s/=n
print(s)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define mod 998244353
#define int long long
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int add(int x,int y){return x+y>mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
#define N 200005
struct Node
{
	int x,h;
};
Node a[N];
bool cmp(Node x,Node y)
{
	return x.x<y.x;
}
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	int n,d,x;
	cin>>n>>d>>x;
	d*=2;
	for(int i=1;i<=n;i++) a[i].x=read(),a[i].h=read();
	sort(a+1,a+n+1,cmp);
	queue<pii> q;
	int ans=0,cur=0;
	for(int i=1;i<=n;i++)
	{
		while(!q.empty()&&a[i].x-d>q.front().fir)
		{
			cur-=q.front().sec*x;
			q.pop();
		}
		a[i].h-=cur;
		if(a[i].h>0)
		{
			int go=(a[i].h+x-1)/x;
			ans+=go;
			cur+=go*x;
			q.push(mp(a[i].x,go));
		}
	}
	cout<<ans<<endl;
#ifdef __LOCAL__
	cout<<"Time Used : "<<clock()<<endl;
#endif
	return 0;
}



Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  string S;
  cin >> S;

  if (S == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;

  return 0;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
typedef long long ll; 
int que[105], dis1[105], dis2[105], n; 
int lst[105], to[205], pre[205], tot, deg[105];
int dep[105], sz[105], mxs[105], mxd;
ll mx[105]; 
bool vis[105]; 
inline void add_edge(int u, int v)
{
	to[tot] = v; 
	pre[tot] = lst[u]; 
	lst[u] = tot++; 
	deg[v]++; 
}
int bfs(int st, int *dis)
{
	int he = 0, ta = 0;
	que[ta++] = st; 
	memset(dis, 0x3f, n << 2); 
	dis[st] = 0; 
	while (he < ta)
	{
		int u = que[he++]; 
		for (int i = lst[u]; ~i; i = pre[i])
		{
			if (dis[to[i]] > dis[u] + 1)
			{
				dis[to[i]] = dis[u] + 1; 
				que[ta++] = to[i]; 
			}
		}
	}
	return std::max_element(dis, dis + n) - dis; 
}
void dfs(int u, int fa = -1)
{
	if (fa == -1)
		dep[u] = 0; 
	int cnt = 0; 
	for (int i = lst[u]; ~i; i = pre[i])
	{
		if (to[i] == fa)
			continue; 
		dep[to[i]] = dep[u] + 1; 
		dfs(to[i], u); 
		cnt++; 
	}
	mxs[dep[u]] = std::max(mxs[dep[u]], cnt); 
	mxd = std::max(mxd, dep[u]); 
}
int main()
{
	// freopen("AGC024-D.in", "r", stdin); 
	memset(lst, -1, sizeof(lst)); 
	scanf("%d", &n); 
	for (int i = 1; i < n; i++)
	{
		int u, v; 
		scanf("%d%d", &u, &v); 
		add_edge(--u, --v); 
		add_edge(v, u); 
	}
	int u = bfs(0, dis1), v = bfs(u, dis1), dia = dis1[v] + 1; 
	bfs(v, dis2); 
	printf("%d ", dia + 1 >> 1);
	ll ans = 1e18; 
	for (int i = 0; i < n; i++)
	{
		mxd = 0; 
		memset(mxs, 0, sizeof(mxs)); 
		memset(mx, 0, sizeof(mx)); 
		dfs(i); 
		// printf("%d %d\n", i, mxd);
		if (mxd >= (dia + 1 >> 1))
			continue; 
		for (int j = n; j >= 0; j--)
		{
			if (!mxs[j])
				mx[j] = 1; 
			else
				mx[j] = (ll)mxs[j] * mx[j + 1]; 
		}
		ans = std::min(ans, mx[0]); 
	}
	for (int i = 0; i < n - 1; i++)
	{
		int x = to[i << 1], y = to[i << 1 | 1]; 
		mxd = 0; 
		memset(mxs, 0, sizeof(mxs)); 
		memset(mx, 0, sizeof(mx)); 
		dep[x] = dep[y] = 0; 
		dfs(x, y); 
		dfs(y, x); 
		if (mxd >= (dia + 1 >> 1))
			continue; 
		for (int j = n; j >= 0; j--)
		{
			if (!mxs[j])
				mx[j] = 1; 
			else
				mx[j] = (ll)mxs[j] * mx[j + 1]; 
			// printf("%d %d %d %d %lld\n", x, y, j, mxs[j], mx[j]);
		}
		ans = std::min(ans, mx[0] * 2); 
	}
	printf("%lld\n", ans);
	return 0; 
}


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

using namespace std;

int main()
{
	int h[2], k[2];
	int a, b, c, d;
	cin >> h[0] >> h[1];
	cin >> k[0] >> k[1];
	cin >> a >> b >> c >> d;

	int hiro, ken;
	hiro = h[0] * a + h[1] * b + h[0] / 10 * c + h[1] / 20 * d;
	ken = k[0] * a + k[1] * b + k[0] / 10 * c + k[1] / 20 * d;

	if (hiro > ken)
	{
		cout << "hiroshi" << endl;
	}
	else if (hiro < ken)
	{
		cout << "kenjiro" << endl;
	}
	else
	{
		cout << "even" << endl;
	}

	return 0;
}



Measured memory_bytes: 3108
#include <vector>
#include <algorithm>
#include <cstdio>
#define LIMIT 10000
using namespace std;
bool ck(vector<int>&v){
	for(int i=0;i<v.size();i++)if(v[i]!=i+1)return false;
	return true;
}
main(){
	int n,i,j,s,x,l;
	vector<int>tri;
	for(i=1;i<999;i++)tri.push_back(i*(i+1)/2);
	for(;scanf("%d",&n),n;){
		vector<int>v;
		for(s=i=0;i<n;i++){
			scanf("%d",&x);
			s+=x;
			v.push_back(x);
		}
		vector<int>::iterator idx=find(tri.begin(),tri.end(),s);
		i=LIMIT+1;
		if(idx!=tri.end()){
			for(i=0;i<=LIMIT&&!ck(v);i++){
				l=v.size();
				for(j=0;j<l;j++)v[j]--;
				v.erase(remove(v.begin(),v.end(),0),v.end());
				v.push_back(l);
			}
		}
		printf("%d\n",i>LIMIT?-1:i);
	}
}

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

int main(){
  
  int N;
  cin >>N;
  vector<int> H(N);
  
  for(int i=0;i<N;i++){
    int x;
    cin >>x;
    H[i] = x;
  }
  
  int peak = 0;
  int temp = 0;
  
  for(int i=0;i<N-1;i++){
    if(H[i]>=H[i+1]){
      temp ++;
      peak = max(peak,temp);
    }else{
      temp = 0;
    }
  } 
  
  cout << peak << endl;
}

Measured memory_bytes: 640
using System;
using System.Linq;

namespace ABC127
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ').ToArray();

            int A = int.Parse(line[0]);
            int B = int.Parse(line[1]);

            if(A >= 6 && A <= 12)
            {
                Console.WriteLine(B / 2);
            }else if(A < 6)
            {
                Console.WriteLine(0);
            }else
            {
                Console.WriteLine(B);
            }
        }
    }
}


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

int main() {
  long double a, b, c;
  cin >> a >> b >> c;
  
  if (sqrt(a/c) + sqrt(b/c) < 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
long long a[100005];

int main(){
	
	int n,t=0;
	int x=0,y=0,z=0;
	
	scanf("%d",&n);
	for(int i=0;i<n;i++)
    {
	  scanf("%lld",&a[i]);
	  if(a[i]%2==1)
	    x++;
	  if(a[i]%4==0)
	   y++;
	  if(a[i]%4!=0&&a[i]%2==0)
	  z++;  
	  
	}
	
	  if(x-y>=2)
	    printf("No\n");
	   else
	   {
	   	if(x-y<=0)
	   	 printf("Yes\n");
	   	else
		 if(z%2==0)
		 printf("Yes\n");
		 else
		 printf("No\n");   
	   	
	   	
	   	
		} 
		
		
		
		return 0;}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
#include<math.h>
#include<list>
#include<map>
using namespace std;
typedef long long ll;
#define PI 3.14159265358979323846  


int main() {
	int a[3][3];
	bool af[3][3] ;
	vector<int> b;
	int n;
	bool ans=false;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
			af[i][j] = false;
		}
	}
	cin >> n;
	for (int k = 0; k < n; k++) {
		int v;
		cin >> v;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (a[i][j] == v) {
					af[i][j] = true;
				}
				
			}
		}
		//b.push_back(v);
	}
	for (int i = 0; i < 3; i++) {
		if (af[i][0] && af[i][1] && af[i][2]) {
			ans = true;
		}
	}
	for (int i = 0; i < 3; i++) {
		if (af[0][i] && af[1][i] && af[2][i]) {
			ans = true;
		}
	}
	if (af[0][0] && af[1][1] && af[2][2]) {
		ans = true;
	}
	if (af[0][2] && af[1][1] && af[2][0]) {
		ans = true;
	}
	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>x(n);
    vector<int>y(n);
    int64_t sum1=0;int64_t sum2=0; int64_t sum3=0;int64_t sumI=0;
    for(int i=0;i<n;i++){cin>>x.at(i);}
    for(int i=0;i<n;i++){cin>>y.at(i);}
    cout << fixed << setprecision(10);
    for(int i=0;i<n;i++){
        sum1+=abs(x.at(i)-y.at(i));
        sum2+=(x.at(i)-y.at(i))*(x.at(i)-y.at(i));
        sum3+=abs(((x.at(i)-y.at(i))*(x.at(i)-y.at(i))*(x.at(i)-y.at(i))));
        if(sumI<=abs(x.at(i)-y.at(i))){sumI=abs(x.at(i)-y.at(i));
         }
    } 
    cout<<sum1<<endl;
    cout<<sqrt(sum2)<<endl;
    cout<<cbrt(sum3)<<endl;
    cout<<sumI<<endl;;
    return 0; 
}


Measured memory_bytes: 3428
#include <bits/stdc++.h>
using namespace std;
const int P = 1'000'000'007;
int main() {
	int n;
	cin >> n;
	vector<vector<int> > G;
	G.resize(n);
	for(int i = 0; i < n - 1; ++i) {
		int u, v;
		cin >> u >> v;
		--u;
		--v;
		G[u].emplace_back(v);
		G[v].emplace_back(u);
	}
	vector<int> sz;
	vector<int> bin;
	sz.resize(n);
	bin.resize(n + 1);
	bin[0] = 1;
	for(int i = 1; i <= n; ++i) {
		bin[i] = 2LL * bin[i - 1] % P;
	}
	int ans = 0;
	function<void(int, int)> dfs = [&] (int u, int f) {
		sz[u] = 1;
		for(auto v : G[u]) {
			if(v != f) {
				dfs(v, u);
				sz[u] += sz[v];
				ans = (ans + bin[sz[v]]) % P;
			}
		}
		ans = (ans + bin[n - sz[u]]) % P;
	};
	dfs(0, -1);
	auto power = [&] (int x, int t) {
		int ret = 1;
		for(; t; t >>= 1, x = 1LL * x * x % P) {
			if(t & 1) {
				ret = 1LL * ret * x % P;
			}
		}
		return ret;
	};
	ans = (1LL * n * bin[n - 1] - ans + P) % P;
	ans = (ans + n - 1) % P;
	ans = 1LL * ans * power(bin[n] % P, P - 2) % P;
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 26112
#include<stdio.h>
int main(void){
    int r,f,m,s;
    while(1){
        scanf("%d %d %d",&m,&f,&r);
        s = m + f;
        if (m == -1 && f == -1 && r == -1) break;
        if(m < 0 || f < 0)  puts("F");
        else { 
        if(s >= 80)        puts("A");
        else if(s >= 65)        puts("B");
        else if(s >= 50)        puts("C");
        else if (s < 30)        puts("F");
		else puts(r >= 50 ? "C" : "D");
        }
    }
    return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
int main()
{
  int n;
  ll c,k;
  cin >> n >> c >> k;
  vector<ll> t(n);
  for(int i=0;i<n;i++) cin >> t[i];

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

  ll cnt = 0;
  ll ans = 1;
  ll bus = t[0] + k;
  for(int i=0;i<n;i++){
    if(t[i] <= bus && cnt < c){
      cnt++;
    }else if(t[i] <= bus && cnt >= c){
      ans++;
      cnt = 1;
      bus = t[i] + k;
    }else if(t[i] > bus){
      ans++;
      cnt = 1;
      bus = t[i] + k;
    }
  }


  cout << ans << endl;
}


Measured memory_bytes: 3968
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int ea[200010],eb[200010];
bool ya[200010];
struct tree{
	int fir[200010],dis[400010],nxt[400010],id,fa[200010],dep[200010];
	void link(int a,int b){nxt[++id]=fir[a],fir[a]=id,dis[id]=b;}
	void dfs(int x,int*Bd=0){
		if(Bd&&dep[x]>=Bd[x]){return;}
		for(int i=fir[x];i;i=nxt[i]){
			if(fa[x]==dis[i])continue;
			fa[dis[i]]=x;
			dep[dis[i]]=dep[x]+1;
			dfs(dis[i],Bd);
		}
	}
}A,B;
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi(),sa=gi(),sb=gi(),a,b;
	for(int i=1;i<n;++i)ea[i]=gi(),eb[i]=gi();
	for(int i=1;i<n;++i)a=gi(),b=gi(),B.link(a,b),B.link(b,a);
	B.dfs(sb);
	for(int i=1;i<n;++i)
		if(B.fa[ea[i]]==eb[i]||
		   B.fa[eb[i]]==ea[i]||
		   B.fa[B.fa[ea[i]]]==eb[i]||
		   B.fa[B.fa[eb[i]]]==ea[i]||
		   B.fa[ea[i]]==B.fa[eb[i]])
			A.link(ea[i],eb[i]),A.link(eb[i],ea[i]);
		else ya[ea[i]]=ya[eb[i]]=1;
	memset(A.dep,-1,sizeof A.dep);A.dep[sa]=0,A.dfs(sa,B.dep);
	for(int i=1;i<=n;++i)if(~A.dep[i]&&ya[i]&&A.dep[i]<B.dep[i])return puts("-1"),0;
	int ans=0;
	for(int i=1;i<=n;++i)if(~A.dep[i])ans=std::max(ans,B.dep[i]);
	printf("%d\n",ans*2);
	return 0;
}


Measured memory_bytes: 18048
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)

const int mx=100010;
const ll mod=1e9+7;

string s,t;

int main(){
  cin >> s >> t;
  int n=s.size();
  int m=t.size();
  if(n<m){cout<<"UNRESTORABLE"<<endl; return 0;}
  
  for(int i=n-m; i>=0; i--){
    bool flag = true;
    rep(j,m){ if(s[i+j]!=t[j] && s[i+j]!='?'){flag = false;} }	//s[i]kara mojiretsu ari = true
    if(flag){
      rep(j,i){ if(s[j]=='?'){ cout<<'a'; } else {cout<<s[j];} } //[****]t****
      cout<<t;                                                   //****[t]****
      REP(j,i+m,n){ if(s[j]=='?'){ cout<<'a'; } else {cout<<s[j];} }
                                                                 //****t[****]
      cout<<endl;
      return 0;
    }
  }
  
  cout<<"UNRESTORABLE"<<endl;
  return 0;  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1<<30;
//aoj 0534
vp tmp;
int r,l,co;
void f(){
	while(1){
		if(r<0||l>=tmp.size())return;
		int t=tmp[r].second+tmp[l].second;
		if(tmp[r].first==tmp[l].first&&t>=4){
			co+=t;
			r--;l++;
		}else break;
	}
}
int main(){
	int n;
	while(cin>>n,n){
		vi q(n);
		vp in;
		rep(i,n)cin>>q[i];
		q.pb(0);
		co=1;
		loop(i,1,n+1){
			if(q[i]!=q[i-1]){
				in.pb(pii(q[i-1],co));
				co=1;
			}else co++;
		}
		int out=0;
		rep(i,in.size())if(in[i].second==3){
			if(i){
				tmp=in;
				tmp[i-1].second--;
				r=i-1;l=i+1;
				co=4;
				if(tmp[i-1].second==0){
					r-=2;
					if(i>1)co+=tmp[i-2].second;
				}
				f();
				out=max(out,co);
			}
			if(i!=in.size()-1){
				tmp=in;
				tmp[i+1].second--;
				r=i-1;l=i+1;
				co=4;
				if(tmp[i+1].second==0){
					l+=2;
					if(i<in.size()-2)co+=tmp[i+2].second;
				}
				f();
				out=max(out,co);
			}
		}
		cout<<n-out<<endl;
	}
}

Measured memory_bytes: 1324
#include <string.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iomanip>

using namespace std;
#define INF 1e9
#define MAX 100005
#define MOD 1000000007
#define Q queue
#define PQ priority_queue
#define fr first
#define sc second
#define pb push_back
#define mp make_pair
#define FOR( i, L, U ) for(int i=(int)L ; i<(int)U ; i++ )
#define FORD( i, U, L ) for(int i=(int)U ; i>=(int)L ; i-- )
#define wa cout<<"Wa"<<endl
#define READ(filename)  freopen(filename, "r", stdin);
#define WRITE(filename)  freopen(filename, "w", stdout);

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int> > vvi;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef map<int, string> mis;
typedef map<int , vector<int> > mvi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;

void base(){
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
}


int main(){
//	base();
	int x,y,arr[MAX];
	FOR(i,1,13){
		if (i==1 || i==3 || i==5 || i==7 || i==8 || i==10 || i==12) arr[i]=1;
		else if (i==4 || i==6 || i==9 || i==11) arr[i]=2;
		else arr[i]=3;
	}
	cin>>x>>y;
	if (arr[x]==arr[y]) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}



Measured memory_bytes: 764
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int query(int i) {
    write(i);
    flush(cout);
    string s;
    cin >> s;
    return s[0] == 'V' ? 0 : s[0] == 'M' ? 1 : -1;
}

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

    int low = 0, high = N - 1;
    int slow = query(low);
    if (slow == 0) return 0;
    int shigh = query(high);
    if (shigh == 0) return 0;

    for (int i = 0; i < 18; ++i) {
        int mid = (low + high) / 2;
        int smid = query(mid);
        if (smid == 0) return 0;

        if ((smid != slow) ^ ((mid - low) % 2)) {
            high = mid;
            shigh = smid;
        }
        else if ((smid != shigh) ^ ((high - mid) % 2)) {
            low = mid;
            slow = smid;
        }
        else {
            low = mid;
            slow = smid;
        }
    }
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int n,x,L[maxn];

vector<int> D = {0};

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

  cin>>n>>x;
  for (int i=0; i<n; i++) {
    cin>>L[i];
  }
  
  for (int i=0; i<n; i++) {
    int d = D.back() + L[i];
    if (d <= x) {
      D.push_back(d);
    } else {
      out(D.size());
    }
  }
  out(D.size());
  return 0;
}


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

vector<pair<int, int> > adj[100005];
pair<int, int> edge[100005];
bool dir[100005];
bool used[100005];
int deg[100005];
int sz[100005];
void dfs(int node)
{
	used[node]=true;
	sz[node]+=deg[node];
	for(auto i:adj[node])
	{
		if(!used[i.first])
		{
			dfs(i.first);
			if(sz[i.first]%2==1)
			{
				dir[i.second]^=1;
			}
			sz[node]+=sz[i.first];
		}
	}
}

signed main()
{
	int n, m;
	cin>>n>>m;
	for(int i=1; i<=m; i++)
	{
		int u, v;
		cin>>u>>v;
		edge[i]={u,v};
		deg[u]++;
		adj[u].pb({v,i});
		adj[v].pb({u,i});
	}
	int cut=0;
	for(int i=1; i<=n; i++)
	{
		deg[i]%=2;
		if(deg[i]==1)
		{
			cut++;
		}
	}
	if(cut%2==1)
	{
		cout<<-1;
		return 0;
	}
	dfs(1);
	for(int i=1; i<=m; i++)
	{
		if(dir[i])
		{
			cout<<edge[i].second<<" "<<edge[i].first<<endl;
		}
		else
		{
			cout<<edge[i].first<<" "<<edge[i].second<<endl;
		}
	}
}

Measured memory_bytes: 13312
#python3
from itertools import permutations

def main():
    n, m = map(int, input().split())
    edge = set()
    for _ in range(m):
        a, b = map(int, input().split())
        edge.add((a-1, b-1))
        edge.add((b-1, a-1))
    
    node = []
    for i in range(n):
        node.append(i)
    cnt = 0
    for p in permutations(node):
        if p[0] == 0:
            f = True
            for j in range(n-1): 
                if (p[j], p[j+1]) not in edge:
                    f = False
            if f:
                cnt += 1 
    print(cnt)
main()


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

#define en "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fs first
#define sc second
#define size(a) (int) a.size()
#define deb(x) cerr << #x << " => " << x << en
#define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en;
#define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<<a.fs<<", "<<a.sc<<") "; cerr << en;
#define debm(x) cerr << #x << en; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << en;}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)
int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m;
while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;}
#define inv(a) fastpow(a, HELL - 2)

int32_t main() { fastio;
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while (a > 0 and c > 0) {
		c -= b;
		a -= d;
	}
	if (c <= 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

int main(void){
    int n;
    string s,t;
    cin >> n >> s >> t;
    int ans = 2*n;
    for(int i = 0;i < n;i++){
        string b = s.substr(i);
        if(s.substr(i) == t.substr(0,n-i)){
            ans -= b.size();
            break;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// const ll INF = 1e18;
//const ll MOD = 1e9+7;
//const double pi = 3.14159265358979;
using vl = vector<ll>;
# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()

ll N,M;
string s;

int Main() {
    cin >> s;

    if(s.compare("ABC") == 0) {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
    
    return 0;
}

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


Measured memory_bytes: 3648
K = int(input())
A, B = input().split()
a = int(A)
b = int(B)
k = 1
while k <= 1000:
    key = K*k
    if (key >= a) and (key <= b):
        print("OK")
        break
    elif (key >= b):
        print("NG")
        break
    k += 1

Measured memory_bytes: 9184
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
using namespace std;

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  int a,b;
  cin >> a >> b;
  if (a + b < 10){
    cout << a + b << '\n';
  }
  else{
    cout << "error\n";
  }
  return 0;
}

Measured memory_bytes: 256
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
// const int MOD = 1e9 + 7;
const int MOD = 10007;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
const double PI = acos(-1);

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

int n;
int a[N], max;
ll buc[N], m, ps[N], cnt;

inline bool check(int mid) {
    cnt = 0;
    for (int i = 1; i <= n; i++) {
        int gap = std::max(mid - a[i], 0);
        if (gap <= max) cnt += buc[gap];
    }
    return cnt >= m;
}

int main() {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        chkmax(max, a[i]);
        buc[a[i]]++;
        ps[a[i]] += a[i];
    }
    for (int i = max; i >= 0; i--) {
        buc[i] += buc[i + 1];
        ps[i] += ps[i + 1];
    }
    int l = 1, r = max * 2;
    while (r - l > 4) {
        int mid = l + (r - l) / 2;
        if (check(mid)) l = mid;
        else r = mid;
    }
    int real = -1;
    for (int i = r; i >= l; i--) {
        if (check(i)) {
            real = i;
            break;
        }
    }
    // printf("%d %lld\n", real, cnt);
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        int gap = std::max(real - a[i], 0);
        if (gap <= max) ans += ps[gap] + buc[gap] * a[i];
    }
    printf("%lld\n", ans - (cnt - m) * real);
    return 0;
}

Measured memory_bytes: 2176
/*
	ID: sixathofpain
	TASK: friday
	LANG: C++   

*/


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 998244353;
const int N = int(3e5) + 999;
#define int long long int

void print0(int x=0){
	cerr<<x<<endl;
	cout<<0<<endl;
	exit(0);
}
map<int,int> mp;

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



    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int A,B;
    cin >> A >>B;

    int fullArea = A * B;
    int P = A *1;
    int E = B * 1;
    int K = 1* 1;

    int Area = P + E -K;
    Area = fullArea - Area;

    cout << Area << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
//#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb emplace_back
#define mp make_pair
#define MOD (int) 1e9+7
#define for0(i, n) for (int i = 0; i < n; i++)
#define ff first
#define ss second
#define endl "\n"
#define bits(n) __builtin_popcount(n)
#define ini(a, i) memset(a, i, sizeof(a))

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	// cin >> t;
	t  = 1;
	while (t--)
	{
		string s;
		cin >> s;
		ll p = 0;
		for (ll i = 0; i < s.size(); i++)
		{
			p += s[i] - '0';
		}
		if (p % 9 == 0)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3736
n=int(input())
d=sorted(list(map(int,input().split())))
m=int(input())
t=sorted(list(map(int,input().split())))
if m>n:
    print("NO")
else:
    a=0
    for i in range(m):
        flag=0
        while flag!=1:
            if a==n:
                print("NO")
                exit()
            if t[i]>d[a]:
                a+=1
            elif t[i]==d[a]:
                a+=1
                flag=1
            else:
                print("NO")
                exit()
    print("YES")


Measured memory_bytes: 36820
#include <bits/stdc++.h>
#define  pb push_back
#define nl "\n"
#define fastScan ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
int dp[123456];
int s[123456];
int main()
{
	fastScan;
	int n,k;cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>s[i];
	for(int i=1;i<=k;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i>=s[j] && dp[i-s[j]]==0)
			{
				dp[i]=1;
				break;
			}
		}
	}
	if(dp[k]==1)
		cout<<"First"<<nl;
	else
		cout<<"Second"<<nl;
}


Measured memory_bytes: 640
N, W = map(int, input().split())
Ws = []
Vs = []

for _ in range(N):
  w, v = map(int, input().split())
  Ws.append(w)
  Vs.append(v)

Ans = [[0 for _ in range(W+1)] for _ in range(N)]

for i in range(W+1):
  if i >= Ws[0]:
    Ans[0][i] = Vs[0]

for i in range(1, N):
  for w in range(W+1):
    if w - Ws[i] >= 0:
      Ans[i][w] = max(Ans[i-1][w-Ws[i]] + Vs[i], Ans[i-1][w], Ans[i][w])
    else:
      Ans[i][w] = max(Ans[i-1][w], Ans[i][w])

print(max(Ans[N-1]))


Measured memory_bytes: 171656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e3+7;
map<int,int> mp;
vector<int> a[maxn];
int main()
{
	ll n;cin>>n;cout<<n*n<<endl;
	//int a,b,c;cin>>a>>b>>c; 
 } 

Measured memory_bytes: 256
def enq(a,x)
  b = a[i=-1]
  until b.frozen?
    return a << x  if x >= (a=b)[-1]
    return a.unshift x  if x <= a[0]
    b = a[i = a.bsearch_index{|y| x < (y.frozen? ? y: y[0])}-1]
  end  if b && b=a
  return a.insert i+1, x  unless a[i+9]
  i>0 ? a[i]=[b,x] : enq(a[i+=1].to_a,x)  rescue a[i]=[x,a[i]]
end
def deq(a) r=a.shift; a.unshift *a.shift if !a[0].frozen?; r end
def poq(a) r=a.pop; a.push *a.pop if !a[-1].frozen?; r end
N,M,*A = $<.read.split.map{|x| x.to_i}
A.sort!
M.times { break if A[-1]==0; enq A, (poq A)/2 }
p A.flatten.inject(0,:+)

Measured memory_bytes: 15976
#include <cstdio>
#include <iostream>

using namespace std;

int INFTY = 1000000001;

long long merge(int A[], int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;

	int L[n1];
	int R[n2];

	for (int i = 0; i < n1; ++i) {
		L[i] = A[left + i];
	}

	for (int i = 0; i < n2; ++i) {
		R[i] = A[mid + i];
	}

	L[n1] = INFTY;
	R[n2] = INFTY;

	int i = 0;
	int j = 0;

	long long cnt = 0;

	for (int k = left; k < right; ++k) {
		if (L[i] <= R[j]) {
			A[k] = L[i];
			++i;
		} else {
			A[k] = R[j];
			++j;
			cnt += n1 - i;
		}
	}
	return cnt;
}

long long mergeSort(int A[], int left, int right) {

	if (left + 1 < right) {
		int mid = (left + right) / 2;

		long long v1 = mergeSort(A, left, mid);
		long long v2 = mergeSort(A, mid, right);
		long long v3 = merge(A, left, mid, right);

		return v1 + v2 + v3;
	} else {
		return 0;
	}

}

int main() {

	int n;
	scanf("%d", &n);

	int A[n];
	for (int i = 0; i < n; ++i) {
		scanf("%d", &A[i]);
	}
	A[n] = INFTY;

	long long v = mergeSort(A, 0, n);

	cout << v << endl;

	return 0;
}

Measured memory_bytes: 4680
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
bool matrix[110][110];
int main()
{
    int w,h,n;
    scanf("%d%d%d",&w,&h,&n);
    int x,y,a;
    memset(matrix,false,sizeof(matrix));
    int ans=w*h;
    while(n--)
    {
        scanf("%d%d%d",&x,&y,&a);
        switch(a)
        {
        case 1:
            for(int i=1;i<=h;i++)
            {
                for(int j=1;j<=x;j++)
                {
                    if(!matrix[i][j])
                    {
                        ans--;
                        matrix[i][j]=true;
                    }
                }
            }
            break;
        case 2:
            for(int i=1;i<=h;i++)
            {
                for(int j=x+1;j<=w;j++)
                {
                    if(!matrix[i][j])
                    {
                        ans--;
                        matrix[i][j]=true;
                    }
                }
            }
            break;
        case 3:
            for(int i=1;i<=y;i++)
            {
                for(int j=1;j<=w;j++)
                {
                    if(!matrix[i][j])
                    {
                        ans--;
                        matrix[i][j]=true;
                    }
                }
            }
            break;
        case 4:
            for(int i=y+1;i<=h;i++)
            {
                for(int j=1;j<=w;j++)
                {
                    if(!matrix[i][j])
                    {
                        ans--;
                        matrix[i][j]=true;
                    }
                }
            }
            break;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[2097160];
ll arr[25][25];
ll n;
ll mod=1e9L+7;
ll f(ll i,ll mask)
{
	if(i==n)
		return 1;
	if(dp[mask]!=-1)
		return dp[mask];
	ll a=0;
	for(ll j=0;j<n;j++)
	{
		if(arr[i][j]&&(!(mask&(1<<j))))
		{
			a=(a+f(i+1,mask|(1<<j)))%mod;
		}
	}
	return dp[mask]=a;
}
int main()
{
	cin>>n;
	ll i,j;
	memset(dp,-1,sizeof(dp));
	for(i=0;i<n;i++)
	for(j=0;j<n;j++)
	cin>>arr[i][j];
	cout<<f(0,0);
	return 0;
}

Measured memory_bytes: 16640
import sys

N, M = map(int, input().split())

sys.setrecursionlimit(10**7)

v_neighbor = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    v_neighbor[a-1].append(b-1)
    v_neighbor[b-1].append(a-1)


v_visit = [False for _ in range(N)]

def search(n):
    count = 0
    for n_ in set(v_neighbor[n]):
        if not v_visit[n_]:
            v_visit[n_] = True
            count += 1
            count += search(n_)
    return count

res = 1
for i in range(N):
    if v_visit[i]:
        continue
    search_res = search(i)
    res = max(res, search_res)


print(res)


Measured memory_bytes: 571144
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int posa=0,posz=0;
    cin>>s;
    bool a = false ;
    for(int i = 0;i<s.size();i++)
    {
        if(s[i]=='A'&&!a)
        {
            posa=i;
            a = true;
        }
        if(s[i]=='Z')
            posz=i;
    }
    cout<<posz - posa +1 ;
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <map>
#include <vector>
#include <unordered_map>

#define div 1000000000+7

using ll = long long;
using namespace std;

void solve() {
    int x, y, z;
    cin >> x >> y >> z;
    x = x - z;
    cout << x/(y+z) << endl;
}

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

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef vector<vector<P>> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<ll> vec;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    string s;
    cin>>s;
    ll n=0;
    rep(i,4){
        if(s[i]=='2') n++;
    }
    cout<<n<<endl;
    
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		int a, b, c, d, e, k;
		a = scan.nextInt();
		b = scan.nextInt();
		c = scan.nextInt();
		d = scan.nextInt();
		e = scan.nextInt();
		k = scan.nextInt();

		int distanceA[] = new int[4];
		int distanceB[] = new int[3];
		int distanceC[] = new int[2];
		int distanceD[] = new int[1];

		distanceA[0] = b - a;
		distanceA[1] = c - a;
		distanceA[2] = d - a;
		distanceA[3] = e - a;

		distanceB[0] = c - b;
		distanceB[1] = d - b;
		distanceB[2] = e - b;

		distanceC[0] = d - c;
		distanceC[1] = e - c;

		distanceD[0] = e - d;

		for (int i = 0; i < 4; i++) {
			if (distanceA[i] > k) {
				System.out.println(":(");
				return;
			}
		}

		for (int i = 0; i < 3; i++) {
			if (distanceB[i] > k) {
				System.out.println(":(");
				return;
			}
		}

		for (int i = 0; i < 2; i++) {
			if (distanceC[i] > k) {
				System.out.println(":(");
				return;
			}
		}

		if (distanceD[0] > k) {
			System.out.println(":(");
			return;
		}

		System.out.println("Yay!");

	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define CON 1000000000000
#define SIX 1000000
using namespace std;

int main() {
  int H, W,h,w;

  string s = "No";
  cin >> H >> W;
  cin >> h >> w;
  cout << H*W - (H*w + W*h - h*w) << endl;
  return 0;
}


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

int main(){
  int H, W;
  cin >> H >> W;
  
  string str[H];
  for(int i=0 ; i<H ; i++)
    cin >> str[i];
  
  for(int i=0 ; i<H ; i++)
    cout << str[i] << endl << str[i] << endl;
}

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

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 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 LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    A = LI()
    cnt = 0
    for a in A:
        while a % 2 == 0:
            a = a//2
            cnt += 1
    print(cnt)
main()



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

int main(int argc, char *argv[]){
  int n, m, k;
  while(cin >> n >> m >> k, n){
    double ans = 0;
    long long int dp[n + 1][n*m + 1];//num of dice, sum of the spot
    int w = n*m;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= w; j++) {
        dp[i][j] = 0;
      }
    }
    for (int i = 1; i <= w; i++) {
      if(i <= m)
        dp[1][i] = 1;
      else
        dp[1][i] = 0;
    }
    for (int i = 2; i <= n; i++) {
      for (int j = 1; j <= w; j++) {
        for (int k = 1; k <= m; k++) {
          if(k < j)
            dp[i][j] += dp[i - 1][j - k];
        }
      }
    }

    // for (int i = 1; i <= n; i++) {
    //   for (int j = 1; j <= w; j++) {
    //     std::cout << dp[i][j] << " ";
    //   }
    //   std::cout << std::endl;
    // }

    int deno = 1; 
    for (int i = 0; i < n; i++) {
      deno *= m;
    }
    for (int i = n; i <= w; i++) {
      if(i <= k){
        ans += dp[n][i];
      }else{
        ans += dp[n][i] * (i - k);
      }
    }
    printf("%.8lf\n", ans / deno);
  }
  return 0;
}

Measured memory_bytes: 1272
# frozen_string_literal: true

n = gets.to_i
s = []
t = []
n.times do
  st = gets.split
  s.push st[0].chomp
  t.push st[1].to_i
end
x = gets.chomp
flag = false
sum = 0
0.upto(n - 1) do |i|
  sum += t[i] if flag

  flag = true if s[i] == x
end
puts sum


Measured memory_bytes: 1788
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

int main(){
    int N;cin>>N;
    map<int,int> m;
    ll ans = 0;
    for(int i=0;i<N;i++){
        int a;cin>>a;
        ans += a;
        m[a]++;
    }
    int Q;cin>>Q;
    for(int i=0;i<Q;i++){
        int b,c;cin>>b>>c;
        m[c] += m[b];
        ans += (c - b)*m[b];
        m[b] = 0;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 8056
#include <bits/stdc++.h>
using namespace std;
#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 all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int ans = 15;
    rep(i, 5) {
        int a;
        cin >> a;
        ans -= a;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3580
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(c >= a && c <= b){
            System.out.println("Yes");
            return;
        }
            System.out.println("No");
    }
}


Measured memory_bytes: 21332
from sys import stdin
from itertools import product

n, m = map(int, stdin.readline().rstrip().split())
switches = [list(map(int, stdin.readline().rstrip().split())) for _ in range(m)]
ps = list(map(int, stdin.readline().rstrip().split()))
res = 0
for p in product([0,1], repeat=n):
    flag = 0
    for i, s in enumerate(switches):
        total = 0
        for j in s[1:]:
            total += p[j-1]
        if total % 2 != ps[i]:
            flag = 1
            break
    if flag == 0:
        res += 1
print(res)

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

int n, m, x, curr, ans = 1e9;
int C[100], G[100], A[100][100];

void backtrack(int i) {
    if (i == n) {
        bool ok = 1;
        for (int j = 0; j < m; j++)
            ok &= G[j] >= x;
        if (ok)
            ans = min(ans, curr);
    } else {
        curr += C[i];
        for (int j = 0; j < m; j++)
            G[j] += A[i][j];
        backtrack(i + 1);
        curr -= C[i];
        for (int j = 0; j < m; j++)
            G[j] -= A[i][j];
        backtrack(i + 1);
    }
}

void solve() {
    scanf("%d %d %d", &n, &m, &x);
    for (int i = 0; i < n; i++) {
        scanf("%d", &C[i]);
        for (int j = 0; j < m; j++)
            scanf("%d", &A[i][j]);
    }
    backtrack(0);
    curr = 0;
    memset(G, 0, sizeof(G));
    if (ans == 1e9)
        puts("-1");
    else
        printf("%d\n", ans);
}

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

    solve();
    return 0;
}

Measured memory_bytes: 3864
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        int n, x;
        cin >> n >> x;
        if (x == 1 || x == 2 * n - 1) cout << "No" << endl;
        else {
            cout << "Yes" << endl;
            int ans[2 * n - 1];
            ans[n - 2] = x - 1;
            ans[n - 1] = x;
            ans[n] = x + 1;
            int temp = 1;
            rep(i, 2 * n - 1) {
                if (temp == x - 1) temp += 3;
                if (i != n - 2 && i != n - 1 && i != n) {
                    cout << temp << endl;
                    temp++;
                } else {
                    cout << ans[i] << endl;
                }
            }
        }


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,d;
	while(cin>>n>>d)
	{
		int sum=0,num=0;
		for(int i=2*d+1;i<n;i+=(2*d+1))
		{
			num++;
		}
		cout<<num+1<<endl;
	}
}

Measured memory_bytes: 256