akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main()
{
	int n, x, t;
	int cnt;
	scanf("%d%d%d", &n, &x, &t);
	if (n % x != 0)
	{
		cnt = n / x;
		cnt += 1;
		printf("%d", cnt * t);
	}
	else
	{
		cnt = n / x;
		printf("%d", cnt * t);
	}
}

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int cnt[2 * MAX], dp[2 * MAX];

int main(){
    int N;
    cin >> N;
    vector<int> C(N);
    rep(i, N) {
        cin >> C[i];
        C[i]--;
    }

    cnt[C[0]] = 1;
    rep(i, N) {
        if (i < N - 1 && C[i] == C[i + 1]) continue;
        dp[i] = cnt[C[i]];
        cnt[C[i + 1]] += dp[i];
        cnt[C[i + 1]] %= MOD;
    }

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

Measured memory_bytes: 2560
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val max_n = 1000000

    val dp = IntArray(max_n+1)
    dp.fill(max_n, 1)
    var (i, n) = Pair(1, 1)
    while (n <= max_n) {
        for (j in n..max_n)  dp[j] = Math.min(dp[j], dp[j-n]+1)
        n = ++i*(i+1)*(i+2)/6
    }

    val dp_odd = IntArray(max_n+1)
    dp_odd.fill(max_n, 1)
    i = 1; n = 1
    while (n <= max_n) {
        if (n.and(1) == 1)  for (j in n..max_n) dp_odd[j] = Math.min(dp_odd[j], dp_odd[j-n]+1)
        n = ++i*(i+1)*(i+2) / 6
    }

    while (true) {
        val N = sc.nextInt()
        if (N == 0) break
        println("${dp[N]} ${dp_odd[N]}")
    }
}


Measured memory_bytes: 38508
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		int[] b = new int[N];
		long asum = 0;
		long bsum = 0;
		for(int i = 0;i < N;i++) {
			a[i] = sc.nextInt();
			asum += a[i];
		}
		for(int i = 0;i < N;i++) {
			b[i] = sc.nextInt();
			bsum += b[i];
		}
		sc.close();

		long total = bsum - asum;
		long aplsCnt = 0;
		long bplsCnt = 0;
		for(int i = 0;i < N;i++) {
			if(a[i] > b[i]) {
				bplsCnt += (a[i]-b[i]);
			}else{
				if(((b[i]-a[i])%2)==0) {
					aplsCnt += (b[i]-a[i])/2;
				}else {
					aplsCnt += (b[i]-a[i])/2 + 1;
				}
			}
		}
		if(total >= aplsCnt && total >= bplsCnt) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 44096
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = LLONG_MAX / 3;
const double eps = (1e-9);

ll mod = 1000000007;

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

  int h, w, k;
  cin >> h >> w >> k;

  vector<int> bars;  // ルールに反しないように横線を引いたときに，各区間ごとにあり得る場合の数
  for (int i = 0; i < (1<<(w-1)); i++) {
    bool flag = true;
    for (int j = 0; j < w-2; j++) {
      if (((i >> j) & 1) && ((i>>(j+1)) & 1)) flag = false;
    }
    if (flag) bars.push_back(i);
  }

  vector<vector<ll>> dp(h+1, vector<ll>(w, 0));
  dp[0][0] = 1;

  rep(i, h) {
    rep(j, w) {
      for (auto& v : bars) {
        if ((v>>(j-1)) & 1) {       // 左下に移動
          dp[i+1][j-1] += dp[i][j];
          dp[i+1][j-1] %= mod;
        } else if ((v>>j) & 1) {    // 右下に移動
          dp[i+1][j+1] += dp[i][j];
          dp[i+1][j+1] %= mod;
        } else {                    // 真下に移動
          dp[i+1][j] += dp[i][j];
          dp[i+1][j] %= mod;
        }
      }
    }
  }

  cout << dp[h][k-1] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
const int INFTY = (1 << 21); // 2097152
// const ll INFTY = (1LL << 60);

