akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
const int MAX = 1e6 + 10;
const int MOD = 1e9 + 7;
const int oo = 1e9;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	#define endl '\n'
	int h, w, k; cin >> h >> w >> k;
	int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
	vector<vector<bool>> p(h + 2, vector<bool>(w + 2));
	for(int i = 1; i <= h; i++){
		string s; cin >> s;
		for(int j = 1; j<= w; j++)
		{
			
			p[i][j] = (s[j - 1] == '@') ? false : true;
		}
	}
		
	int dir[4][2] = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}};
	vector<vector<int>> dis(h + 2, vector<int>(w + 2, -1));

	vector<pair<int, int>> que;
	que.push_back({x1, y1});
	dis[x1][y1] = 0;
	int front = 0;
	while(front < que.size()){
		auto cur = que[front]; front++;
		int cd = dis[cur.first][cur.second];
		for(int d = 0; d < 4; d++){
			
			for(int t = 1; t <= k; t++)
			{
				int x = cur.first + t * dir[d][0];
				int y = cur.second + t * dir[d][1];
				if(!p[x][y]){
					break;
				}
				if(dis[x][y] != -1){
					if(dis[x][y] <= cd)break;
					else continue;
				}
				dis[x][y] = cd + 1;
				que.push_back({x, y});
			}
			
		}
	}
	cout << dis[x2][y2] << endl;
	
}


Measured memory_bytes: 27496
#include<iostream>
    #include<algorithm>
    #include<bitset>
    using namespace std;
    typedef long long ll;
     
    int main() {
    	ll X, Y, count = 1;
    	cin >> X >> Y;
    	while (1) {
    		Y /= 2;
    		if (X > Y)break;
    		count++;
    	}
    	cout << count << endl;
    	return 0;
    }

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

struct crop{
    string name;
    double effi;
};

bool cmp_effi(const crop &a, const crop &b){
    return a.effi > b.effi;
}

bool cmp_name(const crop &a, const crop &b){
    return a.name < b.name;
}

int main(){
    int n,p,a,b,c,d,e,f,s,m;
    string name;
    while(cin >> n && n){
        int cnt=1;
        vector<crop> anslist;
        while(cnt<=n){
            cnt++;
            cin >> name >> p >> a >> b >> c >> d >> e >> f >> s >> m;
            double effi = (double)(f*s*m-p)/(double)(a+b+c+m*(d+e));
            anslist.push_back({name,effi});
        }
        sort(anslist.begin(),anslist.end(),cmp_name);
        stable_sort(anslist.begin(),anslist.end(),cmp_effi);

        for(auto x:anslist){
            cout << x.name <<endl;
        }
        cout << "#" << endl;
    }
}


Measured memory_bytes: 3156
function Main(input) {
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});
    var N = parseInt(input[0][0], 10);
    var vec_A = input[1].map(e => parseInt(e, 10));
    vec_A.sort((a,b) => b - a);
    var count = 0;
    var ans = vec_A[0];
    if (N > 2){
        var tmpIndex;
        while (true){
            count ++;
            tmpIndex = Math.ceil(count / 2);
            ans += vec_A[tmpIndex];
            if (count === N - 2) break;
        }    
    }
    console.log(ans);

}

Main(require("fs").readFileSync("/dev/stdin", "utf8")); 

Measured memory_bytes: 53076
#define bi
#include <iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<string>
#define MP make_pair
using namespace std;
typedef long long ll;
const ll maxn=1e5+10;
const ll mod=1e9+7;
char ch[maxn];

int main()
{
#ifdef bibi
    freopen("in.txt","r",stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>ch;
    ll len=strlen(ch);
    if(ch[0]==ch[len-1])
    {
        if(len%2==0)
            cout<<"First";
        else
            cout<<"Second";
    }
    else
    {
        if(len%2==0)
            cout<<"Second";
        else
            cout<<"First";
    }
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#define MAX_ARRAY 100

using namespace std;

int main(void){
    int tekichu[MAX_ARRAY],sum,n;

    while(cin>>n,n){
        sum=0;
        for(int i=0;i<MAX_ARRAY;i++){
            tekichu[i]=0;
        }   
        n=n/4;
        for(int i=0;i<n;i++){
            cin>>tekichu[i];
            sum=sum+tekichu[i];
        }   
        cout<<sum<<endl;
    }   
    return 0;
}

Measured memory_bytes: 0
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;

  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<long long, long long>;



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

  ll n;
  std::cin>>n;

  if(n%2==1){
    std::cout<<0<<"\n";
    return 0;
  }
  ll num=0;

  n/=2;

  ll now=5;
  rep(i,0,30){
    if(n/now==0){
      break;
    }
    num+=n/now;
    if(n/5<now){
      break;
    }
    now*=5;
  }

  std::cout<<num<<"\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;
  map<int,int> mp;
  rep(i,M){
    int a, b;
    cin >> a >> b;
    if(a == 1){
      if(mp[b] == 0){
        mp[b]++;
      }
      else{
        cout << "POSSIBLE" << endl;
        return 0;
      }
    }
    if(b == N){
      if(mp[a] == 0){
        mp[a]++;
      }
      else{
        cout << "POSSIBLE" << endl;
        return 0;
      }
    }
  }
  cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 12800
import sys
def todec(s):
    roman_dic = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}
    ret, prev = 0, 0
    for i in reversed(s):
        d = roman_dic[i]
        if d < prev:
            ret -= d
        else:
            ret += d
        prev = d
    return ret

A = sys.stdin.read().split()
for a in A:
    print(todec(a))

Measured memory_bytes: 7420
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

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

    cout << t << s;

    return 0;
}

