akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    ll n, W;
    cin >> n >> W;
    vector<ll> w(n); 
    vector<ll> v(n);
    REP(i,n) cin >> w[i] >> v[i];
    ll z = w[0];
    vector<ll> a[4];

    REP(i,n) REP(j,4) if (w[i] == z+j) a[j].push_back(v[i]);
    REP(i,4) sort(a[i].begin(), a[i].end(), greater<>());
    vector<ll> s[4];
    REP(i,4) s[i].push_back(0);
    REP(i,4) {
        for (auto&& e: a[i]) {
            ll& tmp = s[i].back();
            s[i].push_back(tmp+e);
        }
    }
    ll ans = -1;

    REP(i,s[0].size()) {
        REP(j,s[1].size()) {
            REP(k,s[2].size()) {
                REP(l,s[3].size()) {
                    if (z*i+(z+1)*j+(z+2)*k+(z+3)*l > W || i+j+k+l > n) continue;
                    ll tmp = s[0][i]+s[1][j]+s[2][k]+s[3][l];
                    ans = max(ans,tmp);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from functools import reduce

def combination2(n, r, MOD=10**9+7):
    if not 0 <= r <= n: return 0
    r = min(r, n - r)
    numerator = reduce(lambda x, y: x * y % MOD, range(n, n - r, -1), 1)
    denominator = reduce(lambda x, y: x * y % MOD, range(1, r + 1), 1)
    return numerator * pow(denominator, MOD - 2, MOD) % MOD

def q(x,y):
    return cn*(x**2)*(y**3-y)//6

N, M, K = map(int, input().split())
MOD=10**9+7
cn = combination2(N*M - 2, K-2, MOD)
print((q(N,M) + q(M,N))%MOD)


Measured memory_bytes: 68048
#include <bits/stdc++.h>
#define N 100005

using namespace std;

int n, totBlock;
int size[N];
set<int> g[N];
queue<pair<int, int> > que;

namespace UFS {

int fa[N];
inline void init() { for(int i = 1; i <= n; ++i) fa[i] = i; }
inline int find(int u) { return fa[u] == u ? u : fa[u] = find(fa[u]); }

}

inline void read(int &x) {
	x = 0; char ch = getchar();
	while(!isdigit(ch)) ch = getchar();
	while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
}

void work() {
	int u, v;
	pair<int, int> o;
	while(!que.empty()) {
		o = que.front(), que.pop();
		u = UFS :: find(o.first), v = UFS :: find(o.second);
		if(u != v) {
			--totBlock;
			if(size[u] > size[v]) swap(u, v);
			// merge
			UFS :: fa[u] = v;
			for(set<int> :: iterator it = g[u].begin(); it != g[u].end(); ++it) {
				int to = UFS :: find(*it);
				if(to == v) continue;
				if(g[to].find(v) != g[to].end()) {
					g[to].erase(u), --size[to];
					//g[v].erase(to), --size[v];
					que.push(make_pair(u, to));
				} else {
					g[to].erase(u), g[to].insert(v);
					g[v].insert(to), ++size[v];
				}
			}
		}
	}
}

int main() {
	read(n);
	UFS :: init();
	for(int i = 1, u, v; i <= 2 * n - 2; ++i) {
		read(u), read(v);
		if(g[u].find(v) != g[u].end()) {
			g[u].erase(v), --size[u];
			g[v].erase(u), --size[v];
			que.push(make_pair(u, v));
		} else {
			g[u].insert(v), ++size[u];
			g[v].insert(u), ++size[v];
		}
	}
	
	totBlock = n;
	work();
	
	puts(totBlock == 1 ? "YES" : "NO");
	return 0;
}

Measured memory_bytes: 26240
MOD = 10 ** 9 + 7


def solve(n, a):
    m = 61
    b = [('0'*m + bin(a[i])[2:])[-1:-m:-1] for i in range(n)]
    cnt_bit = [0] * m
    for i in range(n):
        for j, c in enumerate(b[i]):
            if c == '1':
                cnt_bit[j] += 1
    total = 0
    k = 1
    for i in range(m - 1):
        t = 0
        for j in range(n):
            if b[j][i] == '0':
                t += k * cnt_bit[i]
            if b[j][i] == '1':
                t += k * (n - cnt_bit[i])
        t //= 2
        total += t
        k = (k*2 % MOD)
    return total % MOD


def bf(n, a):
    total = 0
    for i in range(n - 1):
        for j in range(i + 1, n):
            total += (a[i] ^ a[j])
    return total % MOD


if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    print(solve(n, a))
    # print(bf(n, a))


Measured memory_bytes: 131984
#include<stdio.h>
int main(){
	int w,h,c,i;
	scanf("%d %d %d",&w,&h,&c);
	i=w;
	while(1){
		if((w%i==0)&(h%i==0)){
		break;
		}
		i--;
	}
	printf("%d\n",(w/i)*(h/i)*c);
	
}


Measured memory_bytes: 2756
#include <iostream>

// int inf = 1 << 28;
int inf = 1000000000;

int dijk(int n,int s, int **g) {
	int sum = 0;
	bool *used = new bool[n];
	int *d = new int[n];

	// std::cout << "n = " << n << " " << "s = " << s << std::endl;

	for(int j=0;j<n;j++){
		for(int i=0;i<n;i++){
			std::cout << g[j][i] << ",";
		}
		std::cout << std::endl;
	}

	for(int i = 0; i < n; i++)
		d[i] = inf;
	d[s] = 0;

	while(true) {
		int u = -1;
		for(int v = 0; v < n; v++)
			if(!used[v] && (u == -1 || d[v] < d[u]))
				u = v;

		// std::cout << "u = " << u << std::endl;

		if(u == -1) break;
		used[u] = true;

		for(int v = 0; v < n; v++)
			if(d[v] > d[u] + g[u][v])
				d[v] = d[u] + g[u][v];
	}

	for(int i = 0; i < n; i++) {
		sum += d[i];
	}

	// for(int i = 0; i < n; i++) {
	// std::cout << d[i] << std::endl;
	// }

	return sum;
}

int main() {
	do {
		int **g; // adjacency matrix, ?
		int *d;
		int *a, *b, *c;
		int edge = 0, min = 0, max = 0;
		int tmp = 0;

		std::cin >> edge;
		if(!edge) break;

		a = new int[edge];
		b = new int[edge];
		c = new int[edge];

		for(int i = 0;i < edge;i++) {
			std::cin >> a[i];
			std::cin >> b[i];
			std::cin >> c[i];
		}

		for(int i = 0; i < edge; i++) {
			if(max < a[i])
				max = a[i];
		}
		for(int i = 0; i < edge; i++) {
			if(max < b[i])
				max = b[i];
		}
		max++;

		g = new int*[max];
		d = new int[max];

		for(int i = 0; i < max; i++) {
			g[i] = new int[max];
		}

		for(int i = 0; i < max; i++)
			for(int j = 0; j < max; j++)
				g[i][j] = inf;

		for(int i = 0; i < edge; i++)
			g[b[i]][a[i]] = g[a[i]][b[i]] = c[i];

		for(int i=0;i<max;i++){
			g[i][i]=0;
		}

		for(int k=0;k<max;k++){
			for(int j=0;j<max;j++){
				for(int i=0;i<max;i++){
					if(g[i][k]+g[k][j]<g[i][j]){
						g[i][j]=g[i][k]+g[k][j];
					}
				}
			}
		}

		//for(int i = 0; i < max; i++)
		//	d[i] = dijk(max, i, g);

		for(int i = 0; i < max; i++){
			d[i]=0;
			for(int j=0;j<max;j++){
				d[i] += g[i][j];
			}
		}

		min = d[0];
		for(int i = 1; i < max; i++) {
			if(min > d[i]) {
				min = d[i];
				tmp = i;
			}
		}

		std::cout << tmp << " " << min << std::endl;
		for(int i = 0; i < max; i++)
			delete[] g[i];
		delete[] g;
		delete[] a;
		delete[] b;
		delete[] c;
		delete[] d;

	}while(true);
	return 0;
}

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

int main()
{
  int S,h,m,s;
  cin>>S;
  h=S/60/60;
  m=S/60-h*60;
  s=S-h*60*60-m*60;
  cout<<h<<':'<<m<<':'<<s<<"\n";
  return(0);
}



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

int main() {
    int x, n, ans; ans = 0;
    cin >> x;
    n = x / 100;
    if (100 * n <= x && x <= 100 * n + n * 5) {
        ans = 1;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

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

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

int main() {
    string S; cin >> S;
    cout << (S[2] == S[3] && S[4] == S[5] ? "Yes" : "No") << '\n';
    return 0;
}


Measured memory_bytes: 256
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();

		for(int i = 0;i < 10000;i++) {
			double xa = (double)i * 0.08;
			double xb = (double)i * 0.1;
			if(a == (int)xa && b == (int)xb) {
				System.out.println(i);
				return;
			}
		}

		System.out.println(-1);
	}
}


Measured memory_bytes: 23252
n, k = input().split()
n = int(n)
k = int(k)
a = [int(s) for s in input().split()]
sums = []
K = k - 1
for i in range(K,n - 1):
    if(a[i - K] < a[i + 1]):
        print("Yes")
    else:
        print("No")

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

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

    int a = 0;
    int z = s.size() - 1;

    for(int i = 0; i < s.size(); ++i)
    {
        if(s[i] == 'A')
        {
            a = i;
            break;
        }
    }

    for(int i = s.size() - 1; i >= 0; --i)
    {
        if(s[i] == 'Z')
        {
            z = i;
            break;
        }
    }

    std::cout << z - a + 1 << std::endl;

    return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

/**
 * Problem P04: CamelCase
 * Java 7 later.
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			String name = line.substring(0, line.indexOf(' '));
			String type = line.substring(line.indexOf(' ') + 1);
			if (type.equals("X")) break;

			ArrayList<StringBuilder> tokens = new ArrayList<>();
			tokens.add(new StringBuilder());

			for (char c : name.toCharArray()) {
				if (c == '_') {
					tokens.add(new StringBuilder());
					continue;
				} else if ('A' <= c && c <= 'Z') {
					if (tokens.get(0).length() != 0) {
						tokens.add(new StringBuilder());
					}
					c += 32;
				}
				tokens.get(tokens.size() - 1).append(c);
			}

			StringBuilder out = new StringBuilder();
			switch (type) {
				case "U":
					for (int i = 0; i < tokens.size(); i++) {
						String token = tokens.get(i).toString();
						token = (char) (token.charAt(0) - 32) + token.substring(1);
						out.append(token);
					}
					break;
				case "L":
					for (int i = 0; i < tokens.size(); i++) {
						String token = tokens.get(i).toString();
						if (i > 0) {
							token = (char) (token.charAt(0) - 32) + token.substring(1);
						}
						out.append(token);
					}
					break;
				case "D":
					for (int i = 0; i < tokens.size(); i++) {
						if (i > 0) out.append("_");
						out.append(tokens.get(i).toString());
					}
					break;
			}
			System.out.println(out.toString());
		} //end while
	} //end main
}

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

int main(){

int a,b,c ;
cin >> a >> b >> c ;
if(a<=b && b<=c){cout << a << " " << b << " " << c << endl ;}
else if (c<=b && b<=a){cout << c << " "  << b << " "  << a << endl ; }
else if (a<=c && c<=b){cout << a << " " << c <<  " " << b << endl ; }
else if(b<=a && a<=c){cout << b << " " << a  << " " << c << endl ; }
else if(b<=c && c<=a){cout << b  << " " << c  << " " << a << endl ; }
else {cout << c  << " " << a  << " " << b << endl ; }
		return 0 ;
		 
		 
	 }
	

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

int main(){
    int K,S;
    int a=0;
  
  	cin >> K >> S;
    for(int i=0;i<=K;i++){
        for(int j=0;j<=K;j++){
            if(0<=(S-i-j) &&(S-i-j)<=K) a++;
        }
    }

    cout << a << endl;
}

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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    vector<int> ans(n);
    for(int i = 0; i < n;){
        int pi = i;
        if(s[i] == 'R'){
            while(s[i] == 'R') i++;
            ans[i-1] += (i - pi + 1) / 2;
            ans[i] += (i - pi) / 2;
        }else{
            while(s[i] == 'L') i++;
            ans[pi-1] += (i - pi) / 2;
            ans[pi] += (i - pi + 1) / 2;
        }
    }
    for(auto& e : ans) cout << e << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll ch[10000007];
int main() {
	// your code goes here
	ll n;
	cin>>n;
	ll out=0;
	for(ll i=1;i<=n;i++)
	{
	    for(ll j=i;j<=n;j+=i)
	    {
	        ch[j]++;
	    }
	    out+=(i*ch[i]);
	}
	cout<<out;
	
}


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

#define ll long long
#define mod 1000000007
#define inf 9223372036854775807
#define F first
#define S second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pll pair<ll,ll>
#define vll vector<ll>
#define umap unordered_map<ll,ll>
#define lpq priority_queue<ll,vector<ll>,greater<ll>>
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define repr(i,a,n) for(ll i=n-1;i>=a;i--)
ll globe=0;

void solution(){
    ll n;
    cin>>n;
    vll h(n);
    for(ll i=0;i<n;i++) cin>>h[i];
    vll dp(n,inf);
    dp[0]=0;
    for(ll i=1;i<n;i++){
        if(i-1>=0) dp[i]=min(dp[i], dp[i-1]+abs(h[i]-h[i-1]));
        if(i-2>=0) dp[i]=min(dp[i], dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1]<<endl;
}

int main() {
    
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll T=1;
    //cin>>T;
    while(T--){
        solution();
    }

    return 0;
}

//BitMasking->setBit: n|(1<<i); unsetBit: n&!(1<<i); checkBit: n&(1<<i);
//ll idcharacter=upper_bound(v.begin(),v.end(),val)-v.begin();
//v.erase(unique(v.begin(),v.end()),v.end());
//ll cnt=count(v.begin(),v.end(),val);
//bool f=find(v.begin(),v.end(),val);

Measured memory_bytes: 4696
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a[1000];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int x;
  cin>>x;
  for(int i=0;i<x;i++){
    int y,z,ans;
    cin>>y>>z;
    reverse(a+y,a+z);
  }
  for(int i=0;i<n;i++){
    if(i!=0) cout<<" ";
    cout<<a[i];
  }
  cout<<endl;
  return 0;
}



Measured memory_bytes: 3032
#include <bits/stdc++.h>
#include "unistd.h"
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream&o,const pair<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
template<typename T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
//V<ll>fac,rfac;void setFac(int n,int mod){fac=rfac=V<ll>(++n);fac[0]=1;FOR(i,1,n)fac[i]=fac[i-1]*i%mod;rfac[n-1]=modInv(fac[n-1],mod);FORR(i,n-1,1)rfac[i-1]=rfac[i]*i%mod;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

void RE(){cout<<1/0;}
void TLE(){sleep(100);}
void WA(){cout<<char(0);exit(0);}

const int N = 12;
int n, m, DP[1<<N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  fill(DP, DP+(1<<N), IINF);
  DP[0] = 0;
  cin >> n >> m;
  FOR(i, 0, m){
    int a, b, d=0;
    cin >> a >> b;
    FOR(j, 0, b){
      int c;
      cin >> c;
      d |= 1<<(c-1);
    }
    FOR(j, 0, 1<<n) mins(DP[d|j], DP[j]+a);
  }
  if(DP[(1<<n)-1]==IINF){
    cout << -1 << endl;
  }else{
    cout << DP[(1<<n)-1] << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>

using namespace std;

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

int main()
{
  ll K, N;
  cin >> K >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A[i];
  }
  vector<int> B(N);
  sort(A.begin(), A.end());
  B[0] = A[0] + (K - A[N - 1]);
  for (int i = 1; i < N; i++)
  {
    B[i] = A[i] - A[i - 1];
  }
  ll B_max = *max_element(B.begin(), B.end());
  cout << K - B_max << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()



int main() {
    string s;
    cin >> s;
    int ans = 0;
    int ctr = 0;
    rep (i, s.size()) {
        if (s[i] == 'g') {
            if (ctr) {
                ctr--;
                ans++;
            } else {
                ctr++;
            }
        } else {
            if (ctr) {
                ctr--;
            } else {
                ans--;
                ctr++;
            }
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 512
my $k=<>;
my $a=0;
my $b=7;
my $count=0;
if($k%2==0||$k%5==0){print "-1";}else{while($a==0){$count=$count+1;if($b%$k==0){$a=1;}else{$b=(($b%$k)*10)+7}}
print "$count";}

Measured memory_bytes: 4720
class UnionFind(object):

    def __init__(self, n):
        self.n = n
        self.par = list(range(n))
        self.rank = [1] * n

    def is_same(self, a, b):
        return self.root(a) == self.root(b)

    def root(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.root(self.par[x])
        return self.par[x]

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.rank[x] > self.rank[y]:
            self.par[y] = x
        elif self.rank[x]  < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            self.rank[x] += 1


N = int(input())
X = []
Y = []
for i in range(N):
    x, y = map(int, input().split())
    X.append((x, i))
    Y.append((y, i))

X = sorted(X)
Y = sorted(Y)
graph = []
for i in range(N - 1):
    graph.append((X[i + 1][0] - X[i][0], X[i][1], X[i + 1][1]))
    graph.append((Y[i + 1][0] - Y[i][0], Y[i][1], Y[i + 1][1]))

graph.sort()
uf = UnionFind(N)

total_cost = 0
for cost, a, b in graph:
    if not uf.is_same(a, b):
        uf.unite(a, b)
        total_cost += cost

print(total_cost)


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

int main(){
  string s;
  cin >> s;
  
  string ans = "No";
  rep(i,3){
    if(s.at(i) == '7') ans = "Yes";
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ret = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if (i*500 + j*100 + k*50) == x:
        ret += 1
print(ret)

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

typedef double du ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;
typedef vector <lli> vi ;
typedef string st ;

#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    vi a[] = { {1 , 3 , 5 , 7 ,8 , 10 , 12} , {4 , 6 , 9 ,  11} , {2} } ;
    lli num1 , num2 , fin = 0;
    bool t = false ;
    cin >> num1 >> num2 ;
    for (lli i = 0 ; i < 3 ; i ++)
    {
        for (lli j  = 0 ;  j < a[i].size() ; j++)
        {
            if (num1 == a[i][j])
                fin = i ;
        }
    }
    for (lli i = 0 ; i < a[fin] . size () ; i ++ )
    {
        if (num2 == a[fin][i])
            t = true ;
    }
    (t ? Yes : No) ;
    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
import sys
input = sys.stdin.readline
H = int(input())
h = [int(ele) for ele in input().split()]
h = [0] + h


def main():
    for i in range(1, H+1):
        print('node ' + str(i) + ': key = ' +
              str(h[i]) + ', ' + parent(i) + left(i) + right(i))


def parent(i):
    if i == 1:
        return ''

    p_idx = int(i/2)
    return 'parent key = ' + str(h[p_idx]) + ', '


def left(i):
    l_idx = 2*i
    if H < l_idx:
        return ''

    return 'left key = ' + str(h[l_idx]) + ', '


def right(i):
    r_idx = 2*i + 1
    if H < r_idx:
        return ''

    return 'right key = ' + str(h[r_idx]) + ', '


if __name__ == "__main__":
    main()



Measured memory_bytes: 5628
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, t = 0;
  cin  >> n;
  REP(i, 5) {
    long long v;
    cin >> v;
    t = max((n + v - 1) / v, t);
  }
  cout << t + 4 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf 10000000000000
#define mod 1000000007
#define maxn 100009
#define maxr 100009
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	ll x;
	rl(x);
	ll c=x/100;
	if(x>=c*100&&x<=c*105)
		cout<<1<<endl;
	else
		cout<<0<<endl;
	return 0;
}

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

int main(){
  long long x;
  cin>>x;
  long long sum=0;
  for(long long i=1;i<=x;i++){
  if(i%3!=0&&i%5!=0){
  sum+=i;
  }
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 3620
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto A = new long[](N);
    auto B = new long[](N);
    foreach (i; 0 .. N)
    {
        scan(A[i], B[i]);
    }
    zip(B, A).sort();
    long t;
    foreach (i; 0 .. N)
    {
        if (B[i] < t + A[i])
        {
            writeln("No");
            return;
        }
        t += A[i];
    }
    writeln("Yes");
}


Measured memory_bytes: 5116
def gcd(a, b)
  while ((r = a%b) != 0) do
    a = b
    b = r
  end
  b
end

def lcm(n, m, g)
  (n*m)/g
end

while gets do
  a, b = $_.split(/\s/).map(&:to_i).sort
  g = gcd(a, b)
  l = lcm(a, b, g)
  puts "#{g} #{l}"
end

Measured memory_bytes: 6100
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
count = 0

for i in range(n):
    if b[i] >= a[i]+a[i+1]:
        count += a[i]+a[i+1]
        a[i+1] = 0
    else:
        if a[i] < b[i]:
            a[i+1] = a[i+1]+a[i]-b[i]
        count += b[i]
print(count)

Measured memory_bytes: 18624
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }
const int Maxn = 1e5 + 5;
int a, b, c;
int main()
{
	cin >> a >> b >> c;
	cout << min(c, b) << " " << max(0, b + c - a) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int
int main(){
  ll n;
  cin >> n;
  ll a[n];
  rep(i,n){
    cin >> a[i];
  }
  ll b[n],j;
  rep(i,n){
    b[i]=0;
  }
  rep(i,n){
    j=a[i]-1;
    b[j]++;
  }
  ll c[n],ans=0;
  rep(i,n){
    c[i]=(b[i]-1)*b[i]/2;
    ans=ans+c[i];
  }
  ll d[n],e[n];
  rep(i,n){
    b[a[i]-1]--;
    e[i]=ans-c[a[i]-1]+(b[a[i]-1]-1)*b[a[i]-1]/2;
    cout << e[i] << endl;
    b[a[i]-1]++;
  }
}

Measured memory_bytes: 8832
N, M = map(int, input().split())
store = [[0] * 2 for i in range(N)]

for i in range(N):

    a, b = (map(int, input().split()))
    store[i] = (a, b)

store.sort(key=lambda x: x[0])

# print(store)

rest = M
index = 0
cost = 0
while (rest > 0):
    c, drink = store[index]
    if drink >= rest:
        drink = rest
        rest = 0
    else:
        rest -= drink
    cost += drink * c
    index += 1

print(cost)


Measured memory_bytes: 19572
let () =
  Scanf.scanf "%d %d\n" @@ fun h w ->
  Printf.printf "%d\n"
    (if h = 1 || w = 1 then 1
     else if h mod 2 = 0 || w mod 2 = 0 then h * w / 2
     else h * (w / 2) + h / 2 + 1)

Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

const int INF = 1<<28;
struct ID{
  map<string, int> maker;
  int get(string s){
    int n = maker.size();
    if(maker.count(s)) return maker[s];
    else return maker[s] = n;
  }
};
struct edge{
  int from, to, cost;
  edge () {}
  edge(int from, int to, int cost) :
    from(from), to(to), cost(cost) {}
  bool operator < (const edge& r) const {
    return cost != r.cost ? cost > r.cost : from != r.from ? from < r.from : to < r.to;
  }
};

typedef vector<edge> edges;
typedef vector<edges> graph;

vector<int> dijkstra(const graph& g, int s){
  int n = g.size();
  vector<bool> visit(n, false);
  vector<int> dist(n, INF);
  vector<int> src(n, -1);
  priority_queue<edge> que;
  que.push(edge(-1, s, 0));
  while(!que.empty()){
    edge e = que.top(); que.pop();
    if(visit[e.to]) continue;
    visit[e.to] = true;

    int from = e.to;
    REP(i, g[from].size()){
      int to = g[from][i].to;
      int ncost = e.cost + g[from][i].cost;
      if(visit[to] || ncost >= dist[to] ) continue;
      dist[to] = ncost;
      src[e.to] = from;
      que.push(edge(from, to, ncost));
    }
  }
  return dist;
}

vector<int> bellmanford(const graph& g, int s){
  int n = g.size();
  vector<int> dist(n, INF);
  dist[s] = 0;
  REP(iter, n){
    bool update = false;
    REP(i, n) REP(j, g[i].size()){
      edge e = g[i][j];
      int ncost = dist[e.from] + e.cost;
      if(ncost < dist[e.to]){
        dist[e.to] = ncost; 
        update = true;
      }
    }
    if(!update) return dist;
  }
  return vector<int>(n, -INF);
}

int main(){
  int n,m;
  while(cin>>n>>m,n){
    graph G(n);
    string s,p,g;
    cin>>s>>p>>g;
    ID id;
    id.get(s);
    id.get(p);
    id.get(g);
    REP(i,m){
      string A,B;
      int ds,t;
      cin>>A>>B>>ds>>t;
      int dist = ds/40 + t;
      int na = id.get(A);
      int nb = id.get(B);
      G[na].push_back(edge(na, nb, dist));
      G[nb].push_back(edge(nb, na, dist));
    }
    vector<int> dist = bellmanford(G, 1);
    cout<<dist[0] + dist[2]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1156
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read


a,b,h,m = [int(i) for i in read().split()]

x = 30*h+30*m/60
y = 6*m

from math import cos, pi, sqrt
theta = (x-y)*2*pi/360
print(sqrt(max(a*a+b*b-2*a*b*cos(theta),0)))




Measured memory_bytes: 9496
'''input
6
2 7 1 8 2 8
'''
n = input()
a = map(int ,raw_input().split())
freq4 = 0
freq2 = 0
for i in a:
	if i%4 == 0:
		freq4 += 1
		continue
	if i%2 ==0 :
		freq2 += 1
if freq4 >= n//2 or freq4 + freq2//2 >= n//2:
	print "Yes"

else:
	print "No"

Measured memory_bytes: 11320
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>
#include <sstream>
#include <map>

using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

const ll mod = 1e9+7;

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n*a, b) << endl;
}

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

using namespace std;

long* primes(long high)
{
  long* p = new long[high];
  for (int i = 0; i < high; i++) {
    p[i] = 0;
  }

  long max = ceil(sqrt(high));
  for (int i = 2; i <= max; i++) {
    if (p[i - 1] == -1) continue;

    int count = 2;
    while (i * count <= high) {
      p[i * count - 1] = -1;
      count++;
    }
  }

  for (int i = 1; i < high; i++) {
    if (p[i] == -1) {
      p[i] = p[i - 1];
    } else {
      p[i] = p[i - 1] + 1;
    }
  }
  
  return p;
}

int main(int argc, char const* argv[])
{
  long* p = primes(999999);
  long n;

  while (cin >> n) {
    cout << p[n - 1] << endl;
  }
  return 0;
}

Measured memory_bytes: 8996
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
	run();
	int a, b, h, m;
	cin >> a >> b >> h >> m;
	double aAngle = ((h * 60 + m) / (12.0 * 60)) * 360;
	double bAngle = (m / 60.0) * 360;
	double th = min(fmod(aAngle - bAngle + 360, 360),
			fmod(bAngle - aAngle + 360, 360)) * acos(-1) / 180;
	cout << fixed << setprecision(10)
			<< sqrt(a * a + b * b - (2 * a * b * cos(th)));
}


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

using namespace std;

string s;
long long n, cnt[30];

int main() {
    cin >> s;
    n = s.size();

    long long ans = n * (n+1) / 2;
    ans -= n-1;

    for (int i = 0; i < n; i++)
        cnt[s[i] - 'a']++;

    for (int i = 0; i < 30; i++)
        ans -= cnt[i] * (cnt[i]-1) / 2;

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
    const long MAX = 10000;
    double r;

    cin >> r;

     double s, l;

    if (r > 0 && r <= MAX) {
        s = M_PI * r * r;
        l = 2 * M_PI * r;
     
        cout << fixed;
        cout << setprecision(6) << s << " " << l << endl;
    }
    return 0;
}


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

int main() {
    int h, n; cin >> h >> n;
    vector<int> a(n);
    int sum =0;
    rep(i, n) {
        cin >> a.at(i);
        sum += a.at(i);
    }

    if (h - sum >0) {
        puts("No");
    }
    else
    {
        puts("Yes");
    }
}

Measured memory_bytes: 640
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
int main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if (c >= a && c <= b) {
		printf("Yes");
	}
	else {
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

class UnionFindTree {
public:
    this(size_t n) {
        parent = iota(n).array();
        rank = new size_t[](n);
    }
    size_t find(size_t n) {
        if(n == parent[n]) {
            return n;
        } else {
            parent[n] = find(parent[n]);
            return parent[n];
        }
    }
    void unite(size_t n, size_t m) {
        auto p1 = find(n);
        auto p2 = find(m);
        if(n == m) {
            return;
        }
        if(rank[p1] < rank[p2]) {
            swap(p1, p2);
        }
        if(rank[p1] == rank[p2]) {
            ++rank[p1];
        }
        parent[p2] = p1;
    }
private:
    size_t[] parent;
    size_t[] rank;
}
unittest {
    auto uft = new UnionFindTree(10);
    foreach(i; iota(10)) {
        assert(uft.find(i) == i);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0).drop(1)) {
        uft.unite(i, i-3);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0)) {
        assert(uft.find(0) == uft.find(i));
    }
    foreach(i; iota(10).filter!(a => a%3 != 0)) {
        assert(uft.find(0) != uft.find(i));
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

void main(){
    auto s = readln().chomp();
    if(s[0] == s[$-1]) {
        writeln(s.length % 2 == 0 ? "First": "Second");
    } else {
        writeln(s.length % 2 == 1 ? "First": "Second");
    }
}



Measured memory_bytes: 2556
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
#define rep(i, n) for (int i=0; i<(int) (n);i++)
using ll = long long;
using P = pair<int, int>;

void solve_1() {//14m
	int a, b;
	cin >> a >> b;
	int total;
	int n = 0;
	while (!((a-1)*n + 1 >= b)) {
		n++;
	}
	cout << n << endl;

}

void solve_2() {//30m
	int n;
	cin >> n;
	vector<int> x;
	int total = 0;
	rep(i, n) {
		int tmp;
		cin >> tmp;
		x.push_back(tmp);
		total += tmp;
	}
	int p1 = (double(total)/double(n)*2 - 1.0) / 2;
	int p2 = (double(total)/double(n)*2 - 1.0) / 2 + 1;
	int point_sum1 = 0, point_sum2= 0;
	rep(i, n) {
		point_sum1 += pow(x[i] - p1, 2);
		point_sum2 += pow(x[i] - p2, 2);
	}
	cout << min(point_sum1, point_sum2) << endl;

}

void solve_2re() {
	int n;
	cin >> n;
	vector<int> x(n);
	int total = 0;
	rep(i, n) {
		cin >> x[i];
		total += x[i];
	}
	int p1 = total / n;
	int p2 = total / n + 1;
	int point_sum1 = 0, point_sum2 = 0;
	rep(i, n) {
		point_sum1 += pow(x[i] - p1, 2);
		point_sum2 += pow(x[i] - p2, 2);
	}
	cout << min(point_sum1, point_sum2) << endl;
}

void solve_3() {//17m
	int n, a, b;
	cin >> n >> a >> b;
	string s;
	cin >> s;
	int sum = a + b;
	rep(i, n) {
		if (s[i] == 'a') {
			cout << (sum > 0 ? "Yes" : "No") << endl;
			if (sum>0) {
				sum--;
			}
		}
		else if (s[i] == 'b') {
			cout << (sum > 0 && b > 0 ? "Yes" : "No") << endl;
			if (sum > 0 && b > 0) {
				if (b>0) {
					sum--;
					b--;
				}
				else {
					sum--;
				}
			}
		}
		else if (s[i] == 'c') {
			cout << "No" << endl;
		}
	}
}

void solve_4() {//7m
	int n;
	cin >> n;
	rep(i, 50000) {
		if (int(i*1.08) == n) {
			cout << i;
			return;
		}
	}
	cout << ":(";
}

void solve_4re() {
	int n;
	cin >> n;
	int x = ceil(n/ 1.08);
	if (int(x*1.08)==n) {
		cout << x;
	}
	else
	{
		cout << ":(";
	}
}

void solve_5() {//7m
	int n, m, c;
	cin >> n >> m >> c;
	vector<int> b(m);
	int score;
	int count = 0;
	rep(i, m) cin >> b[i];
	rep(i, n) {
		score = c;
		rep(i, m) {
			int a;
			cin >> a;
			score += b[i] * a;
		}
		if (score>0) {
			count++;
		}
	}
	cout << count;

}

void solve_6() {
	ll h, w;
	cin >> h >> w;
	if (h==1||w==1) {
		cout << 1;
		return;
	}
	cout << (h*w+1)/2;
}

void solve_7() {

}

void solve_8() {

}

void solve_9() {

}

void solve_100() {//20m
	int n;
	cin >> n;
	vector<int> a(n);
	int pair_count = 0;
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		if (a[a[i]-1] -1 == i) {
			pair_count++;
		}
	}
	cout << pair_count/2;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//solve_1();
	//solve_2();
	//solve_2re();
	//solve_3();
	//solve_4re();
	//solve_5();
	solve_6();
	//solve_5();
	//solve_5();
	//solve_5();
	//solve_5();
	//solve_5();
	//solve_5();
	//solve_100();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint>> que;
priority_queue<llint> q;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

llint a,b,c,d;

void solve(){
	cin >> a >> b >> c >> d;
	while(1){
		c-=b;
		if(c<=0){
			cout << "Yes" << endl;
			return;
		}
		a-=d;
		if(a<=0){
			cout << "No" << endl;
			return;
		}
	}
}

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


Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long ll;
#define _GLIBCXX_DEBUG
#define int long long
using namespace std;
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MAXIN(x) max_element(ALL(x)) - x.begin();
#define MIN(x) *min_element(ALL(x))
#define MININ(x) min_element(ALL(x)) - x.begin();
#define INF 1000000000000
#define MOD 100000070
#define MAXR 100000
#define PI 3.14159265358979323846

using namespace std;

signed main() {

    int a ;
    cin >> a ;

    if(a>=30){
        cout << "Yes" <<endl ;
        return 0;
    }
    cout << "No" <<endl ;



    return 0;
}

Measured memory_bytes: 3640
N, M, C = map(int, input().split())

B = list(map(int, input().split()))
ans = 0
for _ in range(N):
    A = list(map(int, input().split()))
    s = C
    for i in range(M):
        s += A[i] * B[i]
    if s > 0:
        ans += 1

print(ans)


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

ll solve() {
    ll N, a;
    cin >> N;
    map<ll,ll> c;
    ll ans = 0;
    for ( ll i = 0; i < N; i++ ) {
        cin >> a;
        ans += c[-a+i];
        c[a+i]++;
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 26368
patterns = [None] * (10**5 + 10)
patterns[0] = 1
patterns[1] = 1
calcurated_until = 1
MOD = 10**9+7
def get_patterns(n):
  global calcurated_until, patterns
  if patterns[n] is None:
    for i in range(calcurated_until + 1, n + 1):
      patterns[i] = (patterns[i-1] + patterns[i-2])%MOD
    calcurated_until = n
  #print('p', n, patterns[n])
  return patterns[n]

def solve():
  N, M = map(int, input().split())
  A = [-1]
  for _ in range(M):
    A.append(int(input()))
  A.append(N+1)
  #print(A)
  
  ans = 1
  for a1, a2 in zip(A[:-1], A[1:]):
    #print(a1, a2)
    if a2 == a1+1:
      print('0')
      return
    #print('ans', ans)
    #print('get_patterns(a2 - a1 - 2)', get_patterns(a2 - a1 - 2))
    ans *= get_patterns(a2 - a1 - 2)
    #print('ans', ans)
    ans %= MOD
    #print('ans', ans)
  print(ans)
solve()


Measured memory_bytes: 14960
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

bool checkprime(int n)
{
    int f=1;
    for (int i=2;i<=sqrt(n);i++)
    {
        if (n%i==0)
        {
            f=0;
            break;
        }
    }
    return f;
}

signed main() {
	// your code goes here
	int n;
	cin>>n;
	for (int i=n;;i++)
	{
	    if (checkprime(i))
	    {
	        cout<<i<<endl;
	        return 0;
	    }
	}
	//return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <numeric>
#include <queue>
#include <string>

/* INSERT HERE  - ALWAYS - include the 'always include' toolset*/
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using ll = long long;

template <typename T>
std::ostream &operator<<(std::ostream &os, std::vector<T> vec) {
  if (!vec.empty()) {
    std::copy(vec.begin(), vec.end() - 1, std::ostream_iterator<T>(os, " "));
    os << vec.back();
  }
  return os;
}

template <typename T>
class DSU {
  std::unordered_map<T, T> parent;
  std::unordered_map<T, T> index;

public:
  auto make_set(T t) -> void {
    parent[t] = t;
    index[t] = rand();
  }

  auto find_set(T t) -> T {
    if (t == parent[t]) {
      return t;
    }
    return parent[t] = find_set(parent[t]);
  }

  auto union_sets(T a, T b) -> void {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
      if (index[a] < index[b]) {
        std::swap(a, b);
      }
      parent[b] = a;
    }
  }
};

template <typename T>
class SizedDSU {
  std::unordered_map<T, T> parent;
  std::unordered_map<T, T> size_;

public:
  auto make_set(T t) -> void {
    parent[t] = t;
    size_[t] = 1;
  }

  auto find_set(T t) -> T {
    if (t == parent[t]) {
      return t;
    }
    return parent[t] = find_set(parent[t]);
  }

  auto union_sets(T a, T b) -> void {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
      if (size_[a] < size_[b]) {
        std::swap(a, b);
      }
      size_[a] += size_[b];
      parent[b] = a;
      size_[b] = 0;
    }
  }

  auto size(T t) -> T {
    return size_.at(find_set(t));
  }
};

/**/


using namespace std;
using st = std::size_t;
using bo = uint8_t;
typedef std::numeric_limits<double> dbllims;

auto solve_wrapper() -> void {
  int n, m;
  cin >> n >> m;
  int a, b;
  auto dsu = DSU<int>{};
  for (int i{0}; i < n; ++i) {
    dsu.make_set(i);
  }
  for (int i{0}; i < m; ++i) {
    cin >> a >> b;
    a--;
    b--;
    dsu.union_sets(a, b);
  }
  auto s = set<int>{};
  for (int i{0}; i < n; ++i) {
    s.insert(dsu.find_set(i));
  }
  std::cout << s.size() - 1 << "\n";
}

auto main() -> int {
  ll t = 1;
  while (t-- > 0) {
    solve_wrapper();
  }
  return 0;
}


Measured memory_bytes: 13824
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Pranto
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
//#include<math.h>
//#include <algorithm>
#include <iostream>

int getTheAnswer() {
    return 42;
}
typedef struct node Node;

#define ll long long
#define maximum 1000000
#define q_size 100
using namespace std;


class Task {
public:

	void solve(std::istream& cin, std::ostream& cout) {

	   ll n,a,b;
	   cin>>n>>a>>b;
	   ll s=n/(a+b);
	   ll rem=n%(a+b);
	   s=s*a;
	   if(rem>a) s+=a;
	   else s+=rem;
	   cout<<s;

    }
};


int main() {
	Task solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256