akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n,m; cin >> n >> m;
	vl a(n); rep(i,n) cin >> a[i], a[i]--;
	vl b(2*m+1,0);
	vl c(2*m+1,0);
	ll cnt = 0;
	rep(i,n-1){
		ll cur = (a[i] > a[i+1]) ? a[i+1]+m : a[i+1];
		cnt += cur - a[i];
		if(a[i] + 1 == cur) continue;
		ll pre = a[i] + 2;
		b[cur+1] -= cur + 1 - pre;
		c[pre]++; c[cur+1]--;
	}
	rep(i,2*m) c[i+1] += c[i];
	rep(i,2*m+1) b[i] += c[i];
	rep(i,2*m) b[i+1] += b[i];
	/*rep(i,2*m+1) cout << b[i] << " ";
	cout << "\n";*/
	rep(i,m) b[i] += b[i+m];
	cout << cnt - *max_element(all(b)) << endl;
}

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

using namespace std;

int n;

int factors[10000001];

void fact()
{
   for(int i=2;i<=n;i++)
   {
       for(int j=2*i;j<=n;j+=i)
        factors[j]+=1;
   }
}

void test()
{
    cin>>n;

    factors[1]=1;

   for(int i=2;i<=n;i++)
    factors[i]=2;

    fact();

    long long res=0;
    for(int i=1;i<=n;i++)
        res+=(long long)i*factors[i];

    cout<<res;

}

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

    test();

    return 0;
}


Measured memory_bytes: 42688
import itertools
s = input()
ans = 0
ss = [s[i//2] if i%2==0 else "+" for i in range(2*len(s)-1)]

for li in itertools.product(range(2),repeat=len(s)-1):
  for j in range(len(s)-1):
    if li[j] ==1:
      ss[j*2+1] = "+"
    else:
      ss[j*2+1] = ""
  ans = ans+ eval("".join(ss))
print(ans)

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

int main(){
    int n;
    cin>>n;
    int a[n],b[n],d[n];
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>b[i];
    int cnt=0;
    ll sum=0;
    int j=0;
    for(int i=0;i<n;i++){
        if(a[i]<b[i]){
            cnt++;
            sum+=b[i]-a[i];
        }
        else if(a[i]>b[i]){
            d[j]=a[i]-b[i];
            j++;
        }
    }
    
    if(cnt==0){
        cout<<0<<endl;
        return 0;
    }
    ll sum2=0;
    sort(d,d+j);
    for(int i=j-1;i>=0;i--){
        sum2+=d[i];
        cnt++;
        if(sum2>=sum){
            cout<<cnt<<endl;
            return 0;
        }
    }
    
    cout<<-1<<endl;
    

}

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

int main(){
	int s[101][101]={0};
	int i,j,r,c;
 	
	cin>>r>>c;
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			cin>>s[i][j];
			s[i][c]+=s[i][j];
			s[r][j]+=s[i][j];
		}
		s[r][c]+=s[i][c];
	}
	
	for(i=0;i<r+1;i++){
		for(j=0;j<c+1;j++){
			cout<<s[i][j];
			if(j!=c){
				cout<<" ";
			}
		}
		cout<<endl;
	}
  	return 0;
}

Measured memory_bytes: 3132
S = input()

ans = len(S)
for i in range(26):
    c = chr(ord('a') + i)
    if c not in S: continue
    tmp = S
    cnt = 0
    while any(a!=c for a in tmp):
        cnt += 1
        _tmp = ''
        for a,b in zip(tmp,tmp[1:]):
            if a == c or b == c:
                _tmp += c
            else:
                _tmp += a
        tmp = _tmp
    ans = min(ans, cnt)
print(ans)

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

int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++)
		cin >> p[i];
	int ans = 0;
	for (int i = 0; i < n - 1; i++)
		if (p[i] == i + 1) {
			swap(p[i], p[i + 1]);
			ans++;
		}
	if (p[n - 1] == n)
		ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
N = int(input())
R = list(range(1, 10))
cnt = 0

while True:
    cnt += 1
    p = R[cnt - 1]

    if p % 10 != 0:
        R.append(10 * p + p % 10 - 1)
    R.append(10 * p + p % 10)
    if p % 10 != 9:
        R.append(10 * p + p % 10 + 1)
    if cnt == N:
        break

print(R[cnt - 1])

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

#define oo 1000000000000000000LL
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define In insert
#define mod 1000000007
#define File(s) ifstream fin ((string)s + ".in", ios::in), ofstream fout ((string)s + ".out", ios::out);

using namespace std;

typedef long long int ll;
typedef long double ld;

map <ll, ll> mp;

