akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

class UnionFind {
public:
  vector<ll> parent; //parent[i]はiの親
  vector<ll> siz; //素集合のサイズを表す配列(1で初期化)
  map<ll,vector<ll>> group;//素集合ごとに管理する連想配列(keyはそれぞれの素集合の親、valueはその素集合の要素の配列)

  //コンストラクタ
  UnionFind(ll n):parent(n),siz(n,1){
    //全ての要素の根が自身であるとして初期化
    for(ll i=0;i<n;i++){parent[i]=i;}
  }

  //データxの属する木の根を取得(経路圧縮も行う)
  ll root(ll x){
    if(parent[x]==x) return x;
    return parent[x]=root(parent[x]);//代入式の値は代入した変数の値なので、経路圧縮できる
  }

  //xとyの木を併合
  void unite(ll x,ll y){
    ll rx=root(x);//xの根
    ll ry=root(y);//yの根
    if(rx==ry) return;//同じ木にある時
    //小さい集合を大きい集合へと併合(ry→rxへ併合)
    if(siz[rx]<siz[ry]) swap(rx,ry);
    siz[rx]+=siz[ry];
    parent[ry]=rx;//xとyが同じ木にない時はyの根ryをxの根rxにつける
  }

  //xとyが属する木が同じかを判定
  bool same(ll x,ll y){
    ll rx=root(x);
    ll ry=root(y);
    return rx==ry;
  }

  //xの素集合のサイズを取得
  ll size(ll x){
    return siz[root(x)];
  }

  //素集合をそれぞれグループ化
  void grouping(ll n){
    //経路圧縮を先に行う
    rep(i,n)root(i);
    //mapで管理する(デフォルト構築を利用)
    rep(i,n)group[parent[i]].push_back(i);
  }
};

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n,m; cin >> n >> m;
  UnionFind tree(n);
  ll ans = 0;
  rep(i,m){
    int a,b;  cin >> a >> b;
    a--; b--;
    tree.unite(a,b);
  }
  rep(i,n) chmax(ans,tree.size(i));
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 6360
// C++test1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <vector>
#include <numeric>
#include<string>
#include <map>

using namespace std;

#define ll long long
#define rep(cnt,a,n) for(ll cnt=a;cnt<n+a;cnt++) //aから始めてn回ループ
#define vector2(type,name,a,b) vector<vector<type>> name(a, vector<type>(b))
#define PI 3.141592653589793



int main() {
    string s, t;
    cin >> s;
    cin >> t;
    ll changecnt = 0;
    rep(cnt, 0, s.size()) {
        if (s[cnt] != t[cnt]) {
            changecnt++;
            //cout << s[cnt] << endl;
        }
    }
    cout << changecnt << endl;

    return 0;
}


Measured memory_bytes: 3908
import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		String u, nl = System.getProperty("line.separator");
		StringBuilder 
			p = new StringBuilder(1000),
		  	d = (new StringBuilder(100)).append("."),
		  	s = (new StringBuilder(100)).append("#"),
		  	k = new StringBuilder(100);
		Scanner r = new Scanner(System.in);
		int h, w, ww = 0;
		while (4 > ww++) {
			d.append(d);
			s.append(s);
		}
		ww = d.length();
		while (0 != ((h = r.nextInt()) | (w = r.nextInt()))) {
			while (w > ww) {
				d.append(d);
				s.append(s);
				ww += ww;
			}
			p.append(u = s.substring(0, w)).append(nl);
			k.setLength(0);
			k.append(d.substring(0, w)).append(nl)
			.replace(0, 1, "#").replace(w - 1, w, "#");
			while (2 < h--) {
				p.append(k);
			}
			p.append(u).append(nl).append(nl);
		}
		System.out.print(p);
	}
}

Measured memory_bytes: 17172
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define REPI(i, a, b) for (ll (i) = (a); (i) < (b); (i)++)
#define int long long
using namespace std;
using P = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;

int N;
VI a;

signed main() {
  cin >> N;
  a.resize(N);
  REP (i, N) {
    cin >> a[i]; a[i]--;
  }
  vector<bool> visited(N, false);
  int cnt = 0;
  int x = 0;
  while (!visited[x]) {
    visited[x] = true;
    if (x == 1) {
      cout << cnt << endl;
      return 0;
    }
    x = a[x];
    cnt++;
  }
  cout << -1 << endl;
}


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

using namespace std;
using namespace atcoder;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

void solve(long long N, long long Q, std::vector<long long> t,
           std::vector<long long> u, std::vector<long long> v) {
    auto d = dsu(N);
    for (int i = 0; i < Q; i++) {
        if( t[i] == 0 ){
            d.merge(u[i], v[i]);
        }else{
            cout << d.same(u[i], v[i]) << endl;
        }
    }
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long Q;
    scanf("%lld", &Q);
    std::vector<long long> t(Q);
    std::vector<long long> u(Q);
    std::vector<long long> v(Q);
    for (int i = 0; i < Q; i++) {
        scanf("%lld", &t[i]);
        scanf("%lld", &u[i]);
        scanf("%lld", &v[i]);
    }
    solve(N, Q, std::move(t), std::move(u), std::move(v));
    return 0;
}


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

