akhauriyash/Code-Regression huggingface dataset:
# https://atcoder.jp/contests/abc131/tasks/abc131_e

# 最短距離が2の頂点対がちょうどK個ある
# 最短距離が2の頂点対とは→うまく定式化できないな... ちょうど一つのノードを挟んで存在する

# 基本戦略、非連結からつなげてく。全結合から切っていく。一番kが多い状態から減らす
# 一番kが多い状態→ノード0を中心として、周りに1,2,3..を連結させたスターグラフ
# まわりのノードを連結していくたびにkが一つずつ少なくなるのでK=kになるまでそれを繰り返せば良さそう

from itertools import combinations
N, K = map(int, input().split())
k_max = ((N - 1) * (N - 2)) // 2
# print(k_max)
if k_max < K:
    print(-1)
    exit()

k = k_max
ans = []
for i in range(1, N):  # ここは0based
    ans.append((1, i + 1))  # ここは1basedに直す
# スターグラフ(k_maxの状態完成)
# 一つずつ引いていく
for u, v in combinations(range(1, N), r=2):
    if k == K:
        break
    k -= 1
    ans.append((u + 1, v + 1))

print(len(ans))
for u, v in ans:
    print(u, v)


Measured memory_bytes: 43120
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int main(){
  string s,t; cin>>s>>t;
  vector<vector<ll>> dp(s.length()+1,vector<ll>(t.length()+1));
  REP(i,1,s.length()+1){
    REP(j,1,t.length()+1){
      if(s[i-1]==t[j-1]){
        dp[i][j]=dp[i-1][j-1]+1;
      }else{
        dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
      }
    }
  }
  string ans="";
  ll y=s.length(), x=t.length();
  while(1){
    if(s[y-1]==t[x-1]){
      ans+=s[y-1];
      x--,y--;
    }else{
      if(dp[y][x-1] >= dp[y-1][x]){
        x--;
      }else{
        y--;
      }
    }
    if(x==0 || y==0) break;
  }
  reverse(ans.begin(),ans.end());
  cout<<ans<<endl;
}

Measured memory_bytes: 73684
/*
-------関数一覧--------
arr1dto2d(Array) 一次元配列を二次元配列にします
pf(N)素因数分解した結果をオブジェクトで返します
gcd(a,b)最大公約数を返します
lcm(a,b)最小公倍数を返します
num(a,b)a-bを返します。ソート用です
isPrime(n)素数かどうか真偽値で返します
isNumber(n)数かどうか真偽値で返します
arrsum(arr)配列の合計値を返します
nibu(arr,n)n以下で最も大きい数の添字を返します(nを含みます)
br(input)入力を改行で区切ります
*/
const debugMode = false;
const inf = Number.MAX_SAFE_INTEGER;

function Main(input){
  input = input.split("\n");
  var sum = 0;
  var a = input[1].split(" ").map(Number);
  var b = input[2].split(" ").map(Number);
 // console.log(a,b)
  for(var i=0;i<b.length;i++){
      if(a[i]>=b[i]){
          sum+=b[i];
      }else if(b[i]-a[i]<=a[i+1]){
          sum+=b[i];
          a[i+1]-=b[i]-a[i];
          
      }else{
          sum += a[i]+a[i+1];
          a[i+1] = 0;
          
      }
    //  console.log(sum)
  }
  console.log(sum);
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 30776
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i,a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template <class T>inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}

int main()
{
    int n,m;
    cin >> n>> m;
    vector<vector<int>> v(n);
    REP(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    vector<ll> s(n,INF);
    vector<int> ans(n);
    queue<int> q;
    queue<int> mae;
    queue<int> now;
    q.push(0);
    mae.push(0);
    now.push(0);
    while(!q.empty()){
        int i=q.front();
        q.pop();
        int j=now.front();
        now.pop();
        int m=mae.front();
        mae.pop();
        if(s[i]>j){
            s[i]=j;
            ans[i]=m;
        }
        else{
            continue;
        }
        for(auto& k:v[i]){
            q.push(k);mae.push(i);now.push(j+1);
        }
    }
    cout << "Yes" << endl;
    REP(i,n-1){
        i++;
        cout << ans[i]+1 << endl;
        i--;
    }
}

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

#include<bits/stdc++.h>

using namespace std;

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

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

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

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class EReversingAndConcatenating {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, k; cin >> n >> k;
      string s; cin >> s;
      string r = s;
      reverse(r.begin(), r.end());
      string ss = s+r;

      if (k==1) {
        vector<string> vec(n+1);
        rep(i, n+1) {
          rep(j, n) {
            vec[i].push_back(ss[i+j]);
          }
        }
        sort(all(vec));
        cout << vec[0] << endl;
        return;
      }

      vector<string> vec(n+1);
      rep(i, n+1) {
        rep(j, n) {
          vec[i].push_back(ss[i+j]);
        }
        reverse(vec[i].begin(), vec[i].end());
      }
      sort(all(vec));
      int cnt = 1;
      for(int i=1; i<n; i++) {
        if (vec[0][i] == vec[0][0]) {
          cnt = i+1;
        } else {
          break;
        }
      }
      int tmp = cnt;
      k--;
      while(k--) {
        cnt *= 2;
        if (cnt >= n) {
          cnt = n;
          break;
        }
      }
      string ans;
      rep(i, cnt) {
        ans.push_back(vec[0][0]);
      }
      while(ans.size()<n) {
        ans.push_back(vec[0][tmp]);
        tmp++;
      }

      cout << ans << endl;
    }
};

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

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

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    if (v.empty()) {
        ostr << "{ }";
        return ostr;
    }
    ostr << "{" << v.front();
    for (auto itr = ++v.begin(); itr != v.end(); itr++) {
        ostr << ", " << *itr;
    }
    ostr << "}";
    return ostr;
}

