akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

int main() {
	string s;
	while (getline(cin, s), s != ".") {
		stack <char> st;
		bool judge = true;
		rep (i, s.size()) {
			if (s[i] == '(' || s[i] == '[') {
				st.push(s[i]);
			}
			if (s[i] == ')' || s[i] == ']') {
				if (st.size() < 1) {
					judge = false;
					continue;
				}
				judge &= s[i] == ')' && st.top() == '('
					  || s[i] == ']' && st.top() == '[';
				st.pop();
			}
		}
		judge &= st.size() == 0;
		cout << (judge ? "yes" : "no") << endl;
	}
	return 0;
}


Measured memory_bytes: 3104
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    ll n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n)cin >> a[i];
    sort(a.begin(), a.end());
    vector<ll> c, d;
    rep(i,n){
        if(a[i] < 0)c.push_back(-a[i]);
        else if(a[i] > 0) d.push_back(a[i]);
    }
    reverse(c.begin(), c.end());
    show(c, d);
    auto check = [&](ll num) -> bool{
        ll cnt = 0;
        if(num > 0){
            int i = 0;
            int j = (int)c.size() - 1;
            while(i < j){
                if(c[i] * c[j] <= num){
                    cnt += (j - i);
                    i++;
                }else{
                    j--;
                }
            }
            i = 0;
            j = (int)d.size() - 1;
            while(i < j){
                if(d[i] * d[j] <= num){
                    cnt += (j - i);
                    i++;
                }else{
                    j--;
                }
            }
            ll zero = n - c.size() - d.size();
            cnt += (ll)(c.size() + d.size()) * zero + zero * (zero - 1) / 2 + (ll)c.size() * (ll)d.size();

        }else if(num == 0){
            ll zero = n - c.size() - d.size();
            cnt += (ll)(c.size() + d.size()) * zero + zero * (zero - 1) / 2 + (ll)c.size() * (ll)d.size();
        }else{
            num = - num;
            cnt += (ll) c.size() * (ll)d.size();
            int j = (int)d.size() - 1;
            for(int i = 0; i < c.size(); i++){
                while(j >= 0 and c[i] * d[j] >= num)j--;
                cnt -= j + 1;
            }
        }
        return cnt >= k;
    };
    ll ng = -1e18-1;
    ll ok = 1e18+1;
    while(abs(ng - ok) > 1){
        ll mid = (ok + ng) / 2;
        if(check(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    cout << ok << endl;
}


Measured memory_bytes: 4084
#include <iostream>
#include <string.h>
#include <algorithm>

using namespace std;

int main(void)
{
  int N;
  int X[100];

  cin >> N;
  for (int i = 0; i < N; i++) {
      cin >> X[i];
  }

  int dist_list[101];

  int cost_table[201];
  for (int i = 0; i <= 200; i++) {
      cost_table[i] = (i - 100) * (i - 100);
  }

  int x_current[100];
  for (int i = 0; i < N; i++) {
      x_current[i] = X[i] + 100;
      // cout << "x_current[i] : " << x_current[i] << endl;
      // cout << "cost: " << cost_table[x_current[i]] << endl;
  }

  for (int p = 0; p <= 100; p++) {
      int sum = 0;
      for (int i = 0; i < N; i++) {
          sum += cost_table[x_current[i]];
      }
      //cout << sum << endl;
      for (int i = 0; i < N; i++) {
          if (x_current[i] == 0) {
              x_current[i] = 200;
          } else {
              x_current[i] = x_current[i] - 1;
          }
      }
      dist_list[p] = sum;
  }
  //cout << "---" << endl;
  for (int p = 0; p <= 100; p++) {
      //cout << dist_list[p] << endl;
  }

  sort(dist_list, dist_list + 101);

  cout << dist_list[0];

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <math.h>
#include <map>
#include <stack>
using namespace std;
static const int INF = 1e9+7;
// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i =a; i < b; i++)
#define all(a) a.begin(), a.end()
#define PI 3.14159265359

int main() {
    int h, w; cin >> h >> w;
    string board[50];
    rep(i, h) cin >> board[i];

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

    rep(i, h){
        rep(j, w){
            if(board[i][j] == '#') continue;

            int num = 0;
            rep(k, 8){
                const int ni = i + dy[k];
                const int nj = j + dx[k];

                if(ni < 0 or h <= ni) continue;
                if(nj < 0 or w <= nj) continue;
                if(board[ni][nj] == '#') num++;
            }
            board[i][j] = char(num + '0');
        }
    }

    rep(i, h) cout << board[i] << endl;

    return 0;
}


Measured memory_bytes: 3628
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)(2.19e15+1);
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	int n,m,k,i,j;cin>>n>>m>>k;
	llint dp[4001]={0};//1の個数
	llint ans=0;
	for(i=0;i<(n+m-1)/(k-1);i++){
		//下からdp
		//int wa=(i+1)*(k-1)+1;cerr<<wa<<"    ";
		llint ddp[4001]={0};
		for(j=0;j<=i*(k-1);j++){
			for(int a=0;a<k;a++){//前回からのア
				//if(j+a>m||wa-(j+a)>n){continue;}
				ddp[j+a]+=dp[j];
			}
		}
		for(int a=1;a<=(i+1)*(k-1);a++){ddp[a]++;}
		for(j=0;j<=(i+1)*(k-1)+1;j++){dp[j]=ddp[j]%mod;}
	}
	cout<<dp[m]<<endl;
	RE;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
using namespace std;
int main()
{
	std::set<long> s,s1;
	long n, m;
	cin >> n;
	for (long i = 0; i < n; i++) {
		long t;
		cin >> t;
		s.insert(t);
	}
	cin >> m;
	for (long i = 0; i < m; i++) {
		long t;
		cin >> t;
		if (s.find(t) != s.end())
    {
      s.erase(t);
    }
		else
    {
      s.insert(t);
    }
	}
	for (std::set<long>::iterator itr = s.begin(); itr != s.end(); itr++)
		cout << *itr << endl;
	return 0;
}



Measured memory_bytes: 21772
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)(x).size())
#define mset(a,v) memset(a,v,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
using namespace std;
typedef long long ll;

