akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1e18;

int main() {
  //
  ll n, k;
  cin >> n >> k;
  vl a(n), f(n);
  rep(i, n) { cin >> a[i]; }
  rep(i, n) cin >> f[i];
  sort(ALL(a), greater<ll>());
  sort(ALL(f));
  ll ok = a[0] * f[n - 1];
  ll ng = -1;
  while (ok - ng > 1) {
    ll mid = (ok + ng) / 2;
    // cerr << ng << ":" << ok << ":" << mid << endl;
    ll cnt = 0;
    rep(i, n) {
      ll v = f[i] * a[i];
      if (v > mid) {
        cnt += (v - mid) / f[i];
        if ((v - mid) % f[i] > 0) {
          cnt++;
        }
      }
      // cerr << " " << a[i] << "x" << f[i] << ":" << cnt << endl;
    }
    if (cnt > k) {
      ng = mid;
    } else {
      ok = mid;
    }
  }
  cout << ok << endl;
  return 0;
}


Measured memory_bytes: 3328
// luogu-judger-enable-o2
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <bits/stdc++.h>
#define gi get_int()
#define _FILE(s) freopen(#s".in", "r", stdin); freopen(#s".out", "w", stdout)
const int MAXN = 5e5;
int get_int()
{
	int x = 0, y = 1; char ch = getchar();
	while (!isdigit(ch) && ch != '-')
		ch = getchar();
	if (ch == '-') y = -1, ch = getchar();
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * y;
}

int pre[MAXN]['z' + 1], f[MAXN];

int main()
{
	std :: string str;
	std :: cin >> str;
	int n = str.size();

	for (int i = 'a'; i <= 'z'; i++) pre[n][i] = n;
	memset(f, 0x3f, sizeof(f));
	f[n + 1] = 0; f[n] = 1;
	for (int i = n - 1; i >= 0; i--) {
		for (int j = 'a'; j <= 'z'; j++)
			pre[i][j] = pre[i + 1][j];
		pre[i][str[i]] = i;
	}
	
	for (int i = n - 1; i >= 0; i--)
		for (int j = 'a'; j <= 'z'; j++)
			f[i] = std :: min(f[i], f[pre[i][j] + 1] + 1);



	int now = 0;
	for (int i = 0; i < f[0]; i++)
		for (int j = 'a'; j <= 'z'; j++) {
			if (f[now] == f[pre[now][j] + 1] + 1) {
				printf("%c", j);
				now = pre[now][j] + 1;
				break;
			}
		}

	return 0;
}


Measured memory_bytes: 98948
package main

import "fmt"

func main() {
        var a, b, k int
        fmt.Scanf("%d %d %d", &a, &b, &k)
        fmt.Printf("%d\n", findInt(a, b, k))
}

func findInt(a, b, k int) int {
        lim := min(a, b)
        count := 0
        for i := lim; i >= 1; i-- {
                if a%i == 0 && b%i == 0 {
                        count++
                }
                if count == k {
                        return i
                }
        }
        return -1
}

func min(a, b int) int {
        if a < b {
                return a
        }
        return b
}

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

double memo[3210][3210];
double ph[3210];
double pt[3210];
int n;

double solve(int at, int ch, int ct){
	
	if(at == n && ch > ct) return 1.0;
	if(at >= n ) return 0.0;
	if(memo[at][ch] != -1.0) return memo[at][ch];
	
	return memo[at][ch] = solve(at + 1 , ch + 1 , ct)*ph[at] + solve(at + 1 , ch ,ct + 1)*pt[at];
}

int main(){
	
	for(int i = 0 ; i < 3210 ; i ++)
		for(int j = 0 ; j < 3210 ; j ++)
			memo[i][j] = -1.0;
	
	scanf("%d",&n);
	
	for(int i = 0 ; i < n ; i ++){
		scanf("%lf",&ph[i]);
		pt[i] = 1.0 - ph[i];
	}
	
	printf("%.10lf\n", solve(0,0,0));
	
	return 0;
}	

Measured memory_bytes: 81152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;  
  cin >> N ;
  
  if(N%1000==0||(N%1000)%111==0||N%1110<=9){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}

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

int main(){
  int n;
  string start;
  cin >> n;
  while(n--){
    start = "";
    for(int i=0;i<30;i++){
      char s;
      cin >> s;
      start += s;
    }
    map<string,int> min_cost;
    queue<string> que;
    min_cost[start] = 0;
    que.push(start);
    while(!(que.empty())){
      string str = que.front();
      que.pop();
      if(str == "111111111222444666555333333333"){
	cout << min_cost[str] << endl;
	break;
      }
      string next = str;
      swap(next[18],next[20]);
      swap(next[0],next[27]);
      swap(next[1],next[28]);
      swap(next[2],next[29]);
      swap(next[14],next[15]);
      if(min_cost.find(next) == min_cost.end()){
	min_cost[next] = min_cost[str] + 1;
	que.push(next);
      }

      next = str;
      swap(next[9],next[11]);
      swap(next[6],next[21]);
      swap(next[7],next[22]);
      swap(next[8],next[23]);
      swap(next[12],next[17]);
      if(min_cost.find(next) == min_cost.end()){
	min_cost[next] = min_cost[str] + 1;
	que.push(next);
      }
      
      next = str;
      swap(next[15],next[17]);
      swap(next[0],next[23]);
      swap(next[3],next[26]);
      swap(next[6],next[29]);
      swap(next[9],next[20]);
      if(min_cost.find(next) == min_cost.end()){
	min_cost[next] = min_cost[str] + 1;
	que.push(next);
      }

      next = str;
      swap(next[12],next[14]);
      swap(next[2],next[21]);
      swap(next[5],next[24]);
      swap(next[8],next[27]);
      swap(next[11],next[18]);
      if(min_cost.find(next) == min_cost.end()){
	min_cost[next] = min_cost[str] + 1;
	que.push(next);
      }
    }
  }
}
	 

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