int main(void){


  int A, B;
  cin >> A >> B;

  int plus = A + B;
  int minus = A - B;
  int multi = A * B;

  int tmp = max(plus, minus);
  int ans = max(tmp,  multi);
  cout << ans << endl;


  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
	char	s[100+1];
	int	c, a;
	unsigned long long	k;
	int	i;

	scanf("%s", s);
	scanf("%lld", &k);

	a = 0;
	c = 0;
	for (i = 0; i < strlen(s); ++i) {
		if (s[i] == '1') {
			c++;
		}
		else {
			a = s[i];
			break;
		}
	}

	if (k <= c) {
		a = '1';
	}
	printf("%c\n", a);

	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e+10;
const double PI = acos(-1);
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
inline double ABS(double a){return max(a,-a);}
struct Pt {
	double x, y;
	Pt() {}
	Pt(double x, double y) : x(x), y(y) {}
	Pt operator+(const Pt &a) const { return Pt(x + a.x, y + a.y); }
	Pt operator-(const Pt &a) const { return Pt(x - a.x, y - a.y); }
	Pt operator*(const Pt &a) const { return Pt(x * a.x - y * a.y, x * a.y + y * a.x); }
	Pt operator-() const { return Pt(-x, -y); }
	Pt operator*(const double &k) const { return Pt(x * k, y * k); }
	Pt operator/(const double &k) const { return Pt(x / k, y / k); }
	double ABS() const { return sqrt(x * x + y * y); }
	double abs2() const { return x * x + y * y; }
	double arg() const { return atan2(y, x); }
	double dot(const Pt &a) const { return x * a.x + y * a.y; }
	double det(const Pt &a) const { return x * a.y - y * a.x; }
	bool operator<(const Pt &a)const{return sig(x-a.x)?sig(x-a.x)<0:sig(y-a.y)<0;}
};
double tri(const Pt &a, const Pt &b, const Pt &c) { return (b - a).det(c - a); }
int convexHull(int n, Pt p[], Pt q[]) {
	int m = 0, i, r;
	sort(p, p + n);
	for (i = 0; i < n; q[m++] = p[i++]) for (; m > 1 && sig(tri(q[m - 2], q[m - 1], p[i])) <= 0; --m);
	for (i = n - 2, r = m; i >= 0; q[m++] = p[i--]) for (; m > r && sig(tri(q[m - 2], q[m - 1], p[i])) <= 0; --m);
	return m - 1;
}
int sGP(int n, Pt p[], Pt a) {
	int side = -1, i;
	p[n] = p[0];
	for (i = 0; i < n; ++i) {
		Pt p0 = p[i] - a, p1 = p[i + 1] - a;
		if (sig(p0.det(p1)) == 0 && sig(p0.dot(p1)) <= 0) return 0;
		if (p0.y > p1.y) swap(p0, p1);
		if (sig(p0.y) <= 0 && 0 < sig(p1.y) && sig(p0.det(p1)) > 0) side = -side;
	}
	return side;
}
double x[1100];
double y[1100];
Pt p[1100];
Pt tmp[1100];
Pt con[1100];
int main(){
	int a;
	scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%lf%lf",x+i,y+i);
	for(int i=0;i<a;i++)p[i]=Pt(x[i],y[i]);
	bool ok=true;
	for(int i=1;i<a-1;i++){
		for(int j=0;j<=i;j++)tmp[j]=p[j];
		int m=convexHull(i+1,tmp,con);
		if(sGP(m,con,p[i+1])==1)ok=false;
	}
	//if(ok){printf("Possible\n");return 0;}
	reverse(p,p+a);
	//ok=true;
	for(int i=1;i<a-1;i++){
		for(int j=0;j<=i;j++)tmp[j]=p[j];
		int m=convexHull(i+1,tmp,con);
		if(sGP(m,con,p[i+1])==1)ok=false;
	}
	if(ok){printf("Possible\n");return 0;}
	printf("Impossible\n");
}

Measured memory_bytes: 1116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
#define pb push_back
#define mp make_pair
#define PF first
#define PS second
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
#define OUT(x) cout << x << endl;
#define OUTD(x) cout << fixed << x << endl;
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 100000007;
const ll INF = 10e9;
#define PI 3.14159265369;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll ddx[8] = {1,1,1,-1,-1,-1,0,0};
ll ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  IN(ll,N);
  IN(ll,M);
  A2IN(ll,S,ll,C,M);
  vll ans(N,INF);
  REP(i,M){
    if((ans.at(S.at(i)-1) != INF && ans.at(S.at(i)-1) != C.at(i))||(S.at(i) == 1 && C.at(i) == 0LL && N != 1)){
      OUT(-1);
      return 0;
    }
    else
      ans.at(S.at(i)-1) = C.at(i);
  }
  REP(i,N){
    if(i == 0 && ans.at(i) == INF && N != 1){
      cout << 1;
      continue;
    }
    if(ans.at(i) == INF)
      cout << 0;
    else
      cout << ans.at(i);
  }
  OUT("");
}



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