int n;
int a[16][16];
ll w[1<<16];
ll f[1<<16];

int main(){
	scanf("%d",&n);
	fore(i,0,n)fore(j,0,n)scanf("%d",&a[i][j]);
	fore(m,0,1<<n)fore(i,0,n)if(m&(1<<i))fore(j,i+1,n)if(m&(1<<j))
		w[m]+=a[i][j];
	fore(m,1,1<<n){
		for(int t=m;t;t=(t-1)&m)f[m]=max(f[m],w[t]+f[m^t]);
	}
	printf("%lld\n",f[(1<<n)-1]);
	return 0;
}

Measured memory_bytes: 1280
height, width = map(int, input().split())
A = []
for i in range(height):
    A.append(list(map(int, input().split())))
B = [int(input()) for s in range(width)]
C = [0 for i in range(height)]
for i in range(height):
    for j in range(width):
        C[i] += A[i][j] * B[j]
    print(C[i])



Measured memory_bytes: 5984
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
        int ll = s.length();
        int l = s.length() / 2;
        int count = 0;
        for (int i=0; i<l; i++) {
            if (
              !s.substring(i, i+1)
                .equals(s.substring(ll-i-1, ll-i))
            ) count ++;
            
        }
		
		System.out.println(count);
    }
}



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

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef map<ll, ll> mii;
const int MOD = 1e9 + 7;

#define fastIO() \
ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define mp make_pair 

int main() {
    int n;
    cin >> n;
    vector<ld> p(n);
    for (auto& i : p)   cin >> i;
    vector<vector<ld>> dp(n, vector<ld>(n + 1, 0));
    dp[0][0] = 1.0 - p[0];
    dp[0][1] = p[0];
    for (int i = 1; i < n; ++i) {
        for (int j = 0; j <= (i + 1); ++j) {
            if (j > 0)
                dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1.0 - p[i]);
            else
                dp[i][0] = dp[i - 1][0] * (1.0 - p[i]);
        }
    }
    ld ans = 0.0;
    for (int i = n/2 + 1; i <= n; ++i) {
        ans += dp[n - 1][i];
    }
    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}


Measured memory_bytes: 141056
import itertools

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


#print(p, q)

#1,2,3の順列作成
lis = list(itertools.permutations(range(1, n + 1)))

#print(lis)

print(abs(lis.index(p) - lis.index(q)))