ll ans (ll k) {
    if (k == 1)
        return 1;

    k /= 2;
    if (mp.find(k) != mp.end())
        return 2 * mp[k] + 1;

    mp[k] = ans (k);

    return 2 * mp[k] + 1;
}

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

    ll h;

    cin>> h;

    cout<< ans(h) << endl;

    // cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N; cin >> N;
  int num = 1; while (num*(num+1)/2<N) num++;
  if (num*(num+1)/2!=N) { cout << "No" << endl; return 0; }

  int result[num+1][num];
  int count = 1;
  rep(i,num) {
    for (int j=i; j<num; j++) {
      result[i][j] = count;
      result[j+1][i] = count;
      count++;      
    }
  }

  cout << "Yes" << endl;
  cout << num+1 << endl;
  rep(i,num+1) {
    cout << num << " ";
    rep(j,num) cout << result[i][j] << " ";
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 2176
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner scan = new Scanner(System.in);
        long A = scan.nextLong();
        double B = scan.nextDouble();
        BigDecimal a = BigDecimal.valueOf(A);
        BigDecimal b = BigDecimal.valueOf(B);
        System.out.println(a.multiply(b).setScale(0, RoundingMode.FLOOR));
    }
}


Measured memory_bytes: 37692
from collections import deque
K = int(input())
Q = deque([1,2,3,4,5,6,7,8,9])
for i in range(K):
    x = Q.popleft()
    if x%10!=0:
        Q.append(10*x + x%10 - 1)
    Q.append(10*x + x%10)
    if x%10!=9:
        Q.append(10*x + x%10 + 1)
print(x)

Measured memory_bytes: 40816
from collections import deque

N = int(input())
link = [[] * N for _ in range(N)]

for i in range(N-1):
    a, b = map(lambda x: int(x) - 1, input().split())
    link[a].append(b)
    link[b].append(a)

c = list(map(int, input().split()))
c = sorted(c, reverse=True)
sums = sum(c) - max(c)

q = deque([0])
d = [-1] * N

num = 0
while len(q) > 0:
    x = q.popleft()
    d[x] = c[num]
    num += 1
    for y in link[x]:
        if d[y] < 0:
            q.append(y)

print(sums)
print(*d)

Measured memory_bytes: 6168
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999;
	
	public static void Main(string[] args)
	{
		var p = Input();
		var n = p[0].ToLong();
		var a = p[1].ToInt();
		var b = p[2].ToInt();
		
		long wa = ModPow(2, n, Giri) - 1;

		long wa2 = 0;
		wa2 += Combination(n, a);
		wa2 %= Giri;
		wa2 += Combination(n, b);
		wa2 %= Giri;
		Console.WriteLine((wa + Giri - wa2) % Giri);
	}
	
	static long Combination(long n, long k)
	{
		long q = 1;
		long s = 1;
		long j = 1;
		for(long i = n; i >= n-k+1; i--)
		{
			q *= i % Giri;
			q %= Giri;
			s *= ModPow(j, Giri- 2, Giri) % Giri;
			s %= Giri;
			j++;
		}
		
		return (long)(q * s) % Giri;
	}
	
	static long ModPow(long a, long n, long mod)
	{
	    long res = 1;
	    while (n > 0)
	    {
	        if ((n & 1) == 1) res = res * a % mod;
	        a = a * a % mod;
	        n >>= 1;
	    }
	    return res;
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	 }
}


Measured memory_bytes: 11220
def xor(a, b):
    l = len(b)
    za = a.zfill(l)
    ret = ""
    for i in range(l):
        if za[i] == "0" and b[i] == "0":
            ret = ret + "0"
        elif za[i] == "0" and b[i] == "1":
            ret = ret + "1"
        elif za[i] == "1" and b[i] == "0":
            ret = ret + "1"
        else:
            ret = ret + "0"
    return ret

def spxor(n):
    r = ""
    if n % 4 == 1 or n % 4 == 2:
        r = "1" + r
    else:
        r = "0" + r

    k = 1
    while n >= 2 ** k:
        a = n % (2 ** (k + 1))
        if a >= 2 ** k and a % 2 == 0:
            r = "1" + r
        else:
            r = "0" + r
        k += 1
    return r

def to10d(s):
    le = len(s) - 1
    j = len(s) - 1
    re = 0
    while j >= 0:
        re += int(s[j]) * (2 ** (le - j))
        j -= 1
    return re

a, b = map(int, input().split())
if a == 0:
    print(to10d(spxor(b)))
else:
    sa = spxor(a - 1)
    sb = spxor(b)
    print(to10d(xor(sa,sb)))

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

int main(){
    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    long long p[a],q[b],r[c];
    for(int i=0; i<a; i++){
        cin >> p[i];
    }
    for(int i=0; i<b; i++){
        cin >> q[i];
    }
    for(int i=0; i<c; i++){
        cin >> r[i];
    }
    sort(p,p+a,greater<long long>());
    sort(q,q+b,greater<long long>());
    sort(r,r+c,greater<long long>());
    int s=x-1,t=y-1;
    for(int i=0; i<c; i++){
        if(s < 0 && t<0) break;
        else if(s<0){
            if(q[t] < r[i]){
                q[t] = r[i];
                t--;
            }
        }
        else if(t<0){
            if(p[s] < r[i]){
                p[s] = r[i];
                s--;
            }
        }
        else if(r[i] > min(p[s],q[t])){
            if(p[s] < q[t]){
                p[s] = r[i];
                s--;
            }
            else{
                q[t] = r[i];
                t--;
            }
        }
        else break;
    }
    long long ans=0;
    for(int i=0; i<x; i++){
        ans += p[i];
    }
    for(int i=0; i<y; i++){
        ans += q[i];
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> a(H);
    rep(i, H) cin >> a[i];
    rep(i, W + 2) cout << "#";
    cout << endl;
    rep(i, H) cout << "#" << a[i] << "#" << endl;
    rep(i, W + 2) cout << "#";
    cout << endl;
}

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

#define int long long
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; }