int main(void)
{
    char s[11];
    scanf("%s", s);

    if (s[0] == 'A') {
        int f = 0;
        int cPosition;
        for (int i = 2; i < strlen(s)-1; i++) {
            if (s[i] == 'C') {
                cPosition = i;
                f++;
            }
        }
        if (f == 1) {
            for (int i = 1; i < strlen(s); i++) {
                if (i == cPosition)
                    continue;
                else {
                    if (isupper(s[i])) {
                        puts("WA");
                        return 0;
                    }
                }
            }
            puts("AC");
            return 0;
        }
    }
    puts("WA");
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,k,q,a[2600],mi = INF;
	bool ok[2600];
	vector<P> vec;
	cin >> n >> k >> q;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		ok[i] = true;
		vec.pb(P(a[i],i));
	}
	sort(all(vec));
	for(P p : vec){
		priority_queue<int,vector<int>,greater<int>> que,que2;
		for(int j = 0;j < n;j++){
			if(ok[j]) que2.push(a[j]);
			else{
				while(que2.size() >= k){
					que.push(que2.top());
					que2.pop();
				}
				while(!que2.empty()) que2.pop();
			}
		}
		while(que2.size() >= k){
			que.push(que2.top());
			que2.pop();
		}
		int ma = 0;
		for(int j = 0;j < q;j++){
			if(que.empty()){
				ma = INF;
				break;
			}
			chmax(ma,que.top());
			que.pop();
		}
		chmin(mi,ma - p.first);
		ok[p.second] = false;
	}
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 384
n=int(input())
s=input()
ans=0
for i in range(1,n):
    cnt=0
    a=list(set(list(s[0:i])))
    b=list(set(list(s[i:n])))
    if len(a)<len(b):
        for j in range(len(a)):
            if a[j] in b:
                cnt+=1
        ans=max(ans,cnt)
    else:
        for j in range(len(b)):
            if b[j] in a:
                cnt+=1
        ans=max(ans,cnt)
print(ans)

