akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <sstream>
#include <complex>
#include <ctime>
#include <cassert>
#include <functional>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;

#define REP(i,s,t) for(int i=(s);i<(t);i++)
#define FILL(x,v) memset(x,v,sizeof(x))

const ll INF = (ll)1E18;
#define MAXN 100005

int N, M, a[MAXN];
struct event {
  int y, type, dir, save; // type 0: enter, type 1: exit, dir 1: up, dir -1: down
  event(int _y, int _type, int _dir, int _save): y(_y), type(_type), dir(_dir), save(_save) {}
  bool operator < (const event &ano) const {
    if (y != ano.y) return y < ano.y;
    return type < ano.type;
  }
};
int main() {
 // freopen("input", "r", stdin);
  cin >> N >> M;
  ll totCost = 0;
  vector<event> es;
  ll ans = INF, uping=0, downing=0, saving=0;
  REP(i,0,N) {
    scanf("%d", a+i); a[i]--;
    if (i) {
      if (a[i] > a[i-1]) {
        totCost += a[i] - a[i-1];
        es.push_back(event(a[i-1], 0, 1, 0));
        es.push_back(event(a[i], 1, 1, a[i]-a[i-1]));
      } else if (a[i] < a[i-1]) {
        totCost += M - a[i-1] + a[i];
        es.push_back(event(a[i], 1, -1, M-a[i-1]+a[i]));
        es.push_back(event(a[i-1], 0, 1, 0));
        downing++;
        saving += M - a[i-1];
      }
    }
  }
  sort(es.begin(), es.end());
  int ei = 0;
  REP(m,0,M) {
    ll sol = totCost - saving + uping + downing;
    ans = min(ans, sol);
    while (ei < es.size() && es[ei].y == m && es[ei].type == 0) {
      uping++;
      ei++;
    }
    while (ei < es.size() && es[ei].y == m && es[ei].type == 1) {
      if (es[ei].dir == 1) uping--;
      else downing--;
      saving -= es[ei].save;
      ei++;
    }
    saving += uping + downing;
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll w,h,n; cin>>w>>h>>n;
    ll x1=0,x2=w,y1=0,y2=h;
    rep(i,n){
        ll x,y,a; cin>>x>>y>>a;
        if(a==1){
            x1=max(x,x1);
        }else if(a==2){
            x2=min(x2,x);
        }else if(a==3){
            y1=max(y,y1);
        }else{
            y2=min(y,y2);
        }
    }
    
    ll ans;
    if(x1>=x2||y1>=y2) ans=0;
    else ans=(x2-x1)*(y2-y1);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3584
//by azidoazideazide(c2n14)
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm> //#include<map>
#include<vector>
using namespace std;
typedef long long ll;
//#include<fstream>
//ifstream fin("rps.in");
//ofstream fout("rps.out");
//#define pb push_back
ll fact(ll n){
  if(n==1) return 1;
  else return n*fact(n-1);
}
int main(){
	ios::sync_with_stdio(0);
	ll n;
  cin>>n;
  cout<<fact(n)<<endl;
return 0;
}


Measured memory_bytes: 3020
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
  int n,k,c,i;
  vector<int> v,w;
  string s;
  cin >> n >> k >> c;
  cin >> s;
  for(i=0;i<n;i++){
    if(s[i]=='x') continue;
    v.push_back(i);
    i+=c;
  }
  if(v.size()>k) return 0;
  for(i=n-1;i>=0;i--){
    if(s[i]=='x') continue;
    w.push_back(i);
    i-=c;
  }
  for(i=0;i<k;i++)
    if(v[i]==w[k-1-i])
      cout << v[i]+1 << endl;
  return 0;
}

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

int cmp(const void *a, const void *b){
	return **(int**)b - **(int**)a;
}

int main(void){
	int n, **a;
	scanf("%d", &n);
	a = malloc(sizeof(int*) * n);
	for(int i = 0; i < n; i++){
		a[i] = malloc(sizeof(int) * 2);
		scanf("%d", a[i]);
		a[i][1] = i;
	}
	qsort(a, n, sizeof(int*), cmp);
	for(int i = 0; i < n; i++)
		printf("%d\n", a[0][1] == i ? a[1][0] : a[0][0]);
	return 0;
}


Measured memory_bytes: 9596
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 998244353;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
struct mi {
	ll v; explicit operator ll() const { return v; }
	mi() { v = 0; }
	mi(ll _v) { 
		v = (-MOD < _v && _v < MOD) ? _v : _v % MOD;
		if (v < 0) v += MOD;
	}
	friend bool operator==(const mi& a, const mi& b) { 
		return a.v == b.v; }
	friend bool operator!=(const mi& a, const mi& b) { 
		return !(a == b); }
	friend bool operator<(const mi& a, const mi& b) { 
		return a.v < b.v; }
   
	mi& operator+=(const mi& m) { 
		if ((v += m.v) >= MOD) v -= MOD; 
		return *this; }
	mi& operator-=(const mi& m) { 
		if ((v -= m.v) < 0) v += MOD; 
		return *this; }
	mi& operator*=(const mi& m) { 
		v = v*m.v%MOD; return *this; }
	mi& operator/=(const mi& m) { return (*this) *= inv(m); }
	friend mi pow(mi a, ll p) {
		mi ans = 1; assert(p >= 0);
		for (; p; p /= 2, a *= a) if (p&1) ans *= a;
		return ans;
	}
	friend mi inv(const mi& a) { assert(a.v != 0); 
		return pow(a,MOD-2); }
		
	mi operator-() const { return mi(-v); }
	mi& operator++() { return *this += 1; }
	mi& operator--() { return *this -= 1; }
	friend mi operator+(mi a, const mi& b) { return a += b; }
	friend mi operator-(mi a, const mi& b) { return a -= b; }
	friend mi operator*(mi a, const mi& b) { return a *= b; }
	friend mi operator/(mi a, const mi& b) { return a /= b; }
    friend ostream& operator<<(ostream& os, const mi& m) {
        os << m.v; return os;
    }
    friend istream& operator>>(istream& is, mi& m) {
        ll x; is >> x;
        m.v = x;
        return is;
    }
};
 
 
typedef vector<mi> vmi;
typedef pair<mi,mi> pmi;
typedef vector<pmi> vpmi;
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N, S; cin >> N >> S;
    mi dp[N+1][S+1];
    F0R(i, N+1) F0R(j, S+1) dp[i][j] = 0;
    dp[0][0] = pow((mi) 2, N);
    int A[N]; F0R(i, N) cin >> A[i];
    mi inv2 = 2; inv2 = inv(inv2);
    F0R(i, N) {
        F0R(j, S+1) {
            dp[i+1][j] += dp[i][j];
            if (j + A[i] <= S) {
                dp[i+1][j+A[i]] += dp[i][j] * inv2;
            }
        }
    }
 
    cout << dp[N][S] << endl;
	return 0;
}
 