int main(){
  int N; cin >> N;
  int A,B; cin >> A >> B;
  
  int count[3] = {0};
  int p;
  REP(i,N){
    cin >> p;
    if(p<=A) count[0]++;
    else if(p<=B) count[1]++;
    else count[2]++;
  }
  int r = min(count[0], min(count[1],count[2]) );
  cout << r << "\n";
}

Measured memory_bytes: 256
// abc163_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    ll N, M;
    cin >> N >> M;
    vector<ll> A(M);
    REP(i, M) cin >> A[i];

    ll sm = accumulate(ALL(A), 0);

    ll ans = N - sm;
    if (ans < 0){
        print(-1);
    } else{
        print(ans);
    }


    return 0;
}


Measured memory_bytes: 3692
N, K = map(int, input().split())
X = list(map(int, input().split()))

ct = [0]*(N-K+1)

for i in range(N-K+1):
  if (X[i]<0)&(X[i+K-1]>0):
    ct[i] = min(abs(X[i]),(X[i+K-1]))*2+max(abs(X[i]),(X[i+K-1]))
  else:
    ct[i] = max(abs(X[i]),(X[i+K-1]))
  
print(min(ct))

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, K, T, W, H, M, C;

const int MAX = 510000;
const int MOD = 1e9;

const double PI=3.14159265358979323846;

/*
long long fac[MAX], finv[MAX], inv[MAX];

vector<double> cx, cy, c;
 ll MM = 1e12;

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

std::vector<int> Eratosthenes(int n ){
    std::vector<bool> is_prime( n + 1 );
    for( int i = 0; i <= n; i++ ) is_prime[ i ] = true;
    std::vector<int> P;
    for( int i = 2; i <= n; i++ ){
        if( is_prime[ i ] ){
            for( int j = 2 * i; j <= n; j += i ){
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}*/

int length(vector<int> v, int u, int HW){
    if(v.size() == 0) return HW;
    if(v[0] > u) return v[0];
    if(v[v.size() - 1] < u) return HW - v[v.size()- 1] -1;
    else{
        int i = lower_bound(ALL(v), u)- v.begin();
        return v[i] - v[i-1] -1;
    }
}

int st[200001], t[10000];

int main(){
    cin >>N;
    vector<ll> v(N);
    REP(i,N) cin >> v[i];
    vector<vector<ll>> dp(N+1, vector<ll> (2));
    dp[0][0] = 0;
    dp[0][1] = -1e12;
    for(int i = 0; i < N ; ++i){
        dp[i+1][0] = max(dp[i][0] + v[i] , dp[i][1] - v[i]);
        dp[i+1][1] = max(dp[i][0] - v[i] , dp[i][1] + v[i]);
    }
    cout << dp[N][0];
    return 0;
}

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

int sumofdigits(int x) {
  int sum = 0;
  while (x > 0) {
    sum += x % 10;
    x /= 10;
  }
  return sum;
}

int main() {
  int n, k;
  std::cin >> n >> k;
  
  std::vector<int> l(n);
  for (int i = 0; i < n; i++) {
    std::cin >> l.at(i);
  }
  std::sort(l.begin(), l.end(), std::greater<int>());
  
  int sum = 0;
  for (int i = 0; i < k; i++) {
    sum += l.at(i);
  }
  
  std::cout << sum << '\n';
}

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

#define ll long long