Measured memory_bytes: 8980
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int h,w;
	int ans=0;
	cin >>h>>w;
	vector<string>s(h);
	rep(i,h){
		cin>>s[i];
	}
	vector<vector<int>> suma(h, vector<int>(w, 0)), sumb(h, vector<int>(w, 0)), sumc(h, vector<int>(w, 0)), sumd(h, vector<int>(w, 0));
	rep(i,h){
		rep(j,w){
			if(s[i][j]=='#'){
				suma[i][j]=0;
				sumc[i][j]=0;
			}else{
				if(i!=h-1){
					suma[i+1][j]=suma[i][j]+1;
				}
				if(j!=w-1){
					sumc[i][j+1]=sumc[i][j]+1;
				}
			}
		}
	}
	rrep(i,h){
		rrep(j,w){
			if(s[i][j]=='#'){
				sumb[i][j]=0;
				sumd[i][j]=0;
			}else{
				if(i!=0){
					sumb[i-1][j]=sumb[i][j]+1;
					
				}
				if(j!=0){
					sumd[i][j - 1] = sumd[i][j] + 1;
				}
			}
		}
	}
	int add=0;
	rep(i,h){
		rep(j,w){
			if(s[i][j]=='.'){add=1;}else{add=0;}
		//	clog << suma[i][j] + sumb[i][j] + sumc[i][j] + sumd[i][j] <<endl;
			chmax(ans, suma[i][j] + sumb[i][j] + sumc[i][j] + sumd[i][j]+add);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 67200
import math
n=int(input())
d=[list(map(int,input().split())) for i in range(n)]
D=[]
ans=[]

def kaijou(x):
  if x==1:
    return x
  return x*kaijou(x-1)

N=kaijou(n)
NN=kaijou(n-1)

for i in range(n):
  for j in range(n):
    if i!=j :
      D.append(math.sqrt((d[i][0]-d[j][0])**2+ (d[i][1]-d[j][1])**2))
print(sum(D)*(NN)/N)

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

typedef long long ll;
const int maxn=300+10;
int n,m;
char s[maxn][maxn];
ll ans;

inline void work(){
	static int a[maxn<<1];
	for(int i=1,x,y,z;i<=n;++i,memset(a,0,sizeof(a)))
		for(int j=1;j<=m;++j){
			x=j-1,y=j+1,z=i-1;
			while(x&&y<=m&&z){
				if(s[i][x]=='#'&&s[i][y]=='#'&&s[z][j]=='#')
					++ans;
				--x;++y;--z;
			}
			x=j+1,y=i+1;
			while(x<=m&&y<=n){
				if(s[i][x]=='#'&&s[y][j]=='#'&&i+j-x+j>=0&&i+j-x+j<maxn<<1)
					ans+=a[i+j-x+j];
				++x;++y;
			}
			for(int k=1;k<i;++k)
				if(s[k][j]=='#')
					++a[k+j];
		}
}
inline void rotate(){
	static char t[maxn][maxn];
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			t[m-j+1][i]=s[i][j];
	swap(n,m);
	memcpy(s,t,sizeof(s));
}

int main(){
	cin>>n>>m;
	for(int i=1;i<=n;++i)
		cin>>s[i]+1;
	for(int i=1;i<=4;++i,rotate())
		work();
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <limits>
using namespace std;
int main() {
	int a, b, c,d,out;
	cin >> a >> b;
	out = 0;
	if (a > b) {
		c = b;
		for (int i = 1; i < a + 1; i++) {
			d = pow(10, i);
			out += d*c/10;
		}
	}
	else {
		c = a;
		for (int i = 1; i < b + 1; i++) {
			d = pow(10, i);
			out += d*c/10;
		}
	}
	cout << out << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int inf=1e9,mod=1e9+7;
typedef long long ll;
int read() {
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
	while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
main() {
	int n=read(),m=read();
	if(n<=5) puts("0"),exit(0);
	if(n<=12&&n>=6)
		cout<<m/2;
	else cout<<m;
}


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

int main() {
    //freopen("../input1.txt", "r", stdin);
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    int sum = a + b + c;

    int result = 0;
    while (result >= 0) {
        if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1)
            break;
        else if (a == b && b == c) {
            result = -1;
            break;
        }
        a = (sum - a) / 2;
        b = (sum - b) / 2;
        c = (sum - c) / 2;
        result++;
    }


    printf("%d\n", result);
    return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll h, w;
  cin >> h >> w;
  vector<string> s(h);
  REP(i, h)
    cin >> s[i];

  vector<vll> m(h, vll(w, INF));
  REP(i, h){
    REP(j, w){
      if(s[i][j] == '#')
        m[i][j] = 0;
    }
  }

  REP(i, h){
    REP(j, w-1)
      m[i][j+1] = min(m[i][j]+1, m[i][j+1]);

    for(ll j = w-1; j >= 1; j--)
      m[i][j-1] = min(m[i][j]+1, m[i][j-1]);
  }

  REP(j, w){
    REP(i, h-1)
      m[i+1][j] = min(m[i][j]+1, m[i+1][j]);

    for(ll i = h-1; i >= 1; i--)
      m[i-1][j] = min(m[i][j]+1, m[i-1][j]);
  }

  ll ans = 0;
  REP(i, h){
    REP(j, w)
      ans = max(ans, m[i][j]);
  }

  cout << ans << endl;

}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    int ans = 0;
    for(int i = 1, x; i <= m; i++) {
        scanf("%d", &x);
        ans += x;
    }
    if(n >= ans) printf("%d\n", n - ans);
    else printf("-1\n");
    return 0;
}


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

int tax(int x, int r){
    return x*(100+r)/100;
}

using namespace std;
int toff(int v, int r){
    for(int i=v*100/(100+r); ; i++){
        if(tax(i,r) > v){
            if(tax(i-1,r) == v){
                return i-1;
            }else{
                break;
            }
        }
    }
    return -1;
}

int main(){
    int x,y,s;
    while(1){
        cin >> x >> y >> s;
        if(x==0) break;

        int maxval=0;
        for(int i=1; i<=s/2; i++){
            int max0x=toff(i,x);
            int max0y=toff(s-i,x);
            if(max0x==-1 || max0y==-1){
                continue;
            }
            maxval = max( tax(max0x, y) +tax(max0y, y), maxval);
        }
        cout << maxval << endl;
    }
    return 0;
}

Measured memory_bytes: 3016
r, c = map(int,input().split())

A = [list(map(int, input().split())) for i in range(r)]

B = [[0 for i in range(c+1)] for j in range(r+1)]

for i in range(0, r):
  for j in range(0, c):
    B[i][j] = A[i][j]

for i in range(0,r):
  for j in range(0, c):
    B[i][c] += A[i][j] 

for i in range(0, c+1):
  for j in range(0, r):
    B[r][i] += B[j][i]
    
for i in range(0, r+1):
  print(*B[i])


Measured memory_bytes: 6268
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.Set;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            String s = in.next();
            int k = in.nextInt();
            PriorityQueue<String> pq = new PriorityQueue<>(Comparator.reverseOrder());
            Set<String> vis = new HashSet<>();
            for (int i = 0; i < s.length(); i++) {
                for (int j = 1; j <= k; j++) {
                    if (i + j <= s.length()) {
                        String sub = s.substring(i, i + j);
                        if (!vis.contains(sub)) {
                            vis.add(sub);
                            pq.add(s.substring(i, i + j));
                            if (pq.size() > k) {
                                pq.poll();
                            }
                        }
                    }
                }
            }
            out.println(pq.poll());
        }

    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                String line = null;
                try {
                    line = br.readLine();
                } catch (IOException e) {
                }
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;

#define Endl endl

/*--------------------template--------------------*/


int main() {
    vi v(3);
    REP(i,3) {
        cin >> v[i];
    }
    cin >> n;
    sort(ALL(v));
    cout << v[0] + v[1] + v[2] * pow(2, n) << endl;
}

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

typedef long long ll;

#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back

const long double PI = acos(-1);

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll GetDigit(ll num) {return log10(num)+1;}

int main(){
  ll n;
  cin >> n;
  vector<ll> x(n);
  ll xmin = 100000000000000, xmax = 0;
  for(ll i = 0; i < n; i++){
    cin >> x[i];
    xmin = min(xmin, x[i]);
    xmax = max(xmax, x[i]);
  }

  // cout << xmax << " " << xmin << endl;

  ll ans = 1000000000000000000;
  for(ll i = xmin; i <= xmax; i++){
    ll minans = 0;
    for(ll j = 0; j < n; j++){
      minans += pow(x[j] - i, 2);
    }
    ans = min(minans, ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll mod = 1000000007;
char c[15][15];
char d[15][15];
int main() {
	int h, w, k;
	cin >> h >> w >> k;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> c[i][j];
		}
	}
	ll count = 0;

	for (int x = 0; x < (1 << h); x++) {
		for (int y = 0; y < (1 << w); y++) {
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					d[i][j] = c[i][j];
				}
			}
			for (int i = 0; i < h; i++) {
				if (x & (1 << i)) {
					for (int j = 0; j < w; j++) {
						d[i][j] = 'R';
					}
				}
			}
			for (int i = 0; i < w; i++) {
				if (y & (1 << i)) {
					for (int j = 0; j < h; j++) {
						d[j][i] = 'R';
					}
				}
			}
			ll kcount = 0;
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (d[i][j] == '#') {
						kcount++;
					}
				}
			}
			if (kcount == k) {
				count++;
			}
			kcount = 0;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

using namespace std;
typedef long long int64;

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

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

  vector<int64> cum(n);
  cum[0]=a[0];
  for(int i=1;i<n;i++){
    cum[i]=cum[i-1]+a[i];
  }

  unordered_map<int64,int64> count;
  for(auto v:cum){
    if(count.find(v)==count.end()){
      count[v]=1;
    }else{
      count[v]++;
    }
  }

  int64 result=0;
  if(count.find(0)!=count.end()){
    result+=count[0];
  }
  for(auto p:count){
    if(p.second<=1) continue;
    result+=(int64)(p.second)*(p.second-1)/2;
  }
  cout<<result<<endl;






  return 0;
}

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

const int N = 1e5+5, MOD = 1e9+7;
int dp[N][2];
std::vector<int> graph[N];

void add_self(int& a, int b) {
  a += b;
  if (a >= MOD)
    a -= MOD;
}

void multiply_self(int& a, int b) {
  a = (1LL * a * b) % MOD;
}

int f(int v, int p, bool color) {
  if (dp[v][color] != -1)
    return dp[v][color];

  int ans = 1;

  for (int u : graph[v]) {
    if (u != p) {
      int tmp = 0;
      add_self(tmp, f(u, v, 0));
      if (color == 0)
        add_self(tmp, f(u, v, 1));

      multiply_self(ans, tmp);
    }
  }

  return dp[v][color] = ans;
}

int32_t main() {
  int n;
  scanf("%d", &n);

  for (int i = 0; i < n-1; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  memset(dp, -1, sizeof dp);
  int ans = f(1, -1, 0);
  add_self(ans, f(1, -1, 1));

  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 14848
while line = gets
  result = ""
  data = line.chomp.split(//)
  i = 0
  while i < data.size
    if data[i] == "@"
      result +=  data[i+2] * data[i+1].to_i
      i += 2
    else
      result += data[i]
    end
    i += 1
  end
  puts result
end

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

using Matrix = vector< vector<int> >;
const int INF = 1 << 30;
int W, H, ans = 0;

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

void dfs(Matrix &mat, int turn, int x, int y) {
   if (turn > 10) return;

   for (int i = 0; i < 4; i++) {
      int nx = x + dx[i], ny = y + dy[i];
      if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
      if (mat[nx][ny] == 1) continue;

      nx -= dx[i], ny -= dy[i];
      while (1) {
         nx += dx[i], ny += dy[i];
         if (nx < 0 || nx >= H || ny < 0 || ny >= W) {
            break;
         } else if (mat[nx][ny] == 3) {
            ans = min(ans, turn);
            break;
         } else if (mat[nx][ny] == 1) {
            mat[nx][ny] = 0;
            dfs(mat, turn+1, nx-dx[i], ny-dy[i]);
            mat[nx][ny] = 1;
            break;
         }
      }
   }
}

int main() {
   while (cin >> W >> H, W) {
      ans = INF;
      Matrix mat(H, vector<int>(W));

      int x = 0, y = 0;
      for (int i = 0; i < H; i++) {
         for (int j = 0; j < W; j++) {
            cin >> mat[i][j];
            if (mat[i][j] == 2) {
               x = i, y = j;
            }
         }
      }

      dfs(mat, 1, x, y);
      cout << (ans == INF ? -1 : ans) << endl;
   }

   return 0;
}


Measured memory_bytes: 3156
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, q, a, b, p, x;
string str;
vector<ll> tree[200008];
ll cnt[200008];

void dfs(ll from, ll at, ll cum){
	cnt[at] += cum;
	for(ll i = 0; i < tree[at].size(); i++){
		if(tree[at][i] != from){
			dfs(at, tree[at][i], cnt[at]);
		}
	}
}

int main(){
	cin >> n >> q;

	memset(cnt, 0, sizeof(cnt));
	
	for(ll i = 1; i <= n-1; i++){
		cin >> a >> b;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}	
	
	for(ll k = 1; k <= q; k++){
		cin >> p >> x;
		cnt[p] += x;
	}
	
	dfs(-1, 1, 0);
	for(ll i = 1; i < n; i++){
		cout << cnt[i] << " ";
	}
	cout << cnt[n] << endl;
	return 0;
}

Measured memory_bytes: 24320
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#define SNPI 2019810931
using namespace std;

struct Node{
  int key;
  Node *right,*left,*parent;
};

Node *T=(Node*)malloc(sizeof(Node));

void insert(Node *T, int u){
  Node *y=nullptr;
  Node *x=T;
  while(x!=nullptr){
    y=x;
    if(u < x->key) x=x->left;
    else x=x->right;
  }
  Node *z=(Node*)malloc(sizeof(Node));
  z->parent=y;
  z->key=u;
  z->right=nullptr;
  z->left=nullptr;
  if(y==nullptr) T=z;
  else if (z->key < y->key) y->left=z;
  else y->right=z;
}

void inorder(Node *T){
  if(T==nullptr) return;
  inorder(T->left);
  if(T->key<SNPI)
    cout << " " << T->key;
  inorder(T->right);
}

void preorder(Node *T){
  if(T==nullptr) return;
  if(T->key<SNPI)
    cout << " " << T->key;
  preorder(T->left);
  preorder(T->right);
}

int main(){
  int n,num;
  string command;
  T->key=SNPI;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> command;
    if(command=="insert") {
      cin >> num;
      insert(T,num);
    }
    else{
      inorder(T);
      cout << endl;
      preorder(T);
      cout << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 26612
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
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);
}
/*-------------------------------------------*/

int n;
int a[100001];
string s;

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

    cin >> n >> s;
    for(int a0 = 0; a0 <= 1; a0++) {
        a[0] = a0;
        for(int a1 = 0; a1 <= 1; a1++) {
            a[1] = a1;
            for(int i = 1; i < n; i++) {
                if(a[i] ^ s[i] == 'o')
                    a[i + 1] = 1 - a[i - 1];
                else
                    a[i + 1] = a[i - 1];
            }
            if(a[n] == a[0] && (a[0] ^ s[0] == 'o' ^ a[1] == a[n - 1])) {
                for(int i = 0; i < n; i++) {
                    if(a[i])
                        cout << 'S';
                    else
                        cout << 'W';
                }
                return 0;
            }
        }
    }
    cout << -1;

    return 0;
}

Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int i,j;
	int s,w;
	cin>>s>>w;
	if(s<=w) cout<<"unsafe"<<endl;
	else cout<<"safe"<<endl;

}

Measured memory_bytes: 3640
/*==============================================*\
Codeforces ID:    mdshihab
                                                  |
Name:     Md. Shihabul Minhaz                     |
Study:      CSE, JKKNIU                           |
Address:  Trishal, Mymensingh, Bangladesh         |
                                                  |
 mail:   mdshihabul20171@gmail.com                |
 FB  :   fb.com/mdshihabul.minhaz.7               |
 github: Shihabulminhaz                           |
stopstalk :  mdshihab                             |
                                                  |
@uthor   Md. Shihabul Minhaz (shihab)             |
\*===============================================*/


#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void FI()
{
#ifndef ONLINE_JUDGE
    freopen("C:\\Users\\SHIHAB\\Desktop\\input.in","r",stdin);
#endif // ONLINE_JUDGE
}

int main()
{
    fast
    FI(); /// skip this line for compile
    ll n;
    cin >> n;
    cout << (n*(n-1))/2 << endl;
    return 0;
}



Measured memory_bytes: 3632
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    vector<bool> bh(h), bw(w);
    vector< vector<char> > a(h, vector<char>(w));
    for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j) {
        cin >> a.at(i).at(j);
        if (a.at(i).at(j) - '.') {
            bh.at(i) = 1;
            bw.at(j) = 1;
        }
    }
    for (int i = 0; i < h; ++i) {
        if (bh.at(i)) {
            for (int j = 0; j < w; ++j) if (bw.at(j)) cout << a.at(i).at(j);
            cout << endl;
        }
    }
    return 0;
}


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

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

