akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF=(1LL<<50);
double eps=1e-10;
bool eq(double a,double b){
  return (-eps < a-b && a-b < eps);
}

struct segtree{
  ll t[(1<<20)];
  void init(){
    for(int i=0;i<(1<<20);i++)
      t[i]=INF;
  }
  
  ll get(int a,int b,int k=0,int l=0,int r=(1<<19)){
    if( !(a<b) )return INF;
    
    if(b<=l||r<=a)return INF;
    if(a<=l&&r<=b)return t[k];
    return min( get(a,b,k*2+1,l,(l+r)/2) , get(a,b,k*2+2,(l+r)/2,r) );
  }
  void set(int i,ll x){
    i+=(1<<19)-1;
    t[i]=x;
    while(i){
      i=(i-1)/2;
      t[i]=min(t[i*2+1],t[i*2+2]);
    }
  }
};
  
double PI = acos(-1);
struct data{
  double A;
  int x,y,cost;
  bool operator < (const data &p) const {
    return A < p.A;
  }
};

segtree st;
int n;
data t[400000];

ll solve(){
  if(n<3)return -1;
  ll ans=INF;
  int a=0,b=0,c=0,d=0;
  int e=0,f=0;
  
  for(int i=0;i<n;i++){
    while(a+1<n+n){
      if(t[a].A<t[i].A+PI*0.5-eps)a++;
      else break;
    }
    while(b+1<n+n){
      if(t[b].A<t[i].A+PI*1.0-eps)b++;
      else break;
    }
    while(c+1<n+n){
      if(t[c].A<t[i].A+PI*1.0+eps)c++;
      else break;
    }
    while(d+1<n+n){
      if(t[d].A<t[i].A+PI*1.5-eps)d++;
      else break;
    }

    //    cout<< a <<' '<< b << ' ' <<c << ' ' << d<<' ';
    ans=min( ans , st.get(a,b) + st.get(c,d) + t[i].cost);
    
    while(e+1<n+n){
      if(t[e].A<t[i].A+PI*0.0+eps)e++;
      else break;
    }
    while(f+1<n+n){
      if(t[f].A<t[i].A+PI*2.0-eps)f++;
      else break;
    }
    if( eq(t[b].A,t[i].A+PI) ){
      //      cout<<e<<' '<<f;
      ans=min( ans, st.get(e,b) + st.get(b,c) + st.get(c,f) + t[i].cost );
    }
    //    cout<<endl;
  }
  
  if(ans==INF)return -1;
  else return ans;
}

int main(){
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d %d %d",&t[i].x,&t[i].y,&t[i].cost);
    if(t[i].x==0&&t[i].y==0){
      n--;
      i--;
      continue;
    }
    t[i].A=atan2( t[i].y , t[i].x );
    if(t[i].A<0)t[i].A+=PI*2.0;
  }
  sort(t,t+n);
  for(int i=0;i<n;i++){
    t[i+n]=t[i];
    t[i+n].A+=2.0*PI;
  }
  
  st.init();
  for(int i=0;i<n+n;i++){
    st.set( i , t[i].cost );
  }
  cout<<solve()<<endl;

  return 0;
}

Measured memory_bytes: 18880
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define ZERO (1e-10)
#define INF int(1e9+1)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define DEB printf("DEB!\n");
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define EQ(A,B) (A+ZERO>B&&A-ZERO<B)
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
#define IN(n) int n;scanf("%d",&n);
#define FOR(i, m, n) for (int i(m); i < n; i++)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)
#define FT(m, n) FOR(k, m, n)
#define aa first
#define bb second
void ga(int N,int *A){F(N)scanf("%d",A+i);}
#define MOD 998244353
#define MX 222222
void rnm(int*A,int N){
    static ii B[MX];
    int L=0;
    F(N)B[i]={A[i],i};
    sort(B,B+N);
    F(N)A[B[i].bb]=L+=i&&B[i].aa^B[i-1].aa;
}
struct FW{
    int t[MX],S;
    void clr(int s){CL(t,0);S=s;}
    void inc(int i,int d){for(;i<S;i|=i+1)t[i]+=d;}
    int sum(int i){int s(0);while(~i)s+=t[i],i&=i+1,--i;return s;}
    int gt(int l,int r){return sum(r)-sum(l-1);}
}F;
int S,N,X[MX],Y[MX],H[MX],x[MX],y[MX],L[MX],R[MX],l[MX],r[MX];
ll P[MX]={1};
bool cp(int a,int b){return X[a]<X[b];}
void lgr(int*L,int*R){
    F.clr(MX-666);
    F(N)L[i]=F.sum(Y[i]),F.inc(Y[i],1),R[i]=i-L[i];
}
#define E(I) (P[I]-1)
ll go(int i){
    return ((P[N-1]+E(L[i]+l[i])*E(R[i]+r[i])-E(L[i])*E(R[i])-E(l[i])*E(r[i]))%MOD+MOD)%MOD;
}
int main(void){
    FT(1,MX)P[k]=P[k-1]*2%MOD;
    scanf("%d",&N),iota(H,H+N,0);
    F(N)scanf("%d%d",X+i,Y+i);
    rnm(X,N),rnm(Y,N);
    F(N)x[X[i]]=X[i],y[X[i]]=Y[i];
    F(N)Y[i]=y[i],X[i]=i;
    lgr(L,R),reverse(Y,Y+N),lgr(l,r),reverse(Y,Y+N),reverse(l,l+N),reverse(r,r+N);
//    F(N)printf("[%d][%d]: <<%d/%d ... %d/%d>>\n",X[i],Y[i],L[i],R[i],l[i],r[i]);
    F(N)S=(S+go(i))%MOD;
    printf("%d\n",S);
    return 0;
}