Measured memory_bytes: 13964
#include<iostream>
using namespace std;
long long  a,b,n,x,y;
int main(){
    cin >> n >> a;
    for(int i=0;i<a;i++){
        cin >> x >> y;
        if(y+1>n/2+1){
            y=n-y+1;
        }
            if(x+1>n/2+1){
            x=n-x+1;
            }

            if(x<=y)b=x%3;
            else b=y%3;

            if(b==0)b=3;
    cout << b << endl;
    b=0;
    }
return 0;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

int main() {
  int x;
  int min = 2147483647;
  int max = -2147483648;
  long sum = 0;
  cin >> x;
  for (int i = 0; i < x; ++i) {
    int y;
    cin >> y;
    sum += y;
    if (y > max) max = y;
    if (y < min) min = y;
  }
  cout << min << " " << max << " " << sum << endl;
  return 0;
}



Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
using P = pair<int,int>;
using node = pair<string,ll>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9+7;

int main(void) {
  int n,k;
  cin >> n >> k;
  cout << ((n+1)/2 >= k ? "YES" : "NO") << endl;
  return 0;
}


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

#define ll long long
#define ull unsigned ll

#define vi vector <int>
#define ii pair <int, int>
#define vii vector <ii>
#define INFLL 9e18
#define INF 2e9
#define EPS 1e-9
#define pb push_back
#define emp emplace_back
#define PI acos(-1.0)
#define endl "\n"
#define mp make_pair
#define DEBUG 0

ll log(ll number, ll base){
   return (ll)log2(number)/(ll)log2(base); 
}

ll power(ll x, ll y){
    return (ll)(pow(x, y) + EPS);
}

int main ()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    
    int n, w;
    cin >> n >> w;

    vector <ll> dp(w+1);//dp[i] denotes the maximum total value with weight exactly i

    for (int i=0; i<n; i++){
        int weight, value;
        cin >> weight >> value;

        for (int k=w-weight; k>=0; --k){
            dp[k+weight] = max(dp[k+weight], dp[k]+value);
        }
    }

    ll ans = 0;

    for (int i=0; i<=w; i++){
        ans = max(ans, dp[i]);
    }

    cout << ans << endl;



    return 0;
}

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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define LEN(s)      (string(s)).length()
#define NPOS        string::npos
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)     for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<class T>string join(const vector<T>& v,string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(LEN(d));}

template<class T>ostream& operator<<(ostream& s,const vector<T>& v)
{s<<"{";if(SZ(v))s<<join(v,", ");s<<"}";return s;}

template<class T>bool contain(const string& s,const T& v)
{return s.find(v)!=NPOS;}

template<class T,class U>string& replace(string& s,const T& f,const U& t)
{for(auto p=s.find(f);p!=NPOS;p=s.find(f,p+LEN(t)))s.replace(p,LEN(f),t);}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

int main() {
    ll N, L; cin >> N >> L;
    vector<string> S(N); REP(i, N) cin >> S[i];
    SORT(S);
    
    string ans = "";
    REP(i, N) ans += S[i];
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
N,Y = map(int, input().split())

x = -1
y = -1
z = -1
sum = 0
for a in range(N + 1):
    for b in range(N + 1 - a):
        c = N - a - b
        sum = 10000 * a + 5000 * b + 1000 * c
        if (sum == Y):
            x,y,z = a,b,c
print(x,y,z)            

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

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a + b > c + d) cout << "Left";
    else if (a + b < c + d) cout << "Right";
    else cout << "Balanced";
}

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

int main()
{
    int N,M,Input = 0;
    vector<int> student;
    cin >> N >> M;
    
    for(int i = 0;i < N;i++){
        cin >> Input;
        student.push_back(Input);
    }
    
    for(int k = 1;k <= M;k++){
        for(int i = 0;i < N-1;i++){
            if(student[i] % k > student[i+1] % k){
                swap(student[i],student[i+1]);
            }
        }
    }
    
    for(int i = 0;i < student.size();i++){
        cout << student[i] << endl;
    }
    
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
	int N, K;
	cin >> N >> K;
	string s;
	cin >> s;

	int l = 0;
	int k = 1 - (int)(s[0] - '0');
	int res = 1 - k;
	for (int r = 1; r < N; ++r) {
		if ((s[r] == '0') && (s[r - 1] == '1')) {
			++k;
		}
		if (k > K) {
			while (true) {
				++l;
				if ((s[l] == '1') && (s[l - 1] == '0')) { break; }
			}
			--k;
		}
		res = max(res, r - l + 1);
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,u[50];
	int i,j;
	double x=0;
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&u[i]);
	sort(u,u+n);
	x=u[0];
	for(i=0;i<n-1;i++){
		x=(double)((x+u[i+1])/2);
	}
	printf("%lf\n",x);
	return 0;
}

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

#define MAX 256

int array[MAX]; 
int depth = 0;

void push(int n) {
 array[depth++] = n;
}

int pop() {
 return array[--depth];
}

//stack function
void stack(char input, int num)
{
    num=-1;
    while (scanf("%c", &input) != EOF) {

 
  if ('0' <= input && input <= '9') {
   num = (num < 0 ? input - '0' : 10 * num + input - '0');
  }

  //push
  if (input == ' ') {
   if (num >= 0) push(num);
   num = -1;
  }

  if (input == '+') {
   push(pop() + pop());
  }

  if (input == '-') {
   int a = pop(), b = pop();
   push(b - a);
  }

  if (input == '*') {
   push(pop() * pop());
  }
 }

printf("%d\n", pop());
}