using namespace std;

// ABC103-B - String Rotation
int main()
{
    string S, T;
    cin >> S >> T;

    size_t size = S.length();

    string ans = "No";
    RPT(i, size) {
        bool hit = true;
        RPT(j, size) {
            if (S[(i+j)%size] != T[j]) {
                hit = false;
                break;
            }
        }
        if (hit) {
            ans = "Yes";
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
<>;@t=glob<>;@v=glob<>;while(@v){($m+=$t[@v-$_])-=$-=$m-$v[@v-$_]for($m=0)..$#v;$V="@v"<$m?"@v"-$V<"@t"?($\+=("@v"**2-$V**2)/2+("@t"-"@v"+$V)*"@v","@v"):($\+="@t"*($V+"@t"/2),$V+"@t"):$m-$V>"@t"?($\+="@t"*($V+"@t"/2),$V+"@t"):($u=("@t"+$V+$m)/2)>"@v"?($\+=("@v"**2*2-$V**2-$m**2)/2+2*($u-"@v")*"@v",$m):($\+=($u**2-$V**2+$u**2-$m**2)/2,$m);shift@t;shift@v}print

Measured memory_bytes: 896
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string hoge = Console.ReadLine();

            int len = hoge.Length;
		int ans =0;
            for(int i=0;i<len/2;i++){
                    
                    if(hoge[i] != hoge[len-1-i]){
						ans++;
                    }

            }

	Console.WriteLine(ans);


            
        }
    }
}


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

int main(){

   int n;
   cin >> n;
   for(int i = n; ; i++){
      bool ok = true;
      for(int k = 2; k*k <= i; k++)
         if(i % k == 0) {
            ok = false;
            break;
         }
      if(i < 2) ok = false;
      if(ok)
         return cout << i << endl, 0;
   }

   return 0;
}

Measured memory_bytes: 256
// A

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll MOD=1e9+7;
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};