Measured memory_bytes: 12160
use std::io;

fn next_vec() -> Vec<i64> {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace().map(|n| n.parse().unwrap()).collect()
}

fn main() {
    let v = next_vec();
    let n = v[0];
    let a = v[1];
    let b = v[2];

    let minimum = a * (n - 1) + b;
    let maximum = a + b * (n - 1);
    let ans = maximum - minimum + 1;
    println!("{:?}", if ans < 0 {0} else {ans});
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main(void)
{
	int n, a, dou = 0, qu = 0;

	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a;
		if (a % 4 == 0) qu++;
		else if (a % 2 == 0) dou++;
	}
	if (qu >= n - qu - 1 || qu + dou >= n - qu) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <ctype.h>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
// #include <pair> 
       
using namespace std;
       
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
 
// #define MAX 100010
 
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
 
// long long binpow(long long a,long long b)
// {
//     if (b == 1) return a;
//     long long res = binpow(a, b/2)%MOD;
//     if (b % 2) return (res*((res*a)%MOD))%MOD;
//     else return (res * res)%MOD;
// }
 
// long long int fact(long long int a)
// {
//     if(a==0||a==1)
//         return 1;
//     long long int ans = 1;
//     for(int i=a;i>=1;i--)
//         ans = (ans * i);
//     return ans;
// }
 
// long long int ivmod(long long int a)
// {
//     return binpow(a,MOD-2);
// }
 
// long long int ncr(long long int a,long long int b)
// {
//     long long int pans=1;
//     for(int i =a;i>max(b,a-b);i--)
//         pans=pans*i;
//     long long int div = fact(min(b,a-b));
//     // cout<<ans<<"            "<<div<<endl;
//     pans = pans/div;
//     return pans;
// }


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE

    // #endif   
    int a,b,c;
    cin>>a>>b>>c;
    if(c>=a&&c<=b)
        cout<<"Yes";
    else
        cout<<"No";
    cout<<endl;
    return 0;
}

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

using namespace std;
using pdd = pair<double, double>;

template <typename T, typename F = std::plus<T>>
class fenwick_tree {
public:
	using value_type = T;
private:
	std::vector<T> m_data;
	F m_func;
public:
	fenwick_tree()
		: m_data(1)
		, m_func()
	{ }
	explicit fenwick_tree(
		size_t n,
		const value_type& x = value_type(),
		const F& f = F())
		: m_data(n + 1)
		, m_func(f)
	{
		m_data[0] = value_type();
		for(size_t i = 1; i <= n; ++i){
			m_data[i] = x;
			for(size_t j = i; (j & 1) == 0u; j >>= 1){
				m_data[i] = m_func(m_data[j], m_data[i]);
			}
		}
	}
	size_t size() const {
		return m_data.size() - 1;
	}
	value_type query(size_t i) const {
		value_type s = m_data[i];
		for(i -= i & -i; i > 0; i -= i & -i){
			s = m_func(m_data[i], s);
		}
		return s;
	}
	void modify(size_t i, const value_type& x){
		const auto n = m_data.size();
		for(++i; i < n; i += i & -i){
			m_data[i] = m_func(m_data[i], x);
		}
	}
};

int count_inversion(const std::vector<double>& a){
	const int n = a.size();
	vector<double> b(a);
	sort(b.begin(), b.end());
	b.erase(unique(b.begin(), b.end()), b.end());
	fenwick_tree<int> ft(b.size());
	int answer = 0;
	for(int i = 0; i < n; ++i){
		const int k = lower_bound(b.begin(), b.end(), a[i]) - b.begin();
		answer += i - ft.query(k);
		ft.modify(k, 1);
	}
	return answer;
}

double solve(
	const vector<double>& a,
	const vector<double>& b,
	const vector<double>& c)
{
	const int n = a.size();
	const int nc = n * (n - 1) / 2;
	double ly = -1e20, ry = 1e20;
	for(int iter = 0; iter < 100; ++iter){
		const double y = (ly + ry) * 0.5;
		vector<pdd> v(n);
		for(int i = 0; i < n; ++i){
			const double x = (c[i] - b[i] * y) / a[i];
			const double t = -b[i] / a[i];
			v[i] = pdd(x, t);
		}
		sort(v.begin(), v.end());
		vector<double> w(n);
		for(int i = 0; i < n; ++i){ w[i] = v[i].second; }
		const int inv = count_inversion(w);
		if(inv > nc / 2){
			ly = y;
		}else{
			ry = y;
		}
	}
	return ly;
}

int main(){
	ios_base::sync_with_stdio(false);
	cout << setiosflags(ios::fixed) << setprecision(10);
	int n;
	cin >> n;
	vector<double> a(n), b(n), c(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i] >> b[i] >> c[i];
	}
	const double y = solve(a, b, c);
	const double x = solve(b, a, c);
	cout << x << " " << y << endl;
	return 0;
}



Measured memory_bytes: 2688
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>

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

