akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	double n;
  cin >> n;
  double x = 2 * n * PI;
  printf("%0.10lf\n",x);

  return 0;
}


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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

const int INF = 1e9;

int main(void){

	string S; cin >> S;
	set<char> st;
	REP(i,3){
		st.insert(S[i]);
	}
	
	if(st.size() == 1) cout << "No" << endl;
	else cout << "Yes" << endl;


	return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());

		int []div = divisor(n);
		
		int []cnt = new int [5]; //3,5,15,25,75 個の素因数の約数の個数
		
		int ans = 0;
		
		for(int i = 1 ; i <= n ;i++) {
			if(div[i] >= 2) cnt[0]++;
			if(div[i] >= 4) cnt[1]++;
			if(div[i] >= 14) cnt[2]++;
			if(div[i] >= 24) cnt[3]++;
			if(div[i] >= 74) cnt[4]++;
		}
		
		
		if(cnt[4] > 0) {
			ans += cnt[4];
		}
		if(cnt[3] > 0 && cnt[0] > 1) {
			ans += cnt[3] * (cnt[0]-1);
		}
		if(cnt[2] > 0 && cnt[1] > 1) {
			ans += cnt[2] * (cnt[1]-1);
		} 
		if(cnt[1] > 1 && cnt[0] > 2) {
			ans +=(cnt[1] * (cnt[1]-1)* (cnt[0]-2))/2;
		}
		
		System.out.println(ans);
		
	}
	
	
	static int[] divisor(int n) {
		int []d = new int [n+1];
		for(int i = 2 ; i <= n ; i++) {
			Euclid(i,d);
			}
		return d;

	}
	
	static void Euclid(int i , int []d) {
		for(int j = 2 ; j <= i ; j++) {
			if(prime(i)) {
				d[i]++;
				return;
			}
			else if(i % j == 0 && prime(j)) {
				int t = i;
				while(t % j == 0) {
					d[j]++;
					t = t / j;
				}
			}
		}
	}
	
	static boolean prime(int k) {
		
		if(k == 1) return false;
		
		for(int i = 2 ; i <= Math.sqrt(k) ; i++) {
			if(k % i == 0) {
				return false;
			}
		}
		return true;
	}
	
	
}


Measured memory_bytes: 21844
S=input()
if S =="SUN":
  print(7)
if S=="MON":
  print(6)
if S=="TUE":
  print(5)
if S=="WED":
  print(4)
if S=="THU":
  print(3)
if S=="FRI":
  print(2)
if S=="SAT":
  print(1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;++i)