int main(){
  string s;
  cin>>s;
  int a;
  for (int i(0);i<s.size();i++){
    if (s[i] == '+') a++;
    else a--;
  }
  cout << a << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fir first
#define sec second
const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
int n;
pii p[maxn];
int main() {
	scanf("%d",&n);
	for(int i = 1,x,y; i <= n; i++) {
		scanf("%d%d",&x,&y);
		p[i] = pii(x + y,x - y);
	}
	sort(p + 1,p + n + 1);
	int r = -inf,ans = 0;
	for(int i = 1; i <= n; i++) {
		if(p[i].second >= r) ans++,r = max(r,p[i].first);
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	int heights[n];
	for(int i = 0;i<n;i++){
		cin >> heights[i];
	}
	int dp[n];
	dp[0] = 0;
	dp[1] = abs(heights[1] - heights[0]);

	for(int i = 2; i < n;i++){
		dp[i] = min(dp[i-2] + abs(heights[i-2] - heights[i]), dp[i-1] + abs(heights[i-1] - heights[i]));
	}
	cout << dp[n-1] << "\n";
	return 0;
}

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

void fnOutput(const vector<int> &argviSort, int argiSortCnt)
{
  for (int i = 0; i < argviSort.size(); i++)
  {
    if (i) cout << " ";
    cout << argviSort[i];
  }
  cout << endl;
  cout << argiSortCnt << endl;
}

void fnBubbleSort(vector<int> &argviSort, int &argiSortCnt)
{
  int ixSorting = 0;
  bool bSorting = true;

  while (bSorting)
  {
    bSorting = false;
    for (int i = argviSort.size() - 1; i > ixSorting; i--)
    {
      if (argviSort[i] < argviSort[i - 1])
      {
        bSorting = true;
        swap(argviSort[i], argviSort[i - 1]);
        argiSortCnt++;
      }
    }
    ixSorting++;
  }
}
    
int main()
{
  int iSortCnt = 0;
  vector<int> viSort;
  int iMaxSize;
  
  cin >> iMaxSize;
  for (int i = 0; i < iMaxSize; i++)
  {
    int iNum;
    cin >> iNum;
    viSort.push_back(iNum);
  }

  fnBubbleSort(viSort, iSortCnt);
  fnOutput(viSort, iSortCnt);

  return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#define MOD 1000000007
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;

signed main(){
    int n;
    cin>>n;
    int a[114514];
    for(int i=0;i<n;i++)cin>>a[i];
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        int k;
        cin>>k;
        cout<<(int)binary_search(a,a+n,k)<<endl;
    }
    return 0;
}



Measured memory_bytes: 3904
def remove_row(l):
  ret = []
  for row in l:
    s = row[0]
    if any([e == "#" for e in s]):
      ret.append(row)
      
  return ret

def remove_col(l,w):
  num_row = len(l)
  num_col = w
  ret = [[""] for _ in range(num_row)]
  for i in range(num_col):
    if any([l[j][0][i] == "#" for j in range(num_row)]):
      for k in range(num_row):
        ret[k] = [ret[k][0] + l[k][0][i]]
        
  return ret


h, w = map(int, input().split())
l = [input().split() for _ in range(h)]

l = remove_row(l)
l = remove_col(l,w)
for e in l:
  print(e[0])

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
typedef long long ll;
const ll MAX_N = 10 ^ 5;
ll N, M;
//ll a[MAX_N];
//ll b[MAX_N];
vector<pair<ll, ll> > p;
void solve(){
    sort(p.begin(),p.end());
    ll i=-1;
    ll ans=0;
    while(M>0){
        i++;
        ans+=(ll)p[i].first*p[i].second;
        M-=p[i].second;
    }
    ans+=(ll)M*p[i].first;
    cout<<ans<<'\n';
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    for (ll i = 0; i < N; i++){
        ll a, b;
        cin>>a>>b;
        p.push_back(make_pair(a,b));
    }
    solve();
}

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

int main(){
  int x;
  cin >> x;
  
  int num=0,max=0;
  for(int b=1; b<=1000; b++){
	for(int p=2; p<=1000; p++){
      num = pow(b,p);
      if(num<=x && max<num) max = num;
    }
    if(num>=x) break;
  }
  cout << max << endl;
}

Measured memory_bytes: 256
import java.util.*;

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

	public static void main(String[] args) {
		new Main();
	}

	public Main() {
		new aoj0158().doIt();
	}
	class aoj0158 {
		int gu(int n){
			return n/2;
		}
		
		int ki(int n){
			return (n*3)+1;
		}
		
		void doIt() {
			while(true){
				int n = sc.nextInt();
				if(n == 0)break;
				int cnt = 0;
				while(true){
					if(n == 1)break;
					if(n % 2 == 0)n = gu(n);
					else n = ki(n);
					cnt++;
				}
				System.out.println(cnt);
			}
		}
	}
}

Measured memory_bytes: 17204
/**
 * C - Average Length
 * https://atcoder.jp/contests/abc145/tasks/abc145_c
 **/
#include<iostream>
#include<math.h>
#include<vector>
#include<iomanip>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<pair<int, int>> m(N);
    for(int i=0; i<N; i++) {
        int xi, yi;
        cin >> xi >> yi;
        m[i] = pair<int, int>(xi, yi);
    }

    double sum_d = 0.0;
    for(int i=0; i<N; i++) {
        for(int j=i; j<N; j++) {
            if(i == j) continue;
            sum_d += sqrt((double)pow((m[i].first - m[j].first), 2.0) + (double)pow((m[i].second - m[j].second), 2.0));  
        }
    }

    int root_num = 1;
    for(int i=1; i<N+1; i++) {
        root_num = root_num * i;
    }
    cout << setprecision(10) << 2.0 * sum_d / N << endl;
}