int main(){

	int n;
	string name;
	cin >> n >> name;
	int cnt = 0;

	while(n--){
		string old;
		cin >> old;
		for(int i=0; i<old.size(); i++){
			bool flag = false;
			for(int j=1; j<old.size(); j++){
				string tar;
				for(int k=i; k<old.size(); k+=j){
					tar += old[k];
				}
				if(~tar.find(name)){cnt++; flag = true; break;}
			}
			if(flag) break;
		}
	}
	cout << cnt << endl;

	return 0;	
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    bool red[510][510];
    bool blue[510][510];
    for(int i = 0; i <= 505; i++){
        for(int j = 0; j <= 505; j++){
            red[i][j] = false;
            blue[i][j] = false;
        }
    }
    int H, W;
    cin >> H >> W;
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            if(j == 1){
                red[i][j] = true;
                continue;
            }
            if(j == W){
                continue;
            }
            if(i % 2 == 0){
                red[i][j] = true;
            }
        }
    }
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            if(j == W){
                blue[i][j] = true;
                continue;
            }
            if(j == 1){
                continue;
            }
            if(i % 2 == 1){
                blue[i][j] = true;
            }
        }
    }
    string field[505];
    for(int i = 1; i <= H; i++){
        cin >> field[i];
        for(int j = 1; j <= W; j++){
            if(field[i][j - 1] == '#'){
                red[i][j] = true;
                blue[i][j] = true;
            }
        }
    }
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            if(red[i][j]){
                cout << "#";
            } else {
                cout << ".";
            }
        }
        cout << endl;
    }
    cout << endl;
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            if(blue[i][j]){
                cout << "#";
            } else {
                cout << ".";
            }
        }
        cout << endl;
    }
    return 0;
}


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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m, k;
  cin >> n >> m >> k;
  vector<long long> a(n), b(m);
  for (auto&& e : a) cin >> e;
  for (auto&& e : b) cin >> e;
  partial_sum(begin(a), end(a), begin(a));
  partial_sum(begin(b), end(b), begin(b));
  int res = upper_bound(begin(b), end(b), k) - begin(b), c = 0;
  for (auto e : a) {
    if (e > k) break;
    res = max<int>(res, ++c + (upper_bound(begin(b), end(b), k - e) - begin(b)));
  }
  cout << res << '\n';
}


Measured memory_bytes: 6332
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    string s;
    cin >> s;
    ll ans = 0;
    for(int i=0; i<1<<(s.size() - 1); ++i) {
        int pos = 0;
        vector<ll> v;
        for(int j=1; j<s.size(); ++j) {
            if((i >> j-1) & 1) {
                v.push_back(stoll(s.substr(pos, j - pos)));
                pos = j;
            }
        }
        v.push_back(stoll(s.substr(pos, s.size()-pos)));
        ans += accumulate(v.begin(), v.end(), 0LL);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BC
import qualified Data.Map.Strict as M
import Data.Maybe (fromJust)
import Data.Array.IO
import Data.List
import Control.Monad

type Memo = IOUArray Int Int
type Edge = (Int, Int)

main = do
  [n,k,l] <- map read . words <$> getLine :: IO [Int]
  road <- (\[x, y] -> zip x y) . transpose <$> replicateM k getIntListBC
  railway <- (\[x, y] -> zip x y) . transpose <$> replicateM l getIntListBC
  repRoad <- newListArray (1, n) [1..n] :: IO Memo
  repRailway <- newListArray (1, n) [1..n] :: IO Memo
  unionFind repRoad road
  unionFind repRailway railway
  foldM (setRepresentative repRoad) repRailway $ reverse [1..n]
  roadC <- getElems repRoad
  railwayC <- getElems repRailway
  let pair = zip roadC railwayC
      sortedPair = map (\x -> (head x, length x)) . group . sort $ pair
      arr = M.fromList sortedPair
  putStrLn . unwords . map show $ solve arr pair

unionFind :: Memo -> [Edge] -> IO Memo
unionFind memo [] = return memo
unionFind memo ((i, j):es) = do
  pI <- getRepresentative memo i
  pJ <- getRepresentative memo j
  if pI == pJ then unionFind memo es
              else do
                writeArray memo pI pJ
                unionFind memo es

getRepresentative :: Memo -> Int -> IO Int
getRepresentative memo i = do
  parent <- readArray memo i
  if parent == i
    then return i
    else do
      pp <- getRepresentative memo parent
      writeArray memo i pp
      return pp

setRepresentative :: Memo -> Memo -> Int -> IO Memo
setRepresentative road railway i = do
  pI <- getRepresentative road i
  qI <- getRepresentative railway i
  writeArray road i pI
  writeArray railway i qI
  return railway

solve _ []     = []
solve m (x:xs) = let v = fromJust $ M.lookup x m
                 in v : (solve m xs)

bsToInt :: BC.ByteString -> Int
bsToInt = fst . fromJust . BC.readInt

getIntListBC :: IO [Int]
getIntListBC = map bsToInt . BC.words <$> BC.getLine


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

int main() {
  int w, h, x , y ,r;
  cin >> w >> h >> x >> y >> r;
  if(w >= x + r && x >= 0){
    if(h >= y + r && y >= 0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }

  }else{
    cout << "No" << endl;
  }

}



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

using namespace std;

const int INF = (int) 1e9;
const int N = 18;
const int L = 50;

int n;
int a[N];
int b[N];
int dp[1 << N][L + 1];

void read()
{
        cin >> n;
        for (int i = 0; i < n; i++)
                cin >> a[i];
        for (int i = 0; i < n; i++)
                cin >> b[i];
}

void init()
{
        for (int i = 0; i < (1 << N); i++)
                for (int j = 0; j <= 50; j++)
                        dp[i][j] = INF;
        dp[0][1] = 0;
}

bool is(int mask, int i)
{
        if (mask & (1 << i))
                return 1;
        else
                return 0;
}

void compute()
{
        for (int mask = 0; mask < (1 << n) - 1; mask++)
        {
                int p = 0;
                for (int i = 0; i < n; i++)
                        if (is(mask, i))
                                p++;
                for (int i = 0; i < n; i++)
                        if (!is(mask, i))
                        {
                                int cntb = 0;
                                for (int j = i; j < n; j++)
                                        cntb += is(mask, j);
                                        
                                int dist = abs(i - p), nval;
                                if (dist % 2 == 0)
                                        nval = a[i];
                                else
                                        nval = b[i];
                                
                                for (int cur = 1; cur <= nval; cur++)
                                        dp[mask + (1 << i)][nval] = min(dp[mask + (1 << i)][nval], i + cntb - p + dp[mask][cur]);
                        }
        }
}

int solve()
{
        int sol = INF;
        for (int last = 1; last <= 50; last++)
                sol = min(sol, dp[(1 << n) - 1][last]);
        if (sol == INF)
                return -1;
        else
                return sol;
}

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

        read();
        init();
        compute();
        cout << solve() << "\n";
}