#define per(i,a,b) for(int i=(b),i##_end=(a);i>=i##_end;--i)
#define For(i,a,b) for(int i=(a),i##_end=(b);i<i##_end;++i)
#define foe(i,a) for(__typeof(a.begin())i=a.begin();i!=a.end();++i)
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define Es(x,i) for(Edge *i=G[x];i;i=i->nxt)
typedef double ld;
typedef long long L;
typedef long double lf;
typedef unsigned int uint;
typedef unsigned long long uL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f,mo=1e9+7;
template<typename A,typename B>inline bool upmx(A&x,const B&y){return x<y?x=y,1:0;}
template<typename A,typename B>inline bool upmn(A&x,const B&y){return x>y?x=y,1:0;}
template<typename T>inline T gcd(T x,T y){for(;y;swap(x,y))x%=y;return x;}
inline int Pow(int a,int b,int p=mo){int r=1;for(;b;b>>=1,a=1ll*a*a%p)if(b&1)r=1ll*r*a%p;return r;}
#ifdef flukehn
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif
const int N=2011;
int a[N],n,b[N],K,Q;
inline bool cmp(int i,int j){
	return a[i]<a[j];
}
int c[N];
int chk(int m){
	for(int i=1;i<=n-Q+1;i++) 
	{
		memset(c,0,sizeof c);
		for(int j=i;j<=n;j++){
			if(a[b[j]]>a[b[i]]+m)c[b[j]]=-1;
			else c[b[j]]=1;
		}
		int res=0,l=0,t=0;
		for(int j=1;j<=n+1;j++){
			if(!c[j]){
				res+=max(0,min(j-l-K,t));
				l=j,t=0;
			}else if(c[j]>0)++t;
		}
		if(res>=Q)return 1;
	}
	return 0;
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>K>>Q;
	int l=inf,r=-inf;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		upmx(r,a[i]);
		upmn(l,a[i]);
		b[i]=i;
	}
	sort(b+1,b+n+1,cmp);
	r-=l,l=0;
	for(;l<r;){
		int m=l+r>>1;
		if(chk(m))r=m;
		else l=m+1;
	}
	cout<<l;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(s) int(s.size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int main(){FIN;
	ll a,b; cin>>a>>b;
	cout<<a*b<<"\n";
}

Measured memory_bytes: 3640
#include<iostream>
#define m 1000003
using namespace std;

int T[m];

int h(int k,int i){
  return  (k%m+i*(1+k%(m-1)))%m;
}

int  insert(int k){
  int i=0;
  while(1){
    int j=h(k,i);
    if(j<m && T[j]==0 ){ T[j]=k;return j;}
    else i++;
  }
}

int find(int k){
  int i=0;
  while(1){
    int j=h(k,i);
    if(j<m && T[j]==k) return 1;
    else if((j<m && T[j]==0) || i>=m) return 0;
    else i++;
  }
}


int change(string str1){
  int k=0;
  for(int i=str1.size();i>=0;i--){
    if(str1[i]=='A') k+=1;
    else if(str1[i]=='C') k+=2;
    else if(str1[i]=='G') k+=3;
    else if(str1[i]=='T') k+=4;
    if(i>0) k*=5;
  }
  return k;
}

int main(){
  int n,k,f;
  string str,str1;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>str>>str1;
    k=change(str1);
    if(str[0]=='i') insert(k);
    else{
      f=find(k);
      if(f==1) cout<<"yes"<<endl;
      else cout<<"no"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 5104
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int t = 1;
	// cin>>t;
	while (t--)
	{
		int n, cnt = 0;
		cin >> n;
		int L[n];
		for (int i = 0; i < n; i++)cin >> L[i];
		sort(L, L + n);
		for (int i = 0; i < n - 2; i++) {
			for (int j = i + 1; j < n - 1; j++) {
				for (int k = j + 1; k < n; k++) {
					if ( L[k] < L[i] + L[j])cnt++;
				}
			}
		}
		cout << cnt << '\n';
	}
	return 0;
}

Measured memory_bytes: 3712
#include <cstdio>

using namespace std;

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

const int N_MAX = 50;
const int DP0 = 2500;

typedef long long ll;

int N, A;
int x[N_MAX];

ll dp[DP0 * 2 + 1];

void solve() {
  dp[DP0] = 1;
  REP(i, N) {
    x[i] -= A;
    if (x[i] < 0) {
      for (int j = -DP0; j <= DP0 + x[i]; j++) {
        dp[DP0 + j] += dp[DP0 + j - x[i]];
      }
    } else {
      for(int j = DP0; j >= -DP0 + x[i]; j--) {
        dp[DP0 + j] += dp[DP0 + j - x[i]];
      }
    }
  }
  printf("%lld\n", dp[DP0] - 1);
}

void input() {
  scanf("%d%d", &N, &A);
  REP(i, N) scanf("%d", x + i);
}

int main() {
  input();
  solve();
  return 0;
}


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



long long mod = 2019;

long long modplus(long long a, long long b){
	long long ans = a + b;
	ans %= mod;
	return ans;
}

long long modminus(long long a, long long b){
	long long ans = a - b;
	ans %= mod;
	if(ans < 0) ans += mod;
	return ans;
}

long long modmul(long long a, long long b){
	long long ans = (a % mod) * (b % mod);
	ans = ((ans % mod) + mod) % mod;
	return ans;
}

long long modpow(long long A, long long P){
	long long a = A, p = P;
	if(p == 0) return 1;
	if(p == 1) return a;
	long long adash = modmul(a,a);
	if(p % 2) return modmul(modpow(adash, p / 2), a);
	else return modpow(adash, p / 2);
}

long long moddiv(long long a, long long b){
	long long divisor = modpow(b, mod - 2);
	return modmul(a,divisor);
}

int main(){
	string S;
	cin >> S;
	int N = (int)S.length();
	long long T[N+1];
	long long CNT[2019];
	for(int i=0;i<2019;i++){
		CNT[i] = 0;
	}
	CNT[0] = 1;
	T[N] = 0;
	for(int i=N-1;i>=0;i--){
		T[i] = modplus(modmul((S[i] - '0'), modpow(10, N - i - 1)), T[i+1]);
		CNT[T[i]]++;
	}
	long long ans = 0;
	for(int i=0;i<2019;i++){
		ans += CNT[i] * (CNT[i] - 1) / 2;
		//if(CNT[i] > 0)cout << i << ":" << CNT[i] << endl;
	}
	cout << ans << endl;
}


Measured memory_bytes: 5280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

const int MAX = 1e6; // 適宜
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 逆元 a^{-1} mod m
// aがmの倍数でないことが前提。O(log m)
ll modinv(ll a, ll m=MOD) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

struct DP{
	ll val;
	ll sz;
	
	DP(ll val=1, ll sz=0):val(val),sz(sz) {}
	DP addRoot() const {
		DP res = *this;
		res.sz++;
		return res;
	}
	DP operator + (const DP o) const {
		DP res = *this;
		(res.val *= o.val) %= MOD;
		(res.val *= COM(res.sz + o.sz, res.sz)) %= MOD;
		res.sz += o.sz;
		return res;
	}
	DP operator - (const DP o) const {
		DP res = *this;
		(res.val *= modinv(o.val)) %= MOD;
		(res.val *= modinv(COM(res.sz, o.sz))) %= MOD;
		res.sz -= o.sz;
		return res;
	}

};

int mainsolve(){

	// 前処理
    COMinit();

	ll n;
	cin >> n;
	vector<vector<ll>> to(n);
	rep(i,n-1){
		ll a,b;
		cin >> a >> b;
		--a; --b;
		to[a].push_back(b);
		to[b].push_back(a);
	}

	vector<vector<DP>> dp(n); // 要素数 2(n-1)
	rep(i,n) dp[i] = vector<DP>(to[i].size()); // vの子から始まる部分木（vの子自身を含む）
	vector<DP> dpSum(n); // vの子から始まる部分木の和（vを含まない）

	// まず普通にdfsして子方向へのdpを埋める
	function<DP(ll,ll)> dfs = [&](ll v, ll p){
		rep(i,to[v].size()){
			ll u = to[v][i];
			if(u != p){
				dp[v][i] = dfs(u,v).addRoot(); // uがrootである部分木
				dpSum[v] = dpSum[v] + dp[v][i];
			}
		}
		return dpSum[v];
	};
	dfs(0,-1);

	// 各dpSum[v]について、親方向へのノード1個分だけ足せていないので、それを足す
	function<void(ll,ll,DP)> dfs2 = [&](ll v, ll p, DP dpP){
		if(p != -1) dpSum[v] = dpSum[v] + dpP;

		rep(i,to[v].size()){
			ll u = to[v][i];
			DP nextDpP = (dpSum[v] - dp[v][i]).addRoot(); // 親vの部分木から子uの部分木の分だけ引く
			if(u != p) dfs2(u, v, nextDpP);
		}

	};
	dfs2(0,-1,DP());

	rep(i,n) cout << dpSum[i].addRoot().val << endl;
	return 0;

	
}

int main(){
	
		mainsolve();

	return 0;
}

Measured memory_bytes: 55280
#include<stdio.h>

int main(){
    int x[3000][2];
    int max=0;
    for(int i=0;i<10000;i++){
        scanf("%d %d",&x[max][0],&x[max][1]);
        if(x[max][0]==0&&x[max][1]==0){
            break;
        }
        if(x[max][0]>x[max][1]){
            int a = x[max][0];
            x[max][0] = x[max][1];
            x[max][1] = a;
            
        }
        max++;
    }
    
    for(int i=0;i<max;i++){
        printf("%d %d\n",x[i][0],x[i][1]);
    }
    return 0;
}


Measured memory_bytes: 2592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0; i<n; i++)
const int INF= 1LL << 30;

vector<int> dijkstra(const vector<vector<pair<int,int>>>& edge, int start){
    priority_queue<pair<int,int>,vector<pair<int,int>>, greater<pair<int,int>>> que;
    que.push(make_pair(0,start)); //距離、点
    int visited[edge.size()]= {0}; //確定点
    vector<int> costs(edge.size(),INF); //確定点
    int from,dist, to,cost;

    while(!que.empty()){
        tie(dist,from) = que.top(); que.pop();
        if(visited[from] == 1) continue;
        visited[from] = 1;  costs[from] = dist;

        for(auto e:edge[from]){
            tie(to,cost) = e;
            if(visited[to] == 1)continue;
            que.push(make_pair(dist+cost, to));
        }

    }
    return costs;
}
int main(){
    int v,e,r;//v:点,e:辺,r:始点
    cin >> v >> e >> r;
    vector<vector<pair<int,int>>>edge(v);
    REP(i,e){
        int a,b,c;
        cin >> a >> b >> c;
        edge[a].push_back(make_pair(b,c));
    }
    auto costs= dijkstra(edge, r);
    for(int x:costs){
        if(x>=INF) cout << "INF" << endl;
        else cout << x << endl;
    }

}


Measured memory_bytes: 14332
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define INF 1<<30
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

vi getLIS(vi a)
{
	int n = a.size();
	vi dp(n, INF);
	rep(i, 0, n) *lower_bound(dp.begin(), dp.end(), a[i]) = a[i];
	int d = distance(dp.begin(), lower_bound(dp.begin(), dp.end(), INF));
	dp.resize(d);
	return dp;
}

int main()
{
	int n; cin >> n;
	vi a(n);
	rep(i, 0, n) cin >> a[i];
	vi b = getLIS(a);
	//for (int c : b) cout << c << endl;
	cout << b.size() << endl;
}

Measured memory_bytes: 3936
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<functional>

using namespace std;
#define LL long long
#define ALF "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define LLBIG 1999999999999999999
#define INTBIG 1111111111
#define MOD 1000000007
#define PI pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>

int main() {
	int n, k; string s; cin >> n >> s >> k;
	char c = s[k - 1];
	for (int i = 0; i < n; i++)
		if (s[i] != c)s[i] = '*';
	cout << s << endl;


	return 0;
}


Measured memory_bytes: 256
s = input()
flag = 0

for i, c in enumerate(s):
  if (i % 2 == 0) and (c == "L"):
    flag = 1
  elif (i % 2 == 1) and (c == "R"):
    flag = 1

if flag == 1:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define MAXN 200100
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x<n and y >=0 and y<n)
using namespace std;
const ll mod = 1e9 + 7;
int roads[MAXN], rails[MAXN];
map <pii, int> freq;