int main() {
    char input;
    int num;
    stack(input,num);

 return 0;
}


Measured memory_bytes: 2100
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<complex>
#include<set>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
	int n;
	cin >> n;
	int ans = 0;
	int l, r;
	rep(i, n) {
		cin >> l >> r;
		ans += r - l + 1;
	}
	cout << ans << endl;
	return 0;
}

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

#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<30)
#define INFLL (1LL<<62LL)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

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

  vector<int> adj(N, 0);
  vector<bool> visited(N);

  int a;
  rep(i, N) {
    cin >> a;
    adj[i] = --a;
    visited[i] = false;
  }

  int ans = 0;
  int now = 0;
  while (true) {
    if (now == 1)
      break;

    if (visited[now]) {
      ans = -1;
      break;
    }

    visited[now] = true;
    now = adj[now];
    ans++;
  }

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


Measured memory_bytes: 640
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int n = X/100;
    if (n*5 >= X%100) System.out.println(1);
    else System.out.println(0);
  }
}


Measured memory_bytes: 23252
import java.util.*;
import javax.lang.model.util.ElementScanner6;
//import java.lang.Math;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        // 入力
        int n = sc.nextInt();
        int m = sc.nextInt();

        int total = 0;
        int[] a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
            total += a[i];
        }

        // 処理
        double th = total / (4.0 * m);
        int cnt = 0;
        for(int i = 0; i < n; i++){
            if(a[i] >= th){
                cnt++;
            }
        }
        String out;
        if(cnt >= m){
            out = "Yes";
        } else {
            out = "No";
        }

        // 出力
        System.out.println(out);
    }
}

Measured memory_bytes: 21844
# -*- coding: utf-8 -*-

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if e - a > k:
    print(':(')
    exit()

if e - b > k:
    print(':(')
    exit()

if e - c > k:
    print(':(')
    exit()

if e - d > k:
    print(':(')
    exit()

if d - a > k:
    print(':(')
    exit()

if d - b > k:
    print(':(')
    exit()

if d - c > k:
    print(':(')
    exit()

if c - a > k:
    print(':(')
    exit()
if c - b > k:
    print(':(')
    exit()
if b - a > k:
    print(':(')
    exit()
print('Yay!')

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

#define    ll     long long int