Measured memory_bytes: 52480
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

//AtCoderC++.cpp

using namespace std;

void Show(vector<vector<int>> Ns) {
	for (int i = 0; i < Ns.size(); i++) {
		for (int j = 0; j < Ns[i].size(); j++) {
			if (j == Ns[i].size() - 1) {
				cout << Ns[i][j] << endl;
			} else {
				cout << Ns[i][j] << ",";
			}			
		}
	}
}

void Show(vector<int> N) {
	for (int i = 0; i < N.size(); i++) {
		cout << N[i];
		if (i != N.size() - 1) {
			cout << " ";
		} else {
			cout << endl;
		}
	}
}


int main() {
	int M;
	cin >> M;
	cout << 24 - M + 24 << endl;
}

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

using namespace std;
int main() {

	int N, a;
	cin >> N;
	if ((N % 4) == 0 || (N % 7) == 0 || (N % 11) == 0)
	{
		cout << "Yes" << endl;
	}
	else
	{
		a = 1;
		while (true)
		{
			if (4 * a >= N)
			{
				break;
			}

			if (((N - a * 4) % 7) == 0)
			{
				cout << "Yes" << endl;
				return 0;
			}
			a++;
		}
		cout << "No" << endl;
	}


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void judge(string& str);
int main(){
    string str;
    cin >> str;
    judge(str);
    return 0;
}

void judge(string& str) 
{ 
    str[2] == str[3] && str[4] == str[5] ? cout << "Yes" <<endl : cout << "No" <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<cstring>
#include<algorithm>
#define ll long long 
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int t;
	t=b;
	b=a;
	a=t;
	
	t=a;
	a=c;
	c=t;
	cout<<a<<" "<<b<<" "<<c<<endl;
	return 0;
} 

Measured memory_bytes: 256
N, K = map(int, input().split())
h = [0]*N
for i in range(N):
    h[i] = int(input())
h.sort()

min = 10**9
for i in range(N-K+1):
    t = h[i+K-1]-h[i]
    if t < min:
        min = t

print(min)


Measured memory_bytes: 7472
#include<stdio.h>
#include<stdlib.h>
int cmp(const void *a,const void *b)
{
	return (*(int*)a - *(int*)b);
}
int main(void)
{
	int n,a[2005]={0},i,j,high=0,low=0,mid=0,X=0,ans,count=0;
		scanf("%d",&n);
		for(i=0;i<n;i++)
			scanf("%d",&a[i]);

		qsort(a,n,sizeof(int),cmp);

		for(i=0;i<n;i++)
		{
			for(j=i+1;j<n;j++)
			{
				X=a[i]+a[j];
				high=n-1;
				low=j;
				mid=low+(high-low)/2;
              ans = j;
				while(high>=low)
				{
					if(X>a[mid])
					{low=mid+1;ans=mid;}
					else
					{high=mid-1;}
					mid=low+(high-low)/2;
				}
				count+=(ans-j);
			}
		}
		printf("%d\n",count);
		count=0;
	return 0;
}


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

int main()
{
    int  N;
    cin >> N;
    int Hi;
    int maxH = 0;
    int res=0;
    for(int i=0;i<N;i++){
        cin >> Hi;
        if(Hi >= maxH){
            res++;
            maxH = Hi;
        }
    }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

    public static void main(String args[]){

        Scanner scan = new Scanner(System.in);
        Integer n = scan.nextInt();
        Long x[] = new Long[n];
        Long x2[] = new Long[n];
        
        for(int i=0;i<n;i++){
            long l = scan.nextLong();
            x[i] = l;
            x2[i] = l;
        }

        Arrays.sort(x2);

        for(int i=0;i<n;i++){
            if(x2[x2.length/2] <= x[i]){
                System.out.println(x2[x2.length/2-1]);
            }else{
                System.out.println(x2[x2.length/2]);
            }
        }
    }

    static int factorial(int n){
        if(n == 0){
          return 1;
        }
        return n * factorial(n-1);
    }


}

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

int main(int argc, char const *argv[]) {
    long long a, b, n;
    cin >> a >> b >> n;

    long long x;
    if (b > n) x = n;
    else x = b - 1;

    long long ans = floor((double)(a*x)/b);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
int a[1000],b[1000],c[1000],d[1000];
int e,f,n,i,j,k,l;
int main()
{
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{	
		scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]);
	}
	for(j=0;j<4;j++)
	{
		for(k=0;k<3;k++)
		{
			for(l=0;l<10;l++)
			{
				f=0;
				for(i=0;i<n;i++)
				{
					if(j+1==a[i]&&k+1==b[i]&&l+1==c[i])
					{
						f=f+d[i];
					}
				}
				printf(" %d",f);
			}
			printf("\n");
		}
		if(j<=2)
		printf("####################\n");
	}
	
	
	
	
	
	return 0;
}



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