signed main(){
	int n;
	cin >> n;
	int a[1000];
	for(int i = 0;i < n;i++) cin >> a[i];

	sort(a, a+n);
	int ans = 0;
	for(int i = 0;i < n;i++){
		for(int j = i+1;j < n;j++){
			for(int k = j+1;k < n;k++){
				if(a[i] != a[j] && a[j] != a[k] && a[i] != a[k]){
					if(a[i]+a[j] > a[k]) ans++;
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
int N;
int a[100000];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    rep(i,0,N) cin>>a[i];
    sort(a,a+N);
    if(a[0]==a[N-1]){
        if(N==a[0]+1||N>=2*a[0]) cout <<"Yes"<<"\n";
        else cout <<"No"<<"\n";
    }
    else if(a[0]+1==a[N-1]){
        int x,y;
        x=lower_bound(a, a+N, a[0]+2)-lower_bound(a, a+N,a[0]+1);
        y=lower_bound(a, a+N, a[0]+1)-lower_bound(a, a+N,a[0]);
        if(a[N-1]<=y) cout <<"No"<<"\n";
        else if(x>=2*(a[N-1]-y)){
            cout <<"Yes"<<"\n";
        }
        else cout <<"No"<<"\n";
    }
    else{
        cout <<"No"<<"\n";
    }
}

Measured memory_bytes: 640
n, k = map(int, input().split())
ns = []
ans =0
for i in range(k):
    p = int(input())
    s = str(input())
    for i in list(s.split()):
        ns.append(int(i))
for i in range(1,n+1):
    if( i not in ns):
        ans+= 1
print(ans)


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

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

int main() {

    int N;
    cin >> N;
    priority_queue<double, vector<double>, greater<double> > v;

    rep(i,N){
        int w;
        cin >> w;
        v.push((double)w);
    }

    double v1,v2;
    rep(i,N-1){
        v1 = v.top();
        v.pop();
        v2 = v.top();
        v.pop();
        v.push((v1 + v2) / 2.0);

    }

    printf("%lf",v.top());

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <iomanip>
using ll = long long;
using namespace std;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r) { return l.second < r.second; }
bool greaterPair(const ipair& l, const ipair& r) { return l.second > r.second; }

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define irep(i, n) for (int i = 0; i <= (n); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rirep(i, n) for (int i = n; i >= 0; --i)
int factorical(int n) {
	int sum = 1;
	for (int i = 1; i <= n; ++i)
	{
		sum *= i;
	}
	return sum;
}

vector<int> divisors(int n) {
	vector<int> res;
	for (int i = 1; i * i <= n; ++i) {
		if (n % i != 0) continue;
		res.push_back(i);
		if (n / i == i) continue; // 上の行で追加済み。
		res.push_back(n / i);
	}
	return res;
}
vector<ll> divisors_ll(ll n) {
	vector<ll> res;
	for (ll i = 1; i * i <= n; ++i) {
		if (n % i != 0) continue;
		res.push_back(i);
		if (n / i == i) continue; // 上の行で追加済み。
		res.push_back(n / i);
	}
	return res;
}


void printVector(const vector<int>& vec) {
	for (int value : vec) {
		cout << value << " ";
	}
	cout << endl;
}

bool pal(string s) {
	int n = s.length() / 2;
			rep(i, n) {
			if (s[i] != s[s.length() - 1 - i]) return false;
		}
			return true;
}

int euclidean_gcd(int a, int b) {
	if (a < b) return euclidean_gcd(b, a);
	int r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}

vector <string> vec_sort_and_del(vector<string> s) {
	std::sort(s.begin(), s.end());
	s.erase(std::unique(s.begin(), s.end()), s.end());
	return s;
}

int GetDigit(int num) {
	int digit = 0;
	while (num != 0) {
		num /= 10;
		digit++;
	}
	return digit;
}

int main() {
	int a, b, k;
	cin >> k;
	cin >> a >> b;
	int a_ans, b_ans, res;
	string ans = "NG";
	if ((a % k == 0) || (b % k == 0)) ans = "OK";
	a_ans = a / k;
	b_ans = b / k;
	res = b_ans - a_ans;
	if (res != 0) ans = "OK";
	cout << ans << endl;
	return 0;
}




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


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    int h,w,k;
    cin>>h>>w>>k;
    string s[h];
    for(int i=0;i<h;i++){
        cin>>s[i];
    }
    int a[h][w]={};
    int now=1;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#'){
                // left
                for(int k=j;k>=0;k--){
                    if(a[i][k]==0) a[i][k] = now;
                    else break;
                }
                // R
                for(int k=j+1;k<w;k++){
                    if(a[i][k]==0 && s[i][k]=='.') a[i][k]=now;
                    else break;
                }
                now++;
            }
        }
    }
    // for(int i=0;i<h;i++){
    //     for(int j=0;j<w;j++){
    //         cout << a[i][j] << " ";
    //     }
    //     cout << "\n";
    // }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(a[i][j] && i && a[i-1][j]==0){
                for(int k=i-1;k>=0;k--){
                    if(a[k][j]) break;
                    a[k][j] = a[i][j];
                }
            }
            if(a[i][j] && i!=h-1 && a[i+1][j]==0){
                for(int k=i+1;k<h;k++){
                    if(a[k][j]) break;
                    a[k][j]=a[i][j];
                }
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout << a[i][j] << " ";
        }
        cout << "\n";
    }
}