int main(){
    int k,a,b;
    cin>>k>>a>>b;
    int flag=0,ans=0;
    while(ans<=b){
        if(ans>=a && ans<=b){
            flag=1;
            break;
        }
        ans+=k;
    }
    if(flag) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main(void){
    int len, ans = 0;
    string s;
    cin >> s;
    len = s.length();
    for(int i=0;i<len/2;i++){
        if(s[i] != s[len - 1 - i]) ans++;
    }
    cout << ans << endl;
}


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

using ll = unsigned long long;
#define int long long
using namespace std;

// http://drken1215.hatenablog.com/entry/2019/02/24/224100
// https://qiita.com/nomikura/items/4e66f708895fb7db76d1

void chmin(int &a, int b) {
    // b のが小さければ，aを入れ替える
     if (a > b) {
         a = b;
     } 
}


// solve
int rec(int i, int a, int b, int c, const int n, const int ca, const int cb, const int cc, int* l) {

    if(i == n) {
        if(!a || !b || !c) {
            // 1本も使ってない
            // cout << "out" << endl;
            return INT32_MAX;
            // return INFINITY;
        }
        // 合体後の差分
        return abs(a-ca) + abs(b-cb) + abs(c-cc);
    }

    // 選ばないことにした場合のコスト
    int res = rec(i+1,a,b,c,n,ca,cb,cc,l);
    // Aにマージした際のコスト
    chmin(res, rec(i+1, a+l[i], b,c,n,ca,cb,cc,l)+(a>0 ?10:0));
    // Bにマージした際のコスト
    chmin(res, rec(i+1, a, b+l[i],c,n,ca,cb,cc,l)+(b>0 ?10:0));
    // Cにマージした際のコスト
    chmin(res, rec(i+1, a, b,c+l[i],n,ca,cb,cc,l)+(c>0 ?10:0));
    // 1本目はコスト増加なし

    // それぞれを選んだ場合のコストの小さい値にresを入れ替える
    // 深さ優先探索の結果，最小のresがドンドン上に伝搬する
    // 最終的には，全ノードを考慮した探索が行える

    // cout << res << endl;
    return res;

}


signed main() {

    int n, a, b, c;
    cin >> n >> a >> b >> c;
    int *l = new int[n];

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

    cout << rec(0,0,0,0,n,a,b,c,l) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    ll x;
    ll a, b;

    cin >> x;

    for (ll i = -1000; i <= 1000; i++)
    {
        for (ll j = -1000; j <= 1000; j++)
        {
            a = pow(i, 5);
            b = pow(j, 5);

            if (a - b == x)
            {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 4100
#include<stdio.h>
#include<string>
#include<iostream>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<list>
using namespace std;

int main() {
	int N;
	long long num1 = 0;
	cin >> N;
	string s;
	long long num[5] = {0};
	for (int i = 0;i < N;i++) {
		cin >> s;
		if (s[0] == 'M') {
			num[0]++;
		}
		else {
			if (s[0] == 'A') {
				num[1]++;
			}
			else {
				if (s[0] == 'R') {
					num[2]++;
				}
				else {
					if (s[0] == 'C') {
						num[3]++;
					}
					else {
						if (s[0] == 'H') {
							num[4]++;
						}
					}
				}
			}
		}
	}
	sort(num, num + 5);
	for (int i = 0;i < 3;i++) {
		for (int j = i + 1;j < 4;j++) {
			for (int k = j + 1;k < 5;k++) {
				if (num[i] > 0) {
					if (num[j] > 0) {
						if (num[k] > 0) {
							num1 += num[i] * num[j] * num[k];
						}
					}
				}
			}
		}
	}
	
	cout << num1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll x,y,z;
    cin>>x>>y>>z;
    cout<<z<<' '<<x<<' '<<y<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define in insert
#define pb push_back
#define endl '\n'
#define ub upper_bound
#define lb lower_bound
#define pf pop_front
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);srand(time(0));
using namespace std;
ll mod=1e9+7;
void fun()
{
	ll m,n,k;cin>>m>>n>>k;
	ll a[m],b[n];
	
	for(int i=0;i<m;i++)cin>>a[i];
	
	for(int i=0;i<n;i++)cin>>b[i];
	
	ll s=0;int i=0;
	while(i<m&&(s+a[i])<=k)
	{
		s+=a[i];i++;
	}
	int r=0;ll p=0;int ans=0;
	for(int j=i-1;j>=0;j--)
	{
		ll d=k-s;
		while(r<n&&(p+b[r])<=d)
		{
			p+=b[r];r++;
		}
		ans=max(ans,j+r+1);
		s-=a[j];
	}
	i=0;s=0;
	while(i<n&&(s+b[i])<=k)
	{
		s+=b[i];i++;
	}
	ans=max(ans,i);
	cout<<ans;
}
int main()
{
    fast;
    int t=1;
    //cin>>t;
    while(t--)
    {
    	fun();
	}
}

Measured memory_bytes: 6768
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

//inline int read(){int t = 0;int neg=1;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1;continue;}t=t*10+c-48;}return neg*t;}
//inline int readl(){long long t = 0;long long neg=1ll;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1ll;continue;}t=t*10+c-48;}return neg*t;}

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pi;
typedef pair<lli,lli> plli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<pi> vpi;
typedef vector<plli> vplli;
const lli M=1000000007ll;

int main(){
	fast_io 
	string s; cin>>s;
	if(s.size()>=6){
		if(s[2]==s[3] and s[4]==s[5]){
		
		cout<<"Yes";
		return 0;
		}
	
	} 
	cout<<"No";
	return 0;
}

Measured memory_bytes: 888
N, x = [int(i) for i in input().split(" ")]
lst = [int(i) for i in input().split(" ")]
 
lst.sort()
cnt = 0
 
for i in range(0,N-1):
  if x >= lst[i]:
    x -= lst[i]
    cnt += 1
  else:
    break

if x == lst[N-1]:
    cnt +=1
    
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}
int dfs(int v, ll N, bool visited[nmax])
{
    bool all_visited = true;

    for (int i = 0; i < N; i++)
    {
        if (!visited[i])
        {
            all_visited = false;
        }
    }

    if (all_visited)
    {
        return 1;
    }
    int ret = 0;
    for (size_t i = 0; i < N; i++)
    {
        if (!graph[v][i])
        {
            continue;
        }
        if (visited[i])
        {
            continue;
        }

        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }

    return ret;
}

void solve(long long S)
{
    ll sum = 0;
    string str = to_string(S);
    int n = str.size() - 1;
    if (n == 0)
    {
        cout << S << endl;
        return;
    }

    for (int bit = 0; bit < (1 << n); bit++)
    {
        int l = 0, r = 0;
        for (r = 0; r < n; r++)
        {
            if (bit & (1 << r))
            {
                sum += stoll(str.substr(l, r - l + 1));
                l = r + 1;
            }
            if (r == n - 1)
            {
                sum += stoll(str.substr(l, r - l + 2));
            }
        }
    }
    cout << sum << endl;
}

int main()
{
    long long S;
    scanf("%lld", &S);
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define ull unsigned long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,l; cin>>n>>l;
	vector<int> taste(n);
	REP(i,n) taste[i]=i+l;

	int sum=0;
	REP(i,n) sum+=taste[i];

	REP(i,n) taste[i]=abs(taste[i]);
	sort(taste.begin(),taste.end());

	int apple=taste[0];

	if(sum<0) cout<<sum+apple<<endl;
	else cout<<sum-apple<<endl;
}

Measured memory_bytes: 256
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ea=[0]
for i in range(n):
    ea.append(ea[i]+a[i])
eb=[0]
for i in range(m):
    eb.append(eb[i]+b[i])
if n<m:
    ea,eb=eb,ea
    n,m=m,n
tb=m
p=0
for i in range(n+1):
    while ea[i]+eb[tb]>k:
        if tb==0:
            break
        tb-=1
    if ea[i]+eb[tb]<=k:
        p=max(i+tb,p)
print(p)

Measured memory_bytes: 47348
// Sum of 4 integers

#include <iostream>
using namespace std;

int main() {
    int n;

    while (cin >> n) {
        int counter = 0;

        if (n > 36) {
            cout << "0\n";
        } else if (n == 36) {
            cout << "1\n";
        } else {
            for (int a = 0; a <= 9; a++) {
                for (int b = 0; b <= 9; b++) {
                    for (int c = 0; c <= 9; c++) {
                        for (int d = 0; d <= 9; d++)
                            if (a + b + c + d == n) counter++;
                    }
                }
            }
            cout << counter << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 2984
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;

int main() {

	Int x, a;
	cin >> x >> a;

	if (x < a)cout << 0 << endl;
	else cout << 10 << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,popcnt")
#include <bits/stdc++.h>
#define maxn 400010
#define ll long long
#define ull unsigned long long
#define ld long double
#define fi  first
#define se second
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define pii pair<int, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define IL inline
#define ss system
using namespace std;

ll f[maxn], a, b;
const ll p = 1e9 + 7;
vector<int> vec;
template <class T> void read (T &x) {
  char ch = x = 0;
  bool fl = false;
  while (!isdigit(ch))
    fl |= ch == '-', ch = getchar();
  while (isdigit(ch))
    x = x * 10 + ch - '0', ch = getchar();
  x = fl ? -x : x;
}
ll calc(ll x, ll y) {
  if (y > b || x > a)
    return 0;
  ll ret = ((b - y) / x + 1) % p;
  if (y <= a)
    ret = (ret + (a - y) / x + (x < y)) % p;
  return ret;
}
void solve() {
  read(a), read(b);
  if (a > b)
    swap(a, b);
  if (a == 1)
    return printf("%d %lld\n", 1, b % p), void();
  for (int i = 88; ~i; i--) {
    if (a >= f[i] && b >= f[i + 1]) {
      if (i <= 2) {
        printf("1 %lld\n", a % p * (b % p) % p);
        return;
      }
      ll ans = 0;
      map<pll,bool> residue;
      for (int j = i; j >= 0; j--) {
        ll tmp_x = f[i] + f[j] * f[i - j], tmp_y = f[i + 1] + f[j + 1] * f[i - j];
        if (residue[{ tmp_x, tmp_y % tmp_x }])
          continue;
        residue[{ tmp_x, tmp_y % tmp_x }] = true;
        ans = (ans + calc(tmp_x, tmp_y)) % p;
      }
      printf("%d %lld\n", i - 1, ans);
      return;
    }
  }
}
void init() {
  f[1] = f[2] = 1;
  for (int i = 3; i <= 89; i++) {
    f[i] = f[i - 1] + f[i - 2];
   // printf("i = %d, f = %lld\n", i, f[i]);
  }
}
int main() {
  int T;
  for (read(T), init(); T--; solve());
  return 0;
}

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

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

const ll mod =  1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976

int main()
{
    int n;cin >> n;
    int a[n];
    int sum = 0;
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    sort(a,a+n);
    if(sum % 10 != 0){
        cout << sum << endl;
    }else{
        rep(i,n){
            if(a[i] % 10 != 0){
                sum -= a[i];
                break;
            }
        }
        if(sum % 10 == 0) cout << 0 << endl;
        else cout << sum << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  	int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if(a == b && a != c){
    	printf("Yes");
  }else if(a == c && a != b){
    	printf("Yes");
  }else if(b == c && a != c){
    	printf("Yes");
  }else{
		printf("No");
  }
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  
 if(a>0)
 {
   cout<<"Positive";
 }
   else if(b>=0)
  {
     cout<<"Zero";}
  else {
    if((b-a+1)%2==0)
    {cout<<"Positive";}
    else {cout<<"Negative";}
  }
  
  
  
  
  return 0;
}

Measured memory_bytes: 256
import sys

n, k = map(int, sys.stdin.readline().split())
s = sys.stdin.readline().rstrip()

def main():
    cnt_seq = 1
    for i in range(n-1):
        if s[i] != s[i+1]:
            cnt_seq += 1
    
    res = n - cnt_seq
    r = k
    the_other = dict([('L', 'R'), ('R', 'L')])
    a = s[0]
    b = the_other[a]
    for i in range(1, n):
        if not r:
            break
        if s[i] == a and s[i-1] == b:
            res += 2
            r -= 1
    if s[-1] == b and r:
        res += 1

    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define  m_k make_pair
#define   P  pair<int,int>
#define  V vector
typedef long long LL;
typedef unsigned long long ULL;
//补题：题解放在了怎么从第1个得到第k个
//事实上，若a>b,则a变化得到的一定>b变化得到的

int main()
{
    int k;cin>>k;
    if(k<=9){
        cout<<k<<endl;
        return 0;
    }
    queue<LL> que;
    for(int i=1;i<=9;i++) que.push(i);
    LL current;
    for(int i=1;i<=k;i++)
    {
        current=que.front();//第k次取出来的就是第k个
        que.pop();
        int tail=current%10;
        if(tail>0) que.push(current*10+tail-1);
        que.push(current*10+tail);
        if(tail<9) que.push(current*10+tail+1);
    }

    cout<<current<<endl;
    return 0;
}
/*
int f[15][15];
void get(int st,int t,int k,queue<int> &s)
{
    if(t==0) return;
    
    {
        if(st==0)
        {
            if(k<f[t][0]){
                s.push(0);
                get(0,t-1,k,s);
                return;
            }
            else{
                k-=f[t][0];
                s.push(1);
                get(1,t-1,k,s);
                return;
            }

        }
        else
        {
            for(int i=st-1;i<=st+1;i++)
            {
                if(f[t][i]<k) k-=f[t][i];
                else{
                    s.push(i);
                    get(i,t-1,k,s);
                    return;
                }
            }
        }    
    }
    
}
int main()
{
    //i位数，首位是j
    int cnt[15];
    for(int i=0;i<=9;i++) f[1][i]=1;
    cnt[1]=9;
    for(int i=2;i<=13;i++)
    {
        cnt[i]=0;
        for(int j=0;j<=9;j++)
        {
            if(j==0) f[i][j]=f[i-1][0]+f[i-1][1];
            else if(j==9) f[i][j]=f[i-1][9]+f[i-1][8];
            else f[i][j]=f[i-1][j]+f[i-1][j-1]+f[i-1][j+1];
            cnt[i]+=f[i][j];
        }
    }
    int k;
    while(cin>>k)
    {
        queue<int> ans;
        int t=1;
        while(k-cnt[t]>0){
            k-=cnt[t];
            t++;
        }
        //t位数的第k个
        for(int i=1;i<=9;i++)
        {
            if(f[t][i]<k) k-=f[t][i];
            else{
                ans.push(i);
                get(i,t-1,k,ans);
                break;
            }
        }
        
        while(!ans.empty()){
             cout<<ans.front();
             ans.pop();
        }
        cout<<endl;
    }
    return 0;
}
*/

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    int c0 = 0;
    int c1 = 0;
    int c2 = 0;
    bool ans = false;
    rep(i,N){
        if (vec[i] % 2 == 1){
            c0++;
        }
        else if (vec[i] % 4 == 2){
            c1++;
        }
        else{
            c2++;
        }
    }
    if (c1 == 0){
        if (c0 <= c2 + 1) ans = true;
    }
    else{
        if (c0 <= c2) ans = true;
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}



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

long long N=0,K=0,M=0,A=0,B=0,ans=0,p=0;
long long n=0,x=0,s=0,t=0,a=0,b=0;
string S,T,ANS;

long long gcd(long long a,long long b){
        if(a%b == 0) return(b);
        else return(gcd(b,a%b));
}
int main(){
    cin >> A >> B;
    a = max(A,B);
    b = min(A,B);
    s = min(A,B);

    ans = a*s/gcd(a,b);

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define llint long long int

using namespace std;

int N;
int A[100005];

int main(void)
{
	cin >> N;
	for(int i = 0; i < N; i++) cin >> A[i];
	
	sort(A, A+N);
	reverse(A, A+N);
	
	int prev = -1;
	int cnt = 0;
	llint length[2];
	
	for(int i = 0; i < N; i++){
		if(A[i] == prev){
			length[cnt] = A[i];
			cnt++;
			prev = -1;
		}
		else{
			prev = A[i];
		}
		
		if(cnt >= 2) break;
	}
	
	llint ans = length[0] * length[1];
	
	
	if(cnt >= 2) cout << ans << endl;
	else cout << 0 << endl;
	
	return 0;
}

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

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

const int MAX = 2000007;
const int MOD = 1000000007;

ll fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i=2; i<MAX;++i){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

ll COM(int n, int k){
    if(n < k)return 0;
    if(n < 0 || k < 0)return 0;
    return fac[n] * (finv[k] * finv[n-k] %MOD)%MOD;
}

int main() {
    COMinit();
    
    int x,y; cin>>x>>y;
    int ans = 0;
    if( (x + y)%3 != 0)ans = 0;
    else{
        int n = (x + y)/3;
        int k = (n - abs(x - y))/2;
        ans = COM(n, k);
    }
    
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 47104
#!/usr/bin/env python
from math import *
def g(x):
	y = (int((1000 * abs(x)) * 2 + 1) // 2) / 1000
	if x < 0:
		y *= -1
	return y
def func(x):
	x1, y1, x2, y2, x3, y3 = x

	vx1 = x2 - x1
	vy1 = y2 - y1
	vx2 = x3 - x1
	vy2 = y3 - y1
	k = (vx2 ** 2 + vy2 ** 2 - vx1 * vx2 - vy1 * vy2) / (vy1 * vx2 - vx1 * vy2) / 2
	x = vx1 / 2 + k * vy1 + x1
	y = vy1 / 2 - k * vx1 + y1
	r = sqrt((x1 - x) * (x1 - x) + (y1 - y) * (y1 - y))
	x = "{0:.3f}".format(g(x))
	y = "{0:.3f}".format(g(y))
	r = "{0:.3f}".format(g(r))
	print(x + " " + y + " " + r)
n = int(input())
a = []
for _ in range(n):
	a.append(list((map(float, input().split()))))
for i in a:
	func(i)


Measured memory_bytes: 5692
tmp = [int(i) for i in raw_input().split()]
tmp2 = [int(i) for i in raw_input().split()]

all = tmp[0]*tmp[1]
A = tmp[1]*tmp2[0]

B = tmp[0]*tmp2[1]

C = B - tmp2[0]*tmp2[1]

print(all - A - C)

Measured memory_bytes: 2568
L = int(input())
edges = []

p2 = 1
N = 1

""" 2べきのとき多重辺
   0     0     0     0  ...
1 === 2 === 3 === 4 === 5 ...
   1     2     4     8  ...
"""
while L >= p2 * 2:
    N += 1
    p2 *= 2
    edges.append((N - 1, N, 0))
    edges.append((N - 1, N, 2 ** (N - 2)))

rest = L - p2
tmp = p2
for i in range(N, -1, -1):
    if (rest >> i) & 1:
        edges.append((i + 1, N, tmp))
        tmp += 2 ** i

M = len(edges)
# assert N <= 20 and M <= 60
print(N, M)
for edge in edges:
    print(*edge)


Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  ll h,w,k; cin >> h >> w >> k;
  bool f=false;
  for(int i=0; i<=h; i++){
    for(int j=0; j<=w; j++){
      if(i*(w-j)+j*(h-i)==k){
        f=true; break;
      }
    }
  }
  if(f) puts("Yes");
  else puts("No");
  return 0;
}


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

int main(){
    ll N;
    vector<ll>T(5);
    cin >> N;
    rep(i,5)scanf("%lld",&T[i]);

    ll m = *min_element(T.begin(),T.end());
    cout << N/m + 4 + !!N%m << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#define ll long long
using namespace std;



int main(){
    ll n;
    cin>>n;
    vector<ll> smap(5);
    for(int i=0;i<n;i++){
        string s;
        cin>>s;        
        if('M'==s[0]) smap[0]++;
        if('A'==s[0]) smap[1]++;
        if('R'==s[0]) smap[2]++;
        if('C'==s[0]) smap[3]++;
        if('H'==s[0]) smap[4]++;
    }
    ll ans=0;
    for(int bit=0;bit<(1<<5);bit++){
        vector<int>memo;
        for(int i=0;i<5;i++){
            if(bit&(1<<i)) memo.push_back(i);
        }
        if(3!=memo.size())continue;
        ll res=1;
        for(int i=0;i<memo.size();i++){
            res*=smap[memo[i]];
        }
        ans+=res;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0001
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] numberFirst = new int[9];
            int[] numberSecond = new int[9];
            int answer;
            for (int i = 1; i < 10; ++i)
            {
                numberFirst[i-1] = i;
                for (int j = 1; j < 10; ++j)
                {
                    numberSecond[j - 1] = j;
                    answer = numberFirst[i-1] * numberSecond[j-1];
                    Console.WriteLine("{0}x{1}={2}",numberFirst[i-1],numberSecond[j-1],answer);
                }
            }
        }
    }
}



Measured memory_bytes: 15736
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch 100To105 | diff 100To105.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address 100To105.cpp && ./a.out

/*
 
 12/1/2019
 
 4:07-
 
 */

int X;

void solve() {
  int cnt=X/100;
  X%=100;
  int x=X;
  VI A={5,4,3,2,1};
  FORR(a,A) if(x>0&&cnt>0) {
    int b=min(cnt,x/a);
    cnt-=b;
    x-=a*b;
  }
  cout<<(x==0?1:0)<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>X;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[100005],n;
int main()
{
    long s=0,c=0;
  	cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=n;i++)
    {
        c=a[i];
        while(i<n&&a[i+1]!=0)
        {
            c+=a[i+1];
            i++;
        }
        s+=c/2;
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 640
n=int(input())
a=list(map(int,input().split()))

minus_num = 0
for i in range(n):
  if a[i] < 0:
    minus_num += 1

abs_a = list(map(abs,a))
if minus_num % 2 == 0:
  print(sum(abs_a))
else:
  print(sum(abs_a)-2*min(abs_a))

Measured memory_bytes: 19964
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
double add(double a, double b){
    if(abs(a + b) < EPS * (abs(a) + abs(b)))return 0;
    return a + b;
}
struct point {
    double x,y;

    point(){}
    point(double x,double y) :x(x), y(y){
    }

    point operator + (point p){
        return point(add(x,p.x),add(y,p.y));
    }

    point operator - (point p){
        return point(add(x,-p.x),add(y,-p.y));
    }
    point operator * (double d){
        return point(x * d,y * d);
    }
    double dot(point p){ //内積
        return add(x * p.x, y * p.y);
    }
    double det(point p){
        return add(x * p.y, -y * p.x);
    }
};

bool cmp_x(const point& p,const point& q){
    if(p.x != q.x) return p.x < q.x;
    return p.y < q.y;
}
vector<point> convex_hull(vector<point> ps,int n){
    sort(ps.begin(),ps.end(),cmp_x);
    int k = 0;
    vector<point> qs(n * 2);

    for(int i = 0; i < n;i++){
        while(k > 1 && (qs[k-1] - qs[k - 2]).det(ps[i] - qs[k - 1])  < 0)k--;
        qs[k++] = ps[i];
    }

    for(int i = n - 2, t = k;i >= 0;i--){
        while(k > t && (qs[k-1] - qs[k - 2]).det(ps[i]-qs[k-1]) < 0)k--;
        qs[k++] = ps[i];
    }
    qs.resize(k -1);
    return qs;

}
int main(){
    CIN(N);
    vector<point> vec;
    for(int a = 0;a < N;a++){
        CIN(b);CIN(c);
        point p(b,c);
        vec.pb(p);
    }
    vector<point> hoge = convex_hull(vec,N);
    cout<<hoge.size()<<endl;
    point ins(INF,INF);
    int s = -1;
    for(int a = 0;a < hoge.size();a++){
        if(ins.y != hoge.at(a).y){
            if(ins.y > hoge.at(a).y){
                ins = hoge.at(a);
                s = a;
            }
        }else{
            if(ins.x > hoge.at(a).x){
                ins = hoge.at(a);
                s = a;
            }
        }
    }
    for(int a = 0;a < hoge.size();a++){
        cout<<hoge.at((s+a)%hoge.size()).x <<" "<<hoge.at((a+s)%hoge.size()).y<<endl;
    }
    return 0;
}



Measured memory_bytes: 6728
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a[5];
	scanf("%s",a);
	for(int i=0;i<3;i++)
	{
		if(a[i]==a[i+1])
		{
			printf("Bad");
			return 0;
		}	
	}
	printf("Good");
	return 0;
}

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

using namespace std;

int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    char c=s[i]-3;
    if(c<'A'){
      c+='Z'-'A'+1;
    }
    cout<<c;
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 0
S=input()
x=['R','U','D']
y=['L','U','D']
l=len(S)
for i in range(l):
  if (i+1)%2!=0:
    if S[i]not in x:
      print('No')
      exit()
  else:
    if S[i] not in y:
      print('No')
      exit()

print("Yes")

Measured memory_bytes: 9064
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);
 
inline int sn(ll n){
    int ret = 0;
    while(n != 0) ret += (n % 10), n /= 10;
    return ret;
}

using R = long double;

ll f(ll n){
    ll ret = n;

    rep(d, 16){
        ll p = (ll)pow(10., d);
        rep(i, n / p % 10, 10){
            ll cur = ret / (p * 10) * (p * 10) + i * p + (p - 1LL);
            if(cur * sn(ret) < ret * sn(cur)){
                ret = cur;
            }
        }
    }

    return ret;
}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int K; cin >> K;
    ll cur = 1;
    rep(i, K){
        cout << cur << endl;
        cur = f(cur + 1);
    }
 
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define int long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
const int mod=1e9+7;
int up[200005],down[200005],sub[200005],fa[200005],n;
V<int> v[200005];
int f[200005],inv[200005];
int POW(int x,int y){
	if(!y)RE 1;
	int ans=POW(x,y>>1);ans=ans*ans%mod;
	if(y&1)RE ans*x%mod;else RE ans;
}
int C(int x,int y){
	RE f[y]*inv[x]%mod*inv[y-x]%mod;
}
void dfs(int p){
	for(auto u:v[p])if(u!=fa[p]){
		fa[u]=p;
		dfs(u);
		sub[p]+=sub[u];
	}
	int t=sub[p];
	down[p]=1;
	for(auto u:v[p])if(u!=fa[p]){
		down[p]=down[p]*C(sub[u],t)%mod*down[u]%mod;
		t-=sub[u];
	}
	sub[p]++;
}
void solve(int p){
	if(sub[p]==1)RE;
	int h=up[p]*C(n-sub[p],n-1)%mod,t=sub[p]-1;
	for(auto u:v[p])if(u!=fa[p]){
		h=h*C(sub[u],t)%mod*down[u]%mod;
		t-=sub[u];
	}
	for(auto u:v[p])if(u!=fa[p]){
		up[u]=h*POW(C(sub[u],n-1),mod-2)%mod*POW(down[u],mod-2)%mod;
		solve(u);
	}
}
signed main(){
//	ios::sync_with_stdio(0);
//	cin.tie(0);
	int x,y;
	cin>>n;
	inv[0]=f[0]=1;
	FOR(i,1,n){
		f[i]=f[i-1]*i%mod;
		inv[i]=POW(f[i],mod-2);
	}
	rep(i,1,n){
		cin>>x>>y;
		v[x].PB(y);
		v[y].PB(x);
	}
	dfs(1);
	up[1]=1;
	solve(1);
	FOR(i,1,n)cout<<C(sub[i]-1,n-1)*up[i]%mod*down[i]%mod<<'\n';
	RE 0;
}




Measured memory_bytes: 24048
import sys
from collections import Counter

mod = 10**9 + 7
def cmb(n, r, p=mod):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

input = sys.stdin.readline
N = int(input())
A = list(map(int, sys.stdin.readline().split()))

fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 2):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)

counter = Counter(A)
tmp = sorted(counter.items(), key = lambda x: x[1])
dup_n = tmp[-1][0]
# print(dup_n)

indices = [i for i, x in enumerate(A) if x == dup_n]
# print(indices)
left = indices[0]
right = indices[1]

print(cmb(N, 1))
for i in range(2, N+2):
# for i in range(1, N+2):
    tmp = cmb(N+1, i)
    tmp %= mod
    # 重複した数を含むパターン
    # print("debug", cmb(N+1, i), cmb(left, i-1), cmb(N - right, i-1))
    # print("debug", cmb(N+1, i), cmb(left + N - right, i-1))
    # if 1 < i: 
    #     tmp -= cmb(left, i-1) + cmb(N - right, i-1) 
    if 1 < i: 
        tmp -= cmb(left + N - right, i-1) 
    tmp %= mod
    print(tmp)
# print(cmb(N+1, N+1))

Measured memory_bytes: 119636
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
#define NUM 1000000007
typedef long long int lli;

int getAbs(int x);

int main(){
    int n, x;
    cin >> n >> x;
    vector<int> diff;
    for(int i = 0; i < n; i++){
        int p;
        cin >> p;
        diff.push_back(getAbs(p - x));
    }

    sort(diff.begin(), diff.end(), greater<int>());
    int ans = diff[0];
    
    for(int i = 1; i < n; i++){
        ans = __gcd(ans, diff[i]);
    }
    cout << ans << endl;
    //cout << __gcd(21, 14) << endl;
    //cout << __gcd(14, 21) << endl;
    return 0;
}

int getAbs(int x){
    return (x > 0)? x : -x;
}

Measured memory_bytes: 892
from copy import copy, deepcopy
from collections import Counter
from math import sqrt, floor, factorial
from itertools import permutations, combinations, combinations_with_replacement
from operator import mul
from functools import reduce

MOD = 10**9 + 7
INF = float('inf')

N, K = list(map(int, input().split()))
ans = [0] * N
# print(ans)
for _ in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    # print(A)
    for i in range(len(A)):
        ans[A[i]-1] += 1
# print(ans)
print(ans.count(0))


Measured memory_bytes: 9612
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
int main(){
	int A=read(),B=read(),C=read();
	printf("%lld\n",(ll)min(C,B+A+1)+B);
	return 0;
}


Measured memory_bytes: 256