Measured memory_bytes: 73948
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

int a[100010];
signed main(){
    int n,m;
    cin>>n>>m;
    REP(i,n) cin>>a[i];
   sort(a,a+n,greater<int>());
   ll sum=0;
   vector<int>v;
   for (int i = 0; i < n; i++)
   {
       sum+=a[i];
       while(a[i]>0){
           v.push_back(a[i]-a[i]/2);
           a[i]/=2;
       }
   }
   sort(v.rbegin(),v.rend());
    for (int i = 0; i < m; i++)
    {
        sum-=v[i];
        if(sum==0) break;
    }
    
   cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 35812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()





int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    rep (i, n) {
        cin >> l[i];
    }
    int ans = 0;
    rep (i, n) {
        rep (j, i+1, n) {
            rep (k, j+1, n) {
                if (l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue;
                if (l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j]) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
 
int main() {
  ll n;
  cin >> n;
  vl h(n+1);
  rep(i,n){
    ll x;
    cin >> x;
    h[i] = x;
  }
  h[n] = INF;
  ll ans = 0;
  ll res = 0;
  rep(i,n){
    if(h[i+1] > h[i]){
      ans = max(ans, res);
      res = 0;
    } else {
      res++;
    }
  }
  cout << ans;
 return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }
using namespace std;

int n, k, w[100010];

bool check(int p) {
    ll sum = 0;
    int idx = 0;

    rep(i, k) {
        sum = 0;
        while (w[idx] + sum <= p) {
            sum += w[idx];
            idx++;
            if (idx == n) return true;
        }
    }
    return false;
}

int main() {
    cin >> n >> k;
    rep(i, n) cin >> w[i];

    // binary search
    int left = 0, right = 100000 * 10000;
    while (right - left > 1) {
        int mid = (left + right) / 2;
        if (check(mid)) right = mid;
        else left = mid;
    }
    cout << right << endl;
}



Measured memory_bytes: 3484
// main is solve AtCoder ABC110 - A
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	a := readInt()
	b := readInt()
	if solve(a, b) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func solve(a, b int) bool {
	if (a*b)%2 == 0 {
		return false
	}
	return true
}

func read() string {
	sc.Scan()
	return sc.Text()
}

func readInt() int {
	i, e := strconv.Atoi(read())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll a[52][52];
int main() {
	ll n;
	cin>>n;
	vector<ll>a,b,c;
		for(ll j=0;j<n;j++){
			ll now;
			cin>>now;
			a.push_back(now);
		}
		for(ll j=0;j<n;j++){
			ll now;
			cin>>now;
			b.push_back(now);
		}
		for(ll j=0;j<n;j++){
			ll now;
			cin>>now;
			c.push_back(now);
		}	
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());
	ll ans=0;
	for(ll i=0;i<n;i++){
		ll now=b[i];
		auto itr=lower_bound(a.begin(),a.end(),now);
		ll one=itr-a.begin();
		now++;
		itr=lower_bound(c.begin(),c.end(),now);
		ll two=n-(itr-c.begin());
		ans+=one*two;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3316
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String[] s = new String[n];
    int[] p = new int[n];
    int[] data = new int[n];
    String temp_string;
    int temp_int;
    int temp_data;


    for(int i = 0;i < n;i++) {
      s[i] = sc.next();
      p[i] = sc.nextInt();
      data[i] = i+1;
    }

    for(int i = 0;i < n-1;i++) {
      for(int k = 0;k < n-i-1;k++){


        if(s[k].compareTo(s[k+1]) > 0) {
          temp_string = s[k];
          s[k] = s[k+1];
          s[k+1] = temp_string;

          temp_int = p[k];
          p[k] = p[k+1];
          p[k+1] = temp_int;

          temp_data = data[k];
          data[k] = data[k+1];
          data[k+1] = temp_data;

        } else if(s[k].compareTo(s[k+1]) == 0) {
          if(p[k] < p[k+1]) {
            temp_int = p[k];
            p[k] = p[k+1];
            p[k+1] = temp_int;

            temp_data = data[k];
            data[k] = data[k+1];
            data[k+1] = temp_data;
          }
        }


      }
    }

    for(int i = 0;i < n;i++) {
      System.out.println(data[i]);
    }

  }

}


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

int main() {
	int x,N;
  	cin>> x >> N;
  	vector<int> a(N);
  
  	for(int i=0;i<N;i++){
     	 cin>>a.at(i);
    }
  
  	
  	cout<<x/2+x%2<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,m,i,j,x,flg;
	int t[200001];
	x=0; flg=0;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++) scanf("%d",&t[i]);
	if(n==1&&t[0]==0) flg=1;
	else if(n==1&&t[0]!=0) flg=2;
	if(flg==0){
		for(i=1;i<=n;i++){
			if(t[i]+m>t[i+1]&&i+1<=n) x+=t[i+1]-t[i];
			else x+=m;
		}
	}	
	if(flg==0) printf("%d\n",x);
	else if(flg==1) printf("1\n");
	else if(flg==2) printf("%d\n",m);
}	

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()




int main() {
    ll n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep (i, n) {
        cin >> a[i];
        a[i]--;
    }
    int prev = 0;
    map<int, int> m;
    m[0] = 1;
    int ctr = 2;
    while (k > 0) {
        if (m[a[prev]] == 0) {
            m[a[prev]] = ctr;
            ctr++;
            k--;
            prev = a[prev];
        } else {
            k--;
            ll loop = ctr - m[a[prev]];
            k %= loop;
            int q = a[prev];
            rep (i, k) {
                q = a[q];
            }
            cout << q + 1 << endl;
            exit(0);
        }
    }
    cout << prev + 1 << endl;
}


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


void solve(long long N, long long X, long long Y){
	--X, --Y; 
	vector<long long> distances(N); 	
	for (long long i = 0; i < N-1; ++i) {
		for (long long j = i+1; j < N; ++j) {
			long long mindistance = min(abs(j-i), 
					1+abs(X-i)+abs(j-Y));


			mindistance = min(mindistance, abs(Y-i)+abs(j-X)+1);

			distances[mindistance]++; 
		}
	}

	for (auto i = 1; i < N; ++i) {
		cout << distances[i] << endl; 
	}
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(N, X, Y);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N, M;
    cin >> N >> M;
    vector<vector<ll>> G(N*3);
    //vector<ll> degv(N);
    ll a,b,S,T;
    rep(i,M){
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b+N);
        G[a+N].push_back(b+N*2);
        G[a+N*2].push_back(b);
        
        //degv[b]++;
    }
    cin >> S >> T;
    S--;T--;
    //priority_queue<Pll,vector<Pll>,greater<Pll>> que;
    queue<Pll> que;
    vector<ll> memo(N*3,0), dist(N*3,-1);
    que.push(Pll(0,S));
    while(!que.empty()){
        ll c1 = que.front().fi;
        ll v = que.front().se;
        que.pop();
        /*if(c1 % 3 == 0 && memo[v] != 0) continue;
        if(c1 % 3 == 0){
            memo[v] = 1;
            dist[v] = c1;
        }*/
        if(memo[v] != 0) continue;
        memo[v] = 1;
        dist[v] = c1;
        for(auto& u:G[v]){
            que.push(Pll(c1+1, u));
        }
    }
    if(memo[T]){
        cout << dist[T]/3 << endl;
    }else{
        cout << -1 << endl;
    }
    /*
    queue<ll> que;
    vector<ll> tp, memo(N);
    tp.push_back(S);
    que.push(S);
    while(!que.empty()){
        ll v = que.front();
        que.pop();
        if(memo[v] != 0) continue;
        memo[v] = 1;
        for(auto& u:G[v]){
            degv[u]--;
            que.push(u);
            if(degv[u] == 0){
                tp.push_back(u);
            }
        }
    }
    PR(tp,N);*/
}

Measured memory_bytes: 24304
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

#define EPS 1e-10
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point {
public:
  double x, y;
  Point() {};
  Point(double x, double y): x(x), y(y) {}

  Point operator + (const Point &p) { return Point(x + p.x, y + p.y); }
  Point operator - (const Point &p) { return Point(x - p.x, y - p.y); }
  Point operator * (double d) { return Point(d * x, d * y); }
  Point operator / (double d) { return Point(x / d, y / d); }

  bool operator < (const Point &p) const {
    return (x != p.x ? x < p.x : y < p.y);
  }

  bool operator == (const Point &p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }

  friend ostream& operator << (ostream &os, Point &p) {
    return os << "Point(" << p.x << ", " << p.y << ")";
  }
};

double cross (Point p1, Point p2) {
  return p1.x * p2.y - p1.y * p2.x;
}

class Segment {
public:
  Point p1, p2;
  Segment(Point p1, Point p2): p1(p1), p2(p2) {}
};

bool cw(Segment s, Point p2) {
  if (cross(s.p2 - s.p1, p2 - s.p1) < EPS) return true;
  return false;
}

vector<Point> S;
vector<Point> U; // upper part
vector<Point> L; // lower part

void debug() {
  cout << "------- U" << endl;
  for (vector<Point>::iterator it = U.begin(); it != U.end(); it++)
    cout << (*it).x << ' ' << (*it).y << endl;

  cout << "------- L" << endl;
  for (vector<Point>::iterator it = L.begin(); it != L.end(); it++)
    cout << (*it).x << ' ' << (*it).y << endl;
}

bool search_start_p(Point a, Point b) {
  return (a.y == b.y ? a.x < b.x : a.y < b.y);
}

void andrew() {
  sort(S.begin(), S.end());

  for (int i = 0; i < 2; i++) {
    U.push_back(S[i]);
    L.push_back(S[S.size()-i-1]);
  }

  for (int i = 2; i < S.size(); i++) {
    for (int n = U.size(); n >= 2 && !cw(Segment(U[n-2], U[n-1]), S[i]); n--)
      U.pop_back();
    U.push_back(S[i]);
  }

  for (int i = S.size() - 3; i >= 0; i--) {
    for (int n = L.size(); n >= 2 && !cw(Segment(L[n-2], L[n-1]), S[i]); n--)
      L.pop_back();
    L.push_back(S[i]);
  }

  reverse(L.begin(), L.end());
    
  for (int i = U.size() - 2; i >= 1; i--) L.push_back(U[i]);

  Point ccw_begin_p = *min_element(L.begin(), L.end(), search_start_p);
  int idx = distance(L.begin(), find(L.begin(), L.end(), ccw_begin_p));

  cout << L.size() << endl;
  for (int i = 0; i < L.size(); i++) {
    cout << L[idx].x << ' ' << L[idx].y << endl;
    idx = (idx+1) % L.size();
  }
}

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

  for (int i = 0; i < n; i++) {
    double x, y; cin >> x >> y;
    S.push_back(Point(x, y));
  }

  andrew();
}

Measured memory_bytes: 6288
import java.util.*;
         
class Main{
    public static void main(String[] args) {
        
        try(Scanner sc = new Scanner(System.in)){
 
            int around = Integer.parseInt(sc.next());
            int house = Integer.parseInt(sc.next());

            ArrayList<Integer> houseDis = new ArrayList<Integer>();
            
            for(int i = 0; i < house; i++){
                houseDis.add(Integer.parseInt(sc.next()));
            }

            int maxDis = 0;
            int startPoint = 0;

            for(int j = 0; j < house; j++){
                if(j == house - 1){
                    int dis = (around + houseDis.get(0)) - houseDis.get(j);
                    if(dis > maxDis){
                        maxDis = dis;
                        startPoint = 0;
                    }
                }else{
                    int dis = houseDis.get(j + 1) - houseDis.get(j);
                    if(dis > maxDis){
                        maxDis = dis;
                        startPoint = j;
                    }
                }
            }

            System.out.println(around - maxDis);

        }catch(Exception e){
            e.printStackTrace();
        }        
    }
}

Measured memory_bytes: 63328
#include "math.h"
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <functional>
#include <numeric>

using namespace std;

int t;

int main()
{
	cin >> t;
	int f;
	vector<int> friendliness;
	for (int i = 0; i < t; i++)
	{
		cin >> f;
		friendliness.push_back(f);
	}
	sort(friendliness.begin(), friendliness.end(), greater<int>());
	if (t == 1) {
		cout << 0;
	}
	else {
		int j = 2;
		int long long smm = friendliness[0];
		while (j < t) {
			smm+= friendliness[floor(j/2.0)];
			j += 1;
		}
		cout << smm;
	}
	return 0;
}



Measured memory_bytes: 4288
m = 10 ** 9 + 7
def cmb(x,y):
    r = 1
    for i in range(1, y + 1):
        r = (r * (x - i + 1) * pow(i, m-2, m)) % m
    return r

x, y = map(int, input().split())

a = (2 * x - y) / 3
b = (2 * y - x) / 3
if (x + y) % 3 == 0 and a >= 0 and b >= 0:
    print(cmb(int((x + y) / 3), int(a)))
else:
    print(0)

Measured memory_bytes: 40044
#!/usr/bin/python
# -*- coding: UTF-8 -*-

import sys


def get_ints():
    return map(int, sys.stdin.readline().strip().split())


def _main():
    input()
    an = list(get_ints())

    t = 0
    old = 1000000000
    while 1:
        ans = sq(t, an)
        g = sq(t+1, an) - ans
        t -= g / abs(g)
        if old > ans:
            old = ans
        else:
            break
    print(int(old))


def sq(t, an):
    ans = 0
    for ai in an:
        ans += pow(ai - t, 2)
    return ans


if __name__ == "__main__":
    _main()


Measured memory_bytes: 9168
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_set>
using namespace std;
typedef long long ll;

int main(){
  int N,K;
  string s;
  cin >> N >> K;
  vector<int> p(N);
  int a1,a2,a3;
  for(int i = 0; i < N; i++){    
    cin >> p[i];
  }
  int sum = 0;
  for(int i = 0; i < K; i++){
    sum += p[i];
  }
  int sum_max = sum;
  for(int i = 0; i < N - K; i++){
    sum = sum - p[i] + p[K + i];
    if(sum > sum_max){
      sum_max = sum;
    }
  }  
  double ans = (double) (sum_max + K) / 2.0;
  printf("%.10f\n",ans);
  
  return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
	ll T1, T2;
	ll A1, B1, A2, B2;
	cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;

	if (T1 * A1 + T2 * A2 == T1 * B1 + T2 * B2) {
		cout << "infinity" << endl;
		return 0;
	}

	if (T1 * (A1 - B1) + T2 * (A2 - B2) > 0) {
		if (A1 - B1 >= 0) {
			cout << 0 << endl;
			return 0;
		}
		ll Diff = T1 * (A1 - B1) + T2 * (A2 - B2);
		ll ans = (T2 * (A2 - B2)) / Diff;
		if (ans * Diff == (T2 * (A2 - B2)))cout << ans * 2 - 2 << endl;
		else cout << ans * 2 - 1 << endl;
	}

	if (T1 * (A1 - B1) + T2 * (A2 - B2) < 0) {
		if (A1 - B1 <= 0) {
			cout << 0 << endl;
			return 0;
		}
		ll Diff = -(T1 * (A1 - B1) + T2 * (A2 - B2));
		ll ans = (T1 * (A1 - B1)) / Diff;
		ans++;
		if((ans - 1) * Diff == (T1 * (A1 - B1)))cout << ans * 2 - 2 << endl;
		else cout << ans * 2 - 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
using namespace std;
int main()
{
	long long n,m;
	long long a;
	while(~scanf("%lld %lld",&n,&m))
	{
		a=abs((n-2)*(m-2));
	printf("%lld\n",a);
	}
	
	return 0;
 } 

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

int main()
{
	long a,b;
	cin >> a >> b;
  	if(abs(a-b) > 1) {
    	cout << 0 << endl;
      	return 0;
    }
  	if(a > b) swap(a,b);
	long count = 1;int i;
	for(i = 2; i <= a; i++) {
		count *= i;
		count %= (long)1E9+7;
	}
  	if(b-a>=1) {
      	long c = count * i;
		c %= (long)1E9+7;
      
  		count *= c;
    } else {
    	count *= count * 2;
    }
	count %= (long)1E9+7;
	cout << count << endl;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int A, B;

int main() {

	scanf("%d%d", &A, &B);

	if (A <= 8 && B <= 8) printf("Yay!\n");
	else printf(":(\n");

	return 0;
}


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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

/**
 * 負の数に対応済みのMod計算
 */
ll mod(ll val, ll m) {
  ll res = val % m;
  if (res < 0) {
    res += m;
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int c[27] = {0};

  for (int i = 0; i < s.length(); ++i) {
    int d = s[i] - 'a';
    c[d]++;
  }

  ll sum = 1;
  for (int e : c) {
    sum = sum * (e + 1) % MOD;
  }
  p(mod(sum - 1, MOD));
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

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(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll sz = s.size();
    vector<pair<ll,ll>>reach(sz);
    ll num,pl;
    rep(i,sz){
        if(s[i] == 'R'){
            num = 1;
            pl = i;
        }else{
            reach[i] = make_pair(num,pl);
            ++num;
        }
        
    }
    rep(i,sz){
        ll j = sz-i-1;
        if(s[j] == 'L'){
            num = 1;
            pl = j;
        }else{
            reach[j] = make_pair(num,pl);
            ++num;
        }
    }
    vector<ll>ans(sz);
    rep(i,sz){
        if(s[i] == 'R'){
            ll state = reach[i].second - (reach[i].first%2);
            ans[state] ++;
        }else{
            ll state = reach[i].second + (reach[i].first%2);
            ans[state] ++ ;
        }
    }
    rep(i,sz){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 5776
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  ll n;
  cin >> n;
  ll a[n];
  for(ll i=0;i<n;i++) cin >> a[i];
  ll c[61];

  for(ll j=0;j<60;j++){
    c[j] = 0;
  }

  for(ll i=0;i<n;i++){
    for(ll j=0;j<60;j++){
      if(a[i]&(1ll<<j)){
        //cout << i << " " << j << endl;
        c[j]+=1;
      }
    }
  }
  ll ans = 0;
  ll temp;
  ll ref;
  for(ll i=0;i<60;i++){
    temp = c[i]*(n-c[i]);
    temp %= MOD;
    ref = (1ll<<i);
    ref %= MOD;
    ans += temp*ref;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  int N; string S;
  cin >> N >> S;
  int x = 0, y = 0;
  for (int i = 0; i < N; i++) {
    char c = S[i];
    if ('A' <= c && c <= 'M') {
      x++; 
    } else if ('N' <= c && c <= 'Z') {
      x--;
    } else if ('a' <= c && c <= 'm') {
      y--;
    } else if ('n' <= c && c <= 'z') {
      y++;
    }
  }
  cout << abs(x)+abs(y) << endl;
  char o;
  if (y < 0) 
    o = 'a';
  else
    o = 'n';
  for (int i = 0; i < abs(y); i++) {
    cout << o;
  }
  if (x < 0)
    o = 'N';
  else
    o = 'A';
  for (int i = 0; i < abs(x); i++) {
      cout << o;
  }
  cout << endl;
}




Measured memory_bytes: 3336
object Main {
  def main(args: Array[String]): Unit = {
    val s = io.StdIn.readLine()

    val suffixes = Seq("dream", "dreamer", "erase", "eraser")
    def loop(t: String): Boolean = {
      if(t.isEmpty) true
      else {
        suffixes.find(t.endsWith(_)) match {
          case None => false
          case Some(suf) =>
            loop(t.substring(0, t.length - suf.length))
        }
      }
    }
    println(if(loop(s)) "YES" else "NO")
  }
}


Measured memory_bytes: 115468
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
#define rep(i,strt,end) for(long long i = strt;i < end;i++)


int main(){
    string s;
    cin >> s;
    long lng = s.length();
    long long counter = 0;
    for(long i = 0;i < lng;i++){
        if(s[i] == '?'){s[i]='D';}
    }
    cout << s << endl;
    //--------------
    return 0;
}

Measured memory_bytes: 3700
import sys

n = int(input())
ary = [[int(_) for _ in line.strip().split()] for line in sys.stdin]
# ary = [[int(_) for _ in input().split()] for i in range(n)]
ary.sort(key=lambda x: x[0])


def output(i, p, d, t, ch):

    print('node {}: parent = {}, depth = {}, {}, {}'.format(i, p, d, t, ch))


bry = [{
    'id': i,
    'parent': -1,
    'depth': 0,
    'type': 'root',
    'children': []
} for i in range(n)]
for node in ary:
    no = node[0]
    if node[1]:
        for cno in node[2:]:
            bry[no]['children'].append(cno)
            bry[cno]['parent'] = no
            if ary[cno][1]:
                bry[cno]['type'] = 'internal node'
            else:
                bry[cno]['type'] = 'leaf'
    else:
        if n > 1:
            bry[no]['type'] = 'leaf'

tmp = [(node['id'], node['parent']) for node in bry]
root = [min(tmp, key=lambda x: x[1])[0]]
flag = True
while flag:
    flag = False
    tmp = []
    for i in root:
        for cno in bry[i]['children']:
            bry[cno]['depth'] = bry[i]['depth'] + 1
            tmp.append(cno)
            flag = True
    root = tmp

for node in bry:
    output(node['id'], node['parent'], node['depth'], node['type'],
           node['children'])



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

signed
main(){
	int n;
	cin >> n;
	vector<int> p(n);
	for(int i=0;i<n;i++) cin >> p[i];

	int cnt = 0;
	for(int x=0;x<n-2;x++){
		if(p[x] < p[x+1] and p[x+1] < p[x+2]) {
			cnt++;
		}else if(p[x] > p[x+1] and p[x+1] > p[x+2])
		{
			cnt++;
		}
	}
	cout << cnt << endl;
}

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

using State = string::const_iterator;

using ll = long long int;

int expr(State &begin);
int term(State &begin);
int num(State &begin);
int factor(State &begin);

void consume(State &begin, char expected){
    if(*begin == expected){
        begin++;
    }else{
        cerr << "Expected " << expected << " but " << *begin << endl;
        throw "";
    }
}

int expr(State &begin){
    int res = term(begin);
    while(1){
        if(*begin == '+'){
            begin++;
            res += term(begin);
        }else if(*begin == '-'){
            begin++;
            res -= term(begin);
        }else{
            break;
        }
    }
    return res;
}

int term(State &begin){
    int res = factor(begin);
    while(1){
        if(*begin == '*'){
            begin++;
            res *= factor(begin);
        }else if(*begin == '/'){
            begin++;
            res /= factor(begin);
        }else{
            break;
        }
    }
    return res;
}

int num(State &begin){
    int res = 0;
    while(isdigit(*begin)){
        res = res*10 + *begin-'0';
        begin++;
    }
    return res;
}

int factor(State &begin){
    int res = 0;
    if(*begin == '('){
        begin++;
        res = expr(begin);
        consume(begin,')');  // ')'
    }else{
        res = num(begin);
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        State begin = s.begin();
        int ans = expr(begin);
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3056
int main(){
    long int a,b;
    double f;
    scanf("%ld",&a);
    scanf("%ld",&b);
    if(1<=a&&1<=b&&a<=10^9&&b<=10^9){
        f=a/(b + 0.0);
        printf("%d %d %lf\n",a/b,a%b,f);
    }
}


Measured memory_bytes: 2144
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int n = 0;
		int tr = 0;
		String str = null;
		String strTmp1 = null;
		String strTmp2 = null;
		Scanner sc = new Scanner(System.in);
		ArrayList<String> ans = new ArrayList<String>();
		while (true) {
			str = sc.next();
			if(str.equals("-")){
				break;
			}
			 n = sc.nextInt();//?????£??????????????°
			 for(int i = 0; i < n; ++i){
				 tr = sc.nextInt();
				strTmp1 = str.substring(0, tr);
				strTmp2 = str.substring(tr);
				str = (strTmp2+strTmp1);
			 }
				ans.add(str);
		}
		for(int i = 0; i < ans.size(); ++i){
		System.out.println(ans.get(i));
		}
		sc.close();
	}

}

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

vector<pair<long long, long long>> prime_factorize(long long N)
{
    vector<pair<long long, long long>> res;
    for (long long a = 2; a * a <= N; ++a)
    {
        if (N % a != 0)
            continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0)
        {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1)
        res.push_back({N, 1});
    return res;
}

int counter(long long N)
{
    int count = 0;
    long long sum = 0;
    for (long long i = 1; i < N; i++)
    {
        sum += i;
        if (sum <= N)
        {
            count++;
        }
        else
        {
            return count;
        }
    }
}

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

    vector<pair<long long, long long>> prime_factorized_number = prime_factorize(N);

    int count = 0;
    for (int i = 0; i < prime_factorized_number.size(); i++)
    {
        if (prime_factorized_number.at(i).second == 1)
        {
            count++;
        }
        else
        {
            count += counter(prime_factorized_number.at(i).second);
        }
    }
    cout << count << endl;
    return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

char mp[444][444];
bool used[444][444];
ll seica[444*444][2];
ll dx[] = {0,1,0,-1};
ll dy[] = {1,0,-1,0};

ll h,w;

int main(){
	
	cin >> h >> w;
	REP(i,h){
		REP(j,w){
			cin >> mp[i][j];
		}
	}
	
	ll cou = 0;
	REP(i,h){
		REP(j,w){
			if(!used[i][j]){
				queue<pair<int,int>> q;
				q.push(MP(i,j));
				
				while(!q.empty()){
					auto now = q.front();q.pop();
					ll y = now.FI;
					ll x = now.SE;
					if(used[y][x])continue;
					used[y][x] = true;
					if(mp[y][x] == '.')seica[cou][0]++;
					else seica[cou][1]++;
					
					REP(ii,4){
						ll yy = y + dy[ii];
						ll xx = x + dx[ii];
						if(xx >= 0 && xx < w && yy >= 0 && yy < h){
							if(!used[yy][xx] && mp[y][x] != mp[yy][xx]){
								q.push(MP(yy,xx));
							}
						}
					}
				}
			}
			cou++;
		}
	}
	
	ll ans = 0;
	REP(i,444*444)ans += seica[i][0] * seica[i][1];
	cout << ans << endl;
	
	
	return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  
  if (a > b) {
    cout << "a > b" << endl;
  } else if (a < b) {
    cout << "a < b" << endl;
  } else {
    cout << "a == b" << endl;
  }
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
#define mx 500001
using namespace std;
ll mi(ll n,ll m){ll pw=n;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
#define bs binary_search
//#define d double
bool comp(pi a,pi b){
    return a.se<b.se;
}
int main(){
	FIO;
	int n;
	cin>>n;
	vvi vec(n,vi(2));
	rep(i,0,n) cin>>vec[i][0]>>vec[i][1];
	Sort(vec);
	int ans=0,x=0;
	for(int i=1;i<n;i++){
	    if(vec[x][0]+vec[x][1]>vec[i][0]-vec[i][1]){
	        if(vec[x][0]+vec[x][1]>vec[i][0]+vec[i][1]) x=i;
	        ans++;
	    }
	    else x=i;
	}
	cout<<n-ans;
	    
} 
 

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

int main() {
    int N;
    cin >> N;
    int A[N], B[N];
    rep(i, N) cin >> A[i] >> B[i];
    sort(A, A+N);
    sort(B, B+N);
    int medA, medB;
    if(N % 2 == 1) {
        medA = A[(N+1)/2-1];
        medB = B[(N+1)/2-1]; 
    } else {
        medA = (A[N/2-1] + A[N/2]);
        medB = (B[N/2-1] + B[N/2]);
    }
    cout << medB - medA + 1 << endl;
    return 0;
}

Measured memory_bytes: 5200
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;

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

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

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = (int)1e9 + 7;

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

    int n;
    cin >> n;
    vector<int> h(n);
    REP(i, n) cin >> h[i];

    int ans  = 0;
    REP(i, n){
        while(h[i] > 0){
            ans++;
            h[i]--;
            FOR(j, i+1, n){
                if(h[j] <= 0) break;
                h[j]--;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
words = {}

for i in range(n) :
    new_word = input()
    if new_word in words.keys() :
        words[new_word] += 1
    else :
        words[new_word] = 1

mx_freq = max(words.values())
mx_words = [k for k, v in words.items() if words[k] == mx_freq]

mx_words.sort()

for mx_word in mx_words :
    print(mx_word)

Measured memory_bytes: 32096
//verma_ankit484

#include<bits/stdc++.h>

typedef long long ll;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const ll mod = (ll) 1e9+7;

using namespace std;

int main()
{
  IOS
  #ifdef AV
  freopen("int.txt", "r", stdin);
  #endif
  ll k, x;
  cin >> k >> x;
  for(ll i = k-1; i >= 0; i--) {
    cout << x-i << ' ';
  }
  for(ll i = 1; i < k; i++) cout << x+i << ' ';
  return 0;
}


Measured memory_bytes: 256
import java.math.*;
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
    	BigDecimal pi=new BigDecimal("3.14159265359");
    	Scanner sc = new Scanner(System.in);
    	BigDecimal m = sc.nextBigDecimal();
    	System.out.println(m.multiply(pi).multiply(new BigDecimal(2)));
    	
    }
}

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

int main()
{
    /* ------- 宣言と入力 ------- */

    long long int N,K;

    cin >> N>>K;

    /* ------- 計算 ------- */

    long long int ans = 0;

    while (N>0)
    {
        N /= K;
        ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
S=input()
T=input()
flg=0
for i in range(len(S)):
    moji=str()
    for j in range(len(S)):
        word=i+j
        if word>=len(S):
            word=i+j-len(S)
        moji+=S[word]
    if moji==T:
        flg=1
        
print("Yes" if flg else "No")   

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			long x = sc.nextLong();
			long a = sc.nextLong();
			long b = sc.nextLong();

			if (0 <= a - b) {
				System.out.println("delicious");
			} else if (a - b + x < 0) {
				System.out.println("dangerous");
			} else {
				System.out.println("safe");
			}
		}
	}
}

Measured memory_bytes: 21844
from collections import Counter, defaultdict
import sys

sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools

import queue
from collections import deque



def main():
    x = int(input())
    now_price = 100
    now_count = 0
    while 1:
        now_price = now_price * 1.01
        now_price = int(now_price)
        now_count += 1
        if now_price >= x:
            break

    print(now_count)






if __name__ == '__main__':
    main()


Measured memory_bytes: 69032
n, m = input().split()
n = int( n )
m = int( m )
h = input().split()
tower = [ 1 ] * n

for i in range( m ):
    a, b = input().split()
    a = int( a )
    b = int( b )
    if int( h[a-1] ) < int( h[b-1] ):
        tower[a-1] = 0
    elif int( h[a-1] ) == int( h[b-1] ):
        tower[a-1] = 0
        tower[b-1] = 0
    else:
        tower[b-1] = 0

cnt = 0
for tower_i in tower:
    if tower_i == 1:
        cnt = cnt + 1

print( cnt )

Measured memory_bytes: 17564
#include<bits/stdc++.h>
using namespace std;
long long a[200005],b[200005];
int main()
{
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		a[i]+=a[i-1];
	}
	for(int i=1;i<=m;i++)
	{
	  cin>>b[i];
	  b[i]+=b[i-1];	
	}
	int ans=0;
	int j=m;
    for(int i=0;i<=n;i++)
    {
    	if(a[i]>k)break;
    	while(b[j]>k-a[i])
    	{
    		j--;
		}
		ans=max(ans,i+j);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 6696
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  int N, i;
  cin >> N >> i;
  cout << N - i + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(a > b){ int tmp = a;a = b;b = tmp;}
  if(a%2 != b%2){
     cout << "IMPOSSIBLE\n";
  }else{
    cout << (a+b)/2 << endl;
  }
}


Measured memory_bytes: 256
/* ex2_3
   YSK722 */

#include <stdio.h>

int main(void){
    int size, white;
    scanf("%d", &size);
    scanf("%d", &white);
    if(size < 1 || 100 < size){
        return 1;
    }
    if(white < 0 || size * size < white){
        return 1;
    }
    printf("%d\n", size * size - white);
    return 0;
}


Measured memory_bytes: 128