akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
inline void ChMax(int& a, int b){ a = max(a, b); }

const int dy[] = {-1, 0, 0, 1}, dx[] = {0, -1, 1, 0};
const int bitMask = (1 << 12) - 1;
int H, W, K;
char S[50][50];
int dp[50][50][1 << 12];
bool Visited[1 << 12];



int main()
{
  memset(dp, -1, sizeof(dp));
  for (int i = 0; i < (1 << 12); i++) {
    int nx = 0, ny = 0, bit = i;
    for(int j = 0; j < 6; j++, bit >>= 2) {
      nx -= dx[bit & 3], ny -= dy[bit & 3];
      if (nx == 0 && ny == 0) Visited[i] = true;
    }
  }

  cin >> H >> W >> K;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> S[i][j];
    }
  }

  dp[0][0][bitMask] = 0;

  for(int m = K; m >= 0; m--) {
    int notnext = m == 0;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        for (int k = 0; k < (1 << 12); k++) {
          if (dp[i][j][k] == -1) continue;
          int Get = 0;
          if (isdigit(S[i][j]) && !Visited[k]) Get += S[i][j] - '0';
          for (int l = notnext << 1; l < 4; l++) {
            int ny = i + dy[l], nx = j + dx[l];
            if (ny < 0 || nx < 0 || ny >= H || nx >= W) continue;
            if (S[ny][nx] == '#')                       continue;
            ChMax(dp[ny][nx][((k << 2) | l) & bitMask], dp[i][j][k] + Get);
          }
        }
      }
    }
  }
  cout << *max_element(dp[H - 1][W - 1], dp[H - 1][W]) << endl;
}

Measured memory_bytes: 41172
#include<iostream>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
int a[100005][5],dp[100005][5];
int main()
{
    ll n,i,j,k,ans=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
    	for(j=1;j<=3;j++)
    	cin>>a[i][j];
	}
	dp[1][1]=a[1][1];
	dp[1][2]=a[1][2];
	dp[1][3]=a[1][3];
	for(i=2;i<=n;i++)
	{
		for(j=1;j<=3;j++)
		{
			ll mi=0,x;
			for(k=1;k<=3;k++)
			{
				if(k!=j)
				{
					x=dp[i-1][k]+a[i][j];
					mi=mi>x?mi:x;
				}
			}
			dp[i][j]=mi;
		}
	}
	ans=dp[n][1]>dp[n][2]?dp[n][1]:dp[n][2];
	ans=ans>dp[n][3]?ans:dp[n][3];
	cout<<ans;
	return 0;
}


Measured memory_bytes: 7448
<?php
list($S)=sscanf(trim(fgets(STDIN)),"%s");
$h = (int)(strlen($S)/2);
$a = substr($S,0,$h);
$b = strrev(substr($S,$h*-1));
$cnt = 0;
for($i=0;$i<$h;$i++){
    if($a[$i] != $b[$i]){
        $cnt++;
    }
}
printf($cnt);

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

using namespace std;

int main() {

  int num = 0;
  int max_num = 0;
  int n;
  int A[100000];

  int even = 0;
  int odd = 0;

  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> A[i];
    if (A[i] % 2 == 0) ++even;
    else ++odd;
        
  }

  if (odd % 2 == 0 && (even + odd / 2) % 2 == 0) cout << "YES" << endl;
  else {
    even = even + odd / 2;
    odd = odd - (odd / 2) * 2;
    even = even - (even / 2) * 2;
  
    if (odd + even == 1) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;  
}