int main( )
{
    ll y, ans = 0, i, j, k, l;
    cin >> y;
    l = y / 500;
    ans += (l * 1000);
    y = y % 500;
    l = y / 5;
    ans += (l * 5);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int main(){
	int N;
	cin >> N;
	vi a(N);
	multiset<int> s;
	for(int i=0;i<N;i++){
		cin >> a[i];
		s.insert(a[i]);
	}
	for(int i=0;i<N;i++){
		auto it = s.find(a[i]);
		s.erase(it);
		cout << *s.rbegin() << endl;
		s.insert(a[i]);
	}
	return 0;
}



Measured memory_bytes: 11776
line = function()
	local t = {}
	string.gsub(io.read(),"(%S+)", function (v) table.insert(t,tonumber(v)) end)
	return t[1], t[2]
end

N, K = line()

cnt = {}

for i = 1, 100000 do
	cnt[i] = 0	
end

for i = 1, N do
	a, b = line()
	cnt[a] = cnt[a] + b
end

index = 0

for i = 1, 100000 do
	index = index + cnt[i]
	if index >= K then
		print(i)
		break
	end
end



Measured memory_bytes: 19704
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000


int main(){

	int N;
	cin>>N;
	int ans = 0;
	for(int i=0;i<N;i++){
		int l,r;
		cin>>l>>r;
		ans += r-l+1;
	}
	cout<<ans<<endl;
    return 0;
}



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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define UNIQUE(c) sort(ALL(c)), c.erase(unique(ALL(c)), c.end())

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N; cin >> N;
  vector<int> P(N); REP(i, N) cin >> P[i], P[i]--;
  vector<int> rev_P(N); REP(i, N) rev_P[P[i]] = i;
  int ans = 1, now = 1;
  REP(i, N - 1) {
    if (rev_P[i] < rev_P[i + 1]) {
      now++;
    } else {
      ans = max(ans, now);
      now = 1;
    }
  }
  ans = max(ans, now);
  cout << N - ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>

#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;

using namespace std;

int n;
int a[100500];

void solve(){
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
//    for(int i = 0; i < n; i++) cout << a[i] << " ";
//    cout << "\n";
    int cnt = 0;
    for(int i = 0; i < n; i++){
        int l = i;
        int r = n;
        // l <= j < r
        while(r - l > 1){
            int mid = l + (r - l) / 2;
            if(a[mid] - a[i] <= 2) l = mid;
            else r = mid;
        }
        int nums = l - i + 1;
        //cout << a[i] << ' ' << a[l] << ' ' << nums <<endl;
        if(nums >= cnt){
            cnt = nums;
        }
    }
    cout << cnt;
}

int main(){
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}



Measured memory_bytes: 640
//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
//#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
//Using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> Ordered_set;

#define ll              long long
#define int             long long
#define ld             long double
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define vii             vector<vi>
#define vip            vector<pii>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int> 
#define all(v)          v.begin(),v.end()  
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define lb(x)           (x&(-x))
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define itr(it,v)          for(auto it:v)
#define show(arr,n)     for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fir(i,k,n)       for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ff               first 
#define ss               second
#define deb(x) cout << #x << "=" << x << endl
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define check(x) (x && cout<<"Yes\n")||(cout<<"No\n");
#define fin(s)          freopen(s,"r",stdin);  
#define fout(s)         freopen(s,"w",stdout);

const ld pi = 3.141592653589793238462643383279502884;
const int xd[]={-1,0,1,0};
const int yd[]={0,-1,0,1};
int XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[] = { -1, 0,  1, -1, 1, -1, 0, 1 };

int expo(int a,int b,int m);
int mmi(int a,int m);
void ipgraph(int m);

const int N=5*(1e5)+10;
vii adj(N);
int a[N];

void  solve(){

}
int32_t main()
{
    FIO
    int n; cin>>n;
    ld a[n];
    fi(i,n) cin>>a[i];
    map<ld,ld> m;
    m[0]=1.0-a[0];
    m[1]=a[0];
    fir(i,1,n){
        map<ld,ld> temp;
        // itr(it,m)  cout<<it.first<<" "<<it.second<<")"; cout<<"\n";
        itr(it,m){
            temp[it.first+1]+=it.second*a[i];
            temp[it.first]+=it.second*(1.0-a[i]);
        }
        m.clear();
        itr(it,temp) m[it.first]=it.second;
    }
    ld ans=0;
            // itr(it,m)  cout<<it.first<<" "<<it.second<<")"; cout<<"\n";
    itr(it,m){
        if(it.first>(n/2)) ans+=it.second;
    }
    cout<<ps(ans,10)<<"\n";
    return 0;

}

void ipgraph(int m){
    int i, u, v;
    while(m--){
          cin>>u>>v;
         u--, v--;
    adj[u].pb(v);
    adj[v].pb(u);
    }
}
int expo(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return a;
    int val=(expo(a,b/2,m)*expo(a,b/2,m))%m;
    if(b & 1) return (val*a)%m;
    else return val;
}
int mmi(int a,int m){
    return expo(a,m-2,m);
}

Measured memory_bytes: 12544
#include <iostream>
#include <vector>
using namespace std;
int n, m, f[55][55], par[55], res;

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

void unite(int x, int y) {
    if (root(x) == root(y)) return;
    x = root(x);
    y = root(y);
    par[x] = y;
}

int main(void){
    // Your code here!
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        f[a][b] = 1;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (f[i][j] == 0) continue;
            for (int k = 0; k < n; k++) par[k] = k;
            for (int k = 0; k < n; k++) {
                for (int l = 0; l < n; l++) {
                    if (k == i && l == j) continue;
                    if (f[k][l] == 0) continue;
                    unite(k, l);
                }
            }
            int ans = 0;
            for (int k = 1; k < n; k++) {
                if (root(k - 1) != root(k)) ans++;
            }
            if (ans == 0) res++;
        }
    }
    cout <<  m - res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string b;
  cin>>b;
  if(b=="A"){cout<<"T"<<endl;}
   else if(b=="T"){cout<<"A"<<endl;}
  else  if(b=="G"){cout<<"C"<<endl;}
   else{cout<<"G"<<endl;}
}

Measured memory_bytes: 3560
N = gets.to_i
A = gets.split.map(&:to_i)
E = Array.new(N){ [] }
(N-1).times{
	u,v = gets.split.map(&:to_i)
	E[u-1]<<v-1
	E[v-1]<<u-1
}
B = [nil]*N
F = lambda{|u,a|
	next if B[u]
	i = a.bsearch_index{|_| A[u]<=_ }||a.size
	z,a[i] = a[i],A[u]
	B[u] = a.size
	E[u].each{|v|
		F[v,a]
	}
	if z
		a[i] = z
	else
		a.pop
	end
}
F[0,[]]
p(*B)


