akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

const int MOD = 1e9 + 7;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> e(1e5 + 1, 0);
  vector<int> o(1e5 + 1, 0);
  for(int i = 0; i < n; i++)
  {
    int temp;
    cin >> temp;
    if(i % 2 == 0)
    {
      e[temp]++;
    }
    else
    {
      o[temp]++;
    }
  }
  int maxo1 = 0;
  int maxo2 = 0;
  int maxo1idx;
  int maxe1 = 0;
  int maxe2 = 0;
  int maxe1idx;
  for(int i = 1; i < 1e5 + 1; i++)
  {
    if(o[i] > maxo1)
    {
      maxo2 = maxo1;
      maxo1 = o[i];
      maxo1idx = i;
      
    }
    else if(o[i] > maxo2)
    {
      maxo2 = o[i];
    }
    if(e[i] > maxe1)
    {
      maxe2 = maxe1;
      maxe1 = e[i];
      maxe1idx = i;
    }
    else if(e[i] > maxe2)
    {
      maxe2 = e[i];
    }
  }
  if(maxo1idx == maxe1idx)
  {
    cout << min(n - maxo1 - maxe2, n - maxe1 - maxo2);
  }
  else
  {
    cout << n - maxo1 - maxe1;
  }

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

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

int main(){
    int N;
    cin >> N;
    int A,B,C,D;
    string S;
    cin >> A>>B>>C>>D>>S;
    B--;
    A--;
    C--;
    D--;

    if(C < D){
        for(int i = A;i < C-1;i++){
            if(S[i] == '#' && S[i+1] == '#'){
                cout << "No" << endl;
                return 0;
            }
        }
        for(int i = B;i < D-1;i++){
            if(S[i] == '#' && S[i+1] == '#'){
                cout << "No" << endl;
                return 0;
            }           
        }
        cout << "Yes" << endl;
    }
    else{
        for(int i = B;i <= D;i++){
            if(S[i-1] == '.' && S[i] == '.' && S[i+1] == '.'){
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define REV(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin(), v.end()
#define pb push_back
const ll INF = 9e18;
ll n;
vector<ll> p, q, r;

signed main(){
    cin >> n;
    p.resize(n); q.resize(n); r.resize(n);
    REP(i, n) cin >> p[i];
    REP(i, n) cin >> q[i];

    r[0] = 1;
    REP(i, n-1) r[i+1] = r[i] + 1;

    ll a = 0, b = 0;
    bool flag_a = true, flag_b = true;
    do{
        if(!equal(p.begin(), p.end(), r.begin()) && flag_a) a++;
        else flag_a = false;

        if(!equal(q.begin(), q.end(), r.begin()) && flag_b) b++;
        else flag_b = false;
    } while(next_permutation(r.begin(), r.end()));
    cout << abs(a - b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

void solve()
{

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

    lli cur = 1;
    map<lli, lli> ma;
    vector<lli> v;
    ma[1] ++;
    lli X = -1;
    lli idx = -1;
    for(int i = 1; i <= k; i ++) {
        cur = a[cur];
        ma[cur] ++;
        if(ma[cur] == 2) {
            X = cur ;
            idx = i;
            break ;
        }
    }

    if(X == -1) {
        cout<<cur;
        return ;
    }

    v.push_back(X);
    cur = a[X];
    while(cur != X) {
        v.push_back(cur);
        cur = a[cur];
    }


//    cout<<idx<<endl;

//    for(auto it : v) {
//        cout<<it<<' ';
//    }
//    cout<<endl;

    k -= idx ;

    k %= (v.size());

//    cout<<k<<endl;

    cout<<v[k];




    cout<<"\n";
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 16916
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

LL t[100005];
LL s[100005];

int main(){
	int n;
	int i,j,k;
	LL a,b,c;
	cin>>n;
	a=0,b=0;
	for(i=0;i<n;i++){
		cin>>t[i];
		a+=t[i];
		if(i%2==1)b+=t[i];
	}
	s[0]=a-b*2;
	for(i=1;i<n;i++){
		s[i]=t[i-1]*2-s[i-1];
	}
	array_show(s,n);
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
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;}
constexpr long long INF = 1e18,MOD = 998244353;

template<class T>
class SegmentTree{
	private:
	int N;
	T initVal;
	std::vector<T>ary;
	std::function<T(T&,T&)>merge;
	void init(int n){
		while(N < n)N <<= 1;
		ary.resize(N << 1,initVal);
	}
	public:
		SegmentTree(int n,T initVal,std::function<T(T&,T&)>f):
			N(1),initVal(initVal),merge(f){init(n);}
	// -- a[i] = val;
	inline void update(int i,T val){
		ary[i += N] = val;
		while(i > 1){
			i >>= 1;
			ary[i] = merge(ary[i << 1],ary[(i << 1) + 1]);
		}
	}
	// -- a[i] += val;
	inline void add(int i,T val){
		update(i,ary[i + N] + val);
	}
	// -- [l,r)
	inline T query(int l,int r){
		if(l >= r)return initVal;
		T vr = initVal,vl = initVal;
		for(l += N,r += N;l != r;l >>= 1,r >>= 1){
			if(l & 1)vl = merge(vl,ary[l++]);
			if(r & 1)vr = merge(vr,ary[--r]);
		}
		return merge(vl,vr);
	}
	/*
	void debug show(){
		for(iint i = N;i < N;i++)std::cerr << ary[i] << ' ';
		std:::cerr << '\n';
	}
	*/
};
using ST = SegmentTree<int>;
#define SUM ST(n,0,[](int &a,int &b){return a+b};);
#define MIN ST(n,INF,[](int &a,int &b){return min(a,b);});
#define MAX ST(N,0,[](int &a,int &b){return max(a,b);});
//REP(i,N)f(seg.query(0,i),seg.query(i+1,N))でiを除いた全探索

#define P1 pair<pair<int,int>,int>

signed main(){
	int N,M;
	cin>>N>>M;
	vector<P1>v;
	REP(i,M){
		int l,r,c;
		cin>>l>>r>>c;
		l--;r--;
		v.push_back({{r,l},c});
	}
	sort(ALL(v));
	auto seg = SegmentTree<int>(N,INF,[](int &a,int &b){return min(a,b);});
	seg.update(0,0);
	REP(i,M){
		int r = v[i].first.first;
		int l = v[i].first.second;
		int cost = v[i].second;
		seg.update(r,min(seg.query(r,r+1),seg.query(l,r+1)+cost));
	}
	int ans = seg.query(N-1,N);
	if(ans == INF)cout<<-1<<endl;
	else cout<<ans<<endl;
}

Measured memory_bytes: 5488
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define M 1000010
ll f(ll n){
	ll cnt=0;
	if(n==0)return 1;
	while(n)cnt++,n/=10;
	return cnt;
}
vll g[M];
map<pii,ll>mp;
vector<pii>v;
ll col[M]={1},an[M]={1};
void dfs(ll u,ll p,ll c){
	ll col=1;
	for(auto v:g[u]){
		if(p==v)continue;
		if(col==c)col++;
		an[mp[{u,v}]]=col;
		dfs(v,u,col);
		col++;
	}
}
int main(){
	IOS;
	/*ll a,b,x;cin>>a>>b>>x;
	ll ans=0;
	ll mx=1000000000;
	for(ll d=18;d>=1;d--){
		ll j=(x-d*b)/a;
		if(f(j)==d){
			ans=j;
			break;
		}
	}
	for(ll i=M;i>=0;--i)if(x>=(a*i+b*f(i))){ans=max(ans,i);break;}
	if(ans>=mx)ans=mx;
	cout<<ans;*/
	ll n;cin>>n;
	ll ans=0;
	ll deg[n]={0};
	rep(i,0,n-1){
		ll a,b;cin>>a>>b;a--,b--;
		mp[{a,b}]=i;
		v.pb({a,b});
		g[a].pb(b);g[b].pb(a);
		deg[a]++,deg[b]++;
	}
	rep(i,0,n)ans=max(ans,deg[i]);
	cout<<ans<<"\n";
	dfs(0,-1,0);
	rep(i,0,n-1)cout<<an[i]<<"\n";
	return 0;
}



Measured memory_bytes: 38388
#include <cstdio>
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
	int W, H, x, y, r;
	int left, right;
	int up, down;

	cin >> W >> H >> x >> y >> r;

	left = x - r;
	right = x + r;
	up = y + r;
	down = y - r;

	if (left >= 0 && right <= W && up <= H && down >= 0)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}

	return 0;
}

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

double power( double a, int n )
{
  double r;
  int abs_n;

  r = 1; abs_n = n < 0 ? -n : n;
  while ( abs_n > 0 ) {
    if ( abs_n % 2 == 1 ) { r *= a; }
    a *= a;
    abs_n /= 2;
  }

  return n >= 0 ? r : 1/r;
}

double nthroot( double a, int n )
{
  double x, y;

  if ( a <= 0 || n < 0 ) { return 0; }
  if ( n == 0 ) { return 1; }

  /* a > 0 かつ n > 0 の場合 */
  y = (a > 1) ? a : 1;
  do {
    x = y;
    y = ((n-1)*x + a/power(x, n-1)) / n;
  } while ( y < x );

  return y;
}

int is_power( int a )
{
  int i; 

  if ( a == 1 ) { return 1; }

  for ( i = 2; i <= floor(log2(a)); i++ ) {
    if ( power(floor(nthroot(a, i)), i) == a ) { 
      return 1;
    }
  }

  return 0;
}

int main(void){
	int n = 0;
	cin >> n;
	//cout << max_exp(n) << endl;
	for(int i=n;i>=1;i--){
		if(is_power(i)==1){
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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;
}
using namespace std;

void solve(){
    int n,ch;
    cin>>n>>ch;
    vector<vector<int>>imos(ch,vector<int>(100005));
    int s,t,c;
    rep(i,n){
        cin>>s>>t>>c;
        s--;c--;
        imos[c][s]++;
        imos[c][t]--;
    }
    rep(i,ch)rep(j,100001)imos[i][j+1]+=imos[i][j];
    int ans=0;
    rep(i,100001){
        int cnt=0;
        rep(j,ch){
            if(imos[j][i])++cnt;
        }
        chmax(ans,cnt);
    }
    cout<<ans<<"\n";
}
 
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 12416
N, M = gets.chomp.split.map(&:to_i)

is_correct = Array.new(N, false)
wa_count = Array.new(N, 0)

M.times do
  num, ans = gets.chomp.split
  num = num.to_i
  if ans == 'WA'
    wa_count[num - 1] += 1 if is_correct[num - 1] == false
  end

  is_correct[num - 1] = true if ans == 'AC'
end

is_correct.each_with_index do |val, index|
  wa_count[index] = 0 if val == false
end

total = 0
is_correct.each { |val| total += 1 if val == true }
puts "#{total} #{wa_count.inject(&:+)}"


Measured memory_bytes: 3324
#include <iostream>

using namespace std;

int main()
{
    long int s, m, h;

    cin  >> s;
    
    if(0 <= s && s < 86400)
    {
        h = s / 3600;
        m = (s - h * 3600) / 60;
        s = s - h * 3600 - m * 60;
    
        cout << h << ':' << m << ':' << s << endl;
     }
    
    return 0;
}

Measured memory_bytes: 3104
r()=readline()
N=parse(Int,r())
S=chomp(r())

n=length(S)
ss=zeros(UInt8,n)
for i in 1:n
    ss[i]=UInt8(S[i])+N
    ss[i] > 0x5a  && (ss[i]-=26)
end

print.(Char.(ss));

Measured memory_bytes: 114408
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repq(i,a,n) for(int i=a; i<=n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

template <typename T>
class RMQ {
    public:
        int n;
        T dat[2 * (1 << 17) - 1];

        // ????´???° m ??? RMQ ?????????
        RMQ(int m) {
            n = 1;
            while(n < m) n *= 2;
            rep(i,0,2*n-1) dat[i] = INT_MAX;
        }

        // k?????? (0-indexed) ????????? a ?????´??°
        void update(int k, T a) {
            k += n - 1;
            dat[k] = a;
            while(k > 0) {
                k = (k - 1) / 2;
                dat[k] = min(dat[k*2+1], dat[k*2+2]);
            }
        }

        // [a, b) ???????°?????????????
        // ??????????????¨?????? XX.query(a, b, 0, 0, -1) ??¨??????
        T query(int a, int b, int k, int l, int r) {
            if(r == -1) r = n;
            if(r <= a || b <= l) return INT_MAX;
            if(a <= l && r <= b) return dat[k];
            else {
                T vl = query(a, b, k*2+1, l, (l+r)/2);
                T vr = query(a, b, k*2+2, (l+r)/2, r);
                return min(vl, vr);
            }
        }
};

int main() {
    int n, q; cin >> n >> q;
    RMQ<int> r(n);

    int a, x, y;
    rep(i,0,q) {
        cin >> a >> x >> y;
        if(a == 0) {
            r.update(x, y);
        }
        else if(a == 1) {
            int ans = r.query(x, y+1, 0, 0, -1);
            cout << ans << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4092
#include <iostream>
using namespace std;
#define int long long int
//Compiler version g++ 6.3.0

int32_t main()
{
  int n; cin>>n;
  int i = 1;
  int cur=0;
  do {
    cur+=i++;
  }while(cur<n);
  cout<<i-1;
}


Measured memory_bytes: 256
import sys
import itertools
import math
#import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
P = rl()
Q = rl()
L = []
for x in itertools.permutations(range(1, N+1)):
    L.append(list(x))
a = 0
b = 0
for i in range(math.factorial(N)):
    if L[i] == P:
        a = i
    if L[i] == Q:
        b = i

print(abs(a-b))


Measured memory_bytes: 10356
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; ++i) cin >> a[i];
	int ans = 1e9;
	for(int i=1; i<=100; ++i){
		int tmp = 0;
		for(int j=0; j<n; ++j)
			tmp += (a[j] - i) * (a[j] - i);
		if(tmp < ans) ans = tmp;
	}
	cout << ans << "\n";
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

struct Vertex
{
    vector<int> node;
};

pair<ll, bool> A[100005];
Vertex V[100005];
bool U[100005];

int main()
{
    ll N, M;
    cin >> N >> M;
    REP(i, N)
    {
        cin >> A[i].first;
        A[i].second = false;
        U[i] = false;
    }
    REP(i, M)
    {
        ll x, y;
        cin >> x >> y;
        V[x].node.push_back(y);
        V[y].node.push_back(x);
    }

    ll sum = 0;
    int fn = 0;
    REP(i, N)
    {
        if (U[i])
            continue;
        fn++;
        U[i] = true;
        ll min = i;
        queue<int> q;
        q.push(i);
        while (!q.empty())
        {
            int t = q.front();
            q.pop();
            REP(j, V[t].node.size())
            {
                int n = V[t].node[j];
                if (U[n])
                    continue;
                U[n] = true;
                q.push(n);
                if (A[n] < A[min])
                    min = n;
            }
        }
        A[min].second = true;
        sum += A[min].first;
    }
    if (fn == 1)
    {
        cout << 0 << endl;
        return 0;
    }
    if (2 * (fn - 1) > N)
    {
        cout << "Impossible" << endl;
        return 0;
    }
    sort(A, A + N, [](pair<ll, bool> a, pair<ll, bool> b) { return a.first < b.first; });
    fn = 2 * (fn - 1) - fn;
    REP(i, N)
    {
        if (A[i].second)
            continue;
        if (fn-- <= 0)
            break;
        sum += A[i].first;
    }
    cout << sum << endl;
    return 0;
}

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

// OEIS A000254
long long v[100009];
long long fact[100009], factinv[100009];
long long mod = 1000000007;

long long modpow(long long a, long long b, long long m) {
	long long p = 1, q = a;
	for (int i = 0; i < 32; i++) {
		if ((b / (1LL << i)) % 2 == 1) { p *= q; p %= m; }
		q *= q; q %= m;
	}
	return p;
}

long long Div(long long a, long long b, long long m) {
	return (a * modpow(b, m - 2, m)) % m;
}

void init() {
	fact[0] = 1;
	for (int i = 1; i <= 100000; i++) fact[i] = (1LL * fact[i - 1] * i) % mod;
	for (int i = 0; i <= 100000; i++) factinv[i] = Div(1, fact[i], mod);
	v[0] = 0;
	for (int i = 1; i <= 100000; i++) v[i] = (1LL * i * v[i - 1] + fact[i - 1]) % mod;
}

long long N, X[1 << 18];

int main() {
	init();

	cin >> N;
	for (int i = 1; i <= N; i++) cin >> X[i];

	long long ans = 0;
	for (int i = 1; i <= N - 1; i++) {
		long long val = v[i];
		val *= fact[N - 1]; val %= mod;
		val *= factinv[i]; val %= mod;
		ans += val * (X[i + 1] - X[i]);
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <cstring>
#include <map>
#include <set>
#define int long long int
using namespace std;


signed main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    #endif

    int n, i;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    int dp[n][n];
    memset(dp, 0, sizeof(dp));
    for(int low=n-1;low>=0;low--){
        for(int high=low;high<n;high++){
            if(low==high)
                dp[low][high] = a[low];
            else
                dp[low][high] = max(a[low]-dp[low+1][high], a[high]-dp[low][high-1]);
        }
    }
    cout<<dp[0][n-1]<<endl;
}




Measured memory_bytes: 70656
n, y = map(int, input().split())

for i in range(n+1):
    for j in range(n+1-i):
        k = n-i-j
        if 10000 * i + 5000*j + 1000*k == y:
            print("{} {} {}".format(i, j, k))
            exit()
print("-1 -1 -1")

Measured memory_bytes: 3060
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll x,ans=0,sum=0;
  cin >> x;
  for(int i=1;sum<x;i++){
    sum += i;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
(* unihernandez22
 * https://atcoder.jp/contests/abc172/tasks/abc172_b
 * implementation
 * *)

let rec count_diff s t i c =
    if i == String.length s then c
    else if s.[i] != t.[i] then count_diff (s) (t) (i+1) (c+1)
    else count_diff (s) (t) (i+1) (c);;

Printf.printf "%d\n" @@
Scanf.scanf "%s\n%s\n" @@ fun s t ->
    count_diff s t 0 0;;
    


Measured memory_bytes: 4652
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
	char c;
	cin >> c;
	if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
		cout << "vowel" << endl;
	} 
	else{
		cout << "consonant" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner ob=new Scanner(System.in);
	String s=ob.next();
	if(s.charAt(s.length()-1)=='s'){System.out.println(s+"es");}
	else{System.out.println(s+"s");}
	}
}


Measured memory_bytes: 26952
import java.util.Scanner;
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.PriorityQueue;
class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        
        int n = stdIn.nextInt();
        int k = stdIn.nextInt();

        int[] h = new int[n];

        int count = 0;

        for(int i = 0;i < n;i++) {
            h[i] = stdIn.nextInt();
        }

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

       System.out.println(count);
    }

}

Measured memory_bytes: 50676
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int main() {
    int k, x;
    cin >> k >> x;

    vector<int> ans;
    int st;
    if (x-(k-1) < -100000) st = -100000;
    else st = x-(k-1);
    for (; st < x; st++) ans.push_back(st);

    int en;
    if (x+(k-1) > 100000) en = 100000;
    else en = x+(k-1);
    for (int i = x; i <= en; i++) ans.push_back(i);

    for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        System.out.println(bubbleSort(a, n));
        sc.close();
    }

    static StringBuilder bubbleSort(int[] a, int n) {
        int ans = 0;
        boolean flag = true;
        while (flag) {
            flag = false;
            for (int i = n - 1; i > 0; i--) {
                if (a[i] < a[i - 1]) {
                    int tmp = a[i];
                    a[i] = a[i - 1];
                    a[i - 1] = tmp;
                    ans++;
                    flag = true;
                }
            }
        }

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            if (i != 0)
                sb.append(" ");
            sb.append(a[i]);
        }
        sb.append(System.lineSeparator() + ans);

        return sb;
    }
}


Measured memory_bytes: 26224
def solve(S, ops):
    global res
    if len(ops) < (len(S) - 1):
        a = ops[:]
        b = ops[:]
        a.append(0)
        b.append(1)
        solve(S, a)
        solve(S, b)
    else:
        tmp = ""
        tmp += str(S[0])
        for n, op in enumerate(ops):
            if op == 0:
                tmp += str(S[n+1])
            else:
                res += int(tmp)
                tmp = str(S[n+1])
        res += int(tmp)

S = raw_input()
S = [int(x) for x in S]
res = 0
ops = []
solve(S, ops)
print res


Measured memory_bytes: 2692
import { readFileSync } from "fs";

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const range = (n: number | bigint) => [...Array(Number(n))].map((_, i) => i);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const tuple = <T extends unknown[]>(...ts: T) => ts;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [cin, nCin, biCin] = (() => {
  const inputs = readFileSync("/dev/stdin", "utf-8").split(/[\n|\s]+/);
  let count = 0;
  const cin = () => inputs[count++];
  return tuple(
    cin,
    () => Number(cin()),
    () => BigInt(cin())
  );
})();

type Color = "R" | "W";

// 1. R...R
// 2. W...W
// 3. R...RW...W
const getAnswer = (N: number, cs: Color[]): number => {
  const rNum = cs.filter((c) => c === "R").length;

  return [
    rNum,
    N - rNum,
    cs.slice(0, rNum).filter((c) => c === "W").length,
  ].reduce((acc, n) => Math.min(acc, n));
};

{
  const N = nCin();
  const cs = cin()
    .split("")
    .map((c) => c as Color);
  const ans = getAnswer(N, cs);
  console.log(ans);
}


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

int main(){
  int n;
  cin>>n;
  vector<double> vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  double a=0.0;
  for(int i=0;i<n;i++){
    a+=1/vec.at(i);
  }
  cout<<1/a<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>=13)
    {
        cout<<b<<endl;
        return 0;
    }
    else if(a<=12 && a>=6)
        {
        cout<<b*0.5<<endl;
        return 0;
    }
    else

    {
        cout<<b*0<<endl;
        return 0;
    }
}


Measured memory_bytes: 3780
#include <stdio.h>

int main()
{
	long int a, b, ab, buf;

	while(scanf("%lu %lu", &a, &b) != EOF){
		ab = a * b;
		if(a < b){
			buf = a;
			a = b;
			b = buf;
		}

		//最小公約数
		while(a % b != 0){
			a = a % b;

			if(a < b){
				buf = a;
				a = b;
				b = buf;
			}
		}
		printf("%ld", b);

		//最小公倍数
		printf(" %ld\n", ab/b);
	}
	
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define ld long double
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define FTEST int testcase;fin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
#define plii pair<ll,pii>
#define no {cout<<"no"<<endl;return;}
#define yes {cout<<"yes"<<endl;}

const int maxn=1e6;
//const int mod=998244353;
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int arr[maxn];
ll fac[maxn+1];
ll mul(ll a,ll b){
    ll ans=0;
    while(b){
        if(b&1) ans=(ans+a)%MAX;
        b/=2;
        a=(a+a)%MAX;
    }
    return(ans);
}
ll power(ll a,ll b){
    ll ans=1;
    while(b){
        if(b&1) ans=mul(ans,a);
        b/=2;
        a=mul(a,a);
    }
    return(ans);
}
ll inv(ll a){
    return(power(a,MAX-2));
}
void ini(){
    fac[0]=1;
    for(int i=1;i<=maxn;i++){
        fac[i]=(fac[i-1]*i)%MAX;
    }
    return;
}
ll ncr(ll n,ll r){
    ll ans=fac[n];
    ans=mul(ans,inv(fac[n-r]));
    ans=mul(ans,inv(fac[r]));
    return(ans);

}
ll maxAbsValExpr(vector<ll>& x, vector<ll>& y) {
        ll res = 0, n = x.size(), smallest, cur;
        for (int p : {1, -1}) {
            for (int q : {1, -1}) {
                smallest = p * x[0] + q * y[0] + 0;
                for (int i = 1; i < n; ++i) {
                    cur = p * x[i] + q * y[i] ;
                    res = max(res, cur - smallest);
                    smallest = min(smallest, cur);
                }
            }
        }
        return res;
    }
void solve(){
    int n;cin>>n;
    vector<ll> x(n),y(n);
    for(int i=0;i<n;i++) cin>>x[i]>>y[i];
    cout<<maxAbsValExpr(x,y);
    return;

}

int main(){
    IO


    //TEST
    solve();


}



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

typedef long long ll;

const ll MOD = 1e9 + 7;

const int MAX_N = 100000;

vector<vector<int>> win(MAX_N, vector<int>(0));

int solve(int x) {
    if (win[x].size() == 0) return 0;
    vector<int> v(0);
    rep(i, win[x].size()) v.push_back(solve(win[x][i]));
    sort(v.begin(), v.end());
    int ret = -1;
    rep(i, v.size()) {
        if (v[i] > ret) ret = v[i] + 1;
        else ret++;
    }
    return ret;
}

int main() {
    int N, a;
    cin >> N;
    rep(i, N - 1) {
        cin >> a;
        win[a - 1].push_back(i + 1);
    }
    /*
    rep(i, N) {
        cout << i << " ";
        rep(j, win[i].size()) cout << win[i][j] << " ";
        cout << endl;
    }
    */
    cout << solve(0) << endl;
}

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


int main(){
  int n,m;
  cin>>n>>m;
  vector<int> ac(n),pena(n);
  for(int i=0;i<m;i++){
    int num;
    string str;
    cin>>num>>str;
    num--;
    if(ac[num]) continue;
    if(str=="AC"){
      ac[num] =1;
    }else {
      pena[num]++;
    }
  }
  int AC=0,PENA=0;
  for(int i=0;i<n;i++){
    AC+=ac[i];
    if(ac[i]) PENA+=pena[i];
  }
  printf("%d %d",AC, PENA);
  return 0;
}
  
    
  
  
  
  
  


Measured memory_bytes: 1024
n = gets.to_i
an = gets.split.map(&:to_i).sort{|a, b| b<=>a }
i = h = 0

while i < n - 1
  if an[i] != an[i+1]
    i += 1
  elsif an[i] == an[i+1] && h == 0
    h = an[i]
    i += 2
  else
    puts h * an[i]
    exit
  end
end

puts 0

Measured memory_bytes: 10120
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; long long k; cin >>n >>k;
  int r1=0,r2=0,r3=0,t=0; bool shit=0;
  set<int>s; vector<int>v(n); vector<int>r(n);
  for(int i=0; i<n; i++) cin >>v[i];
  for(int i=0; i<n; i++){
    if(i) t=v[t-1];
    else t=v[0];
    s.insert(t);
    if(s.size()==i){r1=i; r2=t; shit=1; break;}
    r[i]=t;
  }
  if(shit) for(int i=0; i<n; i++) if(r[i]==r2) r3=i;
  if(!shit)
  {
    if(k%n) cout <<r[k%n-1];
    else cout <<r[n-1];
    return 0;
  }
  if(k<=r3) cout <<r[k-1];
  else cout <<r[(k-r3-1)%(r1-r3)+r3];
return 0;}

Measured memory_bytes: 14008
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(c<=(a+b))cout<<b+c<<endl;
    else cout<<a+2*b+1<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int>a(n);
  vector<int64_t>s(n,0);
  cin>>a.at(0);
  s.at(0)=a.at(0);
  for(int i=1;i<n;i++){
    cin>>a.at(i);
    s.at(i)=s.at(i-1)+a.at(i);
  }
  int64_t ans=abs(s.at(0)-(s.at(n-1)-s.at(0)));
  for(int i=1;i<n-1;i++){
    ans=min(ans,abs(s.at(i)-(s.at(n-1)-s.at(i))));
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 5584
#include <bits/stdc++.h>
#define MAX_N 10000
#define INF 1e9

using namespace std;

typedef int long long ll;
typedef int long l;
typedef pair<int, int> Pii;
const ll MOD = 1000000007;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d, e;
    string s;
    cin >> s;
    if (s == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
    return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main() {
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	vector<int> l(q), r(q);
	for (int i = 0; i < q; i++) {
		cin >> l[i] >> r[i];
	}
	
	vector<int> ans(n + 1);
	for (int i = 1; i < n; i++) {
		ans[i + 1] = ans[i];
		if (s[i - 1] == 'A' && s[i] == 'C')ans[i + 1]++;
	}
	
	for (int i = 0; i < q; i++) {
		cout << ans[r[i]]-ans[l[i]] << endl;
	}

	return 0;
}

Measured memory_bytes: 2176
mod = 10 ** 9 + 7

def fact(n):
    res = 1
    for i in range(2, n + 1):
        res = (res * i) % mod
    return res


N, *X = map(int, open(0).read().split())

ans = 0
for i in range(N - 1):
    ans += (X[-1] - X[i]) * pow(i + 1, mod - 2, mod)
    ans %= mod

print(ans * fact(N - 1) % mod)

Measured memory_bytes: 14052
#include<bits/stdc++.h>
typedef long long int lli;
#define _FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define _READ freopen("input.txt","r", stdin);
#define F first
#define S second
using namespace std;
int main()
{
	lli a,b,c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30);
const ll INFL = (1LL<<62);
const int MOD = 1000000007;
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> ll mod_pow(ll a, ll n, T mod) { mod=(ll)mod; ll res=1, p=a%mod; while(n){ if(n&1) res=res*p%mod; p=p*p%mod; n>>=1; } return res; }

int main() {
    int i = 1;
    while(true){
        int x;
        cin >> x;
        if(x == 0) return 0;
        cout << "Case " << i << ": " << x << endl;
        i++;
    }

    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;
ll N, W;
ll w1;
vector<ll> st[4]; // st[w]...vector<ll> val : wごとにvalueのvectorが繋がっている

signed main()
{
    cin >> N >> W;
    rep(i, N)
    {
        ll w, v;
        cin >> w >> v;
        if (i == 0) {
            w1 = w;
        }
        st[w - w1].push_back(v);
    }
    rep(i, 4)
    {
        // st = (0, biggest,..., smallest)
        sort(st[i].begin(), st[i].end());
        st[i].push_back(0);
        reverse(st[i].begin(), st[i].end());
        for (ll j = 1; j < st[i].size(); ++j) {
            st[i][j] += st[i][j - 1]; // wごとに累積和を取る
        }
    }
    ll res = 0;
    rep(i, st[0].size())
    {
        rep(j, st[1].size())
        {
            rep(k, st[2].size())
            {
                rep(l, st[3].size())
                {

                    ll fact = w1 * i + (w1 + 1) * j + (w1 + 2) * k + (w1 + 3) * l;
                    if (fact <= W) {
                        res = max(res, st[0][i] + st[1][j] + st[2][k] + st[3][l]);
                    }
                }
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
A=input()
B=input()
def judge(A,B):
    if len(A)>len(B):
        print("GREATER")
        return
    elif len(A)<len(B):
        print("LESS")
        return
    else:
        i=0
        while i<len(A):
            a=A[i]
            b=B[i]
            if a>b:
                print("GREATER")
                return
            elif a==b:
                i+=1
                continue
            else:
                print("LESS")
                return
        print("EQUAL")
        return
judge(A,B)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;


int main() {
    int n;
    cin >> n;
    if (n == 1) cout << "Hello World" << endl;
    else if (n == 2) {
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    } else {
        return 1;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <map>
#include <cmath>
using namespace std;
const int E=100*1000;
map<long long,long long> op,ap;
map<long long,long long>::iterator it;
bool b[E+5];
long long pr[E];
int n,i,j,cubic,put,tot,ii;
long long x,A,B,T;
void sieve()
{
    for(i=2;i<=E;i++)
      if(!b[i])
        for(j=2*i;j<=E;j+=i)
          b[j]=1;
}
long long sqrtt(long long X)
{
    long long ret=sqrt(X);
    if(1LL*(ret-1)*(ret-1)==X) return ret-1;
    if(1LL*(ret+1)*(ret+1)==X) return ret+1;
    return ret;
}
int main()
{
    //freopen("data.in","r",stdin);
    cin>>n;
    sieve();
    for(i=2;i<=3*1000;i++)
        if(!b[i])
    {
        cubic++;
        pr[cubic]=i;
    }
    for(i=1;i<=n;i++)
    {
        cin>>x;A=B=1;
        for(ii=1;ii<=cubic;ii++)
            if(x%pr[ii]==0)
        {
            put=0;
            while(x%pr[ii]==0)
                x/=pr[ii],put++;
            put%=3;
            if(put!=0)
            {
                for(j=1;j<=put;j++)
                    A*=pr[ii];
                for(j=1;j<=3-put;j++)
                    B*=pr[ii];
            }
        }
        if(x>1)
        {
        T=sqrtt(x);
        if((b[T]==0&&1LL*T*T==x)||(x<=E&&b[x]==0))
        {
            if((b[T]==0&&1LL*T*T==x))
            {
             A*=1LL*T*T;
             B*=T;
            }
            else
            {
                A*=1LL*x;
                B*=1LL*x*x;
            }
        }
        else
            B=0,A=-1;
        }
        ap[A]++;op[A]=B;
    }
    if(ap[1]) tot=1;
    for(it=op.begin();it!=op.end();it++)
        if(ap[it->first]>ap[it->second]||(ap[it->first]==ap[it->second]&&it->first<it->second))
          tot+=ap[it->first];
    cout<<tot;
    return 0;
}

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

Robo = []
for i in range(n):
    x, l = map(int, input().split())
    Robo.append([x-l, x+l])
Robo.sort(key=lambda x: x[1])

#print(Robo)
biggest_right = 2 * -10**9 - 1
counter = 0
for left, right in Robo:
    if biggest_right <= left:
        counter += 1
        biggest_right = max(right, biggest_right)
print(counter)

Measured memory_bytes: 62936
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int max = 0;
      
      for(int i=0; i<=N; i++){
        if(i*i > N){
          break;
        }
        if(i*i >= max){
          max = i*i;
        }
      }
      System.out.println(max);
    }
}

Measured memory_bytes: 23764
#!/usr/bin/python3
import itertools

n = int(input())
A = []
for i in range(n):
    src = input()
    dst = src.replace('-1', '3000')
    ai = list(map(int, dst.split()))
    A.append(ai)
# rand
i = 0
S = 0
G = set()
T = set(range(n))

T.remove(i)
G.add(i)

while len(T) > 0:
    m = 3000
    mg = None
    mt = None
    for g, t in itertools.product(G, T):
        if A[g][t] < m:
            mg = g
            mt = t
            m = A[g][t]
    S += m
    G.add(mt)
    T.remove(mt)

print(S)

Measured memory_bytes: 7820
// https://atcoder.jp/contests/abc115/tasks/abc115_c

#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))

int main() {
    int n, k;
    // ios::sync_with_stdio(false);
    // cin.tie(0);

    cin >> n >> k;
    int h[n], df[n];

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

    // 小さい順に並び替えた後、k個の高さの差を計算する
    for (int i = 0; i < n - k + 1; i++) {
        df[i] = h[i + k - 1] - h[i];
    }
    // 差分を並び替える
    sort(df, df + n - k + 1);

    cout << df[0] << endl;

    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int count = 0;
			int current = 1;
			for (int i = 0; i < n; i++) {
				if (sc.nextInt() == current) {
					current++;
				} else {
					count++;
				}
			}

			if (n == count) {
				System.out.println(-1);
			} else {
				System.out.println(count);
			}
		}
	}
}


Measured memory_bytes: 62824
import java.io.PrintWriter
import java.util.ArrayDeque

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

/** edge info */
data class Edge(val to: Int)

fun solve(out: PrintWriter) {
    val (n, m) = readIntegerList()
    val hList = readIntegerList()
    /** graph[fromNodeIndex]: edges to other node */
    val graph = Array(n) { mutableListOf<Edge>() }
    repeat(m) {
        val (a, b) = readIntegerList().map { it - 1 }
        graph[a].add(Edge(b))
        graph[b].add(Edge(a))
    }

    val isGoodNodeArray = BooleanArray(n) { true }
    val isUnchecked = BooleanArray(n) { true }
    for (i in 0 until n) {
        val nodeQueue = ArrayDeque<Int>()
        nodeQueue.addLast(i)
        isUnchecked[i] = false
        while (nodeQueue.isNotEmpty()) {
            val node = nodeQueue.removeFirst()
            for (edge in graph[node]) {
                if (isUnchecked[edge.to]) {
                    isUnchecked[edge.to] = false
                    nodeQueue.addLast(edge.to)
                }

                if (hList[node] <= hList[edge.to]) {
                    isGoodNodeArray[node] = false
                }
            }
        }
    }

    println(isGoodNodeArray.count { it })
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 82424
import sys
sys.setrecursionlimit(10000000)
N = int(raw_input())
dict = {}
for i in range(1,N+1):
    dict[i]={}
for i in range(1,N):
    a = map(int,raw_input().split())
    dict[a[0]].update({a[1]:a[2]})
    dict[a[1]].update({a[0]:a[2]})
leng = {}
q,K = map(int,raw_input().split())
def rec(bef,now):
    leng[now]=leng[bef]+dict[bef][now]
    for i in dict[now]:
        if i in leng:
            continue
        rec(now,i)
leng[K] = 0
for j in dict[K]:
    rec(K,j)
for i in range(0,q):
    a,b = map(int, raw_input().split())
    print leng[a]+leng[b]

Measured memory_bytes: 149924
N = list(map(int,list(input())))
K = int(input())
#print(N)

def main(k,p):
    l = len(k)
    x = 9 ** p###先頭桁が0
    for i in range(p):
        x *= max(l - 1 - i,0)
    for i in range(p):
        x //= (i+1)
    y = (k[0] - 1)*(9**(p-1))###先頭桁が1以上k[0]-1以下
    for i in range(p-1):
        y *= max(l - 1 - i,0)
    for i in range(p-1):
        y //= (i+1)
    ##以下, 先頭がk[0]
    i = 1
    while i < l-1 and k[i] == 0 :
        i += 1
    #print("i=",i)
    if p == 1:
        z = 1
    elif i == l-1 and k[i]==0:
        z = 0
    else:
        z = main(k[i:],p-1)
    #print(k,x,y,z)
    return (x+y)+z

if len(N) < K:
    print(0)
else:
    print(main(N,K))

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

int Sum(vector<int>& x) {
    int ret = 0;
    for (int i = 0; i < 3; i++) ret += x[9 - i];
    return ret;
}

int main() {
    vector<int> a(10), b(10);
    for (auto& i : a) cin >> i;
    for (auto& i : b) cin >> i;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    cout << Sum(a) << " " << Sum(b) << endl;

    return 0;
}

Measured memory_bytes: 3008
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  string s; 
  cin>>s;
  int a = 0, b=0;
  for(int i = 0 ; i < 3;  i++)
   {
        if(s[i]=='A')
            a++;
        else
            b++;
    }
    if(a==1||b==1)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#ifdef ONLINE_JUDGE
#define D(...)
#else
#define D(...)cerr<<__LINE__<<":"<<"["<<#__VA_ARGS__<<"]->",P(__VA_ARGS__)
#endif
void P(){cerr<<endl;} 
template<typename H,typename...T>void P(H h,T...t){cerr<<h<<" ";P(t...);}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    int cnt=0;
    for(int i=1;i<=n;i+=2){
        int num=i,it=0;
        for(int j=1;j<=num;++j){
            if(num%j==0)it++;
        }
        if(it==8){
            cnt++;
        }
    }
    cout<<cnt;


}

Measured memory_bytes: 3660
#include <iostream>
#include "math.h"

using namespace std;

int main() {
  	int n, m, x;
  	cin >> n >> m >> x;
  	int c[n], a[n][m];
  	for (int i = 0; i < n; i++) {
      	cin >> c[i];
      	for (int j = 0; j < m; j++) {
          	cin >> a[i][j];
        }
    }
  
  	int ans = -1, sum, skil[m], ok;
  	for (int b = 0; b <= pow(2,n); b++) {
      	sum = 0;
      	ok = 1;
      	for (int i = 0; i < m; i++) {
          	skil[i] = 0;
        }
      
      	for (int i = 0; i < n; i++) {
        	if ((int)(b & (int)pow(2,i)) == (int)pow(2,i)) {
              	sum += c[i];
      			for (int j = 0; j < m; j++) {
          			skil[j] += a[i][j];
        		}
            }
        }
      
      	for (int i = 0; i < m; i++) {
          	if (skil[i] < x) {
              	ok = 0;
            }
        }
      	if (ok) {
          	if (sum < ans || ans < 0) {
              	ans = sum;
            }
        }
    }
    cout << ans << endl;
  
  	return 0;
}

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

using namespace std;


#define PI 3.14159265
#define int long long



main(){


	int n, k; cin >> n >> k;

	vector <double> p(n);

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


	double ans = 0, sum = 0;

	for(int i = 0; i < k; i++) sum += (1 + p[i]) / 2;

	ans = sum;

	for(int i = k; i < n; i++){
		sum -= (1 + p[i - k]) / 2;
		sum += (1 + p[i]) / 2;

		ans = max(ans, sum);
	}
	
	cout << fixed << setprecision(10);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1792