int main()
{
    solve();

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int p[10];

bool f(int q[10],bool a){
	int r[10];
	int i;
	for(i=0;i<10;i++)r[i]=q[i];
	for(i=0;i<10;i++){
		if(r[i])break;
	}
	if(i==10)return true;
	if(r[i]>=3){
		r[i]-=3;
		if(f(r,a))return true;
		r[i]+=3;
	}
	if(a==false&&r[i]>=2){
		r[i]-=2;
		if(f(r,true))return true;
		r[i]+=2;
	}
	if(i<=7&&r[i]&&r[i+1]&&r[i+2]){
		r[i]--;
		r[i+1]--;
		r[i+2]--;
		if(f(r,a))return true;
	}
	return false;
}

int main() {
	string str;
	while(cin>>str){
		memset(p,0,sizeof(p));
		int i;
		for(i=0;i<str.size();i++){
			p[str[i]-'0']++;
		}
		int num=0;
		for(i=1;i<10;i++){
			if(p[i]==4)continue;
			p[i]++;
			if(f(p,false)){
				if(num!=0)cout<<" ";
				cout<<i;
				num++;
			}
			p[i]--;
		}
		if(num==0)cout<<0;
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz size
#define se second
#define fe first
#define mper make_pair
#define all(x) x.begin(), x.end()
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define saken string
#define erba continue
using namespace std;

const ll MAXN = 1e5 + 100;

int n, c, k, a[MAXN];

int main(){

cin >> n >> c >> k;

for(int i = 1; i <= n; ++i) {
    cin >> a[i];
}

sort(a + 1, a + 1 + n);

int start = a[1];
int len = 1;
int ans = 0;

for(int i = 2; i <= n; ++i) {
    if(a[i] - start <= k && len + 1 <= c) {len++;}
    else {
        len = 1;
        start = a[i];
        ans++;

    }
}

cout << ans + 1;

return 0;
}



Measured memory_bytes: 640
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
	if cur == N:
		return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
	ret0 = dfs(cur + 1, a, b, c)
	ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
	ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
	ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
	return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
using namespace std;
long long MOD = 1e9 + 7;

string S, T;
vector<int> scount, tcount;

int main() {
	cin >> S >> T;
	scount.resize(26, 0);
	tcount.resize(26, 0);
	for (int n = 0; n < S.size(); n++)scount[S[n] - 'a']++;
	for (int n = 0; n < T.size(); n++)tcount[T[n] - 'a']++;
	sort(scount.begin(), scount.end(), [](int a, int b) {
		return a < b;
	});
	sort(tcount.begin(), tcount.end(), [](int a, int b) {
		return a < b;
	});
	bool flag = true;
	for (int c = 0; c < 26; c++) {
		if (scount[c] != tcount[c]) {
			flag = false;
			break;
		}
	}
	if (flag)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 776
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
long long a[100005];
int main()
{
	long long n,a1,b,minsum=0;
	cin>>n>>a1>>b;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<n;i++)
	minsum+=min(a1*(a[i+1]-a[i]),b);
	cout<<minsum<<endl;
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <numeric>
#include <chrono>
#include <bitset>
#include <tuple>
#include <queue>
#include <map>
#include <cstring>
#include <cassert>
#include <math.h>
using namespace std;

const int N = 2e5 + 10, mod = 1e9 + 7;


int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tc = 1;
    // scanf("%d", &tc);
    for(int cn = 1; cn <= tc; cn++) {
        int n, d; scanf("%d%d", &n, &d);
        long long dis = 1ll * d * d;
        int ans = 0;
        for(int i = 0; i < n; i++) {
            long long x, y; scanf("%lld%lld", &x, &y);
            if(x * x + y * y <= dis) ans++;
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3828
#include<stdio.h>
int main(){
  int a=1,b=0,c=0,tmp;
  char n,m;
  while(scanf("%c,%c",&n,&m)!=EOF){
    if(n=='A'){
      if(m=='B'){
	tmp=a;
	a=b;
	b=tmp;
      }
      else if(m=='C'){
	tmp=a;
	a=c;
	c=tmp;
      }
    }
    else if(n=='B'){
      if(m=='A'){
	tmp=a;
	a=b;
	b=tmp;
      }
      else if(m=='C'){
	tmp=b;
	b=c;
	c=tmp;
      }
    }
    else if(n=='C'){
      if(m=='A'){
	tmp=a;
	a=c;
	c=tmp;
      }
      else if(m=='B'){
	tmp=b;
	b=c;
	c=tmp;
      }
    }
  }
  if(a==1){
    printf("A\n");
  }
  else if(b==1){
    printf("B\n");
  }
  else if(c==1){
    printf("C\n");
  }
  return (0);
}

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

int main(){
  int n , m , a , ans = 0 ;
  cin >> n >> m ;
  for( int i = 0 ; i < m ; i++ ){
	cin >> a ;
    ans += a ;
  }
  cout << max( n - ans , -1 ) << endl ;
  return 0 ;
}

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

int main(){
    int N;
    cin >> N;
    int differences[N];
    for(int i = 0; i < N; i++){
        cin >> differences[i];
    }
    sort(differences, differences + N, greater<int>());
    for(int i = 0; i < N / 2; i++){
        if(differences[i * 2] != N - i * 2 - 1 || differences[i * 2 + 1] != N - i * 2 - 1){
            cout << 0 << endl;
            return 0;
        }
    }
    if(N % 2){
        if(differences[N - 1] != 0){
            cout << 0 << endl;
            return 0;
        }
    }
    int ans = 1;
    for(int i = 0; i < N / 2; i++){
        ans *= 2;
        ans %= int(1e9 + 7);
    }
    cout << ans << endl;
}


Measured memory_bytes: 768
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


long long M = 1000000007;


int main(int argc, char const *argv[]) {
    long long n;cin>>n;
    n++;
    deque<int> dq;
    int k = 0;
    while(n>>k > 0)k++;
    k-=2;
    int l = 1;
    for(;k>-1;k--){
        dq.push_back(l);
        l++;
        if((n>>k)%2==1){
            dq.push_front(l);
            l++;
        }
    }
    cout<<2*(l-1)<<endl;
    for(int i=1;i<l;++i)cout<<i<<" ";
    for(int i:dq)cout<<i<<" ";
    cout<<endl;
    return 0;
}

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

using namespace std;
#define ll long long

ll INF = 1e18;

bool isprime(ll a)
{
    if(a == 2)
        return true;
    if( a < 2 || (a%2 == 0))
        return false;
    for(ll i = 3; i*i<=a; i+=2)
    {
        if(a%i == 0)
            return false;
    }
    return true;
}

int main(){
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);

    ll a,b;
    cin>>a>>b;

    unordered_set<ll> hset;

    for(ll i=2;i*i<=a;i++)
    {
        if((a%i == 0))
        {
            if(isprime(i))
                hset.insert(i);
            if(isprime(a/i))
                hset.insert(a/i);
        }
    }

    if(hset.size() ==0 && a > 1)
        hset.insert(a);

    vector<ll> res;
    res.push_back(1);

    for(auto it:hset)
    {
        if(b%it == 0)
            res.push_back(it);
    }

    cout<<res.size()<<endl;

    return 0;
}


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

int main() {
  int l, r, d;
  cin >> l >> r >> d;
  int ans = 0;
  
  for(int i = l; i <= r; i++) {
    if(i % d == 0) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
/***********************************************************
	When you are inspired by passion 
	and you want to live for the current moment

	When your every thought and action
	has the power to become the story of your future

	When difficulties stand to demolish your Glory
	Just remember that Life is a 'Golden adverse Story'

	Withstand it to acheive your passion and dreams
	more amazingly more easily.

	Why then? When writing the story of your Life
	You want to Let someone else hold your pen

					huzaifa242©

***********************************************************/
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define MAX 100005
#define x first 
#define y second

template <typename T,typename G>
ostream& operator << (ostream& out, const pair<T,G> &a) 
{return out<<"( "<<a.x<<", "<<a.y<<")";}

template <typename T>
ostream& operator << (ostream& out, const vector<T> &a) 
{out<<"[ ";for(const auto &i:a)out<<i<<", ";return out<<"]"<<endl;}

template <typename T>
ostream& operator << (ostream& out, const set<T> &a) 
{out<<"{ ";for(const auto &i:a)out<<i<<", ";return out<<"}"<<endl;}

template <typename T,typename G>
ostream& operator << (ostream& out, const map<T,G> &a) 
{out<<"< ";for(const auto &i:a)out<<i<<", ";return out<<">"<<endl;}

template<typename T, size_t N>
typename enable_if<!is_same<typename remove_cv<T>::type, char>::value,
ostream&>::type operator<<(ostream& out, T(&a)[N])
{out<<"[ ";for(size_t i=0;i<N;++i)out<<a[i]<<", ";out <<"]"<<endl;return out;}

void debug_out(){cerr<<endl;} 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{cerr<<(H)<<" ";debug_out(T...);}
 
#ifdef LOCAL
#define debug(...) cerr<<"#"<<#__VA_ARGS__<<":\n",debug_out(__VA_ARGS__)
#else
#define debug(...) 24
#endif

double x=0,y=0;
vector<pair<double,double> > a; 

double dist(double a, double b){
	return a*a+b*b;
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int n,i,j;
	cin>>n;
	a.resize(n);
	for(i=0;i<n;i++){
		cin>>a[i].x>>a[i].y;
		x+=a[i].x;
		y+=a[i].y;
	}
	x/=n;y/=n;
	double gradient=0.1,d,e;
	for(i=0;i<30000;i++){
		int f=0;
		d=dist(x-a[0].x,y-a[0].y);
		for(j=1;j<n;j++){
			e=dist(x-a[j].x,y-a[j].y);
			if(e>d){
				f=j;
				d=e;
			}
		}
		x+=(a[f].x-x)*gradient;
		y+=(a[f].y-y)*gradient;
		gradient*=0.999;
	}
	d=sqrt(d);
	cout<<fixed<<setprecision(20)<<d;
	return 0;
}


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

using namespace std;

typedef long long ll;

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

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

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

    if (N == 0) {
        cout << "0" << endl;
        return 0;
    }

    vector<int> binary;
    while (N != 0) {
        if (N % (-2)) {
            binary.push_back(1);
            N--;
        } else {
            binary.push_back(0);
        }
        N /= -2;
    }

    reverse(binary.begin(), binary.end());

    for (auto &b : binary) {
        cout << b;
    }
    cout << endl;

    return 0;
}


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

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

int di[4] = {1, 0, -1, 0};
int dj[4] = {0, 1, 0, -1};
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
    int n,m;
    while(cin >> n >> m){
        if(n+m==0) break;
        int h[n], w[m], max_h=0, max_w=0;
        REP(i,n){
            cin >> h[i];
            max_h += h[i];
        }
        REP(i,m){
            cin >> w[i];
            max_w += w[i];
        }

        int wh[max_h+1];
        int ww[max_w+1];
        memset(wh,0,sizeof(wh));
        memset(ww,0,sizeof(ww));
        REP(i,n){
            int sum = 0;
            for(int j=i; j<n; j++){
                sum += h[j];
                wh[sum]++;
            }
        }
        REP(i,m){
            int sum = 0;
            for(int j=i; j<m; j++){
                sum += w[j];
                ww[sum]++;
            }
        }

        int cnt = 0;
        REP(i,min(max_h+1,max_w+1)) {
            cnt += wh[i] * ww[i];
        }
        cout << cnt << endl;
    }
    return 0;
}

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

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}
int main (){
    int n;
    string s;
    int ans=inf;
    cin >> n >> s;
    vector<int>west(n,0);
    vector<int>west_rui(n,0);
    vector<int>east(n,0);
    vector<int>east_rui(n,0);
    rep(i,n){
        if(s[i]=='W')west[i]=1;
        else if(s[i]=='E')east[i]=1;
    }
    rep(i,n){
        if(i==0){
            west_rui[i]=west[i];
            east_rui[i]=east[i];
        }
        else{
            west_rui[i]=west_rui[i-1]+west[i];
            east_rui[i]=east_rui[i-1]+east[i];
        }
    }
    rep(i,n){
        int v;
        if(i==0) v=east_rui[n-1]-east_rui[0];
        else if(i==n-1) v=west_rui[n-2];
        else v=west_rui[i-1]+east_rui[n-1]-east_rui[i];
        ans=min(ans,v);
    }
    cout << ans << endl;
    return 0;
}



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

int main() {
	int k, a, b;
	cin >> k;
	cin >> a >> b;
	int ans = 0;
	for (int i = a; i <= b; i++) {
		if (i % k == 0) ans = 1;
	}
	if (ans == 1) cout << "OK" << "\n";
	else cout << "NG" << "\n";
	return 0;
}

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

int main() {
    int N;
    std::string S;
    std::cin >> N;
    std::cin >> S;

    if (S.size() % 2 == 1) {
        std::cout << "No" << std::endl;
        return 0;
    }

    std::string ans = "Yes";
    for (int i = 0; i < N / 2; i++)
    {
        if (S[i] != S[N / 2 + i]) ans = "No";
    }

    std::cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let ints = readInts()
    let n = ints[0]
    let a = ints[1]
    let b = ints[2]
   
    var total = 0
    for i in 1...n {
        let x = String(i).map { (c) -> Int in
            Int(String(c))!
        }.reduce(0) { (sum, item) -> Int in
            sum + item
        }
        if a <= x && x <= b {
            total += i
        }
    }
    
    print("\(total)")
}

main()


Measured memory_bytes: 8240
def main():
    from sys import setrecursionlimit, stdin
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**9+10

    S = input()
    num_s = 0
    ans = len(S)
    for c in S:
        if c == 'S':
            num_s += 1
        else:
            if num_s > 0:
                num_s -= 1
                ans -= 2
    print(ans)

    
main()

Measured memory_bytes: 41308
//package abc174;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] ip = br.readLine().split(" ");
		
		int N = Integer.parseInt(ip[0]);
		double D = Double.parseDouble(ip[1]);
		
		int ans = 0;
		
		for(int i = 0 ; i < N ; i++) {
			ip = br.readLine().split(" ");
			int x = Integer.parseInt(ip[0]);
			int y = Integer.parseInt(ip[1]);
			
			double d = Math.sqrt(Math.pow(x,2)+Math.pow(y,2));
			
			if(d <= D)
				ans++;
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 55128
#include<cstdio>
using namespace std;
int N,f[300001];
char s[300001];
int min(int i,int j){
	return (i<j?i:j);
}
int ans;
int main(){
	scanf("%d %s",&N,s);
	for(int i=1;i<N;i++){
		if(s[i]=='E')	++f[0];
	}
	ans=f[0];
	for(int i=1;i<N;i++){
		int a=f[i-1];
		if(s[i-1]=='W')	++a;
		if(s[i]=='E')	--a;
		f[i]=a;
		ans=min(f[i],ans);
	}
	printf("%d",ans);
	return 0;
}

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
    int n, m;
    while(cin >> n >> m, n|m){
        vi h, t;
        int htotal = 0, ttotal = 0;
        rep(i, n){
            int input; cin >> input;
            h.pb(input);
            htotal += input;
        }
        rep(i, m){
            int input; cin >> input;
            t.pb(input);
            ttotal += input;
        }
        bool isPossible = false;
        rep(i, n)rep(j, m){
            if(ttotal+h[i]-t[j] == htotal-h[i]+t[j]){
                isPossible = true;
                cout << h[i] << " " << t[j] << endl;
                goto next;
            }
        }
next:;
        if(!isPossible) cout << -1 << endl;
    }
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int A,B;
    cin >> A >> B;
    if(B == 1)
    {
        cout << "0\n";
        return 0;
    }
    A--;B--;
    if(B % A == 0)
        cout << B / A << '\n';
    else
        cout << B / A + 1 << '\n';
    
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
#include <iomanip>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)


typedef long long int ll;
typedef double D;      // ??§?¨?????????????double???long double?????????
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;


const int INF = (1<<30) - 1;
const D EPS = 1e-9;

#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

int N, W;

void solve(){
    vector<int> occurs(15);
    for(int i=0; i<N; i++){
        int v; cin >> v;
        occurs[v/W]++;
    }
    int m = 0;
    for(int o: occurs)
        m = max(m, o);
    
    int leftmost = 15-1;
    while(occurs[leftmost] == 0) leftmost--;
    double ans = 0;
    for(int i=0; i<=leftmost; i++){
        ans += occurs[i] * (leftmost-i) / double(leftmost) / m;
    }
    cout << ans+0.01 << setprecision(10) << endl;
}

//g++ -std=c++0x -msse4.2 -O3
//#include <bits/stdc++.h>
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    while(cin>>N>>W, N|W)
        solve();
    
    return 0;
}

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

void hantei(string s,int n){
	string t;
	int low = -1,high = n+1,mid;
	while(true){
		mid =(high+low)/2;
		cout << mid << endl;
		cin >> t;
		if(t[0]=='V'){
			break;
		}
		if(t[0]==s[0] && mid%2==0){
			low = mid;
		}else if(t[0]!=s[0] && mid%2==1){
			low = mid;
		}else{
			high = mid;
		}
	}
}

int main(){
	int n;
	string s;
	cin >> n;
	cout << 0 << endl;
	cin >> s;
	if(s[0]=='V'){
		return 0;
	}
	hantei(s,n);
}


Measured memory_bytes: 852
N = int(input())
H = list(map(int, input().split()))

ans = 0
ans_tmp = 0
for i in range(0,N-1):
    if H[i+1] <= H[i]:
        ans_tmp += 1
        ans = max(ans, ans_tmp)
    else:
        ans_tmp = 0

print(ans)


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

#define int long long
typedef pair<int, int> P;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

/*
ifstream ifs("in.txt");
ofstream ofs("out.txt");
#define cin ifs
#define cout ofs
//*/
int H, W;
string S[55];
signed main() {
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        cin >> S[i];
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S[i][j] == '.') continue;
            bool flag = false;
            for (int k = 0; k < 4; k++) {
                int ny = i + dy[k], nx = j + dx[k];
                if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
                if (S[ny][nx] == '#') flag = true;
            }
            if (flag == false) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
  #define DUMP(i) 
#endif
 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());

using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

struct Edge{
public:
  int from,to,cost;
  Edge(){}
  Edge(int _from,int _to,int _cost){
    from = _from;
    to = _to;
    cost = _cost;
  }
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

const int EPS = 1e-9;
const int MOD = 1e9+7;


int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  map<int,int> M;
  REP(i,n){
    int a;
    cin >> a;
    M[a]++;
  }

  int ans = 0;
  for(auto a : M){
    if(a.first != a.second){
      if(a.first > a.second)ans += a.second;
      else ans += a.second - a.first;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 4736
<?php
fscanf(STDIN,"%d",$n);
$arr=array();
$arr_2=array();
for($i=1;$i<=$n;++$i){
	fscanf(STDIN,"%s",$s);
	for($j=0;$j<strlen($s);$j++){
		$arr[$i][$j]=substr($s,$j,1);
	}
	sort($arr[$i]);
	for($j=0;$j<strlen($s);$j++){
		$arr_2[$i].=$arr[$i][$j];
	}
}
$arr_3=array_count_values($arr_2);

$cnt=0;
foreach($arr_3 as $key=>$value){
	//echo $key." ".$value."\r\n";
	if($value<>1){
		$c=($value*($value-1))/2;
		$cnt +=$c;
	}
}

echo $cnt;
?>

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<P, ll> PPI;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

int n;
string s;
int nxt[200010][30];
int dp[200010];
int prevv[200010];
char nc[200010];
string ans;

int dfs(int idx){
  if(idx==-1)return 0;
  if(dp[idx]!=-1)return dp[idx];
  int res=INF;
  for(char c='a';c<='z';c++){
    int tmp=dfs(nxt[idx][c-'a'])+1;
    if(res>tmp){
      res=tmp;
      prevv[idx]=nxt[idx][c-'a'];
      nc[idx]=c;
    }
  }
  return dp[idx]=res;
}

void hoge(int idx){
  if(idx==-1)return;
  ans+=nc[idx];
  hoge(prevv[idx]);
}

int main(){
	cin.sync_with_stdio(false);
  cin>>s;
  n=s.length();
  memset(nxt,-1,sizeof(nxt));
  for(int i=n;i>=1;i--){
    for(char c='a';c<='z';c++){
      if(s[i-1]==c)nxt[i-1][c-'a']=i;
      else nxt[i-1][c-'a']=nxt[i][c-'a'];
    }
  }
  memset(dp,-1,sizeof(dp));
  dfs(0);
  hoge(0);
  cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 26132
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.useDelimiter(System.getProperty("line.separator"));
		int n = sc.nextInt();
        String aStr = sc.next();
        int[] a = toIntAry(aStr, n);
        int q = sc.nextInt();
        String mStr = sc.next();
        int[] m = toIntAry(mStr, q);


        for (int i = 0; i < q; i++) {
			if(solve(0,m[i],n,a)){
				System.out.println("yes");
			}else{
				System.out.println("no");
			}
		}

	}



	private static boolean solve(int i, int m, int n, int[] a) {
		if(m==0) return true;
		if(i>=n) return false;
		boolean res = solve(i+1,m,n,a) || solve(i+1,m-a[i],n,a);
		return res;
	}



	private static int[] toIntAry(String str, int n) {
        String[] tmp = str.split(" ");
        int[] A = new int[n];
        for (int i = 0; i < n; i++) {
			A[i] = Integer.parseInt(tmp[i]);
		}
        return A;
	}


}

Measured memory_bytes: 26616
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
const int inf = 10e9 + 7;
#define int long long
#define rep(i,n) for(int i=1;i<=n;i++)
#define loop(i,m,n) for(int i=m;i<n;i++)
#define endre getchar(); getchar();return 0;
int a[100010], b[100010], c[100010];
signed main() {
	int n;
	cin >> n;
	rep(i, n) {
		cin >> a[i] >> b[i] >> c[i];
	}
	a[0] = 0;
	b[0] = 0;
	c[0] = 0;
	rep(i, n) {
		if ((abs(b[i] - b[i - 1]) + abs(c[i] - c[i - 1])) % 2 == (a[i] - a[i - 1]) % 2 && abs(b[i] - b[i - 1]) + abs(c[i] - c[i - 1]) <= a[i] - a[i - 1]) {}
		else { cout << "No" << endl; endre; }
	}
	cout << "Yes" << endl;
	endre;
}

Measured memory_bytes: 2560
/*
�����ߣ�NJYZ_LHW
����ʱ�䣺
�㷨���ͣ�
��Ŀ��

*/
#include <iostream>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstdio> 

using namespace std;

int main()
{
	//freopen("C.out","w",stdout);
	int h,w,k;
	int x[40],y[40];              //�����СҪŪ�壬��ҪŪС��           
	int rlo[40][40];
	int sum=0;
	int rm=0;
	int rs=0;
	cin>>h>>w>>k;
	for (int i=0;i<40;i++)
	{
		for (int j=0;j<40;j++)
		{
			rlo[i][j]=0;
		}
	}
	for (int i=0;i<h;i++)
	{
		string s;
		cin>>s;
		for (int j=0;j<w;j++)
		{
			if (s[j]=='#') 
			{
			
				sum++;
				//if (i==5 && j==2) cout<<"^_^"<<endl;
				
				x[sum-1]=j;
				y[sum-1]=i;
				
				
			}
			
		}
		
	}

	
	for (int i=0;i<((1<<h));i++)//λ�������Ų�����  �Ӽ�ҪŪ�� 
	{
		int my[15];
		int ty;
		int yy=h-1;
		ty=i;
		for (int j=0;j<6;j++)
		{
			my[j]=0;
		}
		while (ty!=0)
		{
			my[yy]=ty % 2;
			ty/=2;
			yy--;
			
		}
		//cout<<(1<<w-1)<<" "<<w<<endl;
		for (int j=0;j<((1<<w));j++)//�Ȳ���Ҫ���� 
		{
			rm=sum;					//��ʱˢ��Ҫ���� 
			
			int mx[15];
			for (int p=0;p<6;p++)   //Ƕ��ѭ������Ҫ���� 
			{
				mx[p]=0;
			}
			int tx;
			int xx=w-1;
			tx=j;
			while ( tx!=0 )
			{
				mx[xx]=tx % 2;
				tx/=2;
				xx--;
			}
			
			for (int p=0;p<sum;p++)
			{
				if (mx[x[p]]==1 || my[y[p]]==1) 
				{
					rm--;
					
				}
			}
			if (rm==k)
			{
				
				
				 rs++;      //��ʱˢ��Ҫ���� 
			}
			
		}
		
	}
	
	cout<<rs;
	return 0;
}



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

public class Main {
    static final long MOD=1000000007;
    public static void main(String[] args) throws IOException{
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));

        StringTokenizer st=new StringTokenizer(f.readLine());
        int n = Integer.parseInt (st.nextToken());
        int k = Integer.parseInt (st.nextToken());
        int[]arr=new int[n];
        st=new StringTokenizer(f.readLine());
        for(int i=0;i<n;i++){
            arr[i]=Integer.parseInt(st.nextToken());
        }
        long[][]dp=new long[n+5][k+5];
        long[][]prefix=new long[n+5][k+5];
        for(int i=0;i<=k && i<=arr[0];i++){
            dp[0][i]=1;
            prefix[0][i]=1;
        }
        for(int i=1;i<=k;i++){
            prefix[0][i]+=prefix[0][i-1];
            prefix[0][i]%=MOD;
        }
        for(int i=1;i<n;i++){
            for(int j=0;j<=k;j++){
                //j candies, give
                //give all to the last or all-a[i];
                long a=j-arr[i]-1>=0?prefix[i-1][j-arr[i]-1]:0;
                dp[i][j]=prefix[i-1][j]-a;
                if(dp[i][j]<0)dp[i][j]+=MOD;
                dp[i][j]%=MOD;
                prefix[i][j]=dp[i][j];
                if(j!=0)prefix[i][j]+=prefix[i][j-1];
                prefix[i][j]%=MOD;
            }
        }
        System.out.println(dp[n-1][k]);
        f.close();

        //print to System. out.println

    }

}


Measured memory_bytes: 242772
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int i=1;
		while(true){
        	String x=br.readLine();
        	if(x.equals("0")) break;
        	sb.append("Case "+i+": "+x+"\n");
        	if(i%2000==0){
        		System.out.print(sb.toString());
        		sb.setLength(0);
        	}
    		i++;
        }
		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 25180
import collections
import heapq
import math
import random
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
d = list(map(int, input().split()))
d = set(d)
while True:
    found = True
    cur = n
    while cur:
        if cur % 10 in d:
            found = False
            break
        cur //= 10
    if found:
        exit(print(n))
    n += 1


Measured memory_bytes: 9828
#include<cstdio>
#include<cctype>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int dp[5][110],n,a[5][110];
int main(){
	scanf("%d",&n);
	for(int i=1;i<3;i++)
		for(int j=1;j<=n;j++)scanf("%d",a[i]+j),dp[i][j]=max(dp[i-1][j],dp[i][j-1])+a[i][j];
	printf("%d",dp[2][n]);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a[1050];
int main()
{
	
	int n,m,sum=0;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	double gg=(sum*1.0)/(4*m);
	int sum1=0; 
	for(int i=1;i<=n;i++)
	{
		if(a[i]>=gg)
		{
			sum1++;
		}
	}
	if(sum1>=m)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	
	return 0;	
} 

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

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

  int l=s.size();
  int c1=0,c2=1,ans=0;
  while (c2 < l) {
    if (s.at(c1) != s.at(c2)) {
      s.erase(c1,2);
      l -= 2;
      ans += 2;
      c2--;
      c1--;
      if (c1<0) {
	c1 = c2;
	c2++;
      }
    }
    else {
      c1++;
      c2++;
    }
  }

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

Measured memory_bytes: 512
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    string s; cin>>s;

    vector<set<int>> alp(26);
    for(int i=0; i<n; i++){
        alp[s[i] - 'a'].emplace(i);
    }

    int q; cin>>q;
    while(q--){
        int ty; cin>>ty;
        if(ty == 1){
            int i; cin>>i;
            char c; cin>>c;
            i--;
            for(int j=0; j<26; j++){
                if(alp[j].count(i)){
                    alp[j].erase(i);
                }
            }
            alp[c - 'a'].emplace(i);
        }
        else{
            int l, r; cin>>l>>r;
            l--, r--;
            int ans = 0;
            for(int i=0; i<26; i++){
                if(alp[i].empty()) continue;
                auto itr = alp[i].lower_bound(l);
                if(itr == alp[i].end()) continue;
                ans += (*itr <= r);
            }
            cout << ans << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 24220
import scala.io.StdIn.{readInt,readLine}

object Main extends App {
  val n = readInt
  val list = for(i <- 0 until n) yield readLine.split(" ").map(_.toInt)
  val sorted = list.sortWith( (x,y) => if( x(1) == y(1) ) x(0) < y(0) else x(1) > y(1) )
  println(sorted(0)(0) + " " + sorted(0)(1))
}

Measured memory_bytes: 43940
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

int main() {
    ll A, B;
    cin >> A >> B;
    ll x = 1;
    while ((double)x * 0.08 < A + 1 && (double)x * 0.10 < B + 1) {
        if ((ll)floor((double)x * 1.08) - x == A && (ll)floor((double)x * 1.10) - x == B) {
            cout << x << endl;
            return 0;
        }
        x++;
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
def f_n(n):
    if n % 2 == 0:
        return(n // 2 % 2 ^ n)
    else:
        return((n+1) // 2 % 2)

def f_ab(A, B):
    return(f_n(A-1) ^ f_n(B))
    
    
A, B = map(int, input().split())

print(f_ab(A, B))

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

int main()
{
  int n;
  cin>>n;
  map<char,set<int> > mp;
  for (int i = 0; i < 13; ++i)
  {
    mp['S'].insert(i+1);
    mp['C'].insert(i+1);
    mp['D'].insert(i+1);
    mp['H'].insert(i+1);
  }
  for (int i = 0; i < n; ++i)
  {
    char c;
    int tmp;
    cin>>c>>tmp;
    mp[c].erase(tmp);
  }
  for (set<int>::iterator itr = mp['S'].begin(); itr != mp['S'].end(); ++itr)
  {
    cout<<"S "<<*itr<<endl;
  }
  for (set<int>::iterator itr = mp['H'].begin(); itr != mp['H'].end(); ++itr)
  {
    cout<<"H "<<*itr<<endl;
  }
  for (set<int>::iterator itr = mp['C'].begin(); itr != mp['C'].end(); ++itr)
  {
    cout<<"C "<<*itr<<endl;
  }
  for (set<int>::iterator itr = mp['D'].begin(); itr != mp['D'].end(); ++itr)
  {
    cout<<"D "<<*itr<<endl;
  }

}


Measured memory_bytes: 3096
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	X := nextInt()
	count := X / 100
	if X <= count*105 {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 640
solve a b c t
    | t == 'a' && null a = "A"
    | t == 'b' && null b = "B"
    | t == 'c' && null c = "C"
    | t == 'a' = solve (tail a) b c (head a)
    | t == 'b' = solve a (tail b) c (head b)
    | t == 'c' = solve a b (tail c) (head c)

main = do
    a <- getLine
    b <- getLine
    c <- getLine
    putStrLn $ solve a b c (head a)

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

struct UnionFind{
    vector<int> par;
    vector<int> rank;

    void init(int n) {
        par = vector<int>(n);
        rank = vector<int>(n);

        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
        }
    }

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

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (rank[x] > rank[y]) {
            par[y] = x;
        } else {
            par[x] = y;
            if (rank[x] == rank[y]) ++rank[x];
        }
    }

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

int n;
P point[55];
P s[55][55];
map<P, int> cnt; // P の出現回数


int main() {
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> point[i].first >> point[i].second;

    sort(point, point + n);

    // (sxij, syij) = (xj, yj) - (xi, yi) を計算する
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if(i >= j)
                continue;
            ll sx = point[j].first - point[i].first;
            ll sy = point[j].second - point[i].second;

            s[i][j] = make_pair(sx, sy);
            cnt[s[i][j]]++;
        }
    }

    int c_max = -1;
    P s_max;

    for(auto itr = cnt.begin(); itr != cnt.end(); ++itr) {
        P k = itr->first;
        int v = itr->second;
        if(c_max < v) {
            c_max = max(c_max, v);
            s_max = k;
        }
    }



    // その添字について，Union
    UnionFind uf;
    uf.init(n);

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if(i >= j)
                continue;

            if(s[i][j].first == s_max.first &&
               s[i][j].second == s_max.second) {
                uf.unite(i, j);
            }
        }
    }

    set<int> st;
    for (int i = 0; i < n; ++i) {
        st.insert(uf.find(i));
    }

    cout << st.size() << endl;
}

Measured memory_bytes: 384