Measured memory_bytes: 259260
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
from decimal import *

a, b, c = MAP()
if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
	print("Yes")
else:
	print("No")


Measured memory_bytes: 5272
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    ll n;
    cin>>n;
    vector<pair<ll,ll>> a(n);
    for(ll i=0;i<n;i++){
        ll b;
        cin>>b;
        a[i]=make_pair(b,i);
    }
    sort(a.begin(),a.end());
    for(ll i=0;i<n;i++)cout<<a[i].second+1<<" ";
}

Measured memory_bytes: 2432
mod = 10**9 + 7
n, a, b = map(int, input().split())
ans = pow(2, n, mod) - 1

for r in [a, b]:
    x = 1
    for i in range(r):
        x *= n-i
        x %= mod
        x *= pow(i+1, mod-2, mod)
        x %= mod
    ans = (ans + mod-x)%mod

print(ans)



Measured memory_bytes: 39024
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

template<typename... Types>
struct dynarr: std::vector<Types...> {
  using std::vector<Types...>::vector;
  using size_type = typename std::vector<Types...>::size_type;
  auto&& operator[](size_type i) { return this->at(i); }
  auto&& operator[](size_type i) const { return this->at(i); }
};

int main() {
  i64 a, b;
  cin >> a >> b;
  if(((a ^ b) & 1)) {
    cout << "IMPOSSIBLE" << endl;
  }
  else {
    cout << (a + b) / 2 << endl;
  }
}


Measured memory_bytes: 256
//  MONSTER >_<
#include <bits/stdc++.h>
#define SPEED ios::sync_with_stdio(false); cin.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define dbg(x) cout<<#x<<": "<<x<<endl
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define mo 1000000007
#define inf 1e18
#define eps 0.0000000001
#define stp setprecision(20)
#define all(v) v.begin(),v.end()
#define endl '\n'
using namespace std;
//mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
ll modu (ll a ,ll b, ll n=mo)
 {  ll x=1 ,y=a;
 while (b>0){
 	if(b%2==1)  x=(x*y)%n ;
 	y=(y*y)%n ;
 	b/=2;
} return(x%n) ;
 }
#define N  int(2e5)+10
int pre[N],cnt[N];
int main()
{    SPEED;

       ll n,k;cin>>n>>k;
       ll a[n+10];
       loop(i,0,n)cin>>a[i];
       
       loop(i,0,n){
       	  loop(j,i,n){
       	  	  if(a[i]>a[j])
       	  	    cnt[i]++;
			 }
	   }
	   loop(i,0,n){
	   	 loop(j,0,i+1){
	   	 	   if(a[i]>a[j])pre[i]++;
			}
	   }
	   ll ans=0;
	   loop(i,0,n){ 
	      ans+=((cnt[i]*((k*(k+1))%mo))%mo)*(modu(2,mo-2));ans%=mo;
	      ans+=((pre[i]*((k*(k-1))%mo))%mo)*(modu(2,mo-2));ans%=mo;
	      ans%=mo;
	   }cout<<ans;
}



Measured memory_bytes: 256
#include <unistd.h>
#include <stdio.h>

int	main(void)
{
  char	str[27] = {0};
  int	i = 0;
  int	j = 0;
  
  read(0, str, 26);
  while (str[i])
  {
    j = i + 1;
    while (str[j])
    {
      if (str[i] == str[j])
      {
        printf("no");
        return (0);
      }
      j++;
    }
    i++;
  }
  printf("yes");
  return (0);
}
  

Measured memory_bytes: 1604
import sys
from collections import deque
h,w = map(int,input().split())
sx,sy = map(int,input().split())
sx -= 1
sy -= 1
gx,gy = map(int,input().split())
gx -= 1
gy -= 1
route = []
for i in range(h):
  lst = list(input())
  route.append(lst)
  
brock = [['#']*w for i in range(h)]

que = deque([])
dx = [-1,0,1,0]
dy = [0,-1,0,1]

brock[sx][sy] = 0
que.append((sx,sy))



while que:
  
  (p,q) = que.popleft()
  if (p,q) == (gx,gy):
    print(brock[gx][gy])
    sys.exit()
  for i in range(4):
    p2,q2 = p+dx[i],q+dy[i]
    if 0 <= p2 < h and 0<= q2 < w and route[p2][q2] == '.' and (brock[p2][q2] == '#' or brock[p2][q2] > brock[p][q]):
      brock[p2][q2] = brock[p][q]
      que.appendleft((p2,q2))
  
  for j in range(-2,3):
    for k in range(-2,3):
      p3 = p+j
      q3 = q+k
      if 0 <= p3 < h and 0<= q3 < w and route[p3][q3] == '.' and brock[p3][q3] == '#':
        brock[p3][q3] = brock[p][q]+1
        que.append((p3,q3))
        
        
            
                  
              