Measured memory_bytes: 1280
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			String word = sc.next();
			// 文字単位で操作しやすいように配列に
			char[] words = word.toCharArray();
			int n = sc.nextInt();
			for(int i = 0; i < n; i++) {
				String cmd = sc.next();
				switch(cmd) {  // 文字列に対し switch を使って良い
				case "replace": {
					int a = sc.nextInt();
					int b = sc.nextInt();
					char[] rs = sc.next().toCharArray();
					for(int j = a; j <= b; j++) {
						words[j] = rs[j-a];
					}
					break;  /* break を忘れない */
				}
				case "reverse": {
					int a = sc.nextInt();
					int b = sc.nextInt();
					while(a < b) {
						char t = words[a];
						words[a] = words[b];
						words[b] = t;
						a++; b--;
					}
					break;  /* break を忘れない */
				}
				case "print": {
					int a = sc.nextInt();
					int b = sc.nextInt();
					for(int j = a; j <= b; j++) {
						System.out.print(words[j]);
					}
					System.out.println();
					break;  /* break を忘れない */
				}
				}
			}
		}
	}
}



Measured memory_bytes: 32740
#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<map>
#include<cstdlib>
#include<stack>
#include<algorithm>
#include<set>
#include<cmath>
#include<vector>
using namespace std;
int main()
{
	#ifdef local
	freopen("1.txt","r",stdin);
	#endif
	int n;
	long long a[200006];
	scanf("%d",&n);
	int i;
	scanf("%lld",&a[0]);
	for(i=1;i<n;i++)
	scanf("%lld",&a[i]),a[i]+=a[i-1];
	long long mn=0x3f3f3f3f3f3f3f3f;
	for(i=0;i<n-1;i++)
	{
		mn=min(mn,abs(a[n-1]-2*a[i]));
	}
	printf("%lld",mn);
}

Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include<stack>
#include<iomanip>
#include<cstdint>

using namespace std;

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
//#define MOD 1000000007
#define MOD 998244353
#define INF LLONG_MAX/2

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T> void AorB(T& a, string A,string B) {if(a){cout << A << ENT;}else{cout << B << ENT;}}



int atcoder(){
    int a,b,c;
	cin>>a>>b>>c;
  	bool ans = (a<c&&c<b) || (b<c&&c<a);
  	YesNo(ans);

    return 0;
}

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


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	double xa,ya,xb,yb,xc,yc,xd,yd;
	
	while(~scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd)){
		if((ya-yb)*(yd-yc)==-(xd-xc)*(xa-xb))printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 0
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N, Q; string S;
	cin >> N >> S >> Q;
	vector<int> dsum(N + 1), msum(N + 1);
	for (int i = 0; i < N; ++i) {
		dsum[i + 1] = dsum[i] + (S[i] == 'D' ? 1 : 0);
		msum[i + 1] = msum[i] + (S[i] == 'M' ? 1 : 0);
	}
	for (int i = 0; i < Q; ++i) {
		int K;
		cin >> K;
		long long cur = 0, ans = 0;
		for (int i = 0; i < N; ++i) {
			if (S[i] == 'C') {
				ans += cur;
			}
			if (S[i] == 'M') {
				cur += dsum[i] - dsum[max(i - K + 1, 0)];
			}
			if (i >= K - 1 && S[i - K + 1] == 'D') {
				cur -= msum[i + 1] - msum[i - K + 2];
			}
		}
		cout << ans << '\n';
	}
	return 0;
}

Measured memory_bytes: 11292
#include <iostream>
#include <vector>
#include <tuple>
using namespace std;

int p_count;
vector<tuple<int, int, int>> pyramid;
vector<tuple<int, int, int>> measure;

void init_pyramid()
{
  p_count = 101 * 101;
  for (auto y = 0; y <= 100; y++) {
    for (auto x = 0; x <= 100; x++) {
      pyramid.emplace_back(make_tuple(x, y, 0));
    }
  }
}