int find_road(int i){
    return roads[i] = (i == roads[i]? i : find_road(roads[i]));
}
int find_rail(int i){
    return rails[i] = (i == rails[i]? i : find_rail(rails[i]));
}
void merge_road(int a, int b){
    int fa = find_road(a);
    int fb = find_road(b);

    if (fa != fb){
        roads[fb] = fa;
    }
}

void merge_rail(int a, int b){
    int fa = find_rail(a);
    int fb = find_rail(b);

    if (fa != fb){
        rails[fb] = fa;
    }
}

int main (){
    ios_base::sync_with_stdio(false);
    int a ,b;
    char op;

    cin >> a >> op >> b;

    cout << (op == '+'? a+b : a-b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
signed main()
{
  SPEED;
  string s;
  int i,c=0;
  cin>>s;
  for(i=0;i<s.length()/2;i++)
  {
    if(s[i]!=s[s.length()-i-1])
      c++;
  }
  cout<<c;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 K, N;
  cin >> K >> N;
  vector<i64> A(N);
  for (i64 i = 0; i < N; i++)
    cin >> A[i];
  i64 ans = K - (A[N - 1] - A[0]);
  for (i64 i = 0; i < N - 1; i++)
    ans = max(ans, A[i + 1] - A[i]);
  cout << K - ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn lower_bound<F>(len: usize, p: F) -> usize
where
    F: Fn(usize) -> bool,
{
    let mut left = 0;
    let mut right = len;

    while left < right {
        let mid = (left + right) / 2;
        if p(mid) {
            right = mid;
        } else {
            left = mid + 1;
        }
    }
    right
}

#[test]
fn test_lower_bound() {
    let v = vec![1, 1, 1, 2, 3, 3, 3, 5, 6];
    assert_eq!(lower_bound(v.len(), |i| 3 < v[i]), 7);
    assert_eq!(lower_bound(v.len(), |i| 3 <= v[i]), 4);
    assert_eq!(lower_bound(v.len(), |i| 10 <= v[i]), v.len());
    assert_eq!(lower_bound(v.len(), |i| 1 < v[i]), 3);
    assert_eq!(lower_bound(v.len(), |i| 0 <= v[i]), 0);
    assert_eq!(lower_bound(v.len(), |i| 6 <= v[i]), v.len() - 1);
}

fn main() {
    let n = scan!(usize);
    let vs = scan!(i64;n);

    let mut seq = vec![];
    for v in vs.iter() {
        if let Some(&w) = seq.last() {
            if w < v {
                seq.push(v);
            } else {
                let n = lower_bound(seq.len(), |i| v <= seq[i]);
                seq[n] = v;
            }
        } else {
            seq.push(v)
        }
    }

    println!("{}", seq.len());
}



Measured memory_bytes: 6960
#include<iostream>
#include<math.h>
using namespace std;

int main()
{
  int n;
  int count = 0;
  string s;
  cin >>n>>s;
  for(int i=0;i<=n-3;i++)
  {
    if(s[i]=='A'&& s[i+1]=='B'&& s[i+2]=='C') count++;
  }

  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

char map[60][60];
bool used[60][60];
int h, w;

void dfs(int x, int y) {
    if (x < 0 || y < 0 || h <= x || w <= y){
        return;
    }
    if(used[x][y])
        return;
    if (map[x][y] == '.') {
        int count = 0;
        for(int i = -1; i != 2; i++){
            for(int j = -1; j != 2; j++){
                if(0 <= x + i && x + i < h && 0 <= y + j && y + j < w)
                    count += map[x + i][y + j] == '#';
            }
        }  
        map[x][y] = '0' + count;
    }
    used[x][y] = true;
    dfs(x, y + 1);
    dfs(x, y - 1);
    dfs(x + 1, y);
    dfs(x - 1, y);
}

int main() {
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> map[i][j];
    }
  }
  dfs(0, 0);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cout << map[i][j];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
using namespace std;
int a[3];
  int main (){
for(int i=0;i<3;i++){
cin>>a[i];}
sort(a,a+3);
for(int i=0;i<3;i++){
cout<<a[i];
if(i!=2){cout<<" ";}}
cout<<endl;
return 0;
}

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

int main()
{
	int s, n, p, q;
	int a[1000000];
	scanf("%d", &s);
	a[1] = s;
	n = 1;
		
	for (q = 1; q <= 1000000; q++) {
		p = 1;
		if (a[q] % 2 == 0) {
			a[q + 1] = a[q] / 2;
		}
		else {
			a[q + 1] = 3 * a[q] + 1;
		}
		while (p < q) {
		
			if (a[p] == a[q]) {
				printf("%d", q);
				return 0;
			}
			else {
				p++;
			}
		}
	}
	

	return 0;
}

Measured memory_bytes: 128
function main(input) {
  const ary = input.split(' ').sort().map(n => parseInt(n, 10));
  console.log(Math.abs(ary[0] -ary[1]) + Math.abs(ary[1] - ary[2]));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

bool Isprime(int x){
    if(x <= 1) return false;
    for(int i=2;i*i<=x;i++){
        if(x % i ==0) return false;
    }
    return true;
}
int main()
{
int x;
cin >> x ;

while(1){
    if(Isprime(x) == true) break;
    x++;
}

cout << x << endl;

return 0;
}

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

using namespace std;

template <int base>
int digit_sum(int n)
{
	int sum = 0;
	while (n > 0) {
		sum += n % base;
		n /= base;
	}
	return sum;
}

using ivec = vector<int>;

ivec read_int_args()
{
	int N;
	cin >> N;
	ivec v(N);
	for (auto& e : v) {
		cin >> e;
	}
	return v;
}

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

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

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


int main()
{
	int N;
	cin >> N;
	int M = N / 2;
	double p  = (double)(N - M) / N;
	cout << p << endl;

	return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#define ll long long int
using namespace std;
int main(){
  string s;cin>>s;
  bool ok=true;
  sort(s.begin(),s.end());
  for(int i=0;i<s.size();++i){
    if(i==0)continue;
    if(s[i-1]==s[i])ok=false;  
  }
  if(ok)cout<<"yes"<<endl;
  else cout<<"no"<<endl;
}


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

using namespace std;
int main() {
    int N,count,a,L,box;
    cin >> N;
    count = 1;
    L = 0;
    box = 0;
    while(count <= N){
        count = count + 1;
        cin >> a;
        if(L < a){
            box = box + L;
            L = a;
        }
        else{
            box = box + a;
        }
    }
    if(L < box){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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


Measured memory_bytes: 2740
/*
     Author: Wasi Ur Rahman
     RMSTU,Rangamati,Chittagong,Bangladesh
*/
#include <bits/stdc++.h>
using namespace std;
#define  gcd(a,b) __gcd(a,b)
#define  lcm(a,b) (a*b)/gcd(a,b)
#define  PI acos(-1.0)
#define  sqr(x) ((x)*(x))
#define  min3(a,b,c) min(a,min(b,c))
#define  min4(a,b,c,d) min(d,min(a,min(b,c)))
#define  max4(a,b,c,d) max(d,max(a,max(b,c)))
typedef   pair<int, int> ii;
typedef   std::vector<ii> vii;
#define   vi   std::vector<int>
#define   vll  std::vector<ll>
#define   all(n) n.begin(),n.end()
#define  mpsi std::map<string, int>
#define  pb             push_back
#define  ll             long long int
#define  ln             printf("\n");
#define  fast           ios::sync_with_stdio(false);cin.tie(0)
#define  max3(a,b,c)    max(a,max(b,c))
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define dec(x,y)        fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
#define  mod           1e9 + 7;
bool prm[1000001];
void sieve()
{
    prm[0] = prm[1] = 1;
    for(ll i = 4 ; i <= 1000000 ; i += 2)
        prm[i] = 1 ;
    for(ll i = 3 ; i * i <= 1000000 ; i += 2)
    {
        if(!prm[i])
        {
            for(ll j = i * i ; j <= 1000000 ; j+= i + i)
                prm[j] = 1 ;
        }
    }
}
int floorSqrt(int x)
{
    // Base cases
    if (x == 0 || x == 1)
    return x;

    // Staring from 1, try all numbers until
    // i*i is greater than or equal to x.
    int i = 1, result = 1;
    while (result <= x)
    {
      i++;
      result = i * i;
    }
    return i - 1;
}
int main()
{
    fast;
    int M, D; cin >> M >> D;
     int ans = 0;
      for (int d = 10; d <= D; ++d) {
            int d_1 = d % 10, d_10 = d / 10;
      if (d_1 >= 2 && d_10 >= 2 && d_1 * d_10 <= M) {
            ++ans; } }
      cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <cstdio>
#include<bits/stdc++.h>
#include <cstring>
#define ll long long int
#define ii int
#define jmp cout<<"\n"
#define vl vector<ll>
#define pb push_back
#define printv(v) for(auto x:v) cout<<x<<" "; jmp;
#define endll "\n"
#define SORT(v) sort(v.begin(),v.end())
#define REV(x)  reverse(x.begin(),x.end())
#define ff first
#define ss second
#define iin insert
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
using namespace std;
const ll N = 1e5 + 5;
const ll inf = 0x3f3f3f3f;

void dfs(int vis[], vector<int> arr[] ,int v, int dp[])
{
    vis[v]=1;
    for(auto i: arr[v])
    {
        if(!vis[i])
           dfs(vis,arr,i,dp);

       dp[v]=max(dp[v],1+dp[i]);  
    }
}



int  solve(vector<int> arr[], int n , int m)
{
    for(int i=0;i<m;i++)
    {
        int a, b;
        cin>>a>>b;
        arr[a].pb(b);
    }
    int vis[n+1];
    int dp[n+1];
    memset(dp, 0, sizeof dp); 
    memset(vis,0,sizeof(vis));
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
           dfs(vis,arr,i,dp);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        ans=max(ans,dp[i]);
    }
    return ans;

}



int32_t main() {
    fast;
    int n, m;
    cin>>n>>m;
    vector<int> arr[n+1];
    cout<<solve(arr,n,m);
    return 0;
}


Measured memory_bytes: 9984
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,a;
  int sm = 0;
  cin >> n >> k;
  for(int i=0;i<n;i++){
    cin >> a;
    sm += (a < k-a?a:k-a)*2;
  }
  cout << sm << endl;
}

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

/**
 * Combinatorial - Coin Changing Problem
 */
public class Main {

	static int INF = Integer.MAX_VALUE;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line;


		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] cs = new int[m];
		int[] dp = new int[n + 1];


		for (int i = 0; i < m; i++) {
			cs[i] = sc.nextInt();
		}

		Arrays.fill(dp, INF);
		dp[0] = 0;

		for (int i = 0; i < m; i++) {
			for (int j = cs[i]; j <= n; j++) {
				dp[j] = Math.min(dp[j], dp[j - cs[i]] + 1);
			}
		}

		System.out.println(dp[n]);
	}
}

Measured memory_bytes: 26864
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use proconio::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

fn main() {
    input! {
        x: String,
        y: String,
        z: String,
    }

    println!("{} {} {}", z, x, y);
}


Measured memory_bytes: 2064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var s = cin.next();
            var t = cin.next();

            var ans = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] != t[i]) ans++;
            }
            Console.WriteLine(ans);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 27524
#include<bits/stdc++.h>
#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define one 1.0
#define inf 1000000000000000000
#define ret return
#define all(vl) vl.begin(),vl.end()
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
int main()
{
	ll n;
	cin>> n;
	vector<ll> vl(n);
	for(int i=0;i<n;i++)
	{
		cin>>vl[i];
	}
	ll cnt = 1;
	sort(vl.begin(),vl.end());
	ll chu = 1e18; 
	for(int i=0;i<n;i++){
		if(vl[i]!=0)
		{
			chu/=vl[i];
		}
		else
		{
			cout<<"0\n";
			return 0;
		}
		if(chu == 0){
			cout<<"-1\n";
			return 0;
		}
	}
	for(int i=0;i<n;i++)
	{
		cnt*=vl[i];
			
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 4052
#include <iostream>
#include <vector>
#include <map>
#include <limits>
using namespace std;

unsigned long long sum = 0;
void out(std::string msg, int* a, int left, int right)
{
    cout << msg << "[" << left << ":" << right  << "): ";
    for(int i=left; i<right; i++) cout << a[i] << " ";
    cout << endl;
}
void merge(int* a, int left, int mid, int right)
{
    //out("merge ", a, left, right);
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1+1], R[n2+1];
    for(int i=0; i<n1; i++){
        L[i] = a[left+i];
    } 
    for(int i=0; i<n2; i++){
        R[i] = a[mid+i];
    }
    //out("L", L, 0, n1);
    //out("R", R, 0, n2);
    L[n1] = 1000000001; /*std::numeric_limits<int>::infinity();*/
    R[n2] = 1000000001; /*std::numeric_limits<int>::infinity();*/
    int i=0, j=0;
    for(int k=left; k<right; k++){
        if(L[i] <= R[j]){
            a[k] = L[i]; i++;
        }else{
            a[k] = R[j]; j++;
        }
        sum++;
    }
    //out("merged", a, left, right);
}
void mergeSort(int* a, int left, int right)
{
    //out("mergeSort", a, left, right);
    if(left+1 >= right) return;
    int mid = (left+right)/2;
    mergeSort(a, left, mid);
    mergeSort(a, mid, right);
    merge(a, left, mid, right);
}
int main()
{
    int n;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int left = 0;
    int right = n;
    mergeSort(a, left, right);

    for(int i=0; i<n; i++){
        cout << a[i];
        if(i != n-1) cout << " ";
        else cout << endl;
    }
    cout << sum << endl;
}


Measured memory_bytes: 6988
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

const int INF = 1e9;
const long long LINF = 1e18;

int main() {
    int N;
    string S;
    cin >> N >> S;

    for (int i = 0; i < S.size(); i++) {
        int ci = S[i] + N;
        if (ci > 'Z') {
            ci = (ci - 'Z' - 1) + 'A';
        }
        S[i] = static_cast<char>(ci);
    }
    cout << S << endl;

    return 0;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long 
#define INF 1e9
#define LINF 1e18
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FORr(i, j, 0)

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;
typedef pair<P, P> PP;
 
const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };
 
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

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

    int r, d, x;
    cin >> r >> d >> x;
    rep(i, 10) {
        x = x * r - d;
        cout << x << endl;
    } 
    return 0;
}


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

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main()
{
    ll x, y;
    cin >> x >> y;

    if (abs(x - y) > 1)
        cout << "Alice" << endl;
    else
        cout << "Brown" << endl;

    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc083/tasks/arc088_a

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const ll Y_MAX = 1e18;

ll X, Y;

void solve() {
  int ans = 1;
  while (true) {
    X *= 2;
    if (X > Y) break;
    ans++;
  }
  printf("%d\n", ans);
}

void input() {
  scanf("%lld%lld", &X, &Y);
}

int main() {
  input();
  solve();
  return 0;
}


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

using namespace std;

int mypow(int b, int n) {
    if (n == 0) return 1;
    if (n == 1) return b;
    if (n % 2 == 0) {
        return mypow(b * b, n / 2);
    } else {
        return mypow(b, n - 1) * b;
    }
}

// n < 2^kなる最小の2^kを返す
int minbeki(int n) {
    int ret = 1;
    while (n >= ret) {
        ret *= 2;
    }
    return ret;
}

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

    map<int, int> cnt;
    // 値とボールの個数を管理

    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        if (cnt.find(a) == cnt.end()) cnt[a] = 0;
        ++cnt[a];
    }

    int ans = 0;

    // cntをkeyが大きい方から見ていく
    for (auto itr = cnt.rbegin(); itr != cnt.rend(); ++itr) {
        int b = itr->first;
        if (cnt[b] == 0) continue;

        int a = minbeki(b) - b;
        // bとペアになりうるaを求める

        if (a == b) {
            // bと書かれたボール同士でペアを作る
            ans += cnt[b] / 2;
        } else {
            if (cnt.find(a) == cnt.end()) continue;
            // aと書かれたボールが存在しなければ次へ

            // 少ない方に合わせてペアを作る
            ans += min(cnt[a], cnt[b]);
            cnt[a] -= min(cnt[a], cnt[b]);
        }
    }

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


Measured memory_bytes: 9600
from collections import defaultdict
from bisect import bisect_right

n, k = map(int, input().split())
alst = list(map(int, input().split()))

dd = defaultdict(list)
dd[0].append(0)
total = 0
for i, num in enumerate(alst, start = 1):
    total += num
    total %= k
    app = total - i
    app %= k
    dd[app].append(i)
ans = 0
for _, lst in dd.items():
    for i, num in enumerate(lst):
        num2 = num + k - 1
        pos = bisect_right(lst, num2)
        ans += pos - i - 1
print(ans)



Measured memory_bytes: 63416
def main2():
    N = int(input())
    A = [int(a) for a in input().split()]
    A.sort(reverse=True)

    ans = 0
    count = N - 1

    for i in range(len(A)):
        lim = 0

        if i == 0:
            lim = 1
        else:
            lim = 2

        for j in range(lim):
            if count > 0:
                ans += A[i]
                count -= 1

    print(ans)

if __name__ == "__main__":
    main2()

Measured memory_bytes: 31520
#include <stdio.h>
#include <ctype.h>  //toupper function使う

void func (char *p);

int main () {
    char a[1600];
    fgets (a,1600,stdin);
    func (a); 
    
    printf ("%s",a);
    return 0;
}

void func (char *p) {
    while (*p != '\0' ) { //空白来ても続ける
        if (islower (*p)) { //小文字来たら
            *p = toupper (*p);
        } else {
            *p = tolower (*p) ;
        }
        *p ++;
    }
    
}


Measured memory_bytes: 2060
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

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

int main() {
  int N, K;
  cin >> N >> K;
  int answer = 1;
  REP(i, N) {
    answer = min(answer * 2, answer + K);
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<int>>
constexpr auto mod = 1000000007;


//2のn乗を求めるよ！！！
int ni(int n) {
	if (n == 0)return 1;
	int x = ni(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;
}

//フィボナッチ数列のx番目を求めるよ！
int f(int x, vector<int> s) {
	if (x == 0)return 0;
	if (x == 1)return 1;
	if (s[x] != 0)return s[x];
	s[x] = f(x - 1, s) + f(x - 2, s);
	return s[x];
}

//aとｂの最大公約数を求めるよ！
llint gcd(llint a, llint b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}



// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}

//m進数のn桁を全列挙やで
void dfs(int m, int n) {

	stack<string> st;
	st.push("");
	while (!st.empty()) {
		string now = st.top();
		st.pop();
		if (now.size() == n) {
			cout << now << endl;
		}
		else {
			for (int i = m - 1; i >= 0; i--) {
				string next = now + to_string(i);
				st.push(next);
			}
		}
	}
}

int main() {
	int n;
	cin >> n;
	vector<pair<int, int>> s(n);
	rep(i, 0, n) {
		int a, b;
		cin >> a >> b;
		s[i] = make_pair(a + b, a - b);
	}
	sort(s);
	int ans = 1;
	int x = s[0].first;
	rep(i, 1, n) {
		if (s[i].second >= x) {
			ans++;
			x = s[i].first;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#define N 100
#define WHITE 0
#define GREY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], time;

void dfs_visit(int u)
{
	int v;
	color[u] = GREY;
	d[u] = ++time;
	for(v = 0; v < n; v++)
	{
		if(M[u][v] == 0)
			continue;
		if(color[v] == WHITE)
			dfs_visit(v);
	}
	color[u] = BLACK;
	f[u] = ++time;
}

void dfs()
{
	int u;
	for(u = 0; u < n; u++)
		color[u] = WHITE;
	time = 0;
	
	for(u = 0; u < n; u++)
	{
		if(color[u] == WHITE)
			dfs_visit(u);
	}
	for(u = 0; u < n; u++)
	{
		printf("%d %d %d\n", u + 1, d[u], f[u]);
	}
}

int main()
{
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			M[i][j] = 0;
	int u, k, v;
	for(int i = 0; i < n; i++)
	{
		scanf("%d%d", &u, &k);
		u--;
		for(int j = 0; j < k; j++)
		{
			scanf("%d", &v);
			v--;
			M[u][v] = 1;
		}
	}
	
	dfs();
}



Measured memory_bytes: 2752
#include <iostream>

#define MOD 1000000007

typedef long long ll;

ll n, m;

ll fact(ll n) {
    if (n <= 1) return 1;
    ll res = 1;
    for (int i=1; i<=n; ++i) {
        res *= i;
        res = res % MOD;
    }
    return res;
}

ll solve() {
    if (std::abs(n-m) > 1) return 0;
    ll res = fact(n) * fact(m) % MOD;
    if (n == m) res = res * 2 % MOD;
    return res;
}

int main() {
    std::cin >> n >> m;
    std::cout << solve() << std::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()
ans = 10**10
for i in range(n-k+1):
  if ans >= h[i+k-1] - h[i]:
    ans = h[i+k-1] - h[i]
    if ans == 0:
      break
print(ans)

Measured memory_bytes: 7472
N = gets.to_i
A = gets.split.map(&:to_i)

sum = A.inject(:+)
ans = Float::INFINITY

left = 0

A[0..-2].each do |a|
  left += a
  right = sum - left

  diff = (left - right).abs

  ans = diff if ans > diff
end

puts ans


Measured memory_bytes: 16132
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    string s;
    cin >> s;
    bool odd = true, even = true;
    for(int i = 0;i < s.size(); i++) {
        if((i + 1) % 2 == 0) {
            if(s[i] == 'R') even = false;
        }
        else {
            if(s[i] == 'L') odd = false;
        }
    }
    if(odd && even) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define INF 10000000
#define PI 3.14159265358979323846
using namespace std;
typedef long long ll;
typedef pair<int, int> p;
typedef vector<int> v;
typedef vector<int, int> v2;
typedef vector< pair<int, int> > vp;
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };

int w, h;
int c[52][52];
int f[52][52];

bool dfs(int y, int x){
	if (c[y][x] == 0) return false;
	if (f[y][x] == 1) return false;
	
	f[y][x] = 1;
	if (y > 0) dfs(y - 1, x);
	if (x > 0) dfs(y, x - 1);
	
	if (y < h) dfs(y + 1, x);
	if (x < w) dfs(y, x + 1);

	if (y > 0 && x > 0) dfs(y - 1, x - 1);
	if (y < h && x > 0) dfs(y + 1, x - 1);
	if (y > 0 && x < w) dfs(y - 1, x + 1);
	if (y < h && x < w) dfs(y + 1, x + 1);

	return true;
}

int main(){
	ios::sync_with_stdio(false);

	while (1){
		cin >> w >>  h;
		if (w == 0 && h == 0) break;

		int ans = 0;

		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++)
				cin >> c[i][j];
			
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++)
				f[i][j] = -1;
		
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++)
				if(dfs(i, j)) ans++;

		cout << ans << endl;

	}

	return 0;
}

Measured memory_bytes: 1320
#include <bits/stdc++.h>
#define MAX (ll)(2e5+5)
#define MOD (ll)(1e17)
#define INF (ll)(1e18 + 3)
#define PI (double)(3.14159265)

using namespace std;
using ll = long long;

int main () {
	int n;
	cin >> n;
	if (n & 1) {
		cout << n / 2 << "\n";
	}
	else {
		cout << (n - 1) / 2 << "\n";
	}
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(str) {
  const num = Number(str);

  if (num <= 2) {
    console.log(2);
    return;
  }

  if (num % 2 === 0) {
    console.log(num);
    return;
  }

  console.log(num * 2);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include  <stdio.h>
     
    int main(){
      int A;
      int B;

       scanf("%d%d",&A,&B);
      if(A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0){
        printf("Possible\n"); 
      }else{
        printf("Impossible\n");
       }  
        return 0;
    }

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////



int main() {
	cout << fixed << setprecision(10);

	ll N;
	cin >> N;
	vector<double> A(N + 1);

	repn(i, N) cin >> A[i];

	double k = 0;
	repn(i, N) k += 1.0 / A[i];

	cout << 1.0 / k;
	system("PAUSE");
}

Measured memory_bytes: 504