print(-1)            

Measured memory_bytes: 169308
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;
using plli=pair<ll,int>;
using vplli=vector<pair<ll,int>>;
using pllll=pair<ll,ll>;
using vpllll=vector<pair<ll,ll>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int n;
    cin>>n;
    string S[]={"AC","WA","TLE","RE"};
    vi cnt(4,0);
    rep(i,0,n){
        string s;
        cin>>s;
        rep(i,0,4){
            if(S[i]==s)cnt[i]++;
        }
    }
    rep(i,0,4){
        cout<<S[i]<<" x "<<cnt[i]<<endl;
    }
    return 0;
}




Measured memory_bytes: 3608
import numpy as np

N = int(input())
p = [int(i) for i in input().split()]

N_array = np.arange(1, N+1, dtype=np.int)

count = 0

for i in range(N):
	if N_array[i] != p[i]:
		count += 1

if count >= 3:
	print('NO')
else:
	print('YES')

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

int sub(string& s, int ch){
    int L = s.size();
    vi w(L);
    rep(i,L) w[i] = s[i] - 'a';

    int ans = 0;
    {
        int cnt = 0;
        rep(i,L) if (w[i]==ch) ++cnt;
        if (cnt == L) return 0;
    }
    while (L > 1) {
        // cerr << w << endl;
        ++ans;
        // vi t(L-1, -1);
        int cnt = 0;
        rep(i,L-1){
            if (w[i]==ch || w[i+1]==ch) {
                w[i] = ch;
                ++cnt;
            }
        }
        if (cnt == L-1) return ans;
        // s = t; --L;
        w.pop_back(); --L;
    }
    return s.size()-1;
}
int solve(string& s) {
    int L = s.size();
    int best = L-1;
    rep(i,26) best = min(best, sub(s,i));
    return best;
}

int main() {
    string s; cin >> s;
    cout << solve(s) << endl;
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
u, v, s = (
    zip(*(map(int, input().split()) for _ in range(m))) if m else
    ((), (), ())
)


class UnionFindTree:
    def __init__(self, n):
        self.p = [i for i in range(n + 1)]
        self.r = [0 for _ in range(n + 1)]

    def find(self, x):
        if self.p[x] != x:
            self.p[x] = self.find(self.p[x])
        return self.p[x]

    def union(self, x, y):
        px = self.find(x)
        py = self.find(y)
        if px != py:
            if self.r[px] < self.r[py]:
                self.p[px] = py
            else:
                self.p[py] = px
                if self.r[px] == self.r[py]:
                    self.r[px] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)


# 適当な全域木をもとに、頂点1に書き込める整数の範囲を求める
# その後、残っている辺について、制約に反することなく整数を書き込めるか判定する
uft = UnionFindTree(n)
E = []
E_ = []
for x, y, w in zip(u, v, s):
    if uft.same(x, y):
        E_.append((x, y, w))
    if not uft.same(x, y):
        E.append((x, y, w))
        uft.union(x, y)

G = [{} for _ in range(n + 1)]
for x, y, w in E:
    G[x][y] = w
    G[y][x] = w
dp = [None for _ in range(n + 1)]
q = [1]
dp[1] = 1
W = {1}
B = set()
while q:
    x = q.pop()
    for y, w in G[x].items():
        if dp[y] is None:
            dp[y] = w - dp[x]
            if x in W:
                B.add(y)
            else:
                W.add(y)
            q.append(y)
W_min = min(dp[x] for x in W)
B_min = min(dp[x] for x in B)

d = -1
for x, y, w in E_:
    if x in W and y in W:
        D = w - dp[x] - dp[y]
        d = (
            D // 2 if D % 2 == 0 and D >= 0 and (d == -1 or D // 2 == d) else
            None
        )
    elif x in B and y in B:
        D = dp[x] + dp[y] - w
        d = (
            D // 2 if D % 2 == 0 and D >= 0 and (d == -1 or D // 2 == d) else
            None
        )
    else:
        d = (
            d if dp[x] + dp[y] == w else
            None
        )
ans = (
    0 if d is None else
    1 if 1 - W_min <= d < B_min else
    max(0, W_min + B_min - 1)
)

print(ans)