void read_measure_data()
{
  int n;
  cin >> n;
  for (auto i = 0; i < n; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    measure.emplace_back(make_tuple(a, b, c));
  }
}

void check1()
{
  for (auto&& m : measure) {
    for (auto&& p : pyramid) {
      if (get<2>(p) < 0) continue;
      if (get<2>(m) == 0) continue;
      int guess = get<2>(m) + abs(get<0>(p) - get<0>(m)) + abs(get<1>(p) - get<1>(m));
      if (get<2>(p) == 0) {
	get<2>(p) = guess;
      } else if (get<2>(p) != guess) {
	get<2>(p) = -1;
	if (--p_count <= 1) return;
      }
    }
  }
}

void check2()
{
  if (p_count <= 1) return;
  for (auto&& m : measure) {
    for (auto&& p : pyramid) {
      if (get<2>(p) < 0) continue;
      if (get<2>(m) != 0) continue;
      int guess = abs(get<0>(p) - get<0>(m)) + abs(get<1>(p) - get<1>(m));
      if (guess - get<2>(p) < 0) {
	get<2>(p) = -1;
	if (--p_count <= 1) return;
      }
    }
  }
}

void print_ans()
{
  for (auto&& p : pyramid) {
    if (get<2>(p) > 0) {
      cout << get<0>(p) << " " << get<1>(p) << " " << get<2>(p) << endl;
    }
  }
}

int main()
{
  init_pyramid();
  read_measure_data();
  check1();
  check2();
  print_ans();
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second

ll FACT[201100] = { 0 }, IFACT[201100] = { 0 };
ll h, w, a, b;
ll extgcd(ll a, ll b, ll &x, ll &y) {
	ll g = a;
	x = 1;
	y = 0;
	if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
	return g;
}
ll invMod(ll a, ll m) {
	ll x, y;
	if (extgcd(a, m, x, y) == 1) return (x + m) % m;
	else                         return 0;
}
ll mod_pow(ll x, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x%MOD;
		x = x * x%MOD;
		n >>= 1;
	}
	return res;
}
void inverse(ll N) {
	FACT[0] = 1;
	IFACT[0] = 1;
	for (int i = 1;i <= N;i++) {
		FACT[i] = FACT[i - 1] * i % MOD;
		IFACT[i] = invMod(FACT[i], MOD);
	}
}
ll combi(ll n, ll r) {
	if (n < 0 || r < 0 || r > n)return 0;
	if (r > n / 2)r = n - r;
	return FACT[n] * IFACT[n - r] % MOD*IFACT[r] % MOD;
}

int main() {
	int n, a[100010], it, fit;
	cin >> n;
	bool b[100010];
	for (int i = 1;i <= n+1;i++) {
		cin >> a[i];
		if (!b[a[i]])b[a[i]] = 1;
		else it = i;
	}
	for (int i = 1;i <= n+1;i++) {
		if (a[i] == a[it]) {
			fit = i;
			break;
		}
	}
	inverse(100010);
	for (int i = 1;i <= n+1;i++) {
		ll sum = 0;
		if (i == 1) {
			cout << n << endl;
			continue;
		}
		sum += combi(n + 1, i);
		sum %= MOD;
		sum -= combi(n + 1 - it + fit - 1, i - 1);
		sum += MOD;
		sum %= MOD;
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3200
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const double pi = acos(-1);
const int maxn = 2e6 + 10;
const double eps = 1e-8;
const ll mod = 1e9 + 7;
const ull base = 131;
const ull mod1 = 1e9 + 9;
const ull mod2 = 1610612741;

int a[5];

int main()
{
    for (int i = 1; i < 4; ++i)
        scanf("%d", a+i);
    sort(a+1, a+4);
    printf("%d\n", unique(a+1, a+4)-a-1);
	return 0;
}

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

using namespace std;
typedef long long ll;

ll N;
double dp[3000][3000];
double p[3000];

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> p[i];
    dp[0][0] = 1;
    for(int i=1;i<=N;i++){
        for(int j=0;j<=i;j++){
            dp[i][j] = dp[i-1][j-1] * p[i-1];
            if(j < i) dp[i][j] += dp[i-1][j] * (1.0 - p[i-1]);
        }
    }
    double ans = 0;
    for(int i=N/2+1;i<=N;i++) ans += dp[N][i];
    cout << fixed << setprecision(15) << ans << endl;
    return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    int martrix[n][m];
    int i, j;
    for (i=0;i<n;i++){
        for(j=0;j<m;j++){
            cin >> martrix[i][j];
        }
    }
    int k;
    int martrix_1[m][1];
    for(k=0;k<m;k++){
        cin >> martrix_1[k][0];   // list 構造を定義するときは　最初が0 からとか考えないで、そのn×mの値を定義すること
    }
    int l;
    int L;
    int martrix_num;
    for(l=0;l<n;l++){
        martrix_num = 0;
        for(L=0;L<m;L++){
            
            martrix_num = martrix_num + (martrix[l][L])*(martrix_1[L][0]);
        }
        cout << martrix_num << endl;
    }
    
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define EPS ((ld)(1e-9))
 
#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define rep(i, e) for (int i = 0, _##i = (e); i < _##i; i++)
#define repp(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)
#define repr(i, s, e) for (int i = (s)-1, _##i = (e); i >= _##i; i--)
#define repi(i, x) for (auto &i : (x))
#define ARR(...) vector<int>({__VA_ARGS__})
#define ARS(...) vector<string>({__VA_ARGS__})
 
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef complex<double> base;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << '(' << pai.first << ' ' << pai.second << ')';
}
 
template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    cout << '[';
    for (auto p : v) cout << p << ",";
    cout << "]";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const set<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
#ifndef __SOULTCH
#define debug(...) 0
#define endl '\n'
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif
 
template<typename T> void get_max(T &a, T b) {a = max(a, b);}
template<typename T> void get_min(T &a, T b) {a = min(a, b);}

int N;
int A[16][16];
ll pt[1<<16];
ll dp[1<<16];

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

    cin >> N;
    rep(i, N) rep(j, N) cin >> A[i][j];

    rep(i, 1<<N) {
        ll v = 0;
        rep(j, N) repp(k, j+1, N) {
            if ((i>>j)&1 and (i>>k)&1) v += A[j][k];
        }
        pt[i] = v;
    }

    rep(i, 1<<N) {
        dp[i] = pt[i];
        for (int j = i; j; j = (j-1)&i) {
            get_max(dp[i], dp[i^j]+pt[j]);
        }
    }

    cout << dp[(1<<N)-1] << endl;
}