using namespace std;

const int N = (int) 1e5;
const int INF = (int) (1e9 + 1);
int h[N];
int cost[N];
int n;
int k;

int main() {
    ios_base::sync_with_stdio(false);

    cin >> n >> k;

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

    fill(cost, cost + n, INF);

    cost[0] = 0;

    for (int i = 1; i < n; i++) {
        for (int j = i - 1; j >= max(i - k, 0); j--) {
            cost[i] = min(cost[i], cost[j] + abs(h[i] - h[j]));
        }
    }

    cout << cost[n - 1] << '\n';

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<ll> Size;
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n + 1); rank.resize(n + 1); Size.resize(n + 1);
        for (int i = 0; i <= n; ++i) par[i] = i, rank[i] = 0, Size[i] = 1;
    }

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

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        Size[x] += Size[y];
        return true;
    }

    ll size(int x){
        return Size[root(x)];
    }
};

typedef pair<long double, int> l_i;

int N, M;
double x[10000], y[10000];
vector<i_i> e;
vector<l_i> v;

long double dist(i_i a) {
    auto dx = x[a.first] - x[a.second];
    auto dy = y[a.first] - y[a.second];
    dx = dx * dx;
    dy = dy * dy;
    return pow(dx + dy, 0.5);
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    for(int i = 0; i < N; i++) cin >> x[i] >> y[i];
    e.resize(M);
    long double ans = 0;
    for(int i = 0; i < M; i++) {
        cin >> e[i].first >> e[i].second;
        e[i].first--;
        e[i].second--;
        ans += dist(e[i]);
        v.push_back({dist(e[i]), i});
    }
    sort(v.begin(), v.end(), greater<l_i>());
    UnionFind uni(N);
    for(auto tmp : v) {
        int idx = tmp.second;
        if(uni.merge(e[idx].first, e[idx].second)) {
            ans -= tmp.first;
        }
    }
    cout << fixed << setprecision(20) << ans << endl;
    return 0;
}