Measured memory_bytes: 640
#include<cstdio>
#include<cmath>
int main() {
	int a, b, c;
	scanf("%d%d", &a, &b);
	int tmp = b;
	while( tmp ) {
		tmp /= 10;
		a *= 10;
	}
	c = a + b;
	int s1 = sqrt(c);
	double s2 = sqrt(c);
	if( (double)s1==s2 ) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
n,m = map(int,input().split())
h = list(map(int,input().split()))
g = [[] for _ in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    g[a-1].append(h[b-1])
    g[b-1].append(h[a-1])
ans = 0
for i in range(n):
    if g[i] == []:
        ans += 1
        continue
    if max(g[i])<h[i]:
        ans += 1
print(ans)

Measured memory_bytes: 92728
#include<bits/stdc++.h>
#include <chrono>
using namespace std::chrono;
using namespace std;
#define fr(x,i,n) for(int x = i; x < n; ++x)
#define fb(x,i,n) for(int x = i; x >= n; --x)
#define pr pair<int,int>
#define ll long long int
const ll mod=1e9+7;
/*    auto start = high_resolution_clock::now();
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
    cout << "\nduration="<<duration.cnt()/1e6 << endl;
*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    ll pre[n+1];
    pre[0]=0;
    fr(i,1,n+1){
        pre[i]=i+pre[i-1];
    }
    ll suf[n+1];
    suf[n]=n;
    fb(i,n-1,0)
    suf[i]=i+suf[i+1];
    ll ans=0;
    fr(i,k,n+2){
        ans=((ans+suf[n-i+1]-pre[i-1]+1)%mod+mod)%mod;
    }
    cout<<ans;
}


Measured memory_bytes: 6776
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static int flg;

    public static void main(String[] args) {
        while (true) {
            // ???????????°?????\???
            int N = sc.nextInt();
            // 0??????????????????
            if (N == 0)
                break;
            List<Integer> x = new ArrayList<Integer>(N);
            List<Integer> y = new ArrayList<Integer>(N);

            // ??????????????§??????????????????
            for (int i = 0; i < N; i++) {
                int tmpx=sc.nextInt();
                int tmpy=sc.nextInt();
            	x.add(tmpx);
                y.add(tmpy);
            }
            // ??????????????°
            int M = sc.nextInt();
            // ??????????????? ????????°??¨???????????´??????????????????
            susumu(M, x, y);
            // ?????????????????????
        }
    }

    static public void susumu(int M, List x, List y) {
        //???????????????????¨????
        Integer xnow = 10;
        Integer ynow = 10;
        for (int i = 0; i < M; i++) {
            // ????§???¨?????¢???????????£???
            String d = sc.next();
            int l = sc.nextInt();
            for (int j = 0; j < l; j++) {
                if (d.equals("N")){ynow++;}
                if (d.equals("S")){ynow--;}
                if (d.equals("E")){xnow++;}
                if (d.equals("W")){xnow--;}
                for (int k = 0; k < x.size(); k++) {
                    if (xnow == x.get(k) && ynow == y.get(k)) {
                        x.remove(k);
                        y.remove(k);
                    }
                }
            }
        }
        if(x.size()==0){
            System.out.println("Yes");
        }else{System.out.println("No");}
    }
}

Measured memory_bytes: 43292
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k, c; cin >> n >> k >> c;
  string s; cin >> s;
  vector<int> dpl(n), dpr(n);
  rep(i, n) {
    if(i+1<n) dpl[i+1] = max(dpl[i], dpl[i+1]);
    if(s[i]=='o'&&i+c+1<n) dpl[i+c+1] = max(dpl[i]+1, dpl[i+c+1]);
  }
  rrep(i, n) {
    if(i-1>=0) dpr[i-1] = max(dpr[i], dpr[i-1]);
    if(s[i]=='o' && i-(c+1)>=0) dpr[i-(c+1)] = max(dpr[i]+1, dpr[i-(c+1)]);
  }
  map<pair<int, int>, int> cnt;
  rep(i, n) if(s[i]=='o' && dpl[i]+dpr[i]==k-1) cnt[{dpl[i], dpr[i]}]++;
  rep(i, n) {
    if(s[i]=='o' && dpl[i]+dpr[i]==k-1 && cnt[{dpl[i], dpr[i]}]==1) {
      cout << i+1 << "\n";
    }
  }
  return 0;
}


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

int main() 
{
    int n;
    cin >> n;
    int a[n];

    int sign = 1;
    int minv = 1000000000 + 1;
    rep(i,n) { 
        cin >> a[i];
        if(a[i] != 0) sign *= (a[i]/abs(a[i]));
        minv = min(minv, abs(a[i]));
    }

    ll ans = 0;
    rep(i,n) ans += abs(a[i]);
    if (sign == -1) ans -= 2*minv;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main()
{
	int a, b, c;
	int i;
	int count;

	count = 0;
	
	scanf("%d %d %d", &a, &b, &c);

	for(i = a; i <= b; ++i)
	{
		if(c % i == 0)
			count++;
	}
	printf("%d\n", count);
	
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll INF = 1000000000000000000LL;
using namespace std;


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

    vector <int> a(N,0);
    vector <int> zan(N,1);
    a[0] = 1;
    REP(i,M)
    {
        int x,y;
        cin >> x >> y;
        --x;--y;
        a[y] = a[x] | a[y];
        zan[x]--;
        zan[y]++;
        if(zan[x] == 0)a[x] = 0;
    }
    int res = 0;
    REP(i,N)
    {
        if(a[i])
        {
            ++res;
        }
    }

    cout << res << endl;

    return 0;
}



Measured memory_bytes: 1024
import bisect
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
A_cumulative_sum = [0]
B_cumulative_sum = [B[0]]
for i in range(N):
    A_cumulative_sum.append(A[i] + A_cumulative_sum[i])
for i in range(1, M):
    B_cumulative_sum.append(B[i] + B_cumulative_sum[i - 1])

for i in range(N + 1):
    if K < A_cumulative_sum[i]:
        remaining_time = K
        idx = bisect.bisect_right(B_cumulative_sum, remaining_time)
        ans = max(ans, idx)
        break
    else:
        remaining_time = K - A_cumulative_sum[i]
        idx = bisect.bisect_right(B_cumulative_sum, remaining_time)
        ans = max(ans, i + idx)
print(ans)

# 113897

Measured memory_bytes: 132824
#include <stdio.h>

int main(void)
{
	int m[51], f[51], r[51], count, count_2;

	count = 0;
	m[count] = 0;
	f[count] = 0;
	r[count] = 0;

	while (count < 51)
	{
		scanf("%d %d %d", &m[count], &f[count], &r[count]);

		if ((m[count] == -1) && (f[count] == -1) && (r[count] == -1))
			break;

		count++;
	}

	for (count_2 = 0; count_2 < count; count_2++)
	{
		if ((m[count_2] == -1) || (f[count_2] == -1))
		{
			printf("F\n");
		}

		if (((m[count_2] + f[count_2]) >= 80) && ((m[count_2] != -1) && (f[count_2] != -1)))
		{
			printf("A\n");
		}

		if ((((m[count_2] + f[count_2]) < 80) && ((m[count_2] + f[count_2]) >= 65)) && ((m[count_2] != -1) && (f[count_2] != -1)))
		{
			printf("B\n");
		}

		if ((((m[count_2] + f[count_2]) < 65) && ((m[count_2] + f[count_2]) >= 50)) && ((m[count_2] != -1) && (f[count_2] != -1)))
		{
			printf("C\n");
		}

		if ((((m[count_2] + f[count_2]) < 50) && (((m[count_2] + f[count_2]) >= 30)) && (r[count_2] >= 50)) && ((m[count_2] != -1) && (f[count_2] != -1)))
		{
			printf("C\n");
		}

		if ((((m[count_2] + f[count_2]) < 50) && (((m[count_2] + f[count_2]) >= 30)) && (r[count_2] < 50)) && ((m[count_2] != -1) && (f[count_2] != -1)))
		{
			printf("D\n");
		}

		if (((m[count_2] + f[count_2]) < 30) && ((m[count_2] != -1) && (f[count_2] != -1)))
		{
			printf("F\n");
		}
	}

	return 0;
}


Measured memory_bytes: 2032
N = int(input())
array = []
for _ in range(N):
  array.append(input())
AC = 0
WA = 0
TLE = 0
RE = 0
for test in array:
  if 'AC' == test:
    AC += 1
  elif 'WA' == test:
    WA += 1
  elif 'TLE' == test:
    TLE += 1
  elif 'RE' == test:
    RE += 1
print(f'AC x {AC}')
print(f'WA x {WA}')
print(f'TLE x {TLE}')
print(f'RE x {RE}')

Measured memory_bytes: 16324
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);
void prime_map(map<ll, ll> &, ll);

struct ch {
    ll f;
    ll a, b;
};

int main() {
    // source
    int h, w;
    cin >> h >> w;
    if (h % 3 == 0 || w % 3 == 0) {
        cout << 0 << endl;
        return 0;
    }

    vector<ch> v;

    rep(i, 2) {
        ch temp;
        ll h_temp = h / 3 + i;
        temp.f = h_temp * w;
        temp.a = h - h_temp;
        temp.b = w;
        if (temp.f != 0 && temp.a * temp.b != 0)
            v.push_back(temp);
    }

    rep(i, 2) {
        ch temp;
        ll w_temp = w / 3 + i;
        temp.f = h * w_temp;
        temp.a = h;
        temp.b = w - w_temp;
        if (temp.f != 0 && temp.a * temp.b != 0)
            v.push_back(temp);
    }

    int index = 0;
    ll result = pow(10, 9);
    rep(i, v.size()) {
        ll ans[3];
        ans[0] = v[i].f;

        if (v[i].a % 2 == 0 || v[i].b % 2 == 0) {
            ans[1] = v[i].a * v[i].b / 2;
            ans[2] = ans[1];
        } else {
            ll big = max(v[i].a, v[i].b);
            ll small = min(v[i].a, v[i].b);
            ans[1] = small * (big / 2);
            ans[2] = small * (big / 2 + 1);
        }

        sort(ans, ans + 3);

        result = min(result, ans[2] - ans[0]);
    }

    // cout << v[index].f << " " << v[index].a << " " << v[index].b << endl;

    cout << result << endl;
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 256
N = int(input())

v = []
for i in range(N):
  A = int(input())
  l = []
  for j in range(A):
    x, y = map(int, input().split())
    l.append((x, y))
  v.append(l)

ans = 0
l = []
for i in range(2**N):
  l.append([(i >> j) & 1 for j in range(N)])
  
for a in l:
  for i in range(N):
    if a[i] == 0:
      continue
    
    for b in v[i]:
      if a[b[0]-1] != b[1]:
        break
    else:
      continue
    break
  else:
    ans = max(ans, sum(a))
      
print(ans)

Measured memory_bytes: 9972
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <numeric>
#include <map>
#define REP(i, N) for(int i=0; i<N; i++)
using namespace std;

int gcd(int a, int b) {
	return b ? gcd(b, a % b) : a;
}

int main() {
	int N, A, B;

	cin >> N >> A >> B;

	cout << min(N * A, B) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

class union_find{
    int n_; 
    vector<int> par, rank, size;
    public:
    union_find(int n): n_{n} {
        par.resize(n_);
        rank.resize(n_);
        size.resize(n_);

        REP(i, n_){
            par[i] = i;
            rank[i] = 1;
            size[i] = 1;
        }
    } 

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);

        if(x == y) return;

        if(rank[x] > rank[y]){
            par[y] = x;
            size[x] += size[y];
        } else {
            par[x] = y;
            size[y] += size[x];
            if(rank[x] == rank[y]) rank[y]++;
        }
    }

    int find(int x) {
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }
};

int main() {
    int n, m; cin >> n >> m;
    vector<int> p(n);
    union_find uf(n);

    REP(i, n){
        cin >> p[i];
        --p[i];
    }

    REP(i, m) {
        int x, y; cin >> x >> y;
        --x; --y;
        uf.unite(x, y);
    }

    int ans = 0;
    
    REP(i, n) {
        if (uf.same(i, p[i])) ans++;
    }

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


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,s;
bool check(ll x){
	if(n/x>=x)return 0;
	if(x<2)return 0;
	ll k=n/x;ll r=n%x;
	if(s==k+r)return 1;
	return 0;
}
ll js(ll x,ll b){
	ll ans=0;
	while(x){
		ans+=x%b;
		x/=b;
	}
	return ans;
}
int main()
{
	//freopen("H:\\c++1\\in.txt","r",stdin);
	//freopen("H:\\c++1\\out.txt","w",stdout);
	cin>>n>>s;
	ll b=1e18;
	if(n==s)b=n+1;
	if(n>s){
		ll temp=n-s;
		for(ll t=1;t<=sqrt(temp);t++){
			if(temp%t==0){
				ll x=t+1,y=temp/t+1;
				if(check(x))b=min(b,x);
				if(check(y))b=min(b,y);
			}
		}
	}
	for(ll t=2;t<=1000000;t++){
		ll cnt=js(n,t);
		if(cnt==s){
			b=min(b,t);
			break;
		}
	}
	if(b==1e18)printf("-1\n");
	else printf("%lld\n",b);
	return 0;
}

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

bool all_of(string s) {
    auto first = s.cbegin();
    auto last = s.cend();
  for ( ; first != last; ++first)
    if (!bool(isdigit(*first))) return false;
  return true;
}

int main(void){
    int A, B;
    string S;
    
    cin >> A >> B;
    cin >> S;
    
    string stringA = S.substr(0, A);
    string f = S.substr(A, 1);
    string stringB = S.substr(A+1 , B);

    if (all_of(stringA) &&
        f == "-" &&
        all_of(stringB)){
            cout << "Yes" << endl;
        }
    else {
        cout << "No" << endl;
    }
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int x,a,b; cin >> x >> a >> b;
  cout << (abs(x-a) < abs(x-b) ? 'A' : 'B') << endl;
}


Measured memory_bytes: 3556
#include <vector>
#include <iostream>
#include <cmath>
using namespace std;

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

  int k;
  cin >> k;
  int arr[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
  cout << arr[k - 1] << endl;

}

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

int main(){
    int N, K;  cin >> N >> K;
    vector<int> h(N);
    for(int i=0; i<N; i++) cin >> h[i];

    sort(h.begin(), h.end());
    int ans = h[N-1];
    for(int i=0; i<N-K+1; i++){
        int dh = h[i+K-1] - h[i];
        if(dh < ans) ans = dh;
    }

    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int main () {
  string S;
  cin >> S;
  sort(all(S));
  cout << (S == "abc" ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int A = Integer.parseInt(st.nextToken());
         int B = Integer.parseInt(st.nextToken());
         for(int price=1; price <= 1000000; price++)
         {
            int c = (int)(1.0*price*0.08);
            int d = (int)(1.0*price*0.1);
            if(A == c && B == d)
            {
               System.out.println(price);
               return;
            }
         }
         System.out.println(-1);
      }
   }

Measured memory_bytes: 22740
#include<bits/stdc++.h>
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> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

llint mod_pow(llint x,llint n,llint md){
    llint res=1;
    while(n>0){
        if(n&1)(res*=x)%=md;
        (x*=x)%=md;
        n >>=1;
    }
    return res;
}

void solve(){
    llint n,m;
    cin >> m >> n;
    llint md=1e9+7;
    cout << mod_pow(m,n,md) << endl;
}

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



Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int n,a,b;
int h[100005];
inline bool check(long long times)
{
	long long tmp=times;
    for(int i=1;i<=n;i++)
    {
        long long blood=h[i]-b*times;
        if(blood>0)
        {
            long long cnt=blood/(a-b)+(blood%(a-b)==0?0:1);
            tmp-=cnt;
            if(tmp<0)
            {
            	return false;
			}
        }
    }
    return true;
}
int main()
{
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++)
	{
		cin>>h[i];
	}
	int lb=0,rb=1e9,mid;
	int ans=0;
	while(lb<=rb)
	{
		mid=(lb+rb)/2;
		if(check(mid))
		{
			ans=mid;
			rb=mid-1;
		}
		else
		{
			lb=mid+1;
		}
	}
	cout<<ans;
	return 0;
}

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

int main(){
  string s,t;
  cin >> s >> t;

  int ns = sz(s);
  int nt = sz(t);

  int ans = inf;

  rep(i,ns-nt+1){
    int cnt = 0;
    rep(j,nt){
      if(s[i+j] != t[j])  cnt++;
    }
    ans = min(ans, cnt);
  }

  cout << ans << endl;


}


Measured memory_bytes: 3572
#import <stdio.h>
int main(){
    int x[100] = {0};
    int n,m;
    scanf("%d %d",&n,&m);
    for (int i=0;i<m;i++) {
        int a,b;
        scanf("%d %d",&a,&b);
        x[a]++;
        x[b]++;
    }
    for(int i=1;i<=n;i++){
        printf("%d\n",x[i]);
    }
}


Measured memory_bytes: 2164
#include <cstdio>

using namespace std;

int main() {
    size_t n;
    scanf("%zu\n", &n);

    char suits[]="SHCD";
    int encode[256]={};
    for (size_t i=0; i<4; ++i)
        encode[suits[i]+0] = i;

    bool card[4][14]={};
    for (size_t i=0; i<n; ++i) {
        char suit;
        int rank_;
        scanf("%c %d\n", &suit, &rank_);
        card[encode[suit+0]][rank_] = true;
    }

    for (size_t i=0; i<4; ++i)
        for (size_t j=1; j<=13; ++j)
            if (!card[i][j])
                printf("%c %zu\n", suits[i], j);

    return 0;
}

Measured memory_bytes: 2680
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;


int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  while(cin >> n >> k && n && k) {
    VI c(n);
    REP(i, 0, n) cin >> c[i];
    if (k == 1) {
      cout << 0 << endl;
      continue;
    }
    int ma = 0;
    int mam = 0;
    REP(i, 0, n - k + 1) {
      int p = 1;
      REP(j, 0, k) p *= c[i + j];
      ma = max(ma, p);
    }
    REP(i, 0, n - k + 1) {
      int p = 0;
      REP(j, 0, n) {
        if (j < i || j >= i + k) p = max(p, c[j]);
      }
      int m = 1e8;
      REP(j, 0, k) {
        p *= c[i + j];
        m = min(m, c[i + j]);
      }
      mam = max(mam, p / m);
    }
    cout << max(0, mam - ma) << endl;
  }
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

unordered_map<ll, ll> memo;

ll f(ll n) {
  if (memo[n] != 0LL) return memo[0LL];
  if (n == 1LL) return 1LL;
  return memo[n] = 1LL + 2LL * f(n / 2LL);
}

int main() {
  ll H;
  cin >> H;

  cout << f(H) << endl;
  return 0;
}


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

using namespace std;

int main(){
    int x,y,s;
    while(cin >> x >> y >> s,x){
        int ans = 0;
        for(int i=1;i<=s;i++){
            for(int j=1;j<=s;j++){
                int sum = i*(100+x)/100 + j*(100+x)/100;
                if(sum == s){
                    ans = max(ans,i*(100+y)/100 + j*(100+y)/100);
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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


#include <bits/stdc++.h>
using namespace std;

typedef  long long ll;
class CMultiplication3 {
public:
    void solve(std::istream& cin, std::ostream& cout) {
		ios::sync_with_stdio(false);
        cin.tie(nullptr);


        ll a,b;
        cin >> a;
        string x;
        cin >> x;

        x.erase(x.find('.'),1);

        b = stol(x);
        //cout << x << endl;
        cout << (a * b) / 100 << endl;
	}
};


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


Measured memory_bytes: 3656
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <limits.h>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll A[300007],L[300007],R[300007];
map<ll,ll> ML,MR;

int main(){
  ll N;
  cin >> N;
  rep(i,3*N){
    cin >> A[i];
  }
  ll SUM=0;
  rep(i,2*N){
    ML[A[i]]++;
    SUM+=A[i];
    if(i>=N){
      ll minv=ML.begin()->first;
      SUM-=minv;
      ML[minv]--;
      if(ML[minv]==0){
        ML.erase(minv);
      }
    }
    L[i]=SUM;
  }
  SUM=0;
  rRep(i,3*N-1,N){
    MR[A[i]]++;
    SUM+=A[i];
    if(i<2*N){
      ll maxv=MR.rbegin()->first;
      MR[maxv]--;
      SUM-=maxv;
      if(MR[maxv]==0){
        MR.erase(maxv);
      }
    }
    R[i]=SUM;
  }
  ll ma=-LINF;
  Rep(i,N-1,2*N){
    //cout << i << endl;
    ma=max(ma,(L[i]-R[i+1]));
  }
  // rep(i,3*N){
  //   cout << L[i] << " ";
  // }
  // cout << endl;
  // rep(i,3*N){
  //   cout << R[i] << " ";
  // }
  // cout << endl;
  cout << ma << endl;
}

Measured memory_bytes: 21476
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int d[100010];
    rep(i, N) cin >> d[i];
    sort(d, d + N);
    cout << max(0, d[N / 2] - d[N / 2 - 1]) << endl;

    return 0;
}


Measured memory_bytes: 640
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
-- import Data.List
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Debug.Trace
-- trace _ = id

solve :: Int -> [Int] -> Int
solve bN as = cost
  where
  vA = VU.fromListN bN as
  acc = VU.scanl' (+) 0 vA

  enc (len,i) = len * bN + i
  size = bN*(bN+1)
  cost = buildVec VU.! (enc (bN,0))

  buildVec = VU.create $ do
    vec <- VUM.replicate size (-1)
    calc vec (bN,0)
    return vec
    where
      calc vec (1,_) = return 0
      calc vec (len,i) = do
        val <- VUM.read vec (enc (len,i))
        if val >= 0 then return val
          else do
          newVal <- top <$> mapM f [1 .. len-1]
          VUM.write vec (enc (len,i)) newVal
          return newVal
        where
          top lst = (minimum lst) + (acc VU.! (i+len)) - (acc VU.! i)
          f k = (+) <$> calc vec (k, i) <*> calc vec (len-k, i+k)

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Int
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_bN]:remLines1 = remLines0
      bN = readBInt bs_bN
      line2:remLines2 = remLines1
      as = map readBInt line2
  in solve bN as

outAnswer :: Int -> IO ()
outAnswer = putStrLn . show

main :: IO ()
main = outAnswer . tmain =<< B.getContents

-------------------------------------------------------------------------------

inp1 = "4\n10 20 30 40\n"
inp2 = "5\n10 10 10 10 10\n"
inp3 = "3\n1000000000 1000000000 1000000000\n"
inp4 = "6\n7 6 8 6 1 1\n"
tv1 = tmain $ B.pack inp1
tv2 = tmain $ B.pack inp2
tv3 = tmain $ B.pack inp3
tv4 = tmain $ B.pack inp4
test1 = tv1 == 190
test2 = tv2 == 120
test3 = tv3 == 5000000000
test4 = tv4 == 68
alltest = test1 && test2 && test3 && test4



Measured memory_bytes: 5372
#include<stdio.h>
#include<stdlib.h>

int main(){
	int n, i, j, ans=0;
	scanf("%d", &n);
	int *k;
	k=(int*)malloc(sizeof(int)*n);
	for(i=0;i<n;i++){
		scanf("%d", &k[i]);
	}
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			ans+=k[i]*k[j];
		}
	}
	printf("%d", ans);
	free(k);
	return 0;
}

Measured memory_bytes: 128
N, M, X = list(map(int,input().split()))

a = []
ans1=[]
for i in range(N):
    a.append(list(map(int,input().split())))
    
for i in range(2**N):
    # print("i=",i)
    x = [0]*M
    c = 0
    flag = True
    
    for j in range(N):
        if ((i >> j) & 1):
            c += a[j][0]
            for k in range(M):
                x[k] += a[j][k+1]
    
    for j in range(M):
        if x[j] < X:
            flag =False
    if flag == True:
        ans1.append(c)
    # print(x)
    # print("c=",c)

if ans1 == []:
    print(-1)
else:
    print(min(ans1))

Measured memory_bytes: 9232
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  int N;
  cin >> N;
  
  vector<int>h(N);
  int sum = 0;
  for (int i = 0; i < N; i++){
    cin >> h.at(i);
    sum += h.at(i);
    if (i != 0){
      sum -= min(h.at(i),h.at(i-1));
    }
  }
  cout << sum << endl;
}
  

Measured memory_bytes: 3636
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)    (x).begin(),(x).end()
# define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
# define mp        make_pair
# define eb        emplace_back
# define REP(i, a) for (int i = 0; i < (a); i++)
# define INIT      std::ios::sync_with_stdio(false);std::cin.tie(0);



bool a[300];

int main() {
	int n;
	while (cin >> n&&n) {
		for (int i = 0; i < 300; i++)a[i] = false;
		vector<int>taro, hana;
		for (int i = 0; i < n; i++) {
			int b;
			cin >> b;
			a[b] = true;
			taro.emplace_back(b);
		}
		for (int i = 1; i <= 2 * n; i++) {
			if (!a[i])hana.emplace_back(i);
		}
		sort(ALL(taro));
		int turn = 0;
		int ba = -1;
		bool taromuri = false, hanamuri = false;
		while (taro.size() && hana.size()) {
			//taroturn
			if (turn % 2 == 0) {

				if (ba == -1) {
					ba = taro[0];
					taro.erase(taro.begin());
				}
				else {
					for (int i = 0; i < taro.size(); i++) {
						if (taro[i] > ba) {
							ba = taro[i];
							taro.erase(taro.begin() + i);
							break;
						}
						if (i == taro.size() - 1)taromuri = true;
					}
				}
				if (taromuri == true) {
					ba = -1;
					taromuri = false;
				}
			}
			//hanaturn
			else {

				if (ba == -1) {
					ba = hana[0];
					hana.erase(hana.begin());
				}
				else {
					for (int i = 0; i < hana.size(); i++) {
						if (hana[i] > ba) {
							ba = hana[i];
							hana.erase(hana.begin() + i);
							break;
						}
						if (i == hana.size() - 1)hanamuri = true;
					}
				}
				if (hanamuri == true) {
					ba = -1;
					hanamuri = false;
				}
			}
			turn++;
		}
		cout << hana.size() << endl;
		cout << taro.size() << endl;
		//system("pause");
	}
}

Measured memory_bytes: 3144
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

// inf
constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

int main() {
    string s;
    cin >> s;
    bool ans = true;
    for (int i = 0; i < s.size(); i += 2) {
        if (s[i] == 'L')
            ans = false;

    }
    for (int i = 1; i < s.size(); i += 2) {
        if (s[i] == 'R')
            ans = false;
        }
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

//#define M 998244353

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define vvii vector<vii>
#define pb push_back
#define endl "\n"
#define f first
#define s second

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

struct node {
    ll v, s, t;

    bool operator<(const node& a) const {
        return this->t < a.t;
    }
};

int main() {
    fast;
    ll n, m, s;
    cin >> n >> m >> s;
    vector<vector<node>> ed(n+1);
    ll u, v, a, b;
    REP(i, 0, m) {
        cin >> u >> v >> a >> b;
        ed[u].pb({v, a, b});
        ed[v].pb({u, a, b});
    }
    vi exc(n+1), cost(n+1);
    REP(i, 1, n+1)
        cin >> exc[i] >> cost[i];
    ll M = 10000;
    vvi dp(n+1, vi(M+1, LLONG_MAX));
    multiset<node> st;
    s = min(s, M);
    dp[1][s] = 0;
    node tmp;
    tmp.t = 0;
    tmp.v = 1;
    tmp.s = s;
    st.insert(tmp);
    while (!st.empty()) {
        auto cur = *st.begin();
        st.erase(st.begin());
        //cout << cur.v << " " << cur.t << " " << cur.s << endl;
        REP(i, 0, ed[cur.v].size()) {
            auto e = ed[cur.v][i];
            if (cur.s >= e.s && dp[e.v][cur.s - e.s] > cur.t + e.t) {
                dp[e.v][cur.s - e.s] = cur.t + e.t;
                tmp.t = cur.t + e.t;
                tmp.v = e.v;
                tmp.s = cur.s - e.s;
                st.insert(tmp);
            }
        }
        ll tc = min(cur.s + exc[cur.v], M);
        ll t = cur.t + cost[cur.v];
        if (dp[cur.v][tc] > t) {
            dp[cur.v][tc] = t;
            tmp.t = t;
            tmp.v = cur.v;
            tmp.s = tc;
            st.insert(tmp);
        }
    }
    REP(i, 2, n+1)
        cout << *min_element(all(dp[i])) << endl;
}


Measured memory_bytes: 25120
N, M = map(int, input().split())
Hlist = list(map(int, input().split()))
ABlist = [list(map(int, input().split())) for _ in range(M)]
res = [0] * N
for a, b in ABlist:
    res[a-1] = max(Hlist[b-1], res[a-1])
    res[b-1] = max(Hlist[a-1], res[b-1])
ans = 0
for i in range(N):
    if Hlist[i] > res[i]:
        # print(i)
        ans += 1
print(ans)


Measured memory_bytes: 32000
import sys
input=sys.stdin.readline
a,b,q=map(int,input().split())
s=[int(input()) for _ in range(a)]
t=[int(input()) for _ in range(b)]
import bisect
for _ in range(q):
    x=int(input())
    sb=bisect.bisect_left(s,x)
    tb=bisect.bisect_left(t,x)
    ss=[x-s[max(sb-1,0)],x-s[min(sb,a-1)]]
    tt=[x-t[max(tb-1,0)],x-t[min(tb,b-1)]]
    l=[]
    for i in ss:
        for j in tt:
            if i*j>=0:
                l.append(max(abs(i),abs(j)))
            else:
                l.append(max(abs(i),abs(j))+2*min(abs(i),abs(j)))
    print(min(l))


Measured memory_bytes: 12188
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int,int> P;
struct edge{int to,cost;};

const int dx[] = {0,0,1,-1};
const int dy[] = {1,-1,0,0};

int field[7][7];
int space_sum;
int W, H;
int sy, sx;

void print_field(){
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            printf("%2d",field[i][j]);
        }
        cout << endl;
    }
}

int get_dim(int y, int x){
    int dim = 0;
    for(int k=0;k<4;k++){
        int nx = x + dx[k], ny = y + dy[k];
        if(nx<0||W<=nx||ny<0||H<=ny)continue;
        if(field[ny][nx]==0) dim++;
    }
    return dim;
}

bool dfs(int y, int x, int d_sum){
    //cout << y << " " << x << endl;
    //print_field();
    if(d_sum==space_sum){
        if(abs(sy-y)+abs(sx-x)==1)return true;
    }else{
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(field[i][j]) continue;
                if(abs(sy-i)+abs(sx-j)==1||abs(y-i)+abs(x-j)==1) continue;
                if(get_dim(i, j)==1) return false;
            }
        }
        for(int i=0;i<4;i++){
            int nx = x + dx[i], ny = y + dy[i];
            if(nx<0||W<=nx||ny<0||H<=ny)continue;
            if(field[ny][nx]==0){
                field[ny][nx] = 1;
                if (dfs(ny, nx, d_sum+1)) return true;
                field[ny][nx] = 0;
            }
        }
    }
    return false;
}

int main(){
    while(cin >> W >> H, W){
        space_sum = 0;
        sy = -1; sx = -1;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                scanf("%d",&field[i][j]);
                //if(field[i][j]==0) space_sum++;
                space_sum += !field[i][j];
                if(sy<0&&!field[i][j]){
                    sy = i; sx = j;
                }
            }
        }
        if(sy>=0) field[sy][sx] = 1;
        if(space_sum<4||space_sum%2==1||!dfs(sy, sx, 1)){
            cout << "No" << endl;
            continue;
        }else{
            cout << "Yes" << endl;
        }
    }

    return 0;
}

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

using namespace std;

const int mod = 1e9 + 7;

struct mint {
  int n;
  mint(int n = 0) : n(n) {}
};

mint operator+(mint a, mint b) { return (a.n += b.n) >= mod ? a.n - mod : a.n; }
mint operator-(mint a, mint b) { return (a.n -= b.n) < 0 ? a.n + mod : a.n; }
mint operator*(mint a, mint b) { return 1LL * a.n * b.n % mod; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

mint dpA[100001];
mint dpB[100001];
mint dpC[100001];
mint dp[100001];

int main() {
  string s;
  cin >> s;
  const int n = s.size();
  dpA[0] = 1;
  for (int i = 0; i < n; i++) {
    dpA[i + 1] += dpA[i];
    dpB[i + 1] += dpB[i];
    dpC[i + 1] += dpC[i];
    dp[i + 1] += dp[i];
    if (s[i] == 'A') {
      dpB[i + 1] += dpA[i];
    } else if (s[i] == 'B') {
      dpC[i + 1] += dpB[i];
    } else if (s[i] == 'C') {
      dp[i + 1] += dpC[i];
    } else {
      dpA[i + 1] += dpA[i] * 2;
      dpB[i + 1] += dpB[i] * 2;
      dpC[i + 1] += dpC[i] * 2;
      dp[i + 1] += dp[i] * 2;
      dpB[i + 1] += dpA[i];
      dpC[i + 1] += dpB[i];
      dp[i + 1] += dpC[i];
    }
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  string s;
  cin>>s;
  int ans=0;
  REP2(i,1,s.size()){
    if(s[i-1]!=s[i]) ans++;
  }
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 512
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    AIN(ll, A, N - 1);
    vi c(N);
    FOR(a, A)
    {
        ++c[a - 1];
    }
    FOR(ans, c)
    {
        OUT(ans);
    }
}

Measured memory_bytes: 6428
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;


class Program
{
    static void Main(string[] args)
    {
        var nk = Console.ReadLine().Split(' ');
        var n = int.Parse(nk[0]);
        var k = int.Parse(nk[1]);
        var hs = Console.ReadLine().Split(' ');

        var ret = hs.Where(v => int.Parse(v) >= k).Count();
        Console.Write(ret);
    }
}

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

int main() {
  long long k;
  cin>>k;
  cout<<50<<endl;
  long long a,b;
  a=k%50;
  b=k/50;
  for(int i=0;i<a;i++){
    cout<<100-a+b<<' ';
  }
  for(int i=0;i<49-a;i++)cout<<49-a+b<<' ';
  cout<<49-a+b<<endl;
}


Measured memory_bytes: 256
/*昇順の選択ソート*/
#include <stdio.h>
#include <stdlib.h>

int main() {
  int flag=1;
  int flag_count =0;
  int key;
  int judge=0;
  int n;
  int i,j=0;
  int *array;
  int min;

  scanf("%d",&n);
  array = (int *)malloc(n * sizeof(int));

  for(i=0;i<n;i++) {
    scanf("%d",array+i);
  }
  while(1)
    {
      if(j == n-1) break;
      min = j+1;
      for(i = j;i<n;i++) {
	if(array[i] < array[min]) {
	  min = i;
	}
      }
      if(array[j] > array[min]) {
       key = array[min];
       array[min] = array[j];
       array[j] = key;
       flag_count++;
      }
      j++;
    }
  for(i=0;i<n-1;i++) {
    printf("%d ",array[i]);
  }
  printf("%d\n%d\n",array[n-1],flag_count);
  
  return 0;
}



Measured memory_bytes: 2064
from collections import Counter
N,M,V,P = map(int,input().split())
cntA = Counter(list(map(int,input().split())))
keyA = sorted(cntA.keys(),reverse=True)

selected_num = 0
dif_val = 0
dif_num = 0
for key in keyA:
  if selected_num < P:
    selected_num += cntA[key]
    if selected_num>=P:
      last_val = key
      last_val_num = cntA[key]
      prv_val = key
      prv_val_num = cntA[key]
  else:
    if last_val-key > M:break
    dif_val += (dif_num+prv_val_num)*(prv_val-key)
    dif_num += prv_val_num
    if dif_val <= (N-V)*M:
      selected_num += cntA[key]
    else:break
    prv_val = key
    prv_val_num = cntA[key]
    #print(last_val, last_val_num, key, M, selected_num)
print(selected_num)

Measured memory_bytes: 70140
import math
nk=list(map(int,input().split()))
a=0
for i in range(1,nk[0]+1):
    if i>=nk[1]:
        a+=1
    else:
        p=math.ceil(math.log(nk[1]/i, 2))
        a+=1/(2**(p))
print(a/nk[0])

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> v;
  for (int i = 0; i < 2*n; i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += v[2*i];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256