int main(){
	int N;
	cin >> N;
	ll L[90];
	L[0] = 2;
	L[1] = 1;
	for (int i = 2; i <=N; i++) {
		L[i] = L[i-1] + L[i-2];
	}
	cout << L[N] << endl;
	
	return 0;
}


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


using namespace std;

int main() {
	int n;
	cin >> n;
	vector <int> a;
	for (int i = 0; i < n; ++i) {
		int new_element;
		cin >> new_element;
		a.push_back(new_element);
	}
	int b0 = 0;
	for (int i = 0; i < n; ++i) {
		if (i % 2 == 0){
			b0 += a[i];
		}
		else {
			b0 -= a[i];
		}
	}
	cout << b0 << ' ';
	int bi = b0;
	for (int i = 1; i < n; ++i) {
		bi = (a[i - 1] - bi / 2) * 2;
		cout << bi << ' ';
	}
}
	

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = 1000000001;

int main(){
  int a, b;
  cin >> a >> b;
  cout << 2*b - a <<endl;
}

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

int main() {
	int k = 0;
	char s[110], t[110]={0}, u[] = "...";
	int len;

	scanf("%d", &k);
	scanf("%s", s);
	len = strlen(s); 
		if (len > k) {
			for (int i = 0; i < k; i++)t[i] = s[i];
			strcat(t, u);
			printf("%s", t);
		}
	if (len <= k) printf("%s", s);

	return 0;
}

Measured memory_bytes: 1732
from sys import stderr, setrecursionlimit, exit
setrecursionlimit(2147483647)
def getInt():
    return int(input())
def getInts():
    return [int(i) for i in input().split()]
def getIntLines(n=1):
    res = []
    for _ in range(n):
        res.append(getInt())
    return res
def getIntsLines(n=1):
    res = []
    for _ in range(n):
        res.append(getInts())
    return res
def debug(*args, **kwargs):
    print(*args, file=stderr, **kwargs)

k,a,b = getInts()

# a>bならひたすら叩くしかない
if a > b:
    print(1+k)
    exit()
# お金を使う操作は順不同なので最後にやってしまって良い
# a枚払ってb枚もらう操作は2回かかるので、差分(b-a)が2枚以下なら2回ポケットを叩くほうが良い
if b - a <= 2 :
    print(1+k)
    exit()

# 初回の交換にかかる回数
k -= a - 1
ans = a