Measured memory_bytes: 256
N, x = [int(_) for _ in input().split()]

A = list(range(N + 1, 2 * N)) + list(range(1, N + 1))
if x in [1, 2 * N - 1]:
    print('No')
else:
    print('Yes')
    if x > N:
        A[x - N - 1], A[N - 1] = A[N - 1], A[x - N - 1]
    else:
        A[x + N - 2], A[N - 1] = A[N - 1], A[x + N - 2]
    print(*A, sep='\n')


Measured memory_bytes: 15672
#include <iostream>
#include <vector>
using namespace std;
 
int main(){
    int n,k,q;
    cin >> n >> k >> q;
    vector<int> a(q),p(n,k-q);
    for(int i = 0; i < q; i++) cin >> a[i];
    for(int i = 0; i < q; i++) p[a[i]-1]++;
    for(int i = 0; i < n; i++){
        if(p[i] <= 0) cout << "No" <<endl;
        else cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define p(x,y) cout<<fixed<<setprecision(y)<<x<<"\n";
#define PI 3.1415926535897
#define debug(x) cout<<" [ " << #x << " is: " << x << " ] "<<endl;
#define mod 1000000007;

int main()
{
    Fast;
    string s;
    cin >> s;
    if(s[s.length() - 1] == 's')s += "es";
    else s += "s";
    cout << s;
    return 0;
}


Measured memory_bytes: 3660