Measured memory_bytes: 72760
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner input = new Scanner(System.in);
       
        int a = input.nextInt();
        int b = input.nextInt();
        int h = input.nextInt();
        
        int area = (a+b)*h/2;
     
        System.out.println(area); 
    }
}


Measured memory_bytes: 26900
x = int(input())
if x >= 1800:
    print('1')
elif x >= 1600:
    print('2')
elif x >= 1400:
    print('3')
elif x >= 1200:
    print('4')
elif x >= 1000:
    print('5')
elif x >= 800:
    print('6')
elif x >= 600:
    print('7')
elif x >= 400:
    print('8')


Measured memory_bytes: 9172
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        long a=fsc.nextLong();
        long b=fsc.nextLong();
        fsc.close();
        long gcd=euclideanGCD(a, b);
        a/=gcd;
        b/=gcd;
        System.out.println(a*b*gcd);
    }
    public static long euclideanGCD(long a, long b) {
        if(a < b) return euclideanGCD(b, a);
        long r=a%b;
        while (r!=0) {
          a = b;
          b = r;
          r=a%b;
        }
        return b;
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


Measured memory_bytes: 23252
n = int(input())

ans = 1
maxcnt = 0
for i in range(1, n+1):
  tmp = i
  cnt = 0
  while True:
    if tmp % 2 == 0:
      tmp = tmp // 2
      cnt += 1
    else:
      break

  if maxcnt < cnt:
    ans = i
    maxcnt = cnt
      
print(ans)

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

int main() {
	unsigned long long H, W, N;
	int dx[3] = {-1, 0, 1}, dy[3] = {-1, 0, 1};
	cin >> H >> W >> N;
	map< pair<int, int>, int > block;
	for (int i = 0; i < N; i++) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		for (int j = 0; j < 9; j++) {
			int xx = x+dx[j%3], yy = y+dy[j/3];
			if (xx <= 0 || xx >= H-1 || yy <= 0 || yy >= W-1) {
				continue;
			}
			block[pair<int, int>(xx, yy)]++;
		}
	}
	map<pair<int, int>, int>::iterator itr = block.begin();
	vector<unsigned long long> ans(9, 0);
	unsigned long long nzero = 0;
	while (itr != block.end()) {
		ans[(itr->second)-1]++;
		nzero++;
		itr++;
	}
	nzero = (W-2)*(H-2) - nzero;
	cout << nzero << endl;
	for (int i = 0; i < 9; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 56448
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

int n,m,flag,dx[]={1,0,-1,0},dy[]={0,1,0,-1};
char c[100][100];

void paint(int x,int y,char ch){
	c[y][x]='o';
	rep(i,4){
		int nx=x+dx[i],ny=y+dy[i];
		if(nx>=0&&nx<n&&ny>=0&&ny<m){
			if(c[ny][nx]==ch)paint(nx,ny,ch);
			if(c[ny][nx]=='&')flag=1;
		}
	}
}

int main(){
	while(cin>>n>>m&&n){
		flag=0;
		rep(i,m)rep(j,n){
			cin>>c[i][j];
			if(i==0||i==m-1||j==0||j==n-1){
				if(c[i][j]=='.')c[i][j]='o';
				if(c[i][j]=='&')flag=1;
			}
		}
		int t=0;
		while(!flag){
			if(t==1)c[0][0]='o';
			if(t)rep(i,m)rep(j,n)if(c[i][j]=='o')paint(j,i,'#');
			rep(i,m)rep(j,n)if(c[i][j]=='o')paint(j,i,'.');
			if(!flag)t++;
		}
		cout<<t<<endl;
	}
}

Measured memory_bytes: 0
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int S[200007];
ll res[200007];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d",S+i);
	}
	ll res=0,cnt=0;
	for(int i=2;i<=n;i++){
		if(S[i]>=i || S[i]>S[i-1]+1){
			cout<<-1;
			return 0;
		}
		if(S[i]==S[i-1]+1) res++;
		else{
			res+=S[i];
		}		
	}
	if(S[1]){res=-1;}
	cout<<res;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>

using namespace std;

#define MAX_N 10011
#define ll long long
#define ull unsigned long long
#define eps 10e-10
#define MOD 1000000007

class SccPuzzele
{
private:
	ll n, m;
public:
	SccPuzzele(){
		cin >> n >> m;

	}
	void exec(){
		ll ans = 0;
		if(n * 2 < m){
			ans += n;
			m -= n*2;
			ans += m / 4;
		}else{
			ans += m / 2;
		}
		cout << ans << endl;

	}
};

int main(){
	SccPuzzele sp = SccPuzzele();
	sp.exec();
}

Measured memory_bytes: 256