akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

//山1に降った雨を多めに見積もると
//山奇数に降った雨も多めに見積もられる
//結果ダムNに多くたまる

int A[100100];

signed main() {
    int N;
    cin >> N;
    rep(i, N) {
        cin >> A[i];
    }
    int cant = -1;
    int can = A[0];
    //cant<山1に降った雨の量/2<=can
    while (can - cant > 1) {
        int m = (cant + can) / 2;
        int prev = m;
        for (int i = 1; i < N; ++i) {
            prev = A[i - 1] - prev;
            if (prev < 0) {
                if (i % 2 == 0) {
                    cant = m;
                } else {
                    can = m;
                }
                goto next;
            }
        }
        if (prev + m >= A[N - 1])can = m;
        else cant = m;
        next:;
    }
    cout << can * 2;
    int prev = can;
    for (int i = 1; i < N; ++i) {
        prev = A[i - 1] - prev;
        if (prev < 0) {
            return 1;
        }
        cout << " " << prev * 2;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2048
import collections

N = int(input())
arr = [list(map(int,input().split())) for _ in range(N)]
if N==1:
  print(1)
else:
  arr = sorted(arr,key=lambda x:(x[0],x[1]))
  diff_arr = []
  for j in range(N):
    for k in range(1,N-j):
      diff_arr.append(str(arr[j+k][0]-arr[j][0])+'_'+str(arr[j+k][1]-arr[j][1]))
  c = collections.Counter(diff_arr)
  print(N-max(c.values()))
  


Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define clr(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn=100010;
char c[100010];
ll p=1e9+7;
ll v[220];
inline ll qpow(ll a,ll b,ll p)
{
	ll ans = 1;
	a %= p;
	b %= p;
	while(b)
	{
		if(b & 1)
		{
			ans *= a;
			ans %= p;
		}
		a *= a;
		a %= p;
		b >>= 1;
	}
	return ans;
}
int main(void)
{
	int i;
	ll ans,sum,n,ss,sss;
	while(~scanf("%lld",&n))
	{
		scanf("%s",c);
		memset(v,0,sizeof(v));
		for(i = 0;i < n;i++)
		{
			v[c[i]]++;
		}
		ans = 0;
		sum = 0;
		ss = 0;
		sss = 1;
		for(i = 'a';i <= 'z';i++)
		{
			if(v[i] >= 2)
			{
				ans += (qpow(2,v[i],p) - v[i] - 1 + p + p) % p * (sss) % p * qpow(2,n - ss - v[i],p) % p;
				//printf("%lld\n",v[i]);
			}
			sum += (v[i] >= 1);
			ss += v[i];
			sss *= (v[i] + 1);
			sss %= p;
			ans %= p;
		}
		//printf("ans = %lld\n",ans);
		printf("%lld\n",(qpow(2,n,p) - ans + p - 1 + p) % p);
	}
	return 0;
}































Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <iomanip>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>

#include <algorithm>
#include <numeric>
#include <random>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define endl '\n'

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7;
const int MAXN = static_cast<int>(2e5) + 17;

int n;
int a[MAXN];

bool read() {
    if (!(cin >> a[0] >> a[1] >> a[2]))
        return false;

    return true;
}

void solve() {
    int ans = INF;

    for (int i = 0; i < 3; ++i)
        for (int j = 0; j < 3; ++j)
            for (int k = 0; k < 3; ++k)
                if (i != j && j != k && i != k)
                    ans = min(ans, abs(a[i] - a[j]) + abs(a[j] - a[k]));

    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::mt19937 rand('S' + 'E' + 'R' + 'E' + 'Z' + 'H' + 'K' + 'A');

#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	int N, K;
	cin >> N >> K;

	cout << ((N % K) ? 1 : 0) << endl;

ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}




Measured memory_bytes: 504
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using INT=mp::cpp_int;
using namespace std;
using ll=long long;
using vec=vector<ll>;
using vect=vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
INT LCM(INT x,INT y){
  INT z=gcd(x,y);
  return x*y/z;
}
ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}
INT modinv(INT a, INT m) {
    INT b = m, u = 1, v = 0;
    while (b) {
        INT t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int main() {
  cout << fixed << setprecision(30);
  ll n;
  cin>>n;
  vec a(n);
  loop(i,n)cin>>a[i];
  sort(all(a));
  bool check=true;
  loop(i,n-1){
    if(a[i+1]==a[i])check=false;
  }
  if(check)putout("YES");
  else putout("NO");
}


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

int main()
{
	int N,i,j,k,d;
	int a[6];
	int m[32];
	int M[32];
	for (i=0; i<32; i++)
	{
		m[i]=1000000000;
		M[i]=-1000000000;
	}
	scanf("%d",&N);
	d=2;
	for (i=0; i<N; i++)
	{
		for (j=0; j<d; j++)
			cin>>a[j];//,fix();
		for (j=0; j<1<<(d-1); j++)
		{
			int x=a[0];
			for (k=0; k<d-1; k++)
				if (j&(1<<k))
					x+=a[k+1];
				else
					x-=a[k+1];
			if (m[j]>x)
				m[j]=x;
			if (M[j]<x)
				M[j]=x;
		}
	}
	int ans=0;
	for (i=0; i<1<<(d-1); i++)
		if (ans<M[i]-m[i])
			ans=M[i]-m[i];
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;

int r, g, b, n, counts=0;

int main() {
	cin >> r >> g >> b >> n;

	for (int i = 0; i <= 3000; ++i)
	{
		for (int j = 0; j <= 3000; ++j)
		{
			int s = n - (r*i + g*j);
			if (s >= 0 && s%b == 0)
			{
				counts++;
			}
		}
	}

	cout << counts << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
using P = pair<int, int>;
const int mx = 105;
int n, a, b, t, ans;
P c[2][mx];
set<int> st;
int main(){
	scanf("%d", &n);
	rep(i,2){
		rep(j,n){
			scanf("%d%d", &a, &b);
			c[i][j] = P(a,b);
		}
		sort(c[i],c[i]+n);
	}
	rep(i,n){
		while(t < n && c[0][t] < c[1][i]) st.insert(-c[0][t++].second);
		auto it = st.lower_bound(-c[1][i].second);
		if(it != st.end()){
			ans++;
			st.erase(it);
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
import Control.Monad
main = do
    n <- read <$> getLine
    as <- map read <$> replicateM n getLine
    putStrLn $ show $ solve as

solve :: [Int] -> Int
solve [] = 0
solve (a:[]) = a `div` 2
solve (a:0:cs)  = a `div` 2 + solve cs
solve (a:b:cs)
    | even a    = a `div` 2 + solve (b:cs)
    | otherwise = a `div` 2 + solve (1+b:cs)

Measured memory_bytes: 59644
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L


int Z_algo(string s) {
    int n = s.length();
    vector<int> z(n);
    int L = 0, R = 0;
    for (int i = 1; i < n; i++) {
        if (i > R) {
            L = R = i;
            while (R < n && s[R - L] == s[R]) R++;
            z[i] = R - L; R--;
        }
        else {
            int k = i - L;
            if (z[k] < R - i + 1) z[i] = z[k];
            else {
                L = i;
                while (R < n && s[R - L] == s[R]) R++;
                z[i] = R - L; R--;
            }
        }
    }
    int mx = 0;
    for (int i = 0; i < n; i++) mx = max(mx, min(i,z[i]));
    return mx;
}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int mx = 0;
    for (int i = 0; i < n; i++) {
        mx = max(mx, Z_algo(s.substr(i, n-i)));
    }
    
    
    cout << mx;
    return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef long long ll;
const ll maxn = 1e5+100,mod = 1e9+7,INF = 1ll<<62;
int main(){
	ll n,t;
	cin>>n>>t;
	cout<<max(n-t,0ll);
}


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

template<typename T>
istream& operator >> (istream& istr, vector<T>& vec){
    for(T& x: vec) istr >> x;
    return istr;
}

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

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

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    ostr << p.first << " " << p.second;
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
// vll x(n); x[i]=a;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
// vvll x(m,vi(n)); x[i][j]=a;
typedef pair<ll,ll> pll;
typedef vector<pair<ll,ll>> vpll;
// vpll x(n); x[i]={a,b}; x[i].first/second;

#define PI 3.1415926535897932
#define EPS 1e-12
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()
// sort(all(x));

int main(){
    ll a, b = 0;
    cin >> a >> b;
    if (a >= 10 || b >= 10){
        cout << -1 << endl;
    }
    else{
        cout << a*b << endl;
    }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

long int getDigits(long int x) {
  long int result = 0;
  while (x) {
    result++;
    x /= 10;
  }
  return result;
}

void Main() {
  // code
  long int n, res = 100000000000;
  cin >> n;

  for (int i = 1; i < sqrt(n) + 1; i++)
    if (n % i == 0)
      res = min(res, max(getDigits(i), getDigits(n / i)));

  cout << res << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
	int N, K;
	cin >> N >> K;
	int D = 0;
	REP( i, K )
	{
		int d;
		cin >> d;
		D |= ( 1 << d );
	}
	for( int n = N; n < 10000000; ++n )
	{
		string s;
		convert( n, s );
		bool isOK = true;
		for( auto c : s )
		{
			if( D & ( 1 << ( c - '0' ) ) )
			{
				isOK = false;
				break;
			}
		}
		if( isOK )
		{
			cout << n << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <string>
using namespace std;
#define loop(i,n) for(int i = 0; i < (n); i++)
#define loops(i,f,n) for(int i = (f); i < (n); i++)
#define VEC vector<int>
typedef pair<int, int>pii;
typedef pair<int, bool>pib;
// vector<VEC> v (n, VEC(n))
//loop(i,n)loop(j,n)dp[i][j]=-1;
//printf("%d\n", n);

int main()
{
	cin.tie(0);
	cin.sync_with_stdio(0);
	int a, b, c;
	cin >> a >> b >> c;
	int ans;
	ans = (a - c) / (b + c);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <cstring>
#include <stdio.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef double LD;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 0.5;
const LL INF = 1e9;
const LL mod = 1000003;
const LL LINF = 1e18 + 10;
const LL MAX = 1e5 + 1;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);

	LL x, y, ans = 0;
	cin >> x >> y;
	if (x == y)
	{
		cout << 0;
		return 0;
	}

	if (y == 0)
	{
		if (x <= 0)
			ans = -x;
		else
			ans = x + 1;

		cout << ans;
		return 0;
	}

	if (x == 0)
	{
		if (y > 0)
			ans = y;
		else
			ans = -y + 1;
		cout << ans;
		return 0;
	}

	if (x >= 0)
	{
		if (y >= 0)
		{
			if (x <= y)
				ans = y - x;
			else
			{
				LL curr = 2 + x - y;
				x *= -1;
				ans = 1;
				ans += y - x;
				ans = min(ans, curr);
			}
		}
		else
		{
			x *= -1;
			if (x <= y)
				ans = y - x + 1;
			else
			{
				x *= -1;
				ans = 1;
				y *= -1;
				ans += (y - x);
			}
		}
	}
	else
	{
		if (y >= 0)
		{
			if (-x <= y)
				ans += (y + x) + 1;
			else
			{
				ans = 1;
				ans += abs(x + y);
			}
		}
		else
		{
			if (x <= y)
				ans = y - x;
			else
				ans = 2 + abs(x - y);
		}
	}

	cout << ans;
	cin >> x;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

int main() {
	ll h, w;
	cin >> h >> w;
	ll ans;
	if (!(h == 1 || w==1)) {
		ans = h * w / 2 + h * w % 2;
	}
	else ans = 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_set>
# include <unordered_map>
using namespace std;


long long n, m;
long long ans;
pair<long long, long long> a[100005];


int main(int argc, const char * argv[]) {
//freopen("/Users/danya.smelskiy/Documents/Danya/Resources/input.txt","r",stdin);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i].first;
        cin >> a[i].second;
    }
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; ++i) {
        long long cur = min(m, a[i].second);
        m -= cur;
        ans += cur * 1ll * a[i].first;
    }
    cout << ans << '\n';
}



Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
  int i,c;
  int ans[64];

  for (i=0;i<64;i++){
    ans[i]=0;
  }

  while((c=getchar())!=EOF){
    if('A'<=c && c<='Z'){
      c=c+('a'-'A');
    }
    ans[c-'a']++;
    //if(c=='\n')break;
  }

  for(int i=0;i<26;i++){
    printf("%c : %d\n",i+'a',ans[i]);
  }
  return 0;
}


Measured memory_bytes: 2040
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cinii(X,A);
    if(X<A) cout << 0 <<nn;
    else cout << 10 << nn;
    return 0;
}

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

using namespace std;

using ll = long long;

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

    int a, b, c;
    cin >> a >> b >> c;
    if (a <= c && c <= b) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


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

int N;
int main(){
    scanf("%d", &N);
    for (int i = 1; i <= 9; i++) {
        if(N%i==0){
            int k = N/i;
            if(k >= 1 && k <= 9) {printf("Yes\n"); return 0;}
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>
#include <set>

long long PRIME = 1e9 + 7;
long long PRIME2 = 998244353;

using namespace std;


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

    if(N % 2 == 0){
        cout << N / 2 - 1;
    }
    else{
        cout << N / 2;
    }
}



Measured memory_bytes: 256
while True:

    string = str(input())
    box = ""
    
    
    if string == "-":
        break
    
    shuffle = int(input())

    h = [0]*shuffle

    for a in range(shuffle):
        h[a] = int(input())

    for b in range(shuffle):
        box = string[0:h[b]]
        string = string[h[b]:]
        string = string+box
        box = ""

    print(string)


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}


int main() {
  int N;
  int64 K;
  cin >> N >> K;
  vector< int > A(N);
  cin >> A;

  for(auto &t: A) --t;

  vector< int > nxt(200000), con(N);
  for(int i = 2 * N - 1; i >= 0; i--) {
    if(i < N) con[i] = nxt[A[i]];
    nxt[A[i % N]] = i;
  }


  int64 y = 0, x = 0;
  vector< pair< int64, int64 > > lis;
  lis.emplace_back(y, x);

  vector< int64 > last(N, -1);
  last[0] = 0;
  while(y + 2 < K) {
    x = con[x] + 1;
    while(x >= N) {
      ++y;
      x -= N;
    }
    lis.emplace_back(y, x);
    if(~last[x]) {
      int64 sa = lis.back().first - lis[last[x]].first;
      if(sa) {
        y += max(0LL, (K - y - 2) / sa) * sa;
      }
    }
    last[x] = (int) lis.size();
  }


  vector< int > vs;
  set< int > exist;
  while(y < K) {
    if(exist.count(A[x])) {
      while(vs.back() != A[x]) {
        exist.erase(vs.back());
        vs.pop_back();
      }
      exist.erase(vs.back());
      vs.pop_back();
    } else {
      vs.emplace_back(A[x]);
      exist.emplace(A[x]);
    }

    ++x;
    while(x >= N) {
      ++y;
      x -= N;
    }

  }

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



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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
//------------------------------------------

//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define in(x) cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
//------------------------------------------

int main() {
  LL N, ans;
  in(N);
  ans = N/111;
  
  if (N%111>=1) {
    ans++;
  }
  
  co(ans*111);
  
  return 0;
}


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

int main()
{
  string s,res;
  cin>>s;
  for(int i=0;i<s.length();i++)
  {
    if(s[i]=='0' || s[i]=='1')
      res+=s[i];
    else if(s[i]=='B' && res.length()>0)
      res.erase(res.length()-1,1);
  }
  cout<<res;
  return 0;
}

Measured memory_bytes: 3644
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int d = sc.nextInt();
        int count = 0;
        for (int i = 0; i < num; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            double length = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
            if(length<=d) {
                count ++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 59076
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
const int N=2e5+100;

ld Ans;

void go(int n, ld a, ld d)
{
	if(!n) return ;
	Ans += (a+d+a+n*2*d)/2;
	go(n-1, a+a/n+3*d/(2*n), 2*d/n+d);
}

int main()
{
	int n,d1,x1;
	scanf("%d%d%d",&n,&d1,&x1);
	go(n,1.0*(d1-x1),1.0*x1);
	printf("%.12Lf",Ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int lucas[87][20];
int main (void){
	lucas[0][0]=1;
	lucas[0][1]=2;
	lucas[1][0]=1;
	lucas[1][1]=1;
	int N;
	cin>>N;
	for (int i=2;i<=N;++i){
		int rnd=0;
		for (int j=1;j<=lucas[i-1][0];++j){
			lucas[i][j]=lucas[i-1][j]+lucas[i-2][j]+rnd;
			rnd=lucas[i][j]/10;
			lucas[i][j]%=10;
		}
		if (rnd!=0) lucas[i][lucas[i][0]=lucas[i-1][0]+1]=rnd;
		else lucas[i][0]=lucas[i-1][0];
//		for (int j=lucas[i][0];j>0;--j) cout<<lucas[i][j];
//		cout<<endl;
	}
	for (int j=lucas[N][0];j>0;--j) cout<<lucas[N][j];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
# include <iostream>
using namespace std;
int a, b;

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


Measured memory_bytes: 3080
/* ****AWARE**** */
#include<bits/stdc++.h>
#include <limits.h> 
#define cut ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll          long long
#define pb          push_back
#define endl        '\n'
#define pii         pair< ll, ll>
#define vi          vector< ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(  ll i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp13       make_pair
using namespace std; 
#define MAX  3000000000
#define MODULO 2
using namespace std;   
#define hell 1000000007 
#define hell1 30000000000000000
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
#define mysizeof(i) (char*)(&i+1)-(char *)(&i);
ll T;
ll dfs(int i ,vector<vector<ll>>&v,vector<ll>&visited)
{   ll mx=0;
    for(auto x: v[i])
    {   if(visited[x]==-1)
        mx=max(mx,dfs(x,v,visited)+1);
        else
      	mx=max(mx,visited[x]+1);
    }
    visited[i]=mx;
	return mx;
}
void solve()
{  ll i,j,k,n,m,mx=0,a,b;
    cin>>n>>m;
    vector<vector<ll>>v(n+1);

   for(i=0;i<m;i++)
   {
   	cin>>a>>b;
   	v[a].push_back(b);
   }
    vector<ll>visited(n+1,-1);
    for(i=1;i<=n;i++)
    {   if(visited[i]==-1)
    	mx=max(mx,dfs(i,v,visited));
    	else
    	mx=max(mx,visited[i]);
     // cout<<visited[i]<<" ";
    }

   cout<<mx<<"\n";

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


Measured memory_bytes: 12072
n, m = map(int, input().split())

gate_cond = [[int(x) for x in input().split()] for _ in range(m)]
max_under_th = max([l[0] for l in gate_cond])
min_upper_th = min([l[1] for l in gate_cond])
if min_upper_th - max_under_th >= 0:
    print(min_upper_th - max_under_th + 1)
else:
    print(0)

Measured memory_bytes: 22048
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <climits>
#include <cmath>
#include <vector>
#include <string>

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

int N, M;
long long int x[1001], y[1001], z[1001];

using namespace std;

int main()
{
    scanf("%d %d", &N, &M);
    REP(i, N) 
        scanf("%lld %lld %lld", &x[i], &y[i], &z[i]);

    long long int ans = 0;
    REP(j, 8) {
        long long int tmpx[1001];
        long long int tmpy[1001];
        long long int tmpz[1001];
        int sigx, sigy, sigz;
        sigx = (j&4)/4;
        sigy = (j&2)/2;
        sigz = (j&1)/1;
        REP(i, N) {
            if(sigx)
                tmpx[i] = -x[i];
            else
                tmpx[i] = x[i];
            if(sigy)
                tmpy[i] = -y[i];
            else
                tmpy[i] = y[i];
            if(sigz)
                tmpz[i] = -z[i];
            else
                tmpz[i] = z[i];
        }
        long long int s[1001];
        REP(i, N)
            s[i] = tmpx[i] + tmpy[i] + tmpz[i];
        sort(s, s+N, greater<long long int>());
        long long int sum = 0;
        REP(i, M)
            sum += s[i];
        ans = max(ans, sum);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()

cnt = [2]*(N+1)
cnt[0] = 0
cnt[1] = 1

for i in range(2, N//2 + 1):
	for j in range(2, N//i + 1):
		cnt[i*j] += 1


for i in range(N+1):
	cnt[i] *= i

print(sum(cnt))


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }

int main()
{
  fastio();

  int n; cin >> n;

  int c = 0;
  forn1(i,n) if (i % 2) c++;

  printf("%.15f\n",double(c)/double(n));

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<map>
#define ll long long
using namespace std;
int n;
int a[120000];


bool checkOne(int i)
{
    return (i&1);
}

int main()
{
    bool flag=0;
    scanf("%d",&n);
    for (int i=1; i<=n; ++i)
    {
        scanf("%d",&a[i]);
        if ((a[i]&1)==1)
        {
            flag=1;
        }
    }
    if (n==1)
    {
        if ((a[1]&1)==1)
            cout<<"first"<<endl;
        else cout<<"second"<<endl;
        return 0;
    }
    if (flag==1)
        cout<<"first"<<endl;
    else cout<<"second"<<endl;
    return 0;
}


Measured memory_bytes: 640
N = int(input())
T, A = list(map(int, input().split()))
H = list(map(int, input().split()))
dif = 10000000000

for i in range(N):
    if abs(A - T + H[i] * 0.006) < dif:
        dif = abs(A - T + H[i] * 0.006)
        ans = i + 1

print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;

/**
 * Amida, the City of Miracle
 *  URL:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2001
 *
 * @author Igari Kazuya
 *
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while(true){
			int n,m,a;
			n = sc.nextInt();
			m = sc.nextInt();
			a = sc.nextInt();

			if(n==0&&m==0&&a==0){
				break;
			}

			int[][] map = new int[1001][n];

			int[][] load = new int[m][3];
			for(int i=0;i<m;i++){
				load[i][0] = sc.nextInt();
				load[i][1] = sc.nextInt();
				load[i][2] = sc.nextInt();
			}

			for(int i=1001;i>0;i--){
				for(int j=0;j<m;j++){
					if(load[j][0] == i){
						if(a==load[j][1]){
							a=load[j][2];
						}else if(a==load[j][2]){
							a=load[j][1];
						}
					}
				}
			}
			System.out.println(a);
		}
	}

}

Measured memory_bytes: 15000
#include <cstdio>
const int MOD = 1000000007;
int N, x[200000], y[200000], f[4001][4001], C[8001][8001], O;
long long fc[8001], fi[8001];
inline void add(int &x, int y)
{
	x = x + y < MOD ? x + y : x + y - MOD;
}
int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; i++)
	{
		scanf("%d%d", x + i, y + i);
		f[2000 - x[i]][2000 - y[i]]++;
	}
	for (int i = 0; i <= 4000; i++)
		for (int j = 0; j <= 4000; j++)
		{
			if (i)
				add(f[i][j], f[i - 1][j]);
			if (j)
				add(f[i][j], f[i][j - 1]);
		}
	for (int i = 0; i < N; i++)
		add(O, f[2000 + x[i]][2000 + y[i]]);
	fc[0] = fi[0] = fi[1] = 1;
	for (int i = 2; i <= 8000; i++)
		fi[i] = (MOD - MOD / i) * fi[MOD % i] % MOD;
	for (int i = 1; i <= 8000; i++)
	{
		fc[i] = fc[i - 1] * i % MOD;
		fi[i] = fi[i - 1] * fi[i] % MOD;
	}
	for (int i = 0; i < N; i++)
		add(O, MOD - fc[x[i] + y[i] << 1] * fi[x[i] << 1] % MOD * fi[y[i] << 1] % MOD);
	printf("%lld\n", (long long)O * (MOD + 1 >> 1) % MOD);
	return 0;
}


Measured memory_bytes: 64768
n=int(input())
A=list(map(int,input().split()))
r=0
ans=0
sum=0
for l in range(n):
  while r<n and (sum^A[r])==(sum+A[r]):
    sum+=A[r]
    r+=1
  ans+=r-l
  if l == r:
    r+=1
  else:
    sum-=A[l]
print(ans)


Measured memory_bytes: 24840
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言
#define MAX 100000

//問題をよく読もう！
//論理的に考えよう！
//サンプルを確認しよう!
//絶対に諦めるな！
//工夫をしろ！
int main() {
  string N;
  cin >> N;

  if(N[0] == N[1] && N[0] == N[2]) {
    cout << "Yes" << endl;
    return 0;
  }

  if(N[1] == N[2] && N[1] == N[3]) {
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;

  return 0;
}


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


int main(){ 
int k;
  cin>>k;
  int a,b;
  cin>>a>>b;
  for(int i=a;i<=b;++i){
    if(i%k==0){
      cout<<"OK";
      return 0;
    }
  }
  cout<<"NG";
    return 0;
}



Measured memory_bytes: 3636
import sys
n = int(sys.stdin.readline())
p1 = [[int(x) for x in sys.stdin.readline().split()] for i in range(n)]
p1.insert(0,[0,0])
p1.append([1000,0])
m = int(sys.stdin.readline())
p2 = [[int(x) for x in sys.stdin.readline().split()] for i in range(m)]
p2.insert(0,[0,1000])
p2.append([1000,1000])
ans = float("inf")
for x1,y1 in p1:
    for x2,y2 in p2:
        r = (x1-x2)**2+(y1-y2)**2
        if r < ans:
            ans = r
for x,y in p1:
    for i in range(m+1):
        p,q = p2[i]
        s,t = p2[i+1]
        a = t-q
        b = p-s
        if (b*(s-x)-a*(t-y))*(b*(p-x)-a*(q-y)) < 0:
            c = -a*p-b*q
            d = (a*x+b*y+c)**2
            d /= (a**2+b**2)
            if d < ans:
                ans = d

for x,y in p2:
    for i in range(n+1):
        p,q = p1[i]
        s,t = p1[i+1]
        a = t-q
        b = p-s
        if (b*(s-x)-a*(t-y))*(b*(p-x)-a*(q-y)) < 0:
            c = -a*p-b*q
            d = (a*x+b*y+c)**2
            d /= (a**2+b**2)
            if d < ans:
                ans = d

print(ans**0.5)



Measured memory_bytes: 5672
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	ll n,m, a,b,low = INT_MIN, high= INT_MAX; cin>>n>>m;
	for(int i =0  ; i<m ;i++)
	{
		cin>>a>>b;
		high = min(b, high);
		low  = max(a, low);
	}
	(high - low+1)>0?(cout<<high - low+1<<endl):cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,fast-math,unroll-loops")
 
#include <bits/stdc++.h>
 
#define int ll
//#define double long double
#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair 
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
//#define PI 3.141592653589
 
using namespace std;
        
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
using pld = pair <ld, ld>;

/*
const ll MAX_MEM = 4e8;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/
        
template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}
        
template <class T> 
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}
        
template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}
        
template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}
        
inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("lol.in", "r", stdin);
    //freopen("lol.out", "w", stdout);
}


signed main()
{
    Start();
    int n, m;
    cin >> n >> m;
    vector <vector <int>> a(n, vector <int> (m));
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            char c;
            cin >> c;
            if (c == '#')
                a[i][j] = 1;
        }
    }
    vector <vector <int>> r(n, vector <int> (m));
    vector <vector <int>> b(n, vector <int> (m));
    for (int i = 0; i < n; i += 2)
    {
        if (i)
            r[i - 1][m - 1] = 1;
        for (int j = (i == 0 || i + 2 >= n ? 0 : 1); j < m; ++j)
        {
            r[i][j] = 1;
        }
    }
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            if (!r[i][j])
                b[i][j] = 1;
            if (a[i][j])
                b[i][j] = r[i][j] = 1;
        }
    }
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
            cout << (r[i][j] ? '#' : '.') << (j + 1 == m ? "\n" : "");
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
            cout << (b[i][j] ? '#' : '.') << (j + 1 == m ? "\n" : "");
    return 0;
}



Measured memory_bytes: 6656
N = int(input())
H = list(map(int, input().split()))
 
ans, b = 0, 0
for i in range(N-1):
  if H[i] >= H[i+1]: b += 1
  else:
    ans = max(ans, b)
    b = 0
    
ans = max(ans, b)
print(ans)

Measured memory_bytes: 20408
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
/* global variables */
/* function */
/* main */
int main(){
    string s;
    cin >> s;
    string ans = s.substr(0, 4) + " " + s.substr(4, 8);
    cout << ans << '\n';
}

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

typedef long long ll;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  ll x, y;
  cin >> x >> y;
  cout << (abs(x - y) > 1 ? "Alice" : "Brown") << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};
 
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; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};
 
 

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Timer TM;

    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b>=c) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	ll n;
	cin >> n;
	if (n % 2 == 0)
	{
		cout << n;
	}
	else
	{
		cout << n * 2;
	}
	cout << endl;

}

Measured memory_bytes: 256