int N;
int a[100000];
int main() {
	cin >> N;
	rep(i , N) cin >> a[i];

	int c1 = 0;
	int c2 = 0;
	rep(i, N){
		if(a[i] % 4 == 0) c2++;
		else if(a[i] % 2 == 0) c1++;
	}

	if(N <= c2*2+1) cout << "Yes" << endl;
	else if (N <= c2*2 + c1) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int main()
{
    int n,x;
    cin>>n;
    double ans=0;
    for(int i=0;i<n;i++){ 
        cin>>x;
        ans+=(1.0/x);
    } 
    cout<<(double)1/ans<<endl; 

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
  
// Function to find special numbers 
void divisibilityCheck(int arr[], int n) 
{ 
  
    // Storing all array elements in a hash 
    // and finding maximum element in the array 
    unordered_set<int> s; 
    int max_ele = INT_MIN; 
    for (int i = 0; i < n; i++) { 
        s.insert(arr[i]); 
  
        // Update the maximum element of the array 
        max_ele = max(max_ele, arr[i]); 
    } 
  
    // Traversing the array elements and storing the array 
    // multiples that are present in s in res 
    unordered_set<int> res; 
    for (int i = 0; i < n; i++) { 
  
        // Check for non-zero values only 
        if (arr[i] != 0) { 
  
            // Checking the factors of current element 
            for (int j = arr[i] * 2; j <= max_ele; j += arr[i]) { 
  
                // If current factor is already part 
                // of the array then store it 
                if (s.find(j) != s.end()) 
                    res.insert(j); 
            } 
        } 
    } 
  
    // For non-distinct elmments 
    // To store the frequency of elements 
    unordered_map<int, int> mp; 
    for (int i = 0; i < n; i++) 
        mp[arr[i]]++; 
  
    unordered_map<int, int>::iterator it; 
    vector<int> ans; 
    for (it = mp.begin(); it != mp.end(); it++) { 
  
        // If frequency is at least 2 
        if (it->second >= 2) { 
            if (res.find(it->first) == res.end()) { 
  
                // If frequency is greater than 1 and 
                // the number is not divisible by 
                // any other number 
                int val = it->second; 
  
                // Then we push the element number of 
                // times it is present in the vector 
                while (val--) 
                    ans.push_back(it->first); 
            } 
        } 
  
        // If frequency is greater than 1 and the number 
        // is divisible by any other number 
        if (res.find(it->first) != res.end()) { 
            int val = it->second; 
  
            // Then we push the element number of 
            // times it is present in the vector 
            while (val--) 
                ans.push_back(it->first); 
        } 
    } 
  int countt=0;
    // Print the elements that are divisible by 
    // at least one other element from the array 
    for (auto x : ans) 
        countt++; 

        cout<<n-countt<<endl;
} 
  
// Driver code 
int main() 
{ 
    int n; cin>>n;
    int arr[n];
    for(int i=0; i<n; i++)cin>>arr[i];
  
    divisibilityCheck(arr, n); 
  
    return 0; 
} 

Measured memory_bytes: 30632
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int k = stdIn.nextInt();
    double per = 0;
    int[] a = new int[n];
    double[] b = new double[n];
    for(int i = 0;i<a.length;i++) {
      a[i] = i+1;
    }
    for(int i = 0;i<a.length;i++) {
      int count = a[i];
      b[i] = 1.0/n;
      for(;count<k;count*=2) {
        b[i] = b[i]*1/2;
      }
    }
    double sum = 0;
    for(int i = 0;i<b.length;i++) {
      sum += b[i];
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 23252
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<deque>
using namespace std;

using ll = long long;

int main(void)
{
        int n;
        cin >> n;
        string s = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51";
        vector<vector <char> > c(33);
        int count = 1;
        for (int i = 0; i < s.size(); i++) {
                if (s[i] == ',') {
                        continue;
                } else if (s[i] == ' ') {
                        count++;
                        continue;
                } else {
                        c[count].push_back(s[i]);
                }
        }
        for (int i = 0; i < c[n].size(); i++) {
                cout << c[n][i];
        }
        cout << endl;
}


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

int main(void){
    string s;
    int a[3][1010];
    while(getline(cin, s), s!=""){
        int c, d;
        stringstream ss(s);
        ss>>c>>d;
        a[0][c]++;
    }
    while(getline(cin, s), s!=""){
        int c, d;
        stringstream ss(s);
        ss>>c>>d;
        a[1][c]++;
    }
    for(int i=1; i<1001; i++){
        if(a[0][i]>0 && a[1][i]>0){
            cout << i << " " << a[0][i]+a[1][i]<<"\n";
        }
    }
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n,y;
  cin >> n >> y;
  y /= 1000;
  rep(man, n + 1){
    rep(gosen, n + 1 - man){
      int sen = n - man - gosen;
      if(man*10 + gosen*5 + sen == y){
        cout << man << " " << gosen << " " << sen << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define INF 1000000007
// cin.eof() 入力個数の問題
int main(){
int n;
cin>>n;
string s;
cin>>s;
int count=0,ans=0;
rep(i,n){
    if(s[i]=='I'){
        count++;
    }else{
        count--;
    }
    ans=max(ans,count);
}

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


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

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

    vector<int> L(2 * N);
    for (int i = 0; i < 2 * N; ++i) {
        cin >> L[i];
    }

    sort(L.begin(), L.end());
    int ans = 0;
    for (int i = 0; i < L.size(); ++i) {
        if (i % 2 == 0) ans += L[i];
    }
    cout << ans << endl;

}


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

constexpr char NL = '\n';
constexpr int MOD = 1e9 + 7;

struct safe_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

void solve()
{
    int n; cin >> n;
    vector<int> v;
    int minval = INT_MAX, maxval = INT_MIN; 
    for (int i = 0; i < n; ++i) {
        int val; cin >> val;
        minval = min(minval, val);
        maxval = max(maxval, val);
        v.push_back(val);
    }
    int ans = INT_MAX;
    for (int i = minval; i <= maxval; ++i) {
        int sumval = 0;
        for (int val : v) {
            sumval += pow(val - i, 2);
        }
        ans = min(ans, sumval);
    }
    cout << ans << '\n';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 3620
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		boolean[] dp=new boolean[100001];
		int[] p={100,101,102,103,104,105};
		dp[0]=true;
		for(int i=0; i<6; i++){
			for(int j=p[i]; j<=100000; j++){
				if(dp[j-p[i]]){
					dp[j]=true;
				}
			}
		}
		if(dp[x]){
			System.out.println(1);
		}else{
			System.out.println(0);
		}
	}
}


Measured memory_bytes: 23124
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  vector<Pii> d(n);
  for (auto &x: d) cin >> x.first >> x.second;

  int count = 0;
  for (auto &x: d) {
    if (x.first == x.second) {
      count++;
      if (count >= 3) {
        cout << "Yes" << endl;
        return 0;
      }
    }
    else count = 0;
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3664
/**
 *    author:	raghuvanshraj
 *    created:	29.08.2020 05:32:25 PM
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define MOD 1000000007
#define INF 1000000000

#define SET_ARR(arr,n,val) for (int i = 0; i < n; ++i) arr[i] = val
#define SET_ARR2D(arr,n,m,val) for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) arr[i][j] = val
#define INPUT_ARR(arr,n) for (int i = 0; i < n; ++i) cin >> arr[i];
#define INPUT_ARR2D(arr,n,m) for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) cin >> arr[i][j];
#define PRINT_ARR(arr) for (auto x : arr) cout << x << ' '; cout << endl
#define PRINT_ARR2D(arr) for (auto x : arr) { for (auto y : x) cout << y << ' '; cout << endl; }

#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()

using namespace std;
using namespace __gnu_pbds;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

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

template <typename T>
using max_heap = priority_queue<T>;

template <typename T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <
	typename T,
	typename = typename enable_if<is_arithmetic<T>::value, T>::type,
	typename U,
	typename = typename enable_if<is_arithmetic<U>::value, U>::type
>
pair<T,U> operator+(const pair<T,U> &a, const pair<T,U> &b) {
	return {a.first + b.first, a.second + b.second};
}

template <
	typename T,
	typename = typename enable_if<is_arithmetic<T>::value, T>::type,
	typename U,
	typename = typename enable_if<is_arithmetic<U>::value, U>::type
>
pair<T,U> operator-(const pair<T,U> &a, const pair<T,U> &b) {
	return {a.first - b.first, a.second - b.second};
}

template <
	typename T,
	typename = typename enable_if<is_arithmetic<T>::value, T>::type,
	typename U,
	typename = typename enable_if<is_arithmetic<U>::value, U>::type,
	typename V,
	typename = typename enable_if<is_arithmetic<V>::value, V>::type
>
pair<T,U> operator*(const V &a, const pair<T,U> &b) {
	return {a * b.first, a * b.second};
}

template <
	typename T,
	typename = typename enable_if<is_arithmetic<T>::value, T>::type,
	typename U,
	typename = typename enable_if<is_arithmetic<U>::value, U>::type,
	typename V,
	typename = typename enable_if<is_arithmetic<V>::value, V>::type
>
pair<T,U> operator*(const pair<T,U> &b, const V &a) {
	return {a * b.first, a * b.second};
}

template <typename T, typename U>
istream& operator>>(istream &input, pair<T,U> &b) {
	input >> b.first >> b.second;
	return input;
}

template <typename T, typename U>
ostream& operator<<(ostream &output, pair<T,U> &b) {
	output << b.first << ' ' << b.second;
	return output;
}

int main(int argc, char const *argv[]) {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int d, t, s;
	cin >> d >> t >> s;

	if (s * t >= d) {
		cout << "Yes";
	} else {
		cout << "No";
	}
	
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>

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

using namespace std;

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    string ans;
    if((A - B) % 2){
        ans = "Borys";
    }else{
        ans = "Alice";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	double w, h, x, y;
	cin>>w>>h>>x>>y;
	double res = (w * h) / 2;
	int t = 0;
	if(w - x == x && h - y == y)t = 1;
	std::cout << std::fixed;
	cout<<setprecision(9)<<res<<" "<<t<<endl;
	return 0;
}


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

using namespace std;

int main(int argc, char *argv[]) {
	int N;
	cin >> N;

	int answer = 0;
	int from, to;
	for (int i = 0; i < N; i++) {
		cin >> from;
		cin >> to;
		answer += (to - from + 1);
	}

	cout << answer << endl;
	return 0;
}


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

using namespace std;

const int MAX = 500000;
int Heap[MAX];
int H;

void makeMaxHeap(int index);

int main(){
    cin >> H;
    for(int i = 1; i <= H; ++i) cin >> Heap[i];
    for(int i = H / 2; i >= 1; --i) makeMaxHeap(i);
    for(int i = 1; i <= H; ++i) cout << " " << Heap[i];
    cout << endl;
    return 0;
}

void makeMaxHeap(int index){
    int maxi= index;
    if(2 * index <= H && Heap[maxi] < Heap[2*index]) maxi = 2 * index;
    if(2 * index + 1 <= H && Heap[maxi] < Heap[2*index + 1]) maxi = 2 * index +1;
    if(maxi != index){
        swap(Heap[index], Heap[maxi]);
        makeMaxHeap(maxi);
    }
}



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

int main()
{
    int n,m,x;
    scanf("%d %d %d", &n, &m, &x);
    int i,arr[m];
    for(i=0;i<m;i++)
        scanf("%d", &arr[i]);
    int low=0,more=0;
    for(i=0;i<m;i++){
        if(arr[i]<x)
            low++;
        if(arr[i]>x)
            more++;
    }
    if(low<more)
        printf("%d\n", low);
    else
        printf("%d\n", more);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int w, h , n;
    cin >> w >> h >> n;
    
    int minX, minY;
    minX = minY = 0;
    int maxX = w;
    int maxY = h;
    
    for (int i=0; i<n; i++) {
        int x, y, a;
        cin >> x >> y >> a;
        if (a == 1) minX = max(minX, x);
        if (a == 2) maxX = min(maxX, x);
        if (a == 3) minY = max(minY, y);
        if (a == 4) maxY = min(maxY, y);
    }
    
    cout << max(0,(maxX - minX)) * max(0, (maxY - minY)) << endl;
}


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

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

int main(void){
  int mN,mE,mS,mW,N,n,d,x[200],y[200];

  while(1){

    mN = mE = mS = mW = 0;

    cin >> N;
    if( N == 0 ) break;


    for( int i = 0 ; i < 200 ; i++ ){
      x[i] = 0;
      y[i] = 0;
    }

    for( int i = 1 ; i < N ; i++ ){
      cin >> n >> d;

      x[i] = x[n] + dx[d];
      y[i] = y[n] + dy[d];

	mN = max( y[i] , mN );
	mS = min( y[i] , mS );
	mW = max( x[i] , mW );
	mE = min( x[i] , mE );
  
   }

    cout << mW - mE + 1 << " " << mN - mS + 1 << endl;

  }

  return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

// 

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  map<ll,ll> mp;
  rep(i,n){
    ll d; cin>>d;
    mp[d]++;
  }
  ll m; cin>>m;
  rep(i,m){
    ll t; cin>>t;
    mp[t]--;
  }
  
  string ans="YES";
  for(auto e: mp){
    if(e.second<0) ans="NO";
  }
  cout<<ans<<endl;
}

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

using namespace std;

typedef long long int ll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

const ll L = 1e5+5;

vector <ll> h(L);

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

    ll N, K;
    cin >> N >> K;

    for(ll i=0; i<N; i++)
    {
        cin >> h[i];
    }

    sort(h.begin(), h.begin()+N);

    ll m = 1e15;

    for(ll i=0; i<=N-K; i++)
    {
        m = min(m, h[i+K-1]-h[i]);
    }

    cout << m << endl;
    

    return 0;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main() {
	var A, B, C int
	fmt.Scan(&A, &B, &C)

	a := abs(A-B) + abs(B-C)
	b := abs(A-C) + abs(C-B)
	c := abs(A-B) + abs(A-C)
	fmt.Println(min(min(a, b), c))
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
 using namespace std; 
 int main() {
    int a, k;
    cin >> a >> k;
    string s;
    cin >> s;
    string res = "";
    for (int i = 0; i < a; i++) {
        if (i == k-1) {
            res = res + char(s[i]+32);
        }
        else {
            res = res + s[i];
        }
    }
    cout << res;

 } 

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

int main(){
	int N,M,C[1000],K[1000],T[1000],MAX[2];
	cin>>N>>M;
	memset(T,0,sizeof(T));
	for(int i=0;i<N;i++){
		cin>>C[i];
	}
	for(int i=0;i<M;i++){
		cin>>K[i];
		for(int j=0;j<N;j++){
			if(C[j]<=K[i]){
				T[j] += 1;
				break;
			}
		}
	}
	MAX[0]=0;
	for(int i=0;i<N;i++){
		if(T[i]>MAX[0]){
			MAX[0]=T[i];
			MAX[1]=i+1;
		}
	}
	cout<<MAX[1]<<endl;
	return 0;
}

Measured memory_bytes: 1172
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
      
        int N = sc.nextInt();
        int L = sc.nextInt();
      
        List<String> list = new ArrayList<String>();
      
        for (int i = 0; i < N; i++){
          list.add(sc.next());
        }
      
        // 並び替え
        Collections.sort(list);
      
        // 回答提出用
        StringBuilder answer = new StringBuilder();
      
        for (int i = 0; i < N; i++){
          answer.append(list.get(i));
        }
       
        System.out.println(answer);

    }
}

Measured memory_bytes: 22096
"""
上手い方法思い付きませんでした（圧縮→行列転置→圧縮→行列転置は悪くなさそう）
～～～登場人物～～～
s：入力
ss：入力から行を圧縮したもの
　　（s[i]にピリオド以外のものがある場合にappendしたやつ）
  
answer：ssから頑張って列を圧縮したもの
       （ss[i][j]がすべてのjでピリオドだった場合のjをcolumn_compに格納
       　その後、column_compに含まれていないjにおいて、answer[i] += ss[i][j] ）

"""

h, w = [int(i) for i in input().split()]

s = []
for i in range(h):
  s.append(input())
#print(s)

#行を圧縮しましゅ
row = 0
ss = []
for i in range(h):
  if s[i].count(".") != w:
    ss.append(s[i])
    row += 1
#print(ss, row)
    
#列を圧縮しましゅ
column_comp = []
for j in range(w):
  period_count = 0
  for i in range(row):
#    print(s[j][i])
    if ss[i][j] == ".":
      period_count += 1
  if period_count == row:
    column_comp.append(j)
#    print(column_comp)

answer = ["" for i in range(row)]
for i in range(row):
  for j in range(w):
    if j not in column_comp:
      answer[i] += ss[i][j]
  print(answer[i])


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

signed main(){
  int S, W;
  cin >> S >> W;
  if(S > W)cout << "safe";
  else cout << "unsafe";
}


Measured memory_bytes: 3604
/**
 *      purpose : ABC 114 C
 *      author  : kyomukyomupurin
 *      created : 2018-12-03 15:37:15
**/

#include <iostream>
#include <vector>
#include <string>
//#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second
#define print(x) cout << (x) << '\n'

vector<int64> v;

int64 n;

void rec(int64 t){
    if (t > n) return;
    v.PB(t);

    t *= 10;

    rec(t + 3); rec(t + 5); rec(t + 7);
}

bool isin(string s, const char c){
    if (s.find(c) != string::npos) return true;
    else return false;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(__null);
    
    cin >> n;
    rec(0);

    int cnt = 0;

    for (int i = 0; i < (int) v.size(); ++i){
        string s = to_string(v[i]);
        if (!isin(s, '3') || !isin(s, '5') || !isin(s, '7')) continue;
        else ++cnt;
    }

    print(cnt);
    
    return 0;
}

Measured memory_bytes: 640
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

k,x=nii()

left=max(-1000000,x-k+1)
right=min(1000000,x+k-1)

ans=[i for i in range(left,right+1)]
print(*ans)

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

int n,k;
vi g[2521];

bool used[2521];

int dfs(int p,int d,int lim){
  if(d>lim)return 0;
  int ret = 1;
  REP(i,g[p].size()){
    int to = g[p][i];
    if(used[to])continue;
    used[to] = true;
    ret += dfs(to,d+1,lim);
  }
  return ret;
}

int main(){
  scanf("%d%d",&n,&k);
  REP(i,n-1){
    int a,b;
    scanf("%d%d",&a,&b);
    --a;--b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int ans = n-2;
  if(k&1){
    // check edge
    vector<bool> checked(n,false);
    REP(i,n){
      checked[i] = true;
      REP(j,g[i].size()){
        int to = g[i][j];
        if(checked[to])continue;
        int tmp = 0;
        fill(used,used+n,false);
        used[i]=used[to]=true;
        tmp += dfs(i,0,k/2);
        tmp += dfs(to,0,k/2);
        CHMIN(ans,n-tmp);
      }
    }
  }else{
    // check node
    REP(i,n){
      fill(used,used+n,false);
      used[i]=true;
      int tmp = dfs(i,0,k/2);
      CHMIN(ans,n-tmp);
    }
  }

  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)

ll M = 1e9 + 7;
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll max3(ll a,ll b,ll c){ return max( max(a,b),c ); }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}


int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	string s; cin>>s;
	if(s[1]=='R') s[1]='B';
	else s[1] = 'R';
	cout<<s;
	
	return 0;
}


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

int water(vector<int> &h, int L, int R) {
//  printf("water(%d, %d)\n", L, R);
  int h_min = 100;
  for (int i = L; i <= R; i++) {
    if (h_min > h[i]) h_min = h[i];
  }
//  printf("h_min = %d\n", h_min);
  for (int i = L; i <= R; i++) {
    h[i] -= h_min;
  }
  return h_min;
}

int count_water(vector<int> &h, int L, int R) {
//  printf("count_water(%d, %d)\n", L, R);
  int res = water(h, L, R);
//  printf("res = %d\n", res);
  
  int h_max = 0;
  for (int i = L; i <= R; i++) {
    if (h_max < h[i]) h_max = h[i];
  }
  
  // base case
  if (h_max == 0) return res;
  
  // induction step
  queue<int> left, right;
  
  if (h[L] > 0) left.push(L);
  if (h[L] > 0 && h [L + 1] == 0) right.push(L);
  for (int i = L + 1; i <= R - 1; i++) {
    if (h[i - 1] == 0 && h[i] > 0) left.push(i);
    if (h[i] > 0 && h[i + 1] == 0) right.push(i);
  }
  if (h[R - 1] == 0 && h[R] > 0) left.push(R);
  if (h[R] > 0) right.push(R);
  
  while(!left.empty()) {
    res += count_water(h, left.front(), right.front());
    left.pop();
    right.pop();
  }
  
  return res;
}

int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  for (int i = 0; i < N; i++) {
    cin >> h[i];
  }
  
  cout << count_water(h, 0, N - 1);
}

Measured memory_bytes: 384
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    s,w=parseMap(split(readline()))
    if w<s
        println("safe")
    else
        println("unsafe")
    end
end
main()

Measured memory_bytes: 160168
#include<bits/stdc++.h>
using namespace std;
const int mod= 1000000007;

void add_self(int &a, int b){
      a+=b;
      while(a>mod)
            a-=mod;
}

int main(){
      string s;
      int d;
      cin>>s>>d;
      int len=s.length();
      vector<vector<int>>dp(d, vector<int>(2, 0));

      dp[0][0] = 1;

      for(int where = 0; where < len; where++){
            
            vector<vector<int>>new_dp(d, vector<int>(2, 0));
            
            for(int sum = 0; sum < d; sum++){
                  
                  for(bool sm_already: {false, true}){
                        
                        for(int digit = 0; digit < 10; digit++){
                              
                              if((digit > s[where] - '0') && !sm_already){
                                    break;
                              }
                              //add_self(new_dp[(sum + digit)%d][sm_already || (digit < (s[where] - '0'))], dp[sum][sm_already]);
                              new_dp[(sum + digit)%d][sm_already || (digit < s[where] - '0')] = (new_dp[(sum + digit)%d][sm_already || (digit < (s[where] - '0'))] + dp[sum][sm_already])%mod;
                              //new_dp[(sum + digit)%d][sm_already || (digit < s[where] - '0')] = (new_dp[(sum + digit)%d][sm_already || (digit < (s[where] - '0'))] + dp[sum][sm_already])%mod;
                        }
                  }
            }
            dp = new_dp;
      }
      int ans=dp[0][1]+dp[0][0];
      ans--;
      ans%=mod;
      if(ans<0)ans=mod-1;
      cout<<ans;
}

Measured memory_bytes: 3664
#include <iostream>
#include <set>
#include <cmath>
#include <vector>
using namespace std;

typedef long long ll;

multiset <int> L,R;
vector<int> A;
vector<ll> A2;
int main() {
  int q;
  cin >> q;
 

  ll ans = 0;
  for(int i = 0; i < q; i++) {
    int num;
    cin >> num;
    if(num == 1) {
      int a,b;
      cin >> a >> b;
      
      if(L.size() == 0 && R.size() == 0) {
	L.insert(a);
	R.insert(a);
	ans += b;
	continue;
      }
      
      if(L.upper_bound(a) == L.end() && R.lower_bound(a) == R.begin()) {
	L.insert(a);
	R.insert(a);
	ans += b;
	continue;
      }
      if(L.upper_bound(a) != L.end()) {
	auto itr = L.end();
	itr--;
	ll tmp = *itr;
	//	cout <<"tmp = "<< tmp << endl;
	L.erase(itr);
       	R.insert(tmp);
	L.insert(a);
	L.insert(a);
	itr = L.end();
	itr--;
	//	cout <<"  "<< (*itr) <<"     ijiji" <<a<<endl;
	ans += abs(tmp - a);
	ans += b;
	continue;
      }
        if(R.lower_bound(a) != R.begin()) {
	auto itr = R.begin();
	ll tmp = *itr;
	R.erase(itr);
	L.insert(tmp);
	R.insert(a);
	R.insert(a);
	ans += abs(tmp - a);
	ans += b;
	continue;
	}
    }
    else {
      auto itr = L.end();
      itr--;
      A.push_back(*itr);
      A2.push_back(ans);
    }
  }
  for(int i = 0; i < A.size(); i++) {
    cout << A[i] <<' '<<A2[i] << endl;
  }
}
      
  


Measured memory_bytes: 18944
<?php
fscanf(STDIN, '%d', $n);
$arr = explode(' ', trim(fgets(STDIN)));

$maxHeight = 0;
$count = 0;
foreach ($arr as $item) {
    $currentHeight = (int) $item;
    if ($maxHeight <= $currentHeight) {
        $maxHeight = $currentHeight;
        $count++;
    }
}
echo $count;


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

int main() {
    std::string A, B, C;
    std::cin >> A >> B >> C;

    if (A[A.size()-1] == B[0] && B[B.size()-1] == C[0]) {
        std::cout << "YES\n";
    } else {
        std::cout << "NO\n";
    }

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  int x=0;
  
  for(int i=0;i<n;i++){
    int l,r;
    cin >> l >> r;
    x +=r-l+1;
  }
  
  cout << x <<endl;
    
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e18+7;
const ll MOD=1e9+7;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N,M;
	cin >> N >> M;
	vector< pair< ll ,pair<ll,ll> > > si(M);
	FOR(i,0,M){
		pair< ll ,pair<ll,ll> > p;
		ll pp,yy;
		cin >> pp >> yy;
		p.first = yy;
		p.second.first = pp;
		p.second.second = i;
		si[i]=p;
	}
	SORT(si);
	vector< ll > zyu(N+1,1);
	vector<string> ans(M);
	FOR(i,0,M){
		string s1="",s2="";
		s1 = to_string(si[i].second.first);
		while(s1.size()!=6)s1='0'+s1;
		s2 = to_string(zyu[si[i].second.first]);
		while(s2.size()!=6)s2='0'+s2;
		zyu[si[i].second.first]++;
		ans[si[i].second.second] = s1+s2;
	}
	for(string x:ans){
		cout << x << endl;
	}
}

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

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

int main(){
    int N, M;
    cin >> N >> M;
    priority_queue<double> p_que;
    ll ans = 0;
    rep(i, N){
        double a;
        cin >> a;
        p_que.push(a);
    }
    rep(i, M){
        double val = p_que.top();
        p_que.pop();
        p_que.push(val/2);
    }
    while(!p_que.empty()){
        double val = p_que.top();
        p_que.pop();
        ll num = val;
        ans += num;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4388
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a[10001];
	int n,ans=0,asd=0;
	cin>>n;
	scanf("%s",&a);
	for(int i=0;i<n;i++)
	{
		if(a[i]=='I')
			asd++;
		if(a[i]=='D')
			asd--;
		ans=max(ans,asd);
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a;
  int ans = 0;
  string aa[a];
  for (int i = 0; i < a; i++) cin >> aa[i];
  cin >> b;
  string bb[b];
  for (int i = 0; i < b; i++) cin >> bb[i];
  for (int i = 0; i < a; i++) {
    int x = 0;
    for (int j = 0; j < a; j++) {
      if (aa[i] == aa[j]) x++;
    }
    for (int j = 0; j < b; j++) {
      if (aa[i] == bb[j]) x--;
    }
    ans = max(ans, x);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    V<string> s(n);
    read(s);
    cout << "AC x " << count(all(s), "AC") << newl;
    cout << "WA x " << count(all(s), "WA") << newl;
    cout << "TLE x " << count(all(s), "TLE") << newl;
    cout << "RE x " << count(all(s), "RE") << newl;
}

Measured memory_bytes: 6352
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
using namespace std;



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

    int ans = 0;
    stack<char> s;

    for( int i = 0; i < S.size(); ++i ){
        if( s.empty() ){
            s.push( S[i] );
            continue;
        }
        int tmp = s.top();
        if( tmp != S[i] ){
            ans += 2;
            s.pop();
        }else{
            s.push( (int) S[i] );
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n, l;
  cin >> n >> l;
  vll a(n);
  for (int i = 0; i < n; i++) a[i] = l + i;
  ll ans = 0, diff = 100000000;
  vll s(n + 1);
  for (int i = 0; i < n; i++) {
    s[i + 1] = s[i] + a[i];
  }
  for (int i = 0; i < n; i++) {
    if (diff > abs(a[i])) {
      diff = abs(a[i]);
      ans = s[n] - a[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/*input
1000000000000
*/
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define watch(x) cout << (#x) << " is " << (x) << endl
#define N 100002

using namespace std;
int main()
{
	fastio
	ll T=1,n,m;string str;
	// cin>>T;
	// cin.ignore(); put after cin, just b4 a getline(cin, s) to avoid getline() directly getting \n
	while(T--)
	{
		ll p=0,q=0,tmp=0,sum=0,count=0; //tmp variable
		int flag=0;
		
		cin>>n;
		tmp=1;
		sum=0;
		while(n>0)
		{
			n/=2;
			sum+=tmp;
			tmp*=2;
			
		}
		cout << sum << endl;

		
	}
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.range;

string[][50] SS;

void main()
{
    auto n = readln.chomp.to!int;
    foreach (i; 0..n) SS[i] = readln.chomp.split("").sort().array
    ;
    auto ss = SS[0..n];

    if (n == 1) {
        writeln(ss[0].join);
    } else {
        auto ret = setIntersection(ss[0], ss[1]).array;

        if (n > 1)
            foreach (s; ss[2..$]) ret = setIntersection(ret, s).array;

        writeln(ret.join);
    }
}

Measured memory_bytes: 508
INF = 10 ** 10
n, m = gets.split.map(&:to_i)
cost_num = []
keys = []
m.times do
  cost_num << gets.split.map(&:to_i)
  keys << gets.split.map(&:to_i).inject(0) { |res, num| res | 2 ** (num - 1) }
end
dp = Array.new(2 ** n, INF)
dp[0] = 0
keys.each_with_index do |key, i|
  dp.each_with_index do |cost, opened|
    next if cost == INF
    next_opened = (opened | key)
    dp[next_opened] = [dp[next_opened], cost + cost_num[i][0]].min
  end
end
puts dp.last == INF ? - 1 : dp.last


Measured memory_bytes: 4220
#include <bits/stdc++.h>
using namespace std;
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a+b>c+d) cout << "Left" << endl;
  else if(a+b==c+d) cout << "Balanced" << endl;
  else cout << "Right" << endl;
  return 0;
}


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

typedef long long ll;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
bool ISINT(double x){return fabs(x-(int)round(x))<EPS;}
bool ISEQ(double x,double y){return fabs(x-y)<EPS;}
string itos(ll x){stringstream ss;ss<<x;return ss.str();}
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin();itr!=c.end();itr++)

int n;
int a[100002];

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

  while (cin >> n) {
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    sort(a, a + n);

    int N = a[n - 1];
    double med = N / 2.0;
    double diffMin = (double)INT_MAX;
    int R = -1;

    for (int i = 0; i < n - 1; i++) {
      double diff = fabs(med - a[i]);
      if (diff < diffMin) {
        diffMin = diff;
        R = a[i];
      }
    }

    cout << N << " " << R << endl;
  }
}


Measured memory_bytes: 640
import sys

n, W = map(int, input().split())
dp = [-1] * (W + 1)
dp[0] = 0
for line in sys.stdin.readlines():
    w, v = map(int, line.split())
    for i in range(W - w, -1, -1):
        if dp[i] == -1:
            continue
        dp[i + w] = max(dp[i + w], dp[i] + v)
print(max(dp))


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


int main(){
  int i,j,hit,blow;
  string qs,as;
  while(1){
    hit = 0;
    blow = 0;
    cin >> qs >> as;
    if(qs[0] == '0' && as[0] == '0')
      break;
    for(i=0;i<4;i++){
      if(qs[i] == as[i]){
	hit++;
      }
      for(j=0;j<4;j++){
	if(qs[i] == as[j])
	  blow++;
      }
    }
    cout << hit << ' ' << blow - hit << endl;
  }
}
    
    

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


#define vt vector
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
#define ll long long
#define ld long double
#define ar array
#define inf() ifstream cin("d.txt")
#define onf() ofstream cout("test.txt")
#define mod 1000000007
#define pb push_back
#define endl cout<<"\n";
#define prt1(a) cout<<a<<" "
#define prt2(a,b) cout<<a<<" "<<b<<" "
#define prt3(a,b,c) cout<<a<<" "<<b<<" "<<c<<" "
#define in(a) cin>>a
#define inn(a,b) cin>>a>>b
#define innn(a,b,c) cin>>a>>b>>c 
#define rep(i,st,end) for(int i=st;i<end;i++)
#define repv(i,st,end) for(int i=st;i>=end;i--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define TEST ll tc;cin>>tc;while(tc--)
#define EACH(x, a) for (auto& x: a)

template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {
    cin >> x;
}
void read(double& d) {
    string t;
    read(t);
    d=stod(t);
}
void read(long double& d) {
    string t;
    read(t);
    d=stold(t);
}
template<class H, class... T> void read(H& h, T&... t) {
    read(h);
    read(t...);
}
template<class A> void read(vt<A>& x) {
    EACH(a, x)
        read(a);
}
template<class A, size_t S> void read(array<A, S>& x) {
    EACH(a, x)
        read(a);
}
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a <<"\n";
    err(++it, args...);
}


void solve()
{
    ll n;
    read(n);
    vt<ll>a(n),b(n);
    read(a);
    read(b) ;
        ll f = 0;
        
        ll r=n-1, i =0;
    
    for(i=0;i<n;i++)
    {
        if(a[i]==b[i])
        {
            if(b[i]==b[r])
            {
                r=n-1;
            }
            swap(b[i],b[r]);
            r--;
        }
    }
    
    ll l=0;
    
    for(i=0;i<n;i++)
    {
        if(a[i]==b[i])
        {
            if(b[i]==b[l])l=0;
            swap(b[i],b[l]);
            l++;
        }
    }


        rep(i, 0 , n)
        {
            if(a[i]==b[i])
            {
                f=1;
                break ;
            }
        }
        if(f==1)
            cout<<"No";
        else
        {
            cout<<"Yes";endl;
            rep(i,0,n)
            cout<<b[i]<<" ";
        }
        

   
   


}

 int main()
 {
    fio;
    ll k = 1;
    ll tc = 1;
    //cin>>tc;
    while(tc--){
       // cout<<"Case #"<<k<<": ";k++;
        solve();
        endl;
    }
    
 }




Measured memory_bytes: 6356