ans += (k//2)*(b-a)
ans += k%2
print(ans)


Measured memory_bytes: 3064
var a:array[0..100050]of longint;
    ans:longint;
    i:longint;
    n:longint;
    mx,x:longint;
function max(a,b:longint):longint;
begin
  if a>b then exit(a) else exit(b);
end;
begin
  read(n);
  for i:=1 to n do
  begin
    read(x);
    inc(a[x]);
    if x>mx then mx:=x;
  end;
  ans:=a[0]+a[1];
  for i:=1 to mx do
  ans:=max(ans,a[i-1]+a[i]+a[i+1]);
  writeln(ans);
end.




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

int q1, b, c1, c2, q2;

void solve()
{
	for (int aizu = q2; aizu > 0; aizu--){
		int x = b - c1 * aizu;
		if (x < 0) continue;
		int nor = x / c2;
		if (aizu + nor < q1) continue;
		
		printf("%d %d\n", aizu, nor);
		return;
	}
	puts("NA");
}

int main()
{
	while (scanf("%d", &q1), q1){
		scanf("%d %d %d %d", &b, &c1, &c2, &q2);
		solve();
	}
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define has(c,i) 		((c).find(i) != end(c))
#define has_str(s, c)	((s).find(c) != string::npos)
typedef long long ll;
const int N = 1e5+5;
vector<int> edges[N];
int in_degree[N]; // the number of edges going to b
int dist[N];
bool visited[N];
void dfs (int a) {
    visited[a] = true;
    for(int b : edges[a]) {
        dist[b] = max(dist[b], dist[a]+1);
        --in_degree[b];
        if(in_degree[b] == 0)
            dfs(b);
    }
}

int main() {
#ifdef LOCAL
    freopen("input.in.txt", "rt", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, m;
    cin >> n >> m;
    while (m--) {
        int a, b;
        cin >> a >> b;
        edges[a].push_back(b);
        ++in_degree[b];
    }
    for(int i = 1; i <= n; ++i) {
        if(!visited[i] && in_degree[i] == 0)
            dfs(i);
    }
    int ans = 0;
    for(int i = 1; i <= n; ++i) {
        ans = max(ans, dist[i]);
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define per(i,n) for(int i = n; i >= 0; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  string s, t;
  cin >> s >> t;
  bool ok = true;
  rep(i,sz(s)) {
    if(s[i] != t[i]) ok = false;
  }
  YesorNo(ok);
}

Measured memory_bytes: 3740
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>

using namespace std;

typedef long long ll;
const ll nmax = 1e9 + 7;
const ll mod = 998244353;
const long long INF = 1e18;
const double PI = 2 * asin(1);

ll gcd (ll A, ll B){
  ll M = max(A, B), m = min(A, B);
  while (M % m != 0){
    ll c = M % m;
    M = m; m = c;
  }
  return m;
}

int main(){
  ll N, X; cin >> N >> X;

  cout << 3 * (N - gcd(N, X)) << endl;
  return 0;
}


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

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    vector<int> b(n - 1);
    rep(i, n - 1)
    {
        cin >> b[i];
    }
    int total = 0;
    rep(i, n)
    {
        if(i == 0){
            total += b[0];
        }else if(i == n - 1)
        {
            total += b[n - 2];
        }else{
            total += min(b[i], b[i - 1]);
        }
    }
    cout << total << endl;
}

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

int main(){
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  int dx = tx - sx, dy = ty - sy;
  for(int i=0; i<dx; i++) cout << 'R';
  for(int i=0; i<dy; i++) cout << 'U';
  for(int i=0; i<dx; i++) cout << 'L';
  for(int i=0; i<dy; i++) cout << 'D';

  cout << 'D';
  for(int i=0; i<dx+1; i++) cout << 'R';
  for(int i=0; i<dy+1; i++) cout << 'U';
  cout << 'L';

  cout << 'U';
  for(int i=0; i<dx+1; i++) cout << 'L';
  for(int i=0; i<dy+1; i++) cout << 'D';
  cout << 'R' << endl;
} 

Measured memory_bytes: 256
program abc142c
   implicit none

   integer :: N, i
   integer, allocatable :: rev(:), A(:)

   read(*,*) N
   allocate(rev(N), A(N))
   read(*,*) A(:)

   do i = 1, N
      rev(A(i)) = i
   end do

   write(*,*) rev(:)
end program abc142c


Measured memory_bytes: 3328
#include <iostream>
#include <functional>
#include <algorithm>
#include <string>
#include <math.h>
#define ll long long
using namespace std;
long long a[30], b[30];
int main() {
  string s, t;
  cin >> s >> t;

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

  sort(a, a+26);
  sort(b, b+26);

  for (int i = 0; i < 26; i++) {
    if (a[i] != b[i]) {
      cout << "No\n";
      return 0;
    }
  }

  cout << "Yes\n";
  return 0;
}

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

using namespace std;

int main()
{
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  if (a == 0)
    cout << 1 << endl;
  else if (b == 0)
    cout << 2 << endl;
  else if (c == 0 )
    cout << 3 << endl;
  else if (d == 0)
    cout << 4 << endl;
  else if (e ==0 )
    cout << 5 << endl;
  return 0;
}

Measured memory_bytes: 3576
using System;
    class Program
    {
        static void Main()
        {
            int number = Convert.ToInt32(Console.ReadLine());
            long fact = GetFactorial(number);
            Console.WriteLine(fact);
        }

        static long GetFactorial(int number)
        {
            if (number == 0)
            {
                return 1;
            }
            return number * GetFactorial(number - 1);
        }
    }

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

using namespace std;

void shellSort(vector<int>& A);
void insertionSort(vector<int>& A, const int g, int& cnt);

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

    vector<int> A(n);
    for(int i = 0; i < n; i++)
        cin >> A[i];
    
    shellSort(A);


    return 0;
}


void shellSort(vector<int>& A) {
    // 間隔の数列
    const vector<int> G = {1, 4, 13, 40, 121, 364, 1093, 3280, 9841, 29524, 88573, 265720, 797161, 2391484};
    int m=0, cnt = 0;

    for(int i = 0; A.size() >= G[i]; i++)
        m = i;
    
    for(int i = m; i >= 0; i--)
        insertionSort(A, G[i], cnt);
    
    cout << m+1 << endl;
    cout << G[m];
    for(int i = m-1; i >= 0; i--)
        cout << ' ' << G[i];
    cout << endl;
    
    cout << cnt << endl;
    for(auto a : A)
        cout << a << endl;
}

void insertionSort(vector<int>& A, const int g, int& cnt) {
    for(int i = g; i < A.size(); i++) {
        int v = A[i], j = i - g;
        while(j >= 0 && A[j] > v) {
            A[j+g] = A[j];
            j -= g;
            cnt++;
        }
        A[j+g] = v;
    }
}


Measured memory_bytes: 6712
#include <bits/stdc++.h>
 
#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)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
template<class T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
 /* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)*/
template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
/* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹) */
///////////////////////////////////////////////
const int MAX = 510000;
 
long long fac[MAX], finv[MAX], inv[MAX];
 



int main() {
ll ans = 0;
	int N; cin >> N;
	ll A[N+3];
	ll B[N+3];
	for (int i = 0; i < N+1; i++){cin >> A[i];}
	for (int i = 0; i < N; i++){cin >> B[i];}
	
	for (int i = 0; i < N; i++)
	{
		if(A[i]>B[i])
		{
			A[i] = A[i] - B [i];
			ans += B[i];
		}
		else if(A[i]+A[i+1]>B[i])
		{
			A[i+1] = A[i+1] + A[i] - B[i];
			A[i] = 0;
			ans += B[i];
		}
		else
		{
			ans += A[i+1] + A[i];
			A[i+1] = 0;
			A[i] = 0;
		}
	}
	cout << ans << endl;
}

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

using namespace std;

int main(){
    int N;
    int nums[4];

    cin >> N;
    for(int i = 3;i >= 0;i--){
        int n = 1;
        for(int j = 0;j < i;j++){
            n *= 10;
        }
        nums[3-i] = N / n;
        N %= n;
    }

    for(int v = 0;v < (1 << 3);v++){
        bitset<3> s(v);
        int ans = nums[0];
        for(int i = 0;i < 3;i++){
            if(s.test(i)){
                ans += nums[i+1];
            }else{
                ans -= nums[i+1];
            }
        }
        if(ans == 7){
            for(int i = 0;i < 3;i++){
                cout << nums[i];
                if(s.test(i)){
                    cout << "+";
                }else{
                    cout << "-";
                }
            }
            cout << nums[3] << "=7" << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define MOD 1000000007
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll r, c, n;
	cin >> r >> c >> n;

	vector<P> x0, xr, y0, yc;
	REP(i, n) {
		ll x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		if (((x1 == 0 || x1 == r) || (y1 == 0 || y1 == c)) && ((x2 == 0 || x2 == r) || (y2 == 0 || y2 == c))) {
			if (x1 == 0) x0.push_back(make_pair(y1, i));
			else if (x1 == r) xr.push_back(make_pair(y1, i));
			else if (y1 == 0) y0.push_back(make_pair(x1, i));
			else if (y1 == c) yc.push_back(make_pair(x1, i));
			if (x2 == 0) x0.push_back(make_pair(y2, i));
			else if (x2 == r) xr.push_back(make_pair(y2, i));
			else if (y2 == 0) y0.push_back(make_pair(x2, i));
			else if (y2 == c) yc.push_back(make_pair(x2, i));

		}
	}

	sort(all(x0));
	sort(all(yc));
	sort(all(xr), greater<P>());
	sort(all(y0), greater<P>());

	x0.insert(x0.end(), all(yc));
	x0.insert(x0.end(), all(xr));
	x0.insert(x0.end(), all(y0));

	stack<ll> stk;
	Array used(n, false);
	for (auto i : x0) {
		ll v = i.second;
		if (used[v]) {
			ll u=stk.top();
			stk.pop();
			if (u != v) {
				cout << "NO" << endl;
				return 0;
			}
		}
		else {
			stk.push(v);
			used[v] = true;
		}
	}

	cout << "YES" << endl;
	

	return 0;
}

Measured memory_bytes: 7984
H,W=$<.read.split.map(&:to_i)

if H%3==0 || W%3==0
    puts 0
    exit
end

min = [H,W].min

1.upto(H-1) do |i|
    a = i*W
    b = (H-i) * (W/2)
    c = (H-i) * (W/2 + (W.odd? ? 1 : 0))
    hmin,hmax = [a,b,c].minmax
    min = hmax-hmin if hmax-hmin < min
end

1.upto(W-1) do |i|
    a = i*H
    b = (W-i) * (H/2)
    c = (W-i) * (H/2 + (H.odd? ? 1 : 0))
    wmin,wmax = [a,b,c].minmax
    min = wmax-wmin if wmax-wmin < min
end

puts min

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

using namespace std ; 

int main () { 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ;
	string s; 
	cin >> s ;
	int q ; 
	cin >> q ; 
	int kebalik = 0 ; 
	for ( int i = 0 ; i < q ; i ++ ) {
		int t ; 
		cin >> t;  
		if ( t==1 ) {
			if (kebalik == 0 )
				kebalik = 1 ;
			else
				kebalik = 0 ;
		}
		else if ( t== 2) {
			char c;  
			int f ; 
			cin >> f >> c;  
			if (kebalik == 0 && f == 1 ) 
				s.insert(s.begin(),1,c);
			else if ( kebalik == 0 && f == 2 ) 
				s.push_back(c);
			else if ( kebalik == 1 && f == 1 ) 
				s.push_back(c);
			else 
				s.insert(s.begin(),1,c);
		}
	}
	
	if (kebalik == 1 ) 
		reverse(s.begin(),s.end() );
	cout << s  << endl ;
	
	
}


Measured memory_bytes: 912
using System;

namespace not
{
    class Program
    {
        static void Main(string[] args)
        {
            int x;

            x= int.Parse(Console.ReadLine());

            if (x == 1)
            {
                Console.WriteLine("0");
            }
            else
            {
                Console.WriteLine("1");
            }
        }
    }
}


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

int main() {
    string t;
    cin >> t;
    ll n = (long long)t.length();

    vector<pair<int, ll>> bag;
    char dig = t[0];
    ll strk = 1;
    for(int i = 1; i < n; i++) {
        if(t[i] != dig) {
            if(dig == '1') bag.push_back({1, strk});
            else bag.push_back({0, strk});
            dig = t[i];
            strk = 1;
        } else strk++;
    }
    if(dig == '1') bag.push_back({1, strk});
    else bag.push_back({0, strk});

    ll sum1 = 0, sum0 = 0;
    rep(i, n) {
        if(t[i] == '1') sum1++;
        else sum0++;
    }

    ll ans = 0;
    rep(i, n) if(i % 2 == 0 && t[i] == '1') ans++;
    ll tmp1 = 0, tmp0 = 0;
    for(auto elm: bag) {
        if(elm.first == 1) {
            ans += sum0 * (elm.second / 2);
            if(elm.second % 2) {
                if((tmp1 + tmp0) % 2) ans += (tmp0 + 1) / 2;
                else ans += tmp0 / 2;
                ans += sum0 - tmp0;
            }
            tmp1 += elm.second;
        } else tmp0 += elm.second;
    }

    rep(i, sum1) ans += (i + 1) / 2;

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


Measured memory_bytes: 7580
/**
class cfmaster {
 public:
  struct code {
  	see the details down there !
  };
};
**/
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, r;
  cin >> n >> r;
  if (n >= 10) {
    cout << r << '\n';
  } else {
    cout << 100 * (10 - n) + r << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <assert.h>

inline int32_t get_num_factors(int64_t n, int64_t base){
    int32_t res = 0;
    while(n % base == 0){
        res++;
        n /= base;
    }
    return res;
}

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

    int32_t N;
    std::cin >> N;
    int64_t A[N];
    for(int32_t i = 0;i < N; i++){
        std::cin >> A[i];
    }
    int32_t sum_factors = 0;
    for(int32_t i = 0;i < N; i++){
        sum_factors += get_num_factors(A[i], 2);
    }

    std::cout << sum_factors << std::endl;
    return 0;
}

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

int main(){
  int s;
  cin >> s;
  
  int ans = 0;
  while(s >0){
    if(s % 10 == 1) ans++;
    s /= 10;
  }
  
  cout << ans << endl;
  return 0;
}

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

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

			Arrays.sort(loc);

			System.out.println(loc[n-1]-loc[0]);

		    sc.close(); }
}



Measured memory_bytes: 21716
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using V = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 10e9+7LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

void solve()
{
    string s; cin >> s;
    yn (s[0] == '7' || s[1] == '7' || s[2] == '7');
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <set>
#include <string>
#include <iomanip>
using namespace std;

int main(){
    string s;
    cin >> s;
    bool judge = true;
    for ( int i = 0 ; i < s.size(); i++ ){
        if ( s.find(s[i]) != s.rfind(s[i])){judge = false;break;}
    }
    if(judge) cout << "yes" << endl;
    else cout << "no" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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 print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<vector<ll>> dp(n + 1, vector<ll>(5, LLINF));
    dp[0][0] = 0;
    for(int i = 1; i <= n; i++) {
        for(int k = 0; k < 5; k++) {
            for(int j = 0; j <= k; j++) {
                if(k == 0 || k == 4) {
                    chmin(dp[i][k], dp[i - 1][j] + a[i - 1]);
                } else if(k == 1 || k == 3) {
                    chmin(dp[i][k], dp[i - 1][j] +
                                        (a[i - 1] == 0 ? 2 : (a[i - 1] & 1LL)));
                } else {
                    chmin(dp[i][k], dp[i - 1][j] + ((a[i - 1] & 1LL) == 0));
                }
            }
        }
    }
    ll ans = LLINF;
    for(int i = 0; i < 5; i++) {
        chmin(ans, dp[n][i]);
    }
    print(ans);
}

Measured memory_bytes: 15872
#include <cstdio>
#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 <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
#include <ctime>
#include <numeric>
using namespace std;
static const double EPS = 1e-8;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const double pi=acos(-1);
int dx[]={0,1,0,-1,1,1,-1,-1},dy[]={1,0,-1,0,1,-1,1,-1};

bool pr[10000];
int p[10000];
int sz;
ll ans[1000001];

int phi(int n){
  ll ret=n;
  for(int i=0;p[i]*p[i]<=n;++i){
    if(n%p[i])continue;
    while(n%p[i]==0)n/=p[i];
    ret=ret*(p[i]-1)/p[i];
  }
  if(n!=1)ret=ret*(n-1)/n;
  return ret;
}

main(){
  pr[0]=pr[1]=true;
  for(int i=2;i<10000;++i){
    if(pr[i])continue;
    p[sz++]=i;
    for(int j=i*2;j<10000;j+=i)pr[j]=true;
  }

  ans[1]=2;
  for(int i=2;i<=1000000;++i){
    ans[i]=ans[i-1]+phi(i);
  }

  int t;
  cin>>t;
  while(t--){
    int n;
    cin>>n;
    cout<<ans[n]<<endl;
  }
}

Measured memory_bytes: 0
s = list(input())
tes = ''
tes2 = ''
tes3 = []
res = 1
tr = -1
for i in range(len(s)) :
    tes += s[i]
    if tes == 'dream' or tes == 'erase' or tes == 'dreamer' or tes == 'eraser' :
        for j in range(i+1,len(s)):
            tes2 += s[j]
            if tes2 == 'dream' or tes2 == 'erase' :
                tr = 1
                #print("TRUE")
                #print(tes2)
                tes2 = ''
                break
            elif len(tes2) >= 7 or j == len(s)-1 :
                tr = 0
                #print("FALSE")
                #print(tes2)
                tes2 = ''
                break
        if tr == 1:
            #print(tes)
            tes3.append(tes)
            tes = ''

            

    elif len(tes) > 7:
        res = 0
        break
        
#print(tes2+'2')
#print(tes3)
#print(tes+'1')
if tes == 'dream' or tes == 'erase' or tes == 'dreamer' or tes == 'eraser':
    tes3.append(tes)
    tes = ''

if  len(tes3) > 0 and len(tes) == 0 :
    print('YES')
else :
    print('NO')

Measured memory_bytes: 10940
import math

N, D = [int(x) for x in input().split()]
x = []

for _ in range(N):
    x.append([int(x) for x in input().split()])

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        sum = 0
        for k in range(D):
            sum += (x[i][k] - x[j][k]) ** 2
        if math.sqrt(sum).is_integer():
            ans += 1


print(ans)




Measured memory_bytes: 3060