Measured memory_bytes: 4612
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	int n;cin>>n;
	vi cnt(5,0);
	string ss="MARCH";

	rep(i,n){
		string s;cin>>s;
		rep(j,5){
			if(s[0]==ss[j]){
				cnt[j]++;
			}
		}
	}
	int ans=0;
	FOR(s1,0,2)FOR(s2,s1+1,3)FOR(s3,s2+1,4){
		ans+=cnt[s1]*cnt[s2]*cnt[s3];
	}
	cout<<ans<<endl;
	return 0;
}



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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	map<string,priority_queue<PLL>> points;
	for (int i = 0; i < n; i++) {
		string s;
		int p;
		cin >> s >> p;
		points[s].push({p,i+1});
	}

	for (auto&& var : points) {
		while (!var.second.empty()) {
			cout << var.second.top().second << endl;
			var.second.pop();
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
using namespace std;


int main(){
    int dp[100]={};
    dp[1]=1;
    dp[2]=2;
    dp[3]=4;
    for(int i=4;i<=30;i++){
        dp[i]+=dp[i-1]+dp[i-2]+dp[i-3];
    }
    while(1){
        int n;
        cin>>n;
        if(n==0){break;}
        int ans=(dp[n]+3649)/3650;
        cout<<ans<<endl;
    }
    
    
    return 0;
}



Measured memory_bytes: 3036
#include<bits/stdc++.h>
#define ll long long
#define reg register
using namespace std;
string s;
map<char,int>a;
int main()
{
    a['p']=1;
	a['d']=2;
	a['q']=3;
	cin>>s;
	s=" "+s; 
    for(reg int l=s.length()-1,i=1;i<=(l>>1)+1;i++)
	if(a[s[i]]^((a[s[l-i+1]]+2)%4))return puts("No"),0;
    return puts("Yes"),0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define rep(i,b) for(ll i=0;i<b;i++)
using namespace std;

int main() {
    ll n;
    cin>>n;
    vector<ll>a(n);
    vector<ll>b(n);
    rep(i,n){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(a.rbegin(),a.rend());
    if(a[0]==a[1]){
        rep(i,n){
            cout<<a[0]<<endl;
        }
    }else{
        rep(i,n){
            if(a[0]!=b[i])cout<<a[0]<<endl;
            else cout<<a[1]<<endl;
        }
    }
}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
    #define rep(i,n) for(int i=0;i<(n);i++)
    #define loop(i,x,n) for(int i=(x);i<(n);i++)
    #define all(x) (x).begin(),(x).end()
    #define pb push_back
    #define mp make_pair
    #define fir first
    #define sec second
    #define ub upper_bound
    #define lb lower_bound
    #define int long long
    using namespace std;
    const int MOD=1000000007;
    const int INF=1000000009;
     
     
     
    signed main(){
      string s;cin>>s;
      bool k=false;
      rep(i,s.size()-1){
        if(s[i]=='A'&&s[i+1]=='C')k=true;
      }
      cout<<(k?"Yes":"No")<<endl;
      return 0;
    }

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
using namespace std;
const int MOD = 1e9 + 7;
int n, d, dp[10000][100][2];
char k[10001];
int calc(int i, int sum, int less) {
	if (i == n) return sum == 0;
	if (dp[i][sum][less] != -1) return dp[i][sum][less];
	int res = 0;
	for (int j = 0; j <= ((less == 1) ? 9 : (k[i] - '0')); j++) {
		res = (res + calc(i + 1, (sum + j) % d, max(less, (j < k[i] - '0') ? 1 : 0))) % MOD;
	}
	return dp[i][sum][less] = res;
}
int main() {
	scanf("%s %d", k, &d);
	n = strlen(k);
	memset(dp, -1, sizeof(dp));
	int ans = (calc(0, 0, 0) - 1 + MOD) % MOD;
	printf("%d\n", ans);
	return 0;
}

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

bool p[50050];

void erato(){
	fill(p, p+50050, true);
	p[0] = p[1] = false;

	for(int i=0; i *i < 50050; i++){
		if(!p[i]) continue;
		for(int j = i+i; j < 50050; j += i){
			p[j] = false;
		}
	}
}

int main(){
	erato();
	int input;
	int ans;
	while(cin >> input, input){
		ans = 0;
		for(int i=0; i <= input/2; i++){
			if(p[i] && p[input-i]){
				if(i + input-i == input) ans++;
			}
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 1208
#include <stdio.h>

int main(void) {
	int n,i,j,k;
	int min,minp;
	int color_id[30][6];
	int color_buf[2][6];
	char color_name[12];
	int count;
	while(1) {
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<n;i++) {
			for(j=0;j<6;j++) {
				scanf("%s",color_name);
				switch(color_name[0]) {
					case 'R':
						color_buf[0][j]=0;
						break;
					case 'Y':
						color_buf[0][j]=1;
						break;
					case 'B':
						color_buf[0][j]=2;
						break;
					case 'M':
						color_buf[0][j]=3;
						break;
					case 'G':
						color_buf[0][j]=4;
						break;
					case 'C':
						color_buf[0][j]=5;
						break;
				}
			}
			for(j=0;j<6;j++)color_buf[1][j]=color_buf[0][j];
			if(color_buf[0][0]==0) {
				/* do nothing */
			} else if(color_buf[0][1]==0) {
				color_buf[1][0]=color_buf[0][1];
				color_buf[1][1]=color_buf[0][5];
				color_buf[1][5]=color_buf[0][4];
				color_buf[1][4]=color_buf[0][0];
			} else if(color_buf[0][2]==0) {
				color_buf[1][0]=color_buf[0][2];
				color_buf[1][2]=color_buf[0][5];
				color_buf[1][5]=color_buf[0][3];
				color_buf[1][3]=color_buf[0][0];
			} else if(color_buf[0][3]==0) {
				color_buf[1][0]=color_buf[0][3];
				color_buf[1][3]=color_buf[0][5];
				color_buf[1][5]=color_buf[0][2];
				color_buf[1][2]=color_buf[0][0];
			} else if(color_buf[0][4]==0) {
				color_buf[1][0]=color_buf[0][4];
				color_buf[1][4]=color_buf[0][5];
				color_buf[1][5]=color_buf[0][1];
				color_buf[1][1]=color_buf[0][0];
			} else if(color_buf[0][5]==0) {
				color_buf[1][0]=color_buf[0][5];
				color_buf[1][3]=color_buf[0][2];
				color_buf[1][5]=color_buf[0][0];
				color_buf[1][2]=color_buf[0][3];
			}
			min=10;minp=0;
			for(j=1;j<5;j++) {
				if(color_buf[1][j]<min) {
					min=color_buf[1][j];
					minp=j;
				}
			}
			for(j=0;j<6;j++)color_id[i][j]=color_buf[1][j];
			switch(minp) {
				case 1:
					/* do nothing */
					break;
				case 2:
					color_id[i][1]=color_buf[1][2];
					color_id[i][2]=color_buf[1][4];
					color_id[i][4]=color_buf[1][3];
					color_id[i][3]=color_buf[1][1];
					break;
				case 3:
					color_id[i][1]=color_buf[1][3];
					color_id[i][2]=color_buf[1][1];
					color_id[i][4]=color_buf[1][2];
					color_id[i][3]=color_buf[1][4];
					break;
				case 4:
					color_id[i][1]=color_buf[1][4];
					color_id[i][2]=color_buf[1][3];
					color_id[i][4]=color_buf[1][1];
					color_id[i][3]=color_buf[1][2];
					break;
			}
		}
		count=0;
		for(i=0;i<n;i++) {
			for(j=0;j<i;j++) {
				for(k=0;k<6;k++) {
					if(color_id[i][k]!=color_id[j][k])break;
				}
				if(k>=6){count++;break;}
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(void){
	string s;
    cin>>s;
    int q;
    cin>>q;
    bool rev = false;
    deque<char> finals;
    for(auto i:s){
        finals.push_back(i);
    }
    for(int i = 0;i < q; i++){
        int t;
        cin>>t;
        if(t == 1){
            rev = !rev;
        }
        else{
            int f;
            cin>>f;
            char c;
            cin>>c;
            if(f == 1){
                if(!rev){
                    finals.push_front(c);
                }
                else{
                    finals.push_back(c);
                }
            }
            else{
                if(!rev){
                    finals.push_back(c);
                }
                else{
                    finals.push_front(c);
                }
            }
        }
    }
    if(rev){
        for(int i = finals.size()-1; i >= 0; i--){
            cout<<finals[i];
        }
        cout<<'\n';
    }
    else{
        for(int i = 0; i < finals.size();i++){
            cout<<finals[i];
        }
        cout<<'\n';
    }
}

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

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    set<int> s;
    
    for(int i = 0; i < 3; i++)
    {
        int n;
        cin >> n;
        s.insert(n);
    }
    cout << s.size() << endl;
 
    return 0;
}

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

const int N = 1e5 + 5;

int main( )
{
    int a,b, c, d;

    cin>>a>>b;

    if(a > b)
        swap(a, b);

    int lo = a, hi = b, mid, k = 200;

    while(k--)
    {
        mid = (lo + hi) / 2;

        c = a - mid;

        if(c < 0)
            c *= (-1);

        d = b - mid;

        if(d < 0)
            d *= (-1);

        if(c == d)
            break;
        else if(c < d)
            lo = mid + 1;
        else
            hi = mid + 1;
    }

    if(c == d)
        cout<<mid<<endl;
    else
        cout<<"IMPOSSIBLE"<<endl;
}


Measured memory_bytes: 256
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	n := sc.nextRuneSlice()
	ans := []rune{}
	for _, r := range n {
		if r == '1' {
			ans = append(ans, '9')
		} else {
			ans = append(ans, '1')
		}
	}

	fmt.Fprintln(wtr, string(ans))
	wtr.Flush()
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define SIZE 200005
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

char str[SIZE];

int main()
{
	scanf("%s",&str);
	int n=strlen(str);
	for(int i=0;i<n;i++) if(str[i]=='?') str[i]='D';
	printf("%s\n",str);
}

Measured memory_bytes: 3848
import std.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

bool f(int[] xs) {
    int d = xs[1] - xs[0];
    foreach (i; 0 .. xs.length - 1) {
        if (xs[i + 1] - xs[i] != d) return false;
    }
    return true;
}

void main() {
    int n;
    while (readf("%d\n", &n), n) {
        int[] xs = readln.chomp.split(" ").map!(to!int).array;
        foreach (i; 0 .. n + 1) {
            if (f(xs[0 .. i] ~ xs[i + 1 .. $])) {
                writeln(xs[i]);
                break;
            }
        }
    }
}

Measured memory_bytes: 2060
let () =
let n, m, x = Scanf.scanf "%d %d %d\n" (fun a b c -> a, b, c) in
let lst = Array.to_list (Array.init m (fun _ -> Scanf.scanf "%d " (fun x -> x))) in
let head = List.length (List.filter (fun a -> a < x) lst) in
let tail = List.length (List.filter (fun a -> a > x) lst) in
Printf.printf "%d\n" (min head tail)

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<queue>
using lint=long long;
using namespace std;

const int dw[]={1,0,-1,0};
const int dh[]={0,-1,0,1};
const int inf=1e9;

int main()
{
	int H,W;
	char s[55][55];
	int wcnt=0;
	
	cin >> H >> W;
	for(int i=0;i<H;i++)
	{
		for(int j=0;j<W;j++)
		{
			cin >> s[i][j];
			if(s[i][j]=='.')
				wcnt++;
		}
	}
	
	queue<pair<int,int>> q;
	q.push(make_pair(0,0));
	int memo[55][55]={};
	for(int i=0;i<55;i++)
		for(int j=0;j<55;j++)
			memo[i][j]=inf;
	memo[0][0]=1;
	while(!q.empty())
	{
		pair<int,int> cur=q.front();
		q.pop();
		
		s[cur.first][cur.second]='#';
		
		for(int i=0;i<4;i++)
		{
			int nh=cur.first+dh[i];
			int nw=cur.second+dw[i];
			
			if(nh<0 || nw<0 || nh>=H || nw>=W)continue;
			if(s[nh][nw]=='.' && memo[cur.first][cur.second]+1<memo[nh][nw])
			{
				memo[nh][nw]=memo[cur.first][cur.second]+1;
				q.push(make_pair(nh,nw));
			}
		}
	}
	
	if(memo[H-1][W-1]==inf)
		cout << -1;
	else
		cout << wcnt-memo[H-1][W-1];
	cout << endl;
	return 0;
}

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

using namespace std;

int main() {
  set<char> odd{'L', 'U', 'D'};
  set<char> even{'R', 'U', 'D'};
  bool is_easy = true;

  string s;
  cin >> s;

  for (size_t i = 0; i < s.size(); i++) {
    if (i % 2 == 0) {
      auto result = even.find(s[i]);
      if (result == even.end()) {
        is_easy = false;
        break;
      }
    } else {
      auto result = odd.find(s[i]);
      if (result == odd.end()) {
        is_easy = false;
        break;
      }
    }
  }
  cout << (is_easy ? "Yes\n" : "No\n");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <regex>
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
#define EPR(msg) cerr << msg << endl;
#define AST(exp, msg) EPR(msg) assert(exp);
#define TAST(exp, msg) EPR(msg) while(!exp){}
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  int N; cin>>N;
  EPR(N)
  AST(N>0, "N>0")
  TAST(N>0, "N>0")
  int  ans = (N+1)/2;
  cout << ans << endl;


  return 0;
}


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

using namespace std;
long long sum = 0;
int main(){
      int N , K;  cin >> N >> K;
      vector<int>v(N);
      for (int i=0; i<N; ++i)  cin >> v[i];
       sort(v.begin(), v.end());
      for(int i=0; i<K; ++i) sum += v[i];

      cout << sum << endl;
      return 0;
}

Measured memory_bytes: 3616
import math
A,B = map(int, input().split())

mn = max(A/0.08,10*B)
mni = math.ceil(mn)
mx = min((A+1)/0.08,10*(B+1))
mxi = int(mx)
# print(A/0.08,(A+1)/0.08)
# print(10*B,10*(B+1))
# print(minans,maxans)
if mn <= mx and (mxi>mn and mx>mni):
    print(mni)
else:
    print(-1)

Measured memory_bytes: 3060
n,x=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
ans=0
for i,a in enumerate(A):
    if i<n-1:
        if x>=a:
            ans+=1
            x-=a
        else:
            break
    else:
        if x==a:
            ans+=1
        else:
            break
print(ans)
    

Measured memory_bytes: 2940
s = []

for i in input().split():
    if i == '+':
        a = s.pop()
        b = s.pop()
        s.append(a+b)
    elif i == '-':
        b = s.pop()
        a = s.pop()   # 引き算の順序に注意
        s.append(a-b)
    elif i == '*':
        a = s.pop()
        b = s.pop()
        s.append(a*b)
    else:
        s.append(int(i))
print(s.pop())


Measured memory_bytes: 5596
# https://atcoder.jp/contests/abc088/tasks/abc088_c

c=[list(map(int,input().split())) for _ in range(3)]

for i in range(2):
    res1=c[i+1][0]-c[i][0]
    res2=c[i+1][1]-c[i][1]
    res3=c[i+1][2]-c[i][2]
    if res1==res2==res3:continue
    else:
        print('No')
        exit()


for j in range(2):
    res1=c[0][j+1]-c[0][j]
    res2=c[1][j+1]-c[1][j]
    res3=c[2][j+1]-c[2][j]
    if res1==res2==res3:continue
    else:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, q;
  cin >> n >> q;
  queue<string> P;
  queue<int> T;
  for (int i = 0; i < n; i++){
    string p;
    int t;
    cin >> p >> t;
    P.push(p);
    T.push(t);
  }
  int t = 0;
  while (!P.empty()){
    string cp = P.front();
    int ct = T.front();
    P.pop();
    T.pop();
    if (ct <= q){
      t += ct;
      cout << cp << ' ' << t << endl;
    } else {
      ct -= q;
      t += q;
      P.push(cp);
      T.push(ct);
    }
  }
}


Measured memory_bytes: 5748
from bisect import bisect_left
from bisect import bisect_right
N = int(input())
A = sorted(map(int, input().split()))
B = list(map(int, input().split()))
C = sorted(map(int, input().split()))
r = 0
for i in range(N):
  ai = bisect_left(A, B[i])
  ci = bisect_right(C, B[i])
  r += ai * (N - ci)
print(r)

Measured memory_bytes: 105444
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
using namespace std;

void solve(){
  string s; cin >> s;
  int k; cin >> k;
  set<string> se;
  for(int i = 0; i < s.length(); i++){
    for(int j = 1; j <= min((int)s.length() - i, 5); j++){
      string str = s.substr(i, j);
      se.insert(str);
    }
  }
  int i = 0;
  for(auto itr = se.begin(); itr != se.end(); ++itr){
    if(i == k - 1) cout << *itr << endl;
    i++;
  }


  return;
}

/*void solve2(){
  string s; cin >> s;
  int k; cin >> k;
  char ch = 'a';
  for(int i = 0; i < s.length(); i++){
    if(s[i] == ch){
      for(int j = 1; j <= min(s.length() - i, 5); j++){
        string str = s.substr(i, j);
        se.insert(str);
      }
    }
  }
}*/
int main(){
  solve();
  //solve2();
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int s;
    cin >> s;
    map<int,int> mp;
    int i = 1;
    while(mp[s] != 2){
        if(mp.count(s)) mp[s]++;
        else mp[s] = 1;
        if(mp[s] == 2){
            cout << i << endl;
            return 0;
        }
        if(s%2 == 0) s /= 2;
        else s = 3*s + 1;
        i++;
    }
}

Measured memory_bytes: 256
import sys
def solve(balls):
    if distribute(balls, 0, 0): print('YES')
    else: print('NO')
  
def distribute(balls, lastR, lastL):    
    if len(balls) != 0:
        next = balls[0]
        if next>lastR:
            if distribute(balls[1:], next, lastL): return True
        
        if next>lastL:
            if distribute(balls[1:], lastR, next): return True
    else:
        return True

sys.setrecursionlimit(2**11)
size = int(input());
for i in range(size):
    balls = []
    for a in input().split(' '):
        balls.append(int(a))   
    solve(balls)

Measured memory_bytes: 7616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rep2(r, aa, bb) for (ll r = (aa)-1; r >= (bb); r--)
#define be(x) (x.begin(), x.end())
#define pb(t) push_back(t)
#define ll long long
int main()
{
	  cout << setprecision(10);
	ll n;
	cin>>n;
	cout<<((n-1)*(n))/2<<endl;
}


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

int main() {
  int N; string S, T; cin >> N >> S >> T;
  string res = "";
  for (int i = 0; i < N; i++)
    res += (S.substr(i, 1) + T.substr(i, 1));
  cout << res << endl;
}

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

const int maxN = 5000 + 9;
ll BASE;

struct StringHash {
    ll MOD;
    vector<ll> h, pw;

    StringHash(const string &s, ll M){
        int n = (int)s.size();
        h.resize(n + 1);    pw.resize(n + 1);
        MOD = M;
        pw[0] = 1;

        for(int i = 1; i <= n; i++){
            pw[i] = (pw[i - 1] * BASE) % MOD;
        }

        for(int i = 1; i <= n; i++){
            h[i] = (h[i - 1] * BASE + (s[i - 1] - 'a' + 1)) % MOD;
            //cerr << h[i] << ' ';
        }
        //cerr << '\n';
    }

    ll getHash(int i, int j){
        return (h[j] - h[i - 1] * pw[j - i + 1] + MOD * MOD) % MOD;
    }
};

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

    int n;  string s;
    cin >> n;
    cin >> s;
    BASE = 27;

    StringHash f(s, 1e9 + 7);
    StringHash g(s, 1e9 + 9);
    StringHash h(s, 1e9 + 23);

    int ans = 0;
    int lo = 1, hi = n;
    while(lo <= hi){
        int len = (lo + hi) / 2;

        bool flag = false;
        map<pair<ll, pair<ll, ll> >, int> idx;

        for(int i = 1; i + len - 1 <= n; i++){
            ll a = f.getHash(i, i + len - 1);
            ll b = g.getHash(i, i + len - 1);
            ll c = h.getHash(i, i + len - 1);
            pair<ll, pair<ll, ll> > p = make_pair(a, make_pair(b, c));

            if(idx.count(p)){
                if(i >= idx[p] + len){
                    flag = true;
                    break;
                }
            } else {
                idx[p] = i;
            }
        }

        if(flag){
            ans = len;
            lo = len + 1;
        } else {
            hi = len - 1;
        }
    }

    cout << ans << '\n';

    return 0;
}


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

long int M[101][101];
long int a[1000];
int n;
void solve(){
  for(int i=0;i<=n;i++){
     M[i][i]=0;
  }
    
  for(int l=2;l<=n;l++){
    for(int i=1;i<=n-l+1;i++){
	  int j=i+l-1;
	  M[i][j]=INT_MAX;
       	  for(int k=i;k<j;k++){
	        long int tmp = M[i][k]+M[k+1][j]+a[i-1]*a[k]*a[j];
		M[i][j] = min(M[i][j],tmp);	
	    }
	}
    }
}

int main(){ 
   cin>>n;
   int p, q;
   for(int i=0; i<n; i++){
    cin>>p>>q;
    if(i == 0){
      a[i] = p;
      a[i+1] = q;
    }else{
      a[i+1] = q;
    }
  }

//   for(int i=0;i<2*n;i++)
//	cout<<a[i]<<endl;
   solve();
// for(int i=0;i<=n;i++){
//	for(int j=0;j<=n;j++){
//	    cout<<"("<<i<<","<<j<<")"<<M[i][j]<<" ";
//	}
//	cout<<endl;
 //  }
   cout<<M[1][n]<<endl;
   return 0;
} 

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

int np[1000];
int mp[1000];
int gp[1000] = {};

int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0;i < n;i++) { cin >> np[i]; }
	for (int i = 0;i < m;i++){cin >> mp[i];}

	for (int i = 0;i < m;i++) {
		for (int j = 0;j < n;j++) {
			if (np[j] <= mp[i]) {
				gp[j]++;
				break;
			}
		}
	}

	int a = 0;
	int b;
	for (int i = 0;i < 1000;i++) {
		if (a < gp[i]) {
			a = gp[i];
			b = i + 1;
		}
	}
	cout << b << endl;

	return 0;
}

Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
#define forout(out, n) for(int i=0; i<n; i++) cout<<out[i]<<endl

int main(){
    int X; cin>>X;
    cout<<10-(X/200)<<endl;
}


Measured memory_bytes: 3624
#include<stdio.h>
#include<algorithm>
using namespace std;
#define ran 111111
#define int64 long long int
int m;
int64 t[ran],x[ran],X;

struct interval{
	int64 S,E;
	interval(){}
	interval(int64 _S,int64 _E){
		S = _S;
		E = _E;
	}
} A[ran], now[ran];

int64 inp(){
	int x;
	scanf("%d",&x);
	return x;
}
void calc_min(int64 S,int64 oS,int64 x,int64&S1,int64&oS1){
	if(S >= x){
		S1 = S - x;
		oS1 = oS;
	}else{
		S1 = 0;
		oS1 = min(oS + (x-S), X);
	}
}
void calc_max(int64 S,int64 oS,int64 x,int64&S1,int64&oS1){
	if(S + x <= X){
		S1 = S + x;
		oS1 = oS;
	}else{
		S1 = X;
		oS1 = max(oS - (S + x - X), 0LL);
	}
}
int main(){
	X = inp();
	m = inp();
	for(int i=1; i<=m; i++){
		t[i] = inp();
		x[i] = t[i] - t[i-1];
	}

	A[0] = now[0] = interval(0, X);
	for(int i=1; i<=m; i++){
		if(i%2){
			calc_min(now[i-1].S, A[i-1].S, x[i], now[i].S, A[i].S);
			calc_min(now[i-1].E, A[i-1].E, x[i], now[i].E, A[i].E);
		}else{
			calc_max(now[i-1].S, A[i-1].S, x[i], now[i].S, A[i].S);
			calc_max(now[i-1].E, A[i-1].E, x[i], now[i].E, A[i].E);
		}
	}

	for(int q=inp(); q--;){
		int64 tt = inp();
		int64 aa = inp();
		int pos = upper_bound(t,t+m+1,tt) - t - 1;
		int64 now1;
		if(aa > A[pos].E){
			now1 = now[pos].E;
		}else
		if(aa < A[pos].S){
			now1 = now[pos].S;
		}else
			now1 = now[pos].S + (aa - A[pos].S);
		int64 tt2 = tt - t[pos];
		if((pos+1)%2){
			now1 -= tt2;
		}else
			now1 += tt2;
		if(now1 < 0) now1 = 0;
		if(now1 > X) now1 = X;
		printf("%d\n",(int)now1);
	}
	return 0;
}


Measured memory_bytes: 6016
s = input()
if s == "W" * len(s):
    print(0)
elif s == "B" * len(s):
    print(0)
else:
    if s == "B" + "W" * (len(s) - 1):
        print(1)
    else:
        num = 0
        k = 1
        if s[0] == "B":
            num += 1
            while s[k] == "B":
                k += 1
        pre = "W"

        for i in range(k, len(s)):
            if pre != s[i]:
                num += 1
            pre = s[i]
        print(num)




Measured memory_bytes: 3316
import java.util.Scanner;

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

		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();

		boolean canK = false;

		outer:
		for (int row = 0; row <= n; row++) {
			for (int clm = 0; clm <= m ; clm++) {
				int black = (m - clm) * row + (n - row) * clm;
				if (black == k) {
					canK = true;
					break outer;
				}
			}
		}

		System.out.println(canK ? "Yes" : "No");
		sc.close();
	}

}


Measured memory_bytes: 23764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int a = fs.nextInt();
		int b = fs.nextInt();
		int h = fs.nextInt();
		int m = fs.nextInt();
		
		
		double w_a = 30 * (h+ (double)m/60);
		double w_b = 6 * m;
		
		double x_a = (double) a * Math.sin(Math.toRadians(w_a));
		double y_a = (double) a * Math.cos(Math.toRadians(w_a));
		
		double x_b = (double) b * Math.sin(Math.toRadians(w_b));
		double y_b = (double) b * Math.cos(Math.toRadians(w_b));
		
		//System.out.println(String.format("%f,%f", x_a, y_a));
		//System.out.println(String.format("%f,%f", x_b, y_b));
		
		double x_diff = x_a - x_b;
		double y_diff = y_a - y_b;
		
		System.out.println(Math.sqrt(x_diff * x_diff + y_diff * y_diff));
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 33332
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	vs := make([]int, n)
	for i := range vs {
		fmt.Scan(&vs[i])
	}
	min := k
	if n < min {
		min = n
	}
	var ans int
	for a := 0; a <= min; a++ {
		for b := 0; b <= min-a; b++ {
			xs := make([]int, 0, a+b)
			xs = append(xs, vs[0:a]...)
			xs = append(xs, vs[len(vs)-b:len(vs)]...)
			sort.Ints(xs)
			var (
				sum int
				d   = k - (a + b)
			)
			for _, v := range xs {
				if v < 0 && d > 0 {
					d--
					continue
				}
				sum += v
			}
			if sum > ans {
				ans = sum
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 896
#include<stdio.h>
int main(void) {
    double w,h,x,y;
    scanf("%lf %lf %lf %lf",&w, &h, &x, &y);
    double size = w*h/2.0;
    int flag;
    if(x==w/2.0 && y==h/2.0)
        flag = 1;
    else
        flag = 0;
    printf("%lf %d\n", size,flag);

}

Measured memory_bytes: 128
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi; 
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_B() {}


int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S; cin >> S;
    int L = S.size();
    char P[4] = { 'A','C','G','T' };

    int ans = 0;;
    int cnt = 0;
    REP(i,L){
        bool ok = false;
        REP(j,4){
            if (S[i] == P[j]){
                ok = true;
                break;
            }
        }
        if (ok) {
            cnt++;
            ans = max(ans, cnt);
        }
        else cnt = 0;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    long N, Y;
    cin >> N >> Y;

    for(long a = Y/10000 + 1; a >= 0; a--){
        for(long b = (Y/10000 - a + 1) * 2; b >= 0; b--){
            if((a+b)>N) continue;
            if((a * 10000 + b * 5000 + (N - a - b) * 1000) == Y){
                cout << a << ' ' << b << ' ' << (N-a-b) << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

typedef unsigned long long int ulint;
typedef long long int lint;

template<typename T>
vector<T> divisor(T n) {
  vector<T> ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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

  vector<bool> A;
  
  for (int i = 0; i < N; ++i) {
    bool a;
    cin >> a;
    A.push_back(a);
  }

  vector<ulint> B(N, 0);
  
  for (int i = N; i >= 0; --i) {
    if (A[i] == 1) {
      ++B[i];
      
      vector<ulint> divs = divisor((ulint) (i + 1));
      for (int j = 0; j < divs.size(); ++j) {
	A[divs[j] - 1] = !A[divs[j] - 1];
      }
    }
  }
  // cout << "A= ";
  // for (int i = 0; i < N; ++i) {
  //   cout << A[i] << " "; 
  // }
  // cout << endl;

  if (*max_element(A.begin(), A.end()) == 1) {
    cout << -1 << endl;
  } else {
    cout << accumulate(B.begin(), B.end(), 0) << endl;
    
    for (int i = 0; i < N; ++i) {
      if (B[i] == 1) {
      	cout << i + 1 << " ";
      }
      // cout << B[i] << " ";
    }
    cout << endl;
  }
  
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
ll n;
ll digit;
int getDigit(ll i)
{
	int dig = 0;
	while (i != 0) {
		i /= ll(10);
		dig++;
	}
	return dig;
}
void rec(vector<ll> &v, ll i)
{
	if (digit < getDigit(i)) return;
	if (v.size() == 0) {
		v.push_back(3);
		v.push_back(5);
		v.push_back(7);
		rec(v, 3);
		rec(v, 5);
		rec(v, 7);
	}
	else {
		v.push_back(i * 10 + 3); rec(v, i * 10 + 3);
		v.push_back(i * 10 + 5); rec(v, i * 10 + 5);
		v.push_back(i * 10 + 7); rec(v, i * 10 + 7);
	}
}
bool judge(ll i)
{
	string s = to_string(i);
	bool three, five, seven;
	three = five = seven = false;
	rep(i, s.size()) {
		if (s[i] == '3') three = true;
		if (s[i] == '5') five = true;
		if (s[i] == '7') seven = true;
	}
	if (three && five && seven) return true;
	return false;
}
int main()
{
	// ABC114-C, 1061, UNSOLVED, 
	cin >> n;
	digit = getDigit(n);
	vector<ll> v;
	rec(v, 0);
	vector<ll> v2;
	rep(i, v.size()) {
		if (judge(v[i])) v2.push_back(v[i]);
	}
	if (v2.size() == 0) {
		cout << 0 << endl;
		return 0;
	}
	sort(v2.begin(), v2.end());
	//rep(i, v2.size()) cout << v2[i] << endl;
	int low, high, mid;
	low = 0;
	if (n < v2[low]) {
		cout << 0 << endl;
		return 0;
	}
	high = v2.size() - 1;
	mid = (high - low) / 2;
	while (1 < high - low) {
 		if (v2[mid] <= n) low = mid;
		else high = mid;
		mid = (high + low) / 2;
	}
	cout << high << endl;
	

	return 0;
}

Measured memory_bytes: 5568
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static final long MOD = 1_000_000_007;

	public static void main(String[] args) {
		char[] S = sc.next().toCharArray();
		int N = S.length;
		int[] K = new int[N];
		for (int i = 0; i < N; i++) {
			K[i] = S[i] - '0';
		}
		int D = sc.nextInt();
		long[][] tight = new long[N + 1][D];
		long[][] free = new long[N + 1][D];
		tight[0][0] = 1;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < D; j++) {
				for (int k = 0; k < K[i]; k++) {
					free[i + 1][(j + k) % D] += tight[i][j];
					if (free[i + 1][(j + k) % D] >= MOD) free[i + 1][(j + k) % D] -= MOD;
				}
				tight[i + 1][(j + K[i]) % D] += tight[i][j];
				if (tight[i + 1][(j + K[i]) % D] >= MOD) tight[i + 1][(j + K[i]) % D] -= MOD;
				for (int k = 0; k <= 9; k++) {
					free[i + 1][(j + k) % D] += free[i][j];
					if (free[i + 1][(j + k) % D] >= MOD) free[i + 1][(j + k) % D] -= MOD;
				}
			}
		}
		System.out.println((free[N][0] + tight[N][0] + MOD - 1) % MOD);
	}
}

Measured memory_bytes: 54996
input = gets.to_i

def aaa(_val)
  if (0 == _val % 7)
    return _val / 7
  elsif (0 == _val % 5)
    return _val / 5
  elsif (0 == _val % 3)
    return _val / 3
  elsif (0 == _val % 2)
    return _val / 2
  end
  return -1
end

val1 = input
val2 = 1

if val1 == 1
  puts 'Yes'
  exit
end

loop do
  tmp = aaa(val1)
  if tmp < 0
    break
  end
  val2 = input / tmp
  val1 = tmp
  if (val1 <= 9 && val2 <= 9)
    puts 'Yes'
    exit
  end
  if val1 == 0
    break
  end
end

puts 'No'

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

long gcd(long a, long b){
    if(a==0) return b;
    if(b==0) return a;
    if(a<0) a=-a;
    if(b<0) b=-b;
    while(b>0){
        long t=a%b;
        a=b;
        b=t;
    }
    return a;
}

int main(void){
    long n, s;
    cin >> n >> s;
    vector<long> x(n);
    for(long i=0; i<n; i++){
        long t;
        cin >> t;
        x[i] = labs(t-s);
    }
    long g=0;
    for(long i=0; i<n; i++){
        g=gcd(g, x[i]);
    }
    cout << g << endl;
    return 0;
}


Measured memory_bytes: 1024
/// However long the night,
///     The dawn will break
/// ICPC next year

#include<bits/stdc++.h>
using namespace std ;
const int N = 2e3+5 ,mod = 1e9+7 ;

int n ,k ;
int mem[N][N] ,mem2[N][N][2] ;
int solve(int rem,int cur){
    if(!rem) return 1;
    if(cur==0) return 0 ;
    int&ret = mem[rem][cur] ;
    if(~ret) return ret;
    return ret = (solve(rem-1,cur) + solve(rem,cur-1))%mod;
}
int solve2(int rem,int cur,bool c){
    if(cur==0) return 1;
    if(rem==0) return cur==1 ;
    int&ret = mem2[rem][cur][c];
    if(~ret) return ret;
    if(c==0) return ret = solve2(rem-1,cur,1) ;
    return ret = (solve2(rem-1,cur,1) + solve2(rem,cur-1,0))%mod ;
}
int main(){
    cin >> n >> k ;
    int blue = k ;
    int red = n-k ;
    memset(mem,-1,sizeof mem);
    memset(mem2,-1,sizeof mem2);

    for(int i=1;i<=k;++i){
        int d = solve(blue-i,i) ;
        int c = solve2(red,i,1);
        int ans = 1ll*c%mod*d%mod ;
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 47488