Measured memory_bytes: 1280
#include <stdio.h>
int main(void){
int n;char s[100005];
int count;
scanf("%d",&n);
scanf("%s",s);

for(count=0;s[count]!='\0';count++){
s[count]=s[count]+n;
  if(s[count]>'Z'){s[count]=s[count]-26;}
}
printf("%s",s);


}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
pair<ll,ll>p[114514];
int main(){
	ll n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>p[i].first>>p[i].second;
	priority_queue<ll>que;
	sort(p,p+n);
	ll ans=0,now=0;
	for(int i=1;i<=m;i++){
		while(1){
			if(p[now].first>i||now==n)break;
			if(p[now].first<=i){
				que.push(p[now].second);
				now++;
			}

		}
		if(!que.empty()){
			ans+=que.top();
			que.pop();
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 2936
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

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

int calc(int[] a) {
    int n = cast(int)a.length;

    // lt[i] = A_0, A_1, ..., A_{i-1} の最大公約数
    auto lt = new int[n + 1];
    // rt[i] = A_i, A_{i+1}, ..., A_{N-1} の最大公約数
    auto rt = new int[n + 1];

    for (int i = 0; i < n; i++)
        lt[i + 1] = gcd(lt[i], a[i]);

    for (int i = n - 1; i >= 0; i--)
        rt[i] = gcd(rt[i + 1], a[i]);

    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans = max(ans, gcd(lt[i], rt[i + 1]));
    }
    return ans;
}

void main() {
    readint;
    auto xs = readints;
    writeln(calc(xs));
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

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

  vector<int> answer(n + 1, 0);

  // https://qiita.com/drken/items/4a7869c5e304883f539b#2-%E8%A8%88%E7%AE%97%E6%A9%9F%E4%B8%8A%E3%81%A7%E3%81%AE%E3%82%B0%E3%83%A9%E3%83%95%E3%81%AE%E8%A1%A8%E3%81%97%E6%96%B9

  using Graph = vector<vector<int>>;
  Graph G(n);
  for (int i = 0; i < n; i++) {
    G[i].push_back(i + 1);
    if (i != n - 1) {
      G[i + 1].push_back(i);
    }
  }
  G[x - 1].push_back(y - 1);
  G[y - 1].push_back(x - 1);

  for (int i = 0; i < n; i++) {
    vector<int> dist(n, -1);
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[i] = 0;
    que.push(i);  // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
      int v = que.front();  // キューから先頭頂点を取り出す
      que.pop();

      // v から辿れる頂点をすべて調べる
      for (int nv : G[v]) {
        if (dist[nv] != -1) continue;  // すでに発見済みの頂点は探索しない

        // 新たな白色頂点 nv について距離情報を更新してキューに追加する
        dist[nv] = dist[v] + 1;
        que.push(nv);
      }
    }

    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    for (int v = i; v < n; ++v) {
      answer[dist[v]]++;
    }
  }

  for (int i = 1; i < n; i++) {
    cout << answer[i] << endl;
  }
}

Measured memory_bytes: 384
N,M,X,Y = gets.split.map(&:to_i)

x = gets.split.map(&:to_i)
y = gets.split.map(&:to_i)


borderX = X
borderY = Y

x.length.times do |i|
	borderX = [borderX,x[i]].max
end

y.length.times do |i|
	borderY = [borderY,y[i]].min
end

if borderX < borderY
	print("No War\n")
else
	print("War\n")
end

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

int main() {
	
	int n;
	cin >> n;
	int64_t cnt{};
	vector<int64_t> a(n),b(n),c(n),d(n),e(n),sum(n+1);
	for(auto &i:a) cin >> i;
	for(auto &i:b) cin >> i;
	for(auto &i:c) cin >> i;
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());
	
	auto it2 = c.begin();
	for(int i=0; i<n; i++){
		it2 = upper_bound(it2,c.end(),b.at(i));
		e.at(i) = c.end() - it2;
	}
	for(int i=n-1; i>=0; i--){
		sum.at(i) = sum.at(i+1) + e.at(i);
	}
	auto it1 = b.begin();
	int j;
	for(int i=0; i<n; i++){
		it1 = upper_bound(it1,b.end(),a.at(i));
		j = it1 - b.begin();
		if(j < n)cnt += sum.at(j);
	}
	cout << cnt << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789


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

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


int A, B, C;

int main(){
    
    cin>>A>>B>>C;
    
    if( A == B && B == C ) puts("Yes");
    else{                  puts("No"); }
    
    return 0;
}


Measured memory_bytes: 256
S = input()
K = int(input())
pre_character = ''
S_list=list(S)
s_len = len(S)
def try_count(pre_character):
    S_list=list(S)
    count = 0
    for i in range(s_len):
        if pre_character == S_list[i]:
            count += 1
            if (s_len - 1) != i:
                S_list[i] = '' #get_abc(pre_character,S_list[i+1])
            else:
                S_list[i] = '' #get_abc(pre_character,S[0])
        pre_character = S_list[i]
    return count,S_list
first_count,fist_list = try_count('')
#print(first_count,fist_list)
second_count,second_list = try_count(fist_list[-1])
#print(second_count,second_list)
third_count,third_list = try_count(second_list[-1])
#print(third_count,third_list)

if second_count == third_count:
    print(first_count+ (second_count*(K-1)))
else:
    gusu = K//2
    kisu = K - gusu
    print((first_count*kisu)+ (second_count*gusu))

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

typedef long long ll;
ll N, A[5],ans, mini = 1000000000000000;

int main() {
  cin >> N;
  for (int i = 0; i < 5 ; i++ ) {
    cin >> A[i];
    mini = min(mini,A[i]);
  }
  ans = (N - 1) / mini;
  cout << ans + 5 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

void solve(){
	int n,d; cin>>n>>d;
	int h=2*d+1;
	int ans = n/h;
	if(n%h) ans++;
  cout<<ans<<endl;
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>
#include <map>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define v_in(v) for(auto&& i : v) cin >> i
#define rep(i,n) for(long long i = 0;i < n;++i)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)
#define ALL(v) v.begin(),v.end()

#define PI 3.14159265358979323846

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;


int main(void){
    FAST_IO
    
    ll n;
    cin >> n;

    vll p(n);
    vll q(n);

    v_in(p);
    v_in(q);

    ll max_iter = 1;
    for(ll i = n;i > 0;i--){
        max_iter *= i;
    }

    vll perm(n);
    rep(i,n){
        perm[i] = i+1;
    }
    ll p_pos = -1;
    ll q_pos = -1;

    rep(pos,max_iter){
        bool is_p = true;
        rep(i,n){
            if(p[i] != perm[i]) is_p = false;
        }
        if(is_p) p_pos = pos+1;

        bool is_q = true;
        rep(i,n){
            if(q[i] != perm[i]) is_q = false;
        }
        if(is_q) q_pos = pos+1;
        
        next_permutation(ALL(perm));
    }
    
    cout << abs(p_pos - q_pos);
    return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


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

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

int main(){
    int64_t S;
    // int res;
    // vector<int64_t> va(100020);
    int64_t a=0, b=0, c=0, d=0;

    // int64_t vp[100010];
    // string res;
    // int64_t vp_xor = 0ll;

    cin >> S;
    // for (int i=1; i<=N; i++){
    //     cin >> va.at(i);
    //     if (maxA <= va.at(i)) {
    //         maxA = va.at(i);
    //         res++;
    //     }
    // }
    int64_t maxBC;
    const int64_t A_MAX = 1e+9 - 1;
    // cout << A_MAX << endl; //debug
    int64_t sqrtS = (int64_t)sqrt(S);
    a = sqrtS;
    d = sqrtS;

    while (S != a*d - b*c) {
        if (a < A_MAX) a++;
        else {d++; a=d;}
        maxBC = a*d - S;
        if (maxBC < 0) { continue; }
        b=maxBC; c=1;
    }

    int64_t y = 0;
    if (b<0) {
        y = -b;
        d -= b;
        b = 0;
    }

    cout << "0 "
    << y << " "
    << a << " " 
    << b << " " 
    << c << " " 
    << d << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef long long int ll;

int main()
{
    ll N,newN;
    string S;
    cin>>N>>S;
    ll ans,tmp;

    ll w=0,b=0;
    for(int i=0;i<N;++i)
        if(S[i]=='#')
            ++b;
        else
            ++w;
    ans=w,tmp=w;
    for(int i=0;i<N;++i)
    {
        if(S[i]=='.')
            --tmp;
        else
            ++tmp;
        if(ans>tmp)
            ans=tmp;
    }
    cout<<ans<<endl;
        
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    
    int a, b, k;
    cin >> a >> b >> k;
    set<int> s;

    repeat (i, k) {
        if (a + i <= b and b - i >= a) {
            s.insert(a + i);
            s.insert(b - i);
        }
    }
    
    for (auto i: s) {
        cout << i << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
using Int = long long int;

Int N, Y;
int main() {
    scanf("%lld%lld", &N, &Y);

    for(Int A=0; A<=N; A++) {
        for(Int B=0; A+B<=N; B++) {
            Int C = N - A - B;
            Int money = 10000 * A + 5000 * B + 1000 * C;

            if(money == Y) {
                printf("%lld %lld %lld\n", A, B, C);
                return 0;
            }
        }
    }

    printf("-1 -1 -1\n");
    return 0;
}

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

using namespace std;
typedef long long ll;

const ll INF = 1145141919810364364;
const ll MOD = 998244353;
const int bs = 450;

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

    vector<vector<ll>> robots(n);
    for (int i = 0; i < n; i++) {
        int x, d;
        cin >> x >> d;
        robots[i] = {x, d};
    }
    robots.push_back({INF, 1001});
    sort(robots.begin(), robots.end());

    vector<ll> pos(n + 1);
    vector<ll> finish(n + 1);
    for (int i = 0; i <= n; i++) {
        pos[i] = robots[i][0];
        finish[i] = robots[i][0] + robots[i][1];
    }

    vector<ll> longests = finish;
    vector<ll> backets(n / bs + 1, -INF * 2);
    vector<ll> move(n + 1);
    vector<ll> stop(n + 1);
    stop[n] = 1;
    for (int i = n - 1; i >= 0; i--) {
        int x = i, y = lower_bound(pos.begin(), pos.end(), finish[i]) - pos.begin() - 1;

        ll longest = -INF * 2;
        while (x <= y && x % bs != 0) longest = max(longest, longests[x++]);
        while (x <= y && y % bs != bs - 1) longest = max(longest, longests[y--]);
        while (x <= y)longest = max(longest, backets[x / bs]), x += bs;
        longests[i] = longest, backets[i / bs] = max(backets[i / bs], longest);

        int index = lower_bound(pos.begin(), pos.end(), longest) - pos.begin();
        move[i] = (move[index] + stop[index]) % MOD;
        stop[i] = (move[i + 1] + stop[i + 1]) % MOD;
    }

    cout << (move[0] + stop[0]) % MOD << endl;
    return 0;
}

Measured memory_bytes: 20528
import java.util.*;

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

    	int ans = 0;

    	for (int i=a; i<=b; i++){
    		String string_i = String.valueOf(i);
    		StringBuffer sb = new StringBuffer(string_i);
    		if (string_i.equals(sb.reverse().toString())){
    			ans += 1;
    		}
    	}

    	System.out.println(ans);
    }
}

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

long long a, b, c, k;

int main(){
	cin>>a>>b>>c>>k;
	if(k<=a)cout<<k<<endl;
	if(k>a&&k<=a+b)cout<<a<<endl;
	if(k>a+b)cout<<a-(k-a-b)<<endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    int N, D;
    cin >> N >> D;
    cout << (N + 2 * D + 1 - 1) / (2 * D + 1) << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない


int main(){
	
	int q[200];
	int ans = 0;
	int n;
	cin >> n;

	rep(i, 2*n) {
		cin >> q[i];
	}
	
	rep(i, 2*n) {
		rep(j, 2*n) {
			if (q[i] < q[j])swap(q[i], q[j]);
		}
	}

	rep(i, n) {
		ans += q[2*i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
#endif

#ifdef _DEBUG
void init_global_B() {}
#else

#endif

int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    int M = 1e5;
    
    int ans = 1;
    REP(i, M) {
        if (i*i > N) {
            ans = (i - 1)*(i - 1);
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  string s; cin>>s;
  ll k; cin>>k;
  ll n = s.size();

  {
    bool flg = true;
    rep(i, n-1) if (s[i] != s[i+1]) flg = false;
    if (flg) {
      cout << n*k/2 << endl;
      return 0;
    }
  }

  vector<ll> a;
  ll t = 1;
  rep(i, n-1) {
    if (s[i] == s[i+1]) t++;
    else {
      a.push_back(t);
      t = 1;
    }
  }
  a.push_back(t);

  ll ans = 0;
  for (auto v:a) {
    ans += v/2;
  }
  ans *= k;
  if (s[0] == s[n-1]) {
    ans -= (a[0]/2 + a.back()/2 - (a[0]+a.back())/2) * (k-1);
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3624