akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 100005;
int N, M;
int A[MAX_N];

signed main()
{
  cin >> N >> M;
  priority_queue<int> pq;
  REP(n,N) {
    cin >> A[n];
    pq.push(A[n]);
  }

  REP(m,M) {
    int p = pq.top(); pq.pop();
    pq.push(p/2);
  }

  int ans = 0;
  while(pq.size()) {
    ans += pq.top(); pq.pop();
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;
#define lint long long


int main() {
    int X;
    cin >> X;
    
    lint l = 2;
    
    for(int i = 0; i < X; ++i){
        l = 2 * l + 2;
    }
    cout << l << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<21)
using namespace std;

int main(){

  int n, tmp = 0;
  int v[210] = {};
  long long ans = INF;
  cin >> n;
  for(int i = 0; i < n; i++) cin >> v[i];
  for(int i = -100; i < 101; i++){
    long long sum = 0;
    for(int j = 0; j < n; j++){
      sum += (i - v[j]) * (i - v[j]);
    }
    ans = min(ans, sum);
  }
  int cnt = 1;
  for(int i = 1; i < n; i++){
    if(v[0] == v[i]) cnt++;
  }
  if(ans == INF || cnt == n) ans = 0;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int array[4][3][10]={};
  int n,b,f,r,v;
  int i,j,k;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d%d%d",&b,&f,&r,&v);
    array[b-1][f-1][r-1]+=v;
  }

  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
	printf(" %d",array[i][j][k]);
      }
      printf("\n");
    }
    if(i!=3) printf("####################\n");
  }

  return 0;
}

Measured memory_bytes: 1800
def prime_factor(n):
    ret = {}
    p = 2
    while p*p <= n:
        while n % p == 0:
            ret[p] = ret.get(p, 0) + 1
            n //= p
        p += 1
    if n != 1: ret[n] = 1
    return ret

n, p = map(int, input().split())

primes = prime_factor(p)
ans = 1

for p, e in primes.items():
    ans *= max(1, p**(e//n))

print(ans)


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

struct Coupon {
  int x;
  int y;
  int c;
};

int main() {
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A + 1), b(B + 1);

  vector<Coupon> m(M + 1);
  rep1(i, A) cin >> a.at(i);
  rep1(i, B) cin >> b.at(i);
  rep1(i, M) {
    int x, y, c;
    cin >> x >> y >> c;
    m.at(i) = {x, y, c};
  }

  int ans = *min_element(a.begin() + 1, a.end()) +
            *min_element(b.begin() + 1, b.end());

  rep1(i, M) {
    Coupon cp = m.at(i);
    ans = min(ans, a.at(cp.x) + b.at(cp.y) - cp.c);
  }

  cout << ans << endl;
  return 0;
}


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

using namespace std;
#define N 2005

int a[10][10];

int main()
{
    ios::sync_with_stdio(0);
    int h,w;
    cin>>h>>w;
    for(int i=0;i<=9;++i){
        for(int j=0;j<=9;++j){
            cin>>a[i][j];
        }
    }
    for(int k=0;k<=9;++k){
        for(int i=0;i<=9;++i){
            for(int j=0;j<=9;++j){
                if(a[i][k]+a[k][j]<a[i][j]){
                    a[i][j]=a[i][k]+a[k][j];
                }
            }
        }
    }
    int t,ans=0;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            cin>>t;
            if(t==-1);
            else{
                ans+=a[t][1];
            }
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n, q;
    cin >> n >> q;
    vl a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    if (n % 2 == 1) {
        a.push_back(-1000000000); // Aoki-kun takes this
        n++;
    }
    sort(a.begin(), a.end(), greater<ll>());
    vl x(q);
    for (int i = 0; i < q; ++i) {
        cin >> x[i];
    }
    vl psum(n);
    psum[0] = a[0];
    vl evensum(n);
    evensum[0] = a[0];
    for (int i = 1; i < n; ++i) {
        psum[i]    = psum[i - 1] + a[i];
        evensum[i] = evensum[i - 1];
        if (i % 2 == 0)
            evensum[i] += a[i];
    }
    auto check = [&](int m, int iq) {
        ll min_tak = a[m];
        ll max_aok = a[m + 1];
        ll min_aok = a[2 * m];
        return abs(a[m] - x[iq]) >= abs(a[2 * m] - x[iq]) && abs(a[m] - x[iq]) >= abs(a[m + 1] - x[iq]);
    };
    for (int i = 0; i < q; ++i) {
        int ok = 0, ng = n / 2;
        while (ok + 1 != ng) {
            int mid = (ok + ng) / 2;
            if (check(mid, i))
                ok = mid;
            else
                ng = mid;
        }
        ll ret = psum[ok] + evensum[n - 1] - evensum[2 * ok];

        cout << ret << "\n";
    }
    return 0;
}

Measured memory_bytes: 4864
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func parseStringSlice(a []int) []string {
	s := make([]string, len(a))
	for i := 0; i < len(a); i++ {
		s[i] = strconv.Itoa(a[i])
	}
	return s
}

func countingSort(A []int) []int {
	S := make([]int, len(A))
	c := make([]int, 10000)
	for _, v := range A {
		c[v]++
	}

	total := 0
	for i := 0; i < 10000; i++ {
		total += c[i]
		c[i] = total
	}

	for i := len(A) - 1; i >= 0; i-- {
		S[c[A[i]] - 1] = A[i]
		c[A[i]]--
	}

	return S
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	A := make([]int, n)

	for i := 0; i < n; i++ {
		A[i] = nextInt()
	}

	S := countingSort(A)
	ans := parseStringSlice(S)
	fmt.Println(strings.Join(ans, " "))
}


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


int main() {
    string s1,s2;
    cin >> s1 >> s2;
    int cnt=0;
    for (int i=0;i<s1.size();i++)
        if (s1[i]!=s2[i]) cnt++;
    cout << cnt;
}


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

int main(void){
	int tmp,wa,sa,seki,tmp3,a,b;
	cin >> a;
	cin >> b;
	wa = a + b;
	sa = a - b;
	seki = a * b;
	tmp = wa;
	if(tmp < sa){
		tmp = sa;
	}
	if(tmp < seki){
		tmp = seki;
	}
	cout << tmp << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll R,C,N;

ll f(ll x,ll y){
    if(y==0) return x;
    else if(x==R) return y+R;
    else if(y==C) return R+C+(R-x);
    else if(x==0) return R+C+R+(C-y);
    assert(false);
}

int main(){
    cin >> R >> C >> N;
    vector<pair<int,ll>> v;
    rep(i,N){
        ll x1,y1,x2,y2;
        cin >> x1 >> y1 >> x2 >> y2;
        ll p1=-1,p2=-1;
        // about point1
        if((x1==0 or x1==R) or (y1==0 or y1==C)){
            p1 = f(x1,y1);
        }
        if((x2==0 or x2==R) or (y2==0 or y2==C)){
            p2 = f(x2,y2);
        }

        if(p1>-1 and p2>-1){
            v.push_back(mp(p1,i));
            v.push_back(mp(p2,i));
        }
    }
    sort(all(v));

    stack<ll> stk;
    set<ll> used;
    for(int i=0;i<v.size();i++){
        int val = v[i].se;
        if(used.count(val)){
            if(stk.top() == val){
                stk.pop();
            }else{
                cout << "NO" << endl;
                return 0;
            }
        }else{
            used.insert(val);
            stk.push(val);
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 8812
// 2017/12/13 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		char c[100];
		for(int i=0; i<n; i++){
			cin >> c[i];
		}

		int cnt[26] = {0};

		for(int i=0; i<n; i++){
			cnt[(int)(c[i]-'A')]++;

			int max1 = -1;
			int max2 = -1;

			for(int j=0; j<26; j++){
				if(cnt[j]>max1){
					max2 = max1;
					max1 = cnt[j];
				}
				else if(cnt[j]>max2){
					max2 = cnt[j];
				}
			}

			if(max1-max2>n-(i+1)){
				for(int j=0; j<26; j++){
					if(cnt[j]==max1){
						cout << (char)(j+'A') << ' ';
						break;
					}
				}
				cout << (i+1) << endl;
				break;
			}

			if(i==n-1){
				cout << "TIE" << endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3052
#include <stdio.h>
#define N 100

int main(){
  int i,j,n,u,v,k;
  int aij[N][N];

  scanf("%d",&n);

  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      aij[i][j]=0;
    }
  }


  for(i=0; i<n; i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=0; j<k; j++){
      scanf("%d",&v);
	aij[u-1][v-1]=1;
    }
  }

  for(i=0; i<n; i++){
    for(j=0; j<n-1; j++){
      printf("%d ",aij[i][j]);
    }
      printf("%d",aij[i][n-1]);
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 644
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	while(true){
		int n;
		cin >> n;
		if(n == 0){ break; }
		vector<int> a(n);
		for(int i = 0; i < n; ++i){ cin >> a[i]; }
		sort(a.begin(), a.end());
		int answer = -1, count = 0, prev = -1;
		for(int i = 0; i < n; ++i){
			if(a[i] == prev){
				if(++count > n / 2){ answer = a[i]; }
			}else{
				count = 1;
			}
			prev = a[i];
		}
		if(n == 1){ answer = a[0]; }
		if(answer < 0){
			cout << "NO COLOR" << endl;
		}else{
			cout << answer << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chMin(T& a,T b){if(a>b){a=b;return true;}else{return false;}};
const int inf=1e9;
  
int main(){
    int N,K;
    cin >>N >>K;
    vector<int> h(N);
    for (int i=0;i<N;i++)cin >>h[i];
    vector<int> mem(N+K,inf); 
    mem[0]=0;
    for(int i=0;i<N;i++){
        for(int j=1;j<=K && i+j<N;j++){
            chMin(mem[i+j],mem[i]+abs(h[i+j]-h[i]));
        }
    }
    cout <<mem[N-1]<<endl;
}

Measured memory_bytes: 1024
<?php
while(true){
list($h, $w) = explode(" ", trim(fgets(STDIN)));
if($h == 0 && $w == 0){ break; }

for($i = 0; $i < $h; $i++){
        printf("%s%s", str_repeat("#", $w), PHP_EOL);
}echo PHP_EOL;
}

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

int main() {
  int A,B,C,D;
  cin >> A;
  cin >> B;
  cin >> C;
  cin >> D;

  if (C <= B) {
    cout << "Yes" << endl;
  }
  if (A <= D && C > B) {
    cout << "No" << endl;
  }
  if (A > D && C > B && C%B != 0 && A%D != 0){
   if (C/B+1 <= A/D+1) {
    cout << "Yes" << endl;
  }
  if (C/B+1 > A/D+1){
    cout << "No" << endl;
  }
  }
   if (A > D && C > B && C%B == 0 && A%D != 0){
   if (C/B <= A/D+1) {
    cout << "Yes" << endl;
  }
  if (C/B > A/D+1){
    cout << "No" << endl;
  }
  }
   if (A > D && C > B && C%B != 0 && A%D == 0){
   if (C/B+1 <= A/D) {
    cout << "Yes" << endl;
  }
  if (C/B+1 > A/D){
    cout << "No" << endl;
  }
  }
   if (A > D && C > B && C%B == 0 && A%D == 0){
   if (C/B <= A/D) {
    cout << "Yes" << endl;
  }
  if (C/B > A/D){
    cout << "No" << endl;
  }
  }
}


Measured memory_bytes: 3592
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)

int main() {
	char s[2];
	fscanf(stdin, "%s", s);
	switch (s[0]) {
	case 'a':
	case 'i':
	case 'u':
	case 'e':
	case 'o':
		P(s, "vowel");
		break;
	default:
		P(s,"consonant");
		break;
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n, cnt, a[MAXN];
int main() {
	read(n), cnt = 0;
	for (int i = 1; i <= n; i++)
		read(a[i]), cnt += a[i] != 0;
	if (cnt == 0) {
		puts("Yes");
		return 0;
	}
	if (n % 3) {
		puts("No");
		return 0;
	}
	sort(a + 1, a + n + 1);
	if ((a[n / 3] ^ a[n / 3 * 2] ^ a[n]) == 0 && a[1] == a[n / 3] && a[n / 3 + 1] == a[n / 3 * 2] && a[n / 3 * 2 + 1] == a[n]) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
using namespace std;

int main(){
  string n;
  cin >> n;
  if(n[0] == n[1] && n[1] == n[2]){
    cout << "Yes" << endl;
  }else if(n[1] == n[2] && n[2] == n[3]) {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

char buf[125252];

int main(){
  scanf("%s",buf);
  string s(buf);
  int k;
  scanf("%d",&k);
  int n = s.size();
  REP(i,n){
    if(s[i]=='a')continue;
    int cnt = 'z'+1-s[i];
    if(k<cnt)continue;
    k-=cnt;
    s[i]='a';
  }
  s[n-1] = (s[n-1]-'a'+k)%26 +'a';
  puts(s.c_str());
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
int main(){
    LL n, m;
    cin >> n >> m;
    if(n == m) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+7;
const int INF  = 1<<30;
const int mod  = 1e9+7;

int s[maxn],n;
bool check(){
    for(int i=1;i<=n;i++){
        if(s[i]!=i)return false;
    }
    return true;
}
void solve(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>s[i];
    if(check()){
        puts("YES");return;
    }else{
        for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++){
            swap(s[i],s[j]);
            if(check()){
                puts("YES");return;
            }else{
                swap(s[i],s[j]);
            }
        }
    }
    puts("NO");
    return;
}

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("in.txt","r",stdin);
#endif
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
#ifndef ONLINE_JUDGE
   // printf("%.10f\n",1.0*clock()/CLOCKS_PER_SEC);
#endif
    return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t h, w;
    cin >> h >> w;

    unordered_map<char, int64_t> m;
    for (auto _ : irange(0L, h)) {
        string s;
        cin >> s;

        for (auto c : s) {
            ++m[c];
        }
    }

    auto n4 = accumulate(m.begin(), m.end(), 0L, [](int64_t s, const auto& kv) {
        return s + kv.second / 4 * 4;
    });

    auto n2 = accumulate(m.begin(), m.end(), 0L, [](int64_t s, const auto& kv) {
        if (kv.second % 4 == 2) {
            return s + 2L;
        } else {
            return s;
        }
    });

    auto n1 = accumulate(m.begin(), m.end(), 0L, [](int64_t s, const auto& kv) {
        if (kv.second % 4 != 2) {
            return s + kv.second % 4;
        } else {
            return s;
        }
    });

    auto no = count_if(m.begin(), m.end(),
                       [](const auto& kv) { return kv.second % 2 > 0; });

    if (h % 2 == 0 && w % 2 == 0) {
        if (n4 == h * w) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else if (h % 2 == 0) {
        if (no == 0 && n2 <= h) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else if (w % 2 == 0) {
        if (no == 0 && n2 <= w) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        if (no == 1 && n1 + n2 <= h + w - 1) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

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

constexpr auto DictSize = ((1 << 26) - 1)/3;

bool dict[DictSize];

inline int myhash(char* str){
    int n = strlen(str);
    int num = 0;
    for (int i = 0; i != n; ++i){
        num *= 4;
        if (str[i] == 'C'){
            num += 1;
        }else if (str[i] == 'G'){
            num += 2;
        }else if (str[i] == 'T'){
            num += 3;
        }
    }
    num += ((1 << (2*n)) - 4) / 3;
    return num;
}


int main()
{
    ios::sync_with_stdio(false);
    memset(dict, false, DictSize);
    int n = 0;
    cin >> n;
    char command[7];
    char str[13];
    for (int i = 0; i != n; ++i){
        cin >> command >> str;
        if (command[0] == 'i'){
            dict[myhash(str)] = true;
        }else if(dict[myhash(str)]){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 25072
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		double sum = 0;
		for(int i = 0; i < N; i++) {
			double num = sc.nextDouble();
			sum += 1 / num;
		}

		System.out.println(1 / sum);
	}

}


Measured memory_bytes: 38140
n = int(input())
a = list(map(int, input().split()))
cnt = []
over = 0
for i in range(n):
    m = a[i] // 400
    if m < 8:
        if m not in cnt:
            cnt.append(m)
    else:
        over += 1
if len(cnt) > 0:
    print(len(cnt), len(cnt)+over)
else:
    print(1, len(cnt)+over)


Measured memory_bytes: 9036
#n=int(input())
h,n=map(int,input().split())
#a=list(map(int,input().split()))
l=[list(map(int,input().split())) for i in range(n)]
#l=[list(input().split()) for i in range(n)]

amax=0
for i in range(n):
    if amax<l[i][0]:
        amax=l[i][0]
        
ldp=[[0 for j in range(h+amax)]for i in range(n)]
for i in range(n):
    for j in range(h+amax):
        if i==0:
            ldp[i][j]=-(-(j+1)//l[i][0])*l[i][1]
        else:
            if j>=l[i][0]:
                ldp[i][j]=min(ldp[i-1][j],ldp[i][j-l[i][0]]+l[i][1])
            else:
                ldp[i][j]=min(ldp[i-1][j],l[i][1])
print(min(ldp[-1][h-1:]))

Measured memory_bytes: 134280
from collections import defaultdict

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


def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table

pr = prime_decomposition(M)
di = defaultdict(int)
for p in pr:
    di[p] += 1
def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y


# mを法とするaの乗法的逆元
def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

def combination(n, mod):
    lst = [1]
    for i in range(1, n+1):
        lst.append(lst[-1] * (n+1-i) % mod * modinv(i, mod) % mod)
    return lst
mod = 10**9+7
ans = 1
for k, v in di.items():
    ans *= combination(v+N-1, mod)[N-1]
    ans %= mod
print(ans)


Measured memory_bytes: 125608
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		StringBuilder sbP = new StringBuilder();
		StringBuilder sbQ = new StringBuilder();
		for(int i = 0; i < n; i++){
		    sbP.append(sc.nextInt());
		}
		for(int i = 0; i < n; i++){
		    sbQ.append(sc.nextInt());
		}
		String p = sbP.toString();
		String q = sbQ.toString();
		
		// 計算
		int result = 0;
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < n; i++){
		    sb.append(i+1);
		}
		String s = sb.toString();
		//System.out.println(s);
		Permutation perm = new Permutation(s);
		int a = perm.list.indexOf(p) + 1;
		int b = perm.list.indexOf(q) + 1;
		result = abs(a - b);
		
		//System.out.println(perm.list);
		
		// 出力
		System.out.println(result);
	}
}

class Permutation {
    int n;
    String s;
    ArrayList<String> list;
    
    public Permutation(String s){
        this.n = s.length();
        this.s = s;
        
        boolean[] used = new boolean[n];
        ArrayList<String> list = new ArrayList<String>();
        dfs("", used, list);
        this.list = list;
    }
    
    private void dfs(String s, boolean[] used, ArrayList<String> list){
        if(s.length() == used.length){
            list.add(s);
            return;
        }
        for(int i = 0; i < used.length; i++){
            if(used[i]) continue;
            used[i] = true;
            dfs(s + this.s.charAt(i), used, list);
            used[i] = false;
        }
    }
}




Measured memory_bytes: 40808
#include <iostream>                                  
#include <cmath>                                     
using namespace std;                                 
                                                     
int main() {                                         
  int x;                                             
  cin >> x;                                          
  int XCubic = pow(x,3);                             
  cout << XCubic << endl;                            
  return 0;                                          
}                        

Measured memory_bytes: 3256
#include <cstdio>
#include <algorithm>

using namespace std;

int main(void)
{
	int a, b, c;
	int t1, t2, t3, t4;
	
	t1 = t2 = t3 = t4 = 0;
	
	while (scanf("%d %d %d", &a, &b, &c) != EOF){
		if (a < b){
            swap(a, b);
        }
        if (a < c){
            swap(a, c);
        }
        if (b < c){
            swap(b, c);
        }
		
		if (a >= b + c){
            break;
        }
		if (a * a == b * b + c * c){
			t1++;
			t2++;
		}
		else if (a * a < b * b + c * c){
            t1++;
			t3++;
		}
		else {
			t1++;
			t4++;
		}
	}
	
	printf("%d %d %d %d\n", t1, t2, t3, t4);
	
	return (0);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rt "\n"
#define sp " "
#define test(n) cout << "test" << n << endl;
#define fixsp(n) fixed << setprecision(n)
#define defsp(n) defaultfloat << setprecision(n)
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
#define iikae auto&
#define vector3D(K, N, M, DP) vector<vector<vector<ll>>> DP(K, vector<vector<ll>>(N, vector<ll>(M)));
#define vector4D(K, N, M, O, DP) vector<vector<vector<vector<ll>>>> DP(K, vector<vector<vector<ll>>>(N, vector<vector<ll>>(M, vector<ll>(O))));
#define zenbu(a) a.begin(), a.end()
#define rzenbu(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long;using ld = long double;using P = pair<ll,ll>;
template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}
template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};
template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}
struct phash{inline size_t operator()(const pair<ll,ll> & p) const{const auto h1 = hash<ll>()(p.first);const auto h2 = hash<ll>()(p.second);return h1 ^ (h2 << 1);}};

/* ここからコード開始 */

vector<vector<ll>> A;
ll H, W, ans{};

void saiki(set<P> hw,ll kyori){
  ans = kyori;
  set<P> hw2;
  for(auto&& i : hw){
    iikae h = i.first;
    iikae w = i.second;
    if(h+1 < H) A[h+1][w] = min(kyori+1, A[h+1][w]);
    if(h > 0) A[h-1][w] = min(kyori+1, A[h-1][w]);
    if(w+1 < W) A[h][w+1] = min(kyori+1, A[h][w+1]);
    if(w > 0) A[h][w-1] = min(kyori+1, A[h][w-1]);
    if(h+1 < H && A[h+1][w] == kyori+1) hw2.insert(P(h+1, w));
    if(h > 0 && A[h-1][w] == kyori+1) hw2.insert(P(h-1, w));
    if(w+1 < W && A[h][w+1] == kyori+1) hw2.insert(P(h, w+1));
    if(w > 0 && A[h][w-1] == kyori+1) hw2.insert(P(h, w-1));
  }
  if(1-hw2.empty()) saiki(hw2, kyori+1);
}

int main(){
  kyopro;
  cin >> H >> W;
  char a;
  A.assign(H, vector<ll>(W,MOD));
  set<P> start;
  rep(i, 0, H) rep(j, 0, W){
    cin >> a;
    if(a == '#') start.insert(P(i, j));
  }
  for(auto&& i : start){
    A[i.first][i.second] = 0;
  }
  saiki(start, 0);
  cout << ans << rt;
}

Measured memory_bytes: 133376
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define rep3(i, x, n) for(int i = x; i > n; i--)
const long long MOD = 1e9+7;
const long long INF = 1e15;
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    string S;
    cin >> S;
    int N = S.size();
    int i = 0;
    vector<ll> vec;
    while(i < N){
        int j = 1;
        while(i+j < N && S[i] == S[i+j]){
            j++;
        }
        if(S[i] == '<') vec.push_back(j);
        else  vec.push_back(-j);
        i += j;
    }
    ll n = vec.size();
    ll sum = 0;
    rep(i, n){
        if(vec[i] > 0) sum += vec[i]*(vec[i]-1)/2;
        else sum += vec[i]*(vec[i]+1)/2;
    }
    rep(i, n-1){
        if(vec[i] > 0 && vec[i+1] < 0) sum += max(vec[i], -vec[i+1]);
    }
    if(vec[0] < 0) sum += -vec[0];
    if(vec[n-1] > 0) sum += vec[n-1];
    cout << sum << endl;
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int K;
  cin >> K;
  int cnt = 0;
  while (A >= B) B *= 2, cnt++;
  while (B >= C) C *= 2, cnt++;
  cout << ((cnt <= K) ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 3616
#include <iostream>

using namespace std;

typedef long long ll;
#define M 1000000007

ll pot(ll a, ll b) {
    if (b == 0) return 1;
    ll u = pot(a,b/2);
    u = u*u;
    u %= M;
    if (b%2 == 1) u *= a;
    u %= M;
    return u;
}

ll inv(ll x) {
    return pot(x,M-2);
}

ll f[202020];

ll ncr(ll a, ll b) {
    if (b > a) return 0;
    ll u = 1;
    u *= f[a];
    u %= M;
    u *= inv(f[b]);
    u %= M;
    u *= inv(f[a-b]);
    u %= M;
    return u;
}

ll matka(ll a, ll b) {
    return ncr(a+b-2,a-1);
}

ll h, w, a, b;

int main() {
    f[0] = 1;
    for (int i = 1; i <= 202000; i++) {
        f[i] = (f[i-1]*i)%M;
    }
    cin >> h >> w >> a >> b;
    ll u = matka(h,w);
    for (int i = 1; i <= b; i++) {
        ll x = matka(i,h-a)*matka(w-i+1,a);
        x %= M;
        u -= x;
        u %= M;
        if (u < 0) u += M;
        u %= M;
    }
    cout << u << "\n";
}

Measured memory_bytes: 1792
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    string s;
    cin>>s;
    ll cnt=0;
    ll ans=0;
    int n=s.length();
    for(int i=n-1;i>0;i--)
    {
        if(s[i]=='A')
        {
            ans+=cnt;
        }
        else if(s[i]=='B')
        {
            cnt=0;
        }
        else
        {
            if(s[i-1]=='B')
            {
                i--;
                cnt++;
            }
            else
                cnt=0;
        }
    }
    if(s[0]=='A')
        ans+=cnt;
    cout<<ans<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 12496
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll INF=4e18;
ll nodeno[30][30];
vector<ll> adj_list[30*30];
bool visited[30*30];
ll level[30*30];
void assign_nodeno(ll h,ll w)
{
	ll k=1;
	for(ll i=0;i<h;i++)
	{
		for(ll j=0;j<w;j++)
		{
			nodeno[i][j]=k;
			k++;
		}
	}
}
void bfs(ll s)
{
	visited[s]=true;
	queue<ll> q;
	q.push(s);
	level[s]=0;
	while(!q.empty())
	{
		ll x=q.front();
		q.pop();
		for(auto it:adj_list[x])
		{
			if(!visited[it])
			{
				level[it]=level[x]+1;
				visited[it]=true;
				q.push(it);
			}
		}
	}
}
void solve()
{
	ll h,w;
	cin>>h>>w;
	assign_nodeno(h,w);
	for(ll i=1;i<=h*w;i++)
	{
		level[i]=0;
		visited[i]=false;
	}
	char g[30][30]; 
	for(ll i=0;i<h;i++)
	{
		for(ll j=0;j<w;j++)
		{
			cin>>g[i][j];
		}
	}
	for(ll i=0;i<h;i++)
	{
		for(ll j=0;j<w;j++)
		{
			if(i!=0)
			{
				if(g[i-1][j]!='#')
					adj_list[nodeno[i][j]].push_back(nodeno[i-1][j]);
			}
			if(i!=h-1)
			{
				if(g[i+1][j]!='#')
					adj_list[nodeno[i][j]].push_back(nodeno[i+1][j]);
			}
			if(j!=0)
			{
				if(g[i][j-1]!='#')
					adj_list[nodeno[i][j]].push_back(nodeno[i][j-1]);
			}
			if(j!=w-1)
			{
				if(g[i][j+1]!='#')
					adj_list[nodeno[i][j]].push_back(nodeno[i][j+1]);
			}
		}
	}
	ll ans=0;
	for(ll p=0;p<h;p++)
	{
		for(ll q=0;q<w;q++)
		{	
			if(g[p][q]!='#')
			{
				bfs(nodeno[p][q]);
				for(ll j=1;j<=h*w;j++)
				{
					ans=max(ans,level[j]);
				}
				for(ll j=1;j<=h*w;j++)
				{
					level[j]=0;
					visited[j]=false;
				}
			}
		}
	}
	cout<<ans<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T=1,p=0;
	//cin>>T;
	do
	{
		solve();
		p++;
	}while(p<T);
	return 0;
}



Measured memory_bytes: 256
// input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// body
fn main() {
    input! {
        n: usize,
        waters: [isize; n]
    }
    let mut answers = vec![0; n];
    let sum = waters.iter().fold(0, |sum, a| sum + a);
    let mut temp = 0;
    let mut previous = 0;
    for i in 1..n {
        previous = 2 * waters[i - 1] - previous;
        temp += previous;
    }
    answers[0] = sum - temp;
    print!("{} ", answers[0]);
    for i in 1..n {
        answers[i] = waters[i - 1] * 2 - answers[i - 1];
        print!("{} ", answers[i]);
    }
}


Measured memory_bytes: 7420
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10


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

	for (int i = 1; i <= 9; i++) {
		if (N%i == 0 && N/i >= 1 && N/i <= 9) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;


	return 0;
}


Measured memory_bytes: 256
<?php
$n = fgets(STDIN);
$input = rtrim(fgets(STDIN));
$omori = explode(' ', $input);

$g1 = 0;    //前半(group1)の重さ
$g2 = array_sum($omori);    //後半(group2)の重さ
$ans = 9999;    //解答（絶対値の最小値）
$sa = 0;

for($i=0; $i<$n; $i++) {
    $g1 += $omori[$i];
    $g2 -= $omori[$i];
    
    $sa = abs($g1 - $g2);
    
    if($sa < $ans) {
        $ans = $sa;
    }
}

echo $ans;
?>

Measured memory_bytes: 4604
#include<stdio.h>
int main()
{
	int sort[100]={0};
	int n,i,j,k,a=0,count=0;
	
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&sort[i]);
	}
	
	for(i=0;i<n;i++)
	{
		for(j=n-1;j>=0;j--)
		{
			if(sort[j-1]>sort[j])
			{
				a=sort[j-1];
				sort[j-1]=sort[j];
				sort[j]=a;
				count++;
			}
		}
	}
	for(i=0;i<n;i++)
	{
		printf("%d",sort[i]);
		if(i<n-1)
		{
			printf(" ");
		}
	}
	printf("\n");
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 604
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N){
    cin >> A.at(i);
  }
  bool up = false;
  bool unk = true;
  int cnt = 0;
  rep(i, N-1){
    if(unk){
      if(A.at(i) < A.at(i+1)){
        unk = false;
        up = true;
      }
      else if(A.at(i) > A.at(i+1)){
        unk = false;
        up = false;
      }
    }
    else if(up){
      if(A.at(i) > A.at(i+1)){
        unk = true;
        cnt++;
      }
    }
    else{
      if(A.at(i) < A.at(i+1)){
        unk = true;
        cnt++;
      }
    }
  }
  cout << cnt+1 << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define lson (o<<1)
#define rson (o<<1|1)
#define fi first
#define sc second
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
using namespace std;
const double pi=acos(-1);
const double eps=1e-6;
inline int lowbit(int x){return x&(-x);}
inline int read(){
	int f=1,x=0;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return f*x;
}
template<typename T> inline T max(T x,T y,T z){return max(max(x,y),z);}
template<typename T> inline T min(T x,T y,T z){return min(min(x,y),z);}
template<typename T> inline T sqr(T x){return x*x;}
template<typename T> inline void checkmax(T &x,T y){x=max(x,y);}
template<typename T> inline void checkmin(T &x,T y){x=min(x,y);}
template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}
template<typename A,typename B,typename C> inline A fpow(A x,B p,C yql){
	A ans=1;
	for(;p;p>>=1,x=1LL*x*x%yql)if(p&1)ans=1LL*x*ans%yql;
	return ans;
}
struct FastIO{
	static const int S=1310720;
	int wpos;char wbuf[S];
	FastIO():wpos(0){}
	inline int xchar(){
		static char buf[S];
		static int len=0,pos=0;
		if(pos==len)pos=0,len=fread(buf,1,S,stdin);
		if(pos==len)return -1;
		return buf[pos++];
	}
	inline int read(){
		int c=xchar(),x=0;
		while(c<=32&&~c)c=xchar();
		if(c==-1)return -1;
		for(;'0'<=c&&c<='9';c=xchar())x=x*10+c-'0';
		return x;
	}
}io;
//#define read io.read
int n,m,cnt;
int f[100001];
int find(int x)
{
	if(x==f[x]) return x;
	else return f[x]=find(f[x]);
}
int main()
{
//	freopen("","r",stdin);
//	freopen("","w",stdout);
	cin >> n >> m;
	for(int i=1;i<=n;i++) f[i]=i;
	while(m--)
	{
		int x,y,z;
		cin >> x >> y >> z;
		int fx=find(x);
		int fy=find(y);
		if(fx!=fy)
		{
			f[fx]=fy;
			cnt++;
		}
	}
	cout << n-cnt;
	return 0;
}


Measured memory_bytes: 640
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it, len;
	fastio() {it=len=0;}
	inline char get()
	{
		if (it<len) return s[it++]; it=0;
		len=fread(s, 1, 100000, stdin);
		if (len==0) return EOF; else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while (c==' '||c=='\n') c=get();
		if (it>0) it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0; bool ng=0; char c; c=_buff.get();
	while (c!='-'&&(c<'0'||c>'9')) c=_buff.get();
	if (c=='-') ng=1, c=_buff.get();
	while (c>='0'&&c<='9') r=r*10+c-'0', c=_buff.get();
	return ng?-r:r;
}
template <class T> inline void putnum(T x)
{
	if (x<0) putchar('-'), x=-x;
	register short a[20]={}, sz=0;
	while (x) a[sz++]=x%10, x/=10;
	if(sz==0) putchar('0');
	for (int i=sz-1; i>=0; i--) putchar('0'+a[i]);
}
inline char getreal() {char c=_buff.get(); while (c<=32) c=_buff.get(); return c;}
ll qpow(ll x, ll k) {return k==0? 1: 1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
const int maxn = 100111;
int n;
ll X[maxn], P[maxn], S;
struct movement
{
	ll pos, ans;
	movement move(ll x)
	{
		movement ret;
		ret.ans = ans+abs(x-pos);
		ret.pos = x;
		return ret;
	}
};
movement solve(int l, int r, ll dl, ll dr)
{
	if (S<=X[l]) return movement({X[r], X[r]-S});
	if (X[r]<=S) return movement({X[l], S-X[l]});
	if (P[l]+dl<P[r]+dr)
	{
		return solve(l+1, r, 0, dl+dr+P[l]).move(X[l]);
	}
	else
	{
		return solve(l, r-1, dl+dr+P[r], 0).move(X[r]);
	}
}
int main()
{
	getii(n, S);
	for (int i=1; i<=n; i++) getii(X[i], P[i]);
	cout<<solve(1, n, 0, 0).ans<<endl;
	return 0;
}


Measured memory_bytes: 4480
H,W = map(int,input().split())
if H%3==0 or W%3==0:
    print(0)
    exit()

ans = min(H,W)

for _ in range(2):
    for i in range(1,W):
        a = H*i
        m = H//2
        b = m*(W-i)
        c = (H-m)*(W-i)
        mx = max(a,b,c)
        mn = min(a,b,c)
        ans = min(ans, mx-mn)
    H,W = W,H
print(ans)

Measured memory_bytes: 3064
from collections import deque
n = input()
G = [[] for i in xrange(n)]
for i in xrange(n-1):
    s, t, w = map(int, raw_input().split())
    G[s].append((t, w))
    G[t].append((s, w))

deq = deque()
def max_dist(dist):
    return dist.items()[dist.values().index(max(dist.values()))]

def bfs(s):
    dist = {s: 0}
    deq.append(s)
    while deq:
        s = deq.popleft()
        for t, w in G[s]:
            if t in dist:
                continue
            dist[t] = dist[s] + w
            deq.append(t)
    return dist

u, co = max_dist(bfs(0))
v, co = max_dist(bfs(u))

dist1 = bfs(u); dist2 = bfs(v)
for i in xrange(n):
    print max(dist1[i], dist2[i])

Measured memory_bytes: 12452
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) { os << p.first << " " << p.second; return os; }

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; }return false; }
template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N, M; cin >> N >> M;
	cout << max({ 2 * N-1,N + M,2 * M-1 }) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1000000007;

void solve() {
  int k, x;
  cin >> k >> x;
  if (k * 500 >= x) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

Measured memory_bytes: 256