akhauriyash/Code-Regression huggingface dataset:
//Author : Nishit Patel
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef double db;
typedef long long ll;
#define pb push_back
#define FAST cin.sync_with_stdio(0); cin.tie(0);
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define arep(i, a, n)  for(int i = a; i <= (n); ++i)
#define drep(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x)     for(auto& a : x)
#define all(x) x.begin(), x.end()
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef map<ll, ll> ml;
typedef unordered_map<ll, ll> hash;
#define deb_1(A)                     {cerr << "[" << #A << "] : " << A << endl;}
#define deb_2(A,B)                   {cerr << "[" << #A << "] : " << A << endl<< "[" << #B << "] : " << B << endl;}
#define deb_3(A,B,C)                 {cerr << "[" << #A << "] : " << A << endl<< "[" << #B << "] : " << B << endl\
									   << "[" << #C << "] : " << C << endl;}
#define deb_4(A,B,C,D)               {cerr << "[" << #A << "] : " << A << endl<< "[" << #B << "] : " << B << endl\
									   << "[" << #C << "] : " << C << endl<< "[" << #D << "] : " << D << endl;}
#define deb_X(x,A,B,C,D,FUNC, ...)  FUNC  
#define deb(...)                    deb_X(,##__VA_ARGS__,\
                                          deb_4(__VA_ARGS__),\
                                          deb_3(__VA_ARGS__),\
                                          deb_2(__VA_ARGS__),\
                                          deb_1(__VA_ARGS__),\
                                         )
ll min(ll a,ll b)
{
	if(a<b) return a;
	return b;
}     

ll max(ll a,ll b, ll c)
{
	if(a>b)
	{ 
		if(a>c)
		{
			return 1;
		}
		else if(c>a)
		{
			return 3;
		}
	}
	else if(b>c && b>a)return 2;
	else if(c>b && b>a) return 3;
	return -1;
}

ll maxn(ll a,ll b, ll c)
{
	if(a>b)
	{ 
		if(a>c)
		{
			return a;
		}
		else
		{
			return c;
		}
	}
	if(b>c)return b;
	else if(c>b) return c;
	return c;
}
		                         
ll max2(ll a,ll b)
{
	if(a>b)return a;
	return b;
}                               

int main() {
	FAST
	ll n,x,y,z;
	cin>>n;
	vector<vl> v(n);
	rep(i,n)
	{
		cin>>x>>y>>z;
		v[i].pb(x);
		v[i].pb(y);
		v[i].pb(z);
		
	}
	ll dp[n][3] = {0};
	rep(j,3)
	{
		dp[0][j] = v[0][j];
	}
	for (int i = 1; i < n; i++) { 
        dp[i][0] = v[i][0] + max2(dp[i - 1][1], dp[i - 1][2]); 
        dp[i][1] = v[i][1] + max2(dp[i - 1][0], dp[i - 1][2]); 
        dp[i][2] = v[i][2] + max2(dp[i - 1][1], dp[i - 1][0]); 
    }
	
	cout<<maxn(dp[n-1][0],dp[n-1][1],dp[n-1][2])<<endl;
			
}


Measured memory_bytes: 12672
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize, q: usize,
        c: [Usize1; n],
        lr: [(Usize1, Usize1); q]
    }

    let mut queries = lr.into_iter().enumerate().sorted_by_key(|&(_, (l, _))| Reverse(l)).collect_vec();

    let mut pairs = Vec::new();
    let mut prevs = vec![n; n];
    for (i, c) in (0..).zip(c) {
        if prevs[c] != n {
            pairs.push((prevs[c], i));
        }
        prevs[c] = i;
    }
    pairs.sort();

    let mut bit = BIT::new(n);
    let mut ans = vec![0; q];
    for (i, (l, r)) in queries {
        while let Some((l2, r2)) = pairs.pop() {
            if l2 < l {
                pairs.push((l2, r2));
                break;
            }
            bit.add(r2+1, 1);
        }
        ans[i] = r + 1 - l - bit.sum(r+1);
    }

    for ans in ans {
        println!("{}", ans);
    }
}

#[allow(dead_code)]
/// Binary Indexed Tree of usize
pub struct BIT {
    buf: Vec<usize>,
}
#[allow(dead_code)]
impl BIT {
    pub fn new(n: usize) -> BIT {
        BIT {
            buf: vec![0; n + 1],
        }
    }
    pub fn sum(&self, i: usize) -> usize {
        let mut i = i;
        let mut s = 0;
        while i > 0 {
            s += self.buf[i];
            i &= i - 1;
        }
        s
    }
    pub fn add(&mut self, i: usize, x: usize) {
        let mut i = i as i64;
        while i < self.buf.len() as i64 {
            self.buf[i as usize] += x;
            i += i & -i;
        }
    }
}

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<double, double> P;

int main(){
    int n;
    cin >> n;
    vector<P> zahyo(n);
    vector<double> kyori(n*(n-1)/2);

    REP(i, n) {
        double x, y;
        cin >> x >> y;
        zahyo[i].first = x;
        zahyo[i].second = y;
    }

    int idx = 0;
    double gokei = 0;

    REP(i, n) {
        REPN(j, i+1, n) {
            //cout << zahyo[i].first << " " << zahyo[i].second << endl;
            //cout << zahyo[j].first << " " << zahyo[j].second << endl;
            //cout << "a" << (zahyo[i].first - zahyo[j].first) << endl;
            //cout << "b" << (zahyo[i].second - zahyo[j].second) << endl;

            double a = (zahyo[i].first - zahyo[j].first) * (zahyo[i].first - zahyo[j].first);
            double b = (zahyo[i].second - zahyo[j].second) * (zahyo[i].second - zahyo[j].second);
            kyori[idx] = sqrt(a + b);
            gokei += kyori[idx];
            idx++;
        }
    }

    //printf("%.7f\n", gokei);

    gokei *= 2;
    gokei /= n;

    printf("%.8f\n", gokei);

    return 0;
}


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

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

int H, W;
string s[55];

int main(){
    cin >> H >> W;
    int b_cnt = 0;
    rep(i, H) {
        cin >> s[i];
        rep(j, W) {
            if (s[i][j] == '#') b_cnt++;
        }
    }

    int dist[55][55];
    rep(i, H)rep(j, W) dist[i][j] = -1;
    queue<P> q;
    dist[0][0] = 0;
    q.push(P(0, 0));

    while (!q.empty()) {
        P p = q.front(); q.pop();

        rep(dir, 4) {
            int nh = p.first + dx[dir];
            int nw = p.second + dy[dir];

            if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
            if (dist[nh][nw] != -1) continue;
            if (s[nh][nw] == '#') continue;

            dist[nh][nw] = dist[p.first][p.second] + 1;
            q.push(P(nh, nw));
        }
    }

    int ans;
    if (dist[H-1][W-1] != -1) ans = H*W - dist[H-1][W-1] - b_cnt - 1;
    else ans = -1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring> 
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
 
using namespace std;

#define mod 1000000007

int main()
{
    int k, t;
    cin >> k >> t;
    vector<int> a;
    for(int i = 0; i < t; i++){
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    sort(a.begin(), a.begin() + t);
    int ans = a[0] - 1, sum = a[0];
    for(int i = 1; i < t; i++){
        if(ans >= a[i]){
            ans -= a[i];
        } else if(a[i] <= sum){
            ans = 0;
        } else {
            ans = a[i] - sum - 1;
        }
        sum += a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    vector<int> v(3);
    for(int i = 0; i < 3; i++){
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    cout << v[2] - v[0];
    cout << endl;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Set<Integer> set = new HashSet<>();
		int q = sc.nextInt();
		for (int i = 0; i < q; i++) {
			int op = sc.nextInt();
			int y = sc.nextInt();
			switch (op) {
				case 0:
					set.add(y);
					System.out.println(set.size());
					break;
				case 1:
					if (set.contains(y)) {
						System.out.println(1);
					} else {
						System.out.println(0);
					}
					break;
				case 2:
					set.remove(y);
					break;
			}
		}
	}
}



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

int main() {
  int n, x, m_min = 1000, donut = 0;

  cin >> n >> x;
  vector<int> m(n);

  for (int i = 0; i < n; i++) {
    cin >> m.at(i);
    if(m_min > m.at(i)) {
      m_min = m.at(i);
    }
    x -= m.at(i);
    if (x < 0) {
      break;
    } else {
      donut++;
    }
  }

  for (;;) {
    x -= m_min;
    if (x < 0) {
      break;
    } else {
      donut++;
    }
  }

  cout << donut << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int r; cin >> r;
    if(r < 1200) cout << "ABC" << endl;
    else if(r < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <string>

#define ll long long

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, m; cin >> n >> m;
	cout << n*m - n - m + 1;
}

Measured memory_bytes: 256
N = int(input())
a = [[] for i in range(N)]

for i in range(N):
    c = int(input())
    for j in range(c):
        x,y = map(int, input().split(" "))
        a[i].append(([x, y]))

from itertools import product

result = 0
for ans in product([0,1], repeat=N):
    flag = True
    for i,check in enumerate(a):
        if ans[i] == 0:
            continue

        for x,y in check:
            if y != ans[x-1]:
                flag =  False
                break

    if flag:
        result = max(sum(ans), result)
print(result)


Measured memory_bytes: 3064
import sys,math,collections,itertools,heapq
input = sys.stdin.readline

def m(n):
    return -1*n

a = []
H,W=list(map(int,input().split()))
for _ in range(H):
    s = input().rstrip()
    a += list(s)
ac = collections.Counter(a)
acval = sorted(ac.values())

#両方偶数
if H%2 == 0 and W%2==0:
    flag = [4]*((H*W)//4)

#どっちか奇数
elif H%2 ==1 and W %2 == 0:
    flag = [2]*(W//2)+[4]*((H*W-W)//4)
elif W%2 ==1 and H %2 == 0:
    flag = [2]*(H//2)+[4]*((H*W-H)//4)

#両方奇数
if H%2 == 1 and W%2==1:
    flag = [1]+[2]*(H//2)+[2]*(W//2)+[4]*((H*W-1-(W-1)-(H-1))//4)
flag.sort()
acval = list(map(m,acval))
heapq.heapify(acval)
while acval:
    tmpq = -1*heapq.heappop(acval)
    tmpf = flag.pop()
    if tmpq < tmpf:
        print('No')
        exit()
    else:
        tmp = tmpq - tmpf
        if tmp !=0:
            heapq.heappush(acval,-1*tmp)
print('Yes')


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

using namespace std;

using LL = long long;           using PII = pair<int, int>;
using ll = long long;           using DBL = double;
using VI = vector<int>;         using VD = vector<DBL>;
using VVI = vector<VI>;         using VVD = vector<VD>;
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define REP(i,n) FOR(i,0,n)
#define SZ(a) ((int)((a).size()))
#define ALL(x) (x).begin(), (x).end()
#define SET(a,v) memset((a), (v), sizeof(a))
#define EB emplace_back #define PB push_back
#define MP make_pair  #define ST first  #define ND second

#define trace(...) {__f(#__VA_ARGS__, __VA_ARGS__);}
template<typename Arg> void __f(const char* name, Arg&& arg) {
  cerr << name << " = " << arg << std::endl;
} template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " = " << arg1<<" | ";__f(comma+1, args...); }
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds; // OST: find_by_order, order_of_key
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// #pragma GCC optimize("Ofast")
// optimize("unroll-loops")
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// /*** RNGS ***/
// SEED=chrono::steady_clock::now().time_since_epoch().count();
// // or high_resolution_clock
// mt19937 rng(SEED); /*or*/ random_device rd; mt19937 rng(rd());
// uniform_int_distribution<> dis(MIN, MAX);// usage: dis(rng)
// struct chash {int operator()(int x) const {return x^SEED;}};
// gp_hash_table<int,int,chash>m;//use cc if very less updates
// /*** FAST IO ***/
// inline int scan(){ bool y=0; int x=0; char c=getchar_unlocked();
// while(c<'0'||c>'9'){ if(c=='-')y=1; c=getchar_unlocked();} 
// while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+c-'0';c=getchar_unlocked();}
// return y?-x:x; }

vector<int> v[302];
int l[302], r[302], x[302];
int dp[302][302][302];
const int MOD = 1000000007;

int calc(int pos, int r, int g, int b) {
	int &y = dp[r][g][b];
	if(y!=-1) return y;
	y = 0;
	bool valid = true;
	for(auto&z: v[pos]) {
		int R = ::r[z];
		int X = x[z];
		valid &= ((X) == ( (r<=R) + (g<=R) + (b<=R) ) );
	}
	if(pos == 0) {
		// trace(pos, r, g, b, valid);
		return y = valid;
	}
	if(valid) {
		y += calc(pos-1, pos, g, b); if(y >= MOD) y -= MOD;
		y += calc(pos-1, r, pos, b); if(y >= MOD) y -= MOD;
		y += calc(pos-1, r, g, pos); if(y >= MOD) y -= MOD;
	}
	// trace(pos, r, g, b, y);
	return y;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, m;
	cin >> n >> m;
	SET(dp, -1);
	for(int i=1; i<=m; ++i) {
		cin >> l[i] >> r[i] >> x[i];
		v[l[i]-1].push_back(i);
	}
	cout << calc(n, n+1, n+1, n+1) << endl;
	return 0;
}

Measured memory_bytes: 107904
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <limits>
#include <cassert>

#define seq(i, n) for (int i = 0; i < (n); i++)
#define seq2(i, f, t) for (int i = (f); i < (t); i++)
#define rev(i, n) for (int i = (n); i >= 0; i--)
#define rev2(i, f, t) for (int i = (f); i >= (t); i--)
#define all(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;

int solve(int n, vector<int> v) {
  vector<bool> t(n,false);
  seq2(i,1,n-1){
    int mx=max({v[i-1],v[i],v[i+1]});
    int mn=min({v[i-1],v[i],v[i+1]});
    if(v[i]!=mx&&v[i]!=mn){
      t[i]=true;
    }
  }
  int i=0;
  for(bool b:t){
    if(b)i++;
  }
  return i;
}

int main() {
#ifdef TEST
  assert(solve(5,{1,3,5,4,2})==2);
  assert(solve(9,{9,6,3,2,5,8,7,4,1})==5);
#else
  int n;
  cin >> n;
  vector<int> v;
  seq(i, n){
    int d;
    scanf("%d", &d);
    v.push_back(d);
  }
  cout << solve(n, v) << endl;
#endif

  return 0;
}


Measured memory_bytes: 256
/*
读题不规范，爆零两行泪。
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	cin>>n;
	long long now=100;
	for(int i=1;;i++){
		now=1.01*now;
		if(now>=n)return cout<<i,0;
	}
	return 0;
}

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

int main() {
    int n;
    double t, ans = 0.0;
    cin >> n >> t;
    REP(i,n){
        double x, h;
        cin >> x >> h;
        ans = max(ans, h/x*t);
    }
    printf("%.8lf\n",ans);
    return 0;
}



Measured memory_bytes: 3268
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    rep(i, N) cin >> a[i];

    vv<ll> dp = vvec(N + 1, K + 1, 0LL);
    dp[0][K] = 1;
    vector<ll> sum(K + 2);
    rep(i, N) {
        sum[0] = 0;
        rep(k, K + 1) sum[k + 1] = (sum[k] + dp[i][k]) % MOD;

        rep(k, K + 1) {
            dp[i + 1][k] = (sum[min(K, k + a[i]) + 1] + MOD - sum[k]) % MOD;
        }
    }

    write(dp[N][0]);
}

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

int main() {
  int n;
  int a[200010] = {};
  int b[200010] = {};
  cin >> n;
  for (int i = 0; i < n; i++) {
      cin >> a[i];
      b[i] = a[i];
  }
  sort(b, b + n);
  int l = b[n / 2 - 1], r = b[n / 2];
  for (int i = 0; i < n; i++) {
    if (a[i] <= l) cout << r << endl;
    else
      cout << l << endl;
  }
  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define do long double
void remax(int a, int b) { 
if (a < b)
a = b; }
  void remin(int a, int b) { 
if (a > b) 
a = b; }
using namespace std;
signed main(){
  int a,b;
  cin>>a>>b;
  int c=-1;
  rep(i,1e9){
    c++;
  if(a>b)
    break;
    a*=2;
  }
  cout<<c;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    long double n,t,i,q=0;
    cin>>n;
    
    for(i=0;i<n;i++)
    {
      cin>>t;
      q = q + (1/t);
    }
    q = 1/q;
  cout<<setprecision(10)<<q;
    
}
  
  




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


Measured memory_bytes: 2036
local mod = 1000000007

local n = io.read("*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
end
local p1, p2, p3 = 0, 0, 0
local ret = 1
for i = 1, n do
  b = a[i]
  local cnt = 0
  if p1 == b then cnt = cnt + 1 end
  if p2 == b then cnt = cnt + 1 end
  if p3 == b then cnt = cnt + 1 end
  ret = (ret * cnt) % mod
  if p1 == b then p1 = p1 + 1
  elseif p2 == b then p2 = p2 + 1
  elseif p3 == b then p3 = p3 + 1
  end
end
print(ret)


Measured memory_bytes: 1280
// Vivek Rai
// Blazer_007

#include<bits/stdc++.h>
using namespace std;

#define fastio    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl      '\n'

typedef long long int ll;
const int hell = 1e9 + 7 ;

signed main() {

    fastio

    int n;
    cin >> n;
    string str, temp;
    cin >> str;
    temp = str;
    sort(begin(str),end(str));
    int cntR = 0 , cntW = 0;
    int swaps = 0;
    for(int i = 0 ; i < str.length() ; i++)
    {
    	if (str[i] != temp[i])
    		swaps++;
    }
    cout << swaps/2 << endl;

    return 0;
}

Measured memory_bytes: 3876
n=int(input())

P = list(map(int,input().split()))

cnt=0

for i in range(n-2):
    if P[i]<P[i+1]:
        if P[i+1]<P[i+2]:
            cnt+=1
    if P[i]>P[i+1]:
        if P[i+1]>P[i+2]:
            cnt+=1
            
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    int n;
    cin >> n;
    cout << n * (n + 1) / 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <complex>
using namespace std;
 
class Solver {
private:
    complex<double> z[4];
public:
    bool input() {
        string str;
        if(!getline(cin, str)) return false;
        for(unsigned int i=0; i<str.size(); i++) {
            if(str[i] == ',') str[i] = ' ';
        }
        stringstream ss(str);
        double x, y;
        for(int i=0; i<4; i++) {
            if(!(ss >> x >> y)) return false;
            z[i].real(x);
            z[i].imag(y);
        }
        return true;
    }
    bool isConvex() {
        return (cross(z[1]-z[0], z[2]-z[1]) > 0
                && cross(z[2]-z[1], z[3]-z[2]) > 0
                && cross(z[3]-z[2], z[0]-z[3]) > 0
                && cross(z[0]-z[3], z[1]-z[0]) > 0)
                || (cross(z[1]-z[0], z[2]-z[1]) < 0
                && cross(z[2]-z[1], z[3]-z[2]) < 0
                && cross(z[3]-z[2], z[0]-z[3]) < 0
                && cross(z[0]-z[3], z[1]-z[0]) < 0);
    }
    double cross(complex<double> z1, complex<double> z2) {
        return z1.real()*z2.imag() - z1.imag()*z2.real();
    }
};
 
int main(int argc, char** argv) {
    Solver solver;
    while(solver.input()) {
        if(solver.isConvex()) {
            cout << "YES" << endl;
        }else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3284
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll ans=0,cnt=0;
    string s; cin>>s;
    rep(i,s.size()){
        if(s[i]=='W'){
            ans+=i-cnt; cnt++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
N,K = list(map(int, input().split()))
A = list(map(int, input().split()))

L = 0
for i in range(K):
    L += A[i]

ans = L

for i in range(N-K):
    L  = L+A[K+i]-A[i]
    ans = max(ans, L)
ans += K
ans /= 2
print(ans)

Measured memory_bytes: 25060
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define MAX 100
void push(int);
int pop();
int isEmpty();
int isFull();

int top,S[MAX];


void push(int s){
  if(isFull() == 1){
    fprintf(stderr, "エラー\n");
    exit(8);
  }
  else S[++top]=s;
}

int pop(){
  if(isEmpty() == 0){
    fprintf(stderr, "エラー\n");
    exit(8);
  }
  else{
  top--;
  return S[top+1];
  }
}

int isFull(){
  if(top>=MAX-1)return 0;
  else return 0;
}

int isEmpty(){
  if(top==0)return 0;
  else return 1;
}


int main(){
  char s[100];
  int hozon;
  
  
  while( scanf("%s",s)!=EOF){

    if(s[0]=='+'){
      push(pop()+pop());
    }
    else if(s[0]=='-'){
      hozon=pop();
      push(pop()-hozon);
    }
    else if(s[0]=='*'){
      push(pop()*pop());
    }
    else push(atoi(s));
  }
  printf("%d\n",pop());
	

  return 0;
}




Measured memory_bytes: 2072
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>

using namespace std;

struct Node{
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x!=NIL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }
        else{
            x = x->right;
        }
    }
    z->parent = y;
    if(y==NIL){
        root = z;
    }
    else{
        if(z->key < y->key){
            y->left = z;
        }
        else{
            y->right = z;
        }
    }
}

Node *find(Node *u, int k){
    while(u!= NIL && k!=u->key){
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}


void inorder(Node *u){
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u){
    if(u==NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(int argc, char const *argv[])
{
    int n;
    scanf("%d", &n);

    string com;
    int x;
    for(int i=0; i<n; i++){
        cin >> com;
        if(com == "find"){
            scanf("%d", &x);
            Node *t=find(root, x);
            if(t!=NIL) printf("yes\n");
            else printf("no\n");
        }else if(com == "insert"){
            scanf("%d", &x);
            insert(x);
        }else if(com == "print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }


    return 0;
}




Measured memory_bytes: 22024
<?php
	while (true) {
		$result = trim(fgets(STDIN));
		list($n, $x) = explode(" ", $result);

		if ($n == 0 && $x == 0) break;

		$count = 0;
		for ($i = 1; $i <= $n - 2; $i++) {
			for ($j = $i + 1; $j <= $n - 1; $j++) {
				for ($k = $j + 1; $k <= $n; $k++) {
					if ($i + $j + $k == $x) $count++;
				}
			}
		}

		print "$count\n";
	}

Measured memory_bytes: 6588
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
#include <map>
#include <numeric>
using namespace std;
typedef long long int ll;

int dp[2][1<<24];
char a[500][500];

void solve(int n,int m){
	int ans=0;
	for(int i=0;i<(1<<n);i++){
		vector<int> t(m,0);
		int cnt=0;
		for(int j=0;j<n;j++){
			if(i>>j&1){
				cnt++;
				for(int k=0;k<m;k++){
					if(a[j][k]=='1')t[k]^=1;
				}
			}
		}
		bool ok=1;
		for(int j=0;j<m;j++){
			if(t[j])ok=0;
		}
		if(ok){
			ans=max(ans,cnt);
		}
	}
	printf("%d\n",ans);
}

void solve1(int n,int m){
	for(int i=0;i<2;i++){
		for(int j=0;j<(1<<24);j++){
			dp[i][j]=-1;
		}
	}
	dp[0][0]=0;
	int t=1;
	for(int i=0;i<n;i++){
		int w=0,d=1;
		for(int j=0;j<m;j++){
			w+=(a[i][j]=='1')*d;
			d*=2;
		}
		for(int j=0;j<(1<<m);j++){
			dp[t][j]=dp[t^1][j];
		}
		for(int j=0;j<(1<<m);j++){
			if(dp[t^1][j]<0)continue;
			dp[t][j^w]=max(dp[t][j^w],dp[t^1][j]+1);
		}
		t^=1;
	}
	printf("%d\n",(dp[t^1][0]));
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(1){
		int n,m; cin >> n >> m;
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				cin >> a[i][j];
			}
		}
		if(n==0&&m==0)break;
		if(n<m){
			solve(n,m);
		}
		else{
			solve1(n,m);
		}
	}
}


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

template<typename D, D zero>
struct Ftree {
  vector<D> dat;
  function<D(D, D)> fadd;
  Ftree(int n, function<D(D, D)> f) : dat(n + 1), fadd(f) {}
  D operator()(int x) {
    D s(zero);
    for (int i = x + 1; i; i -= i & -i) s = fadd(s, dat[i]);
    return s;
  }
  void add(int x, const D &v) {
    for (int i = x + 1; i < dat.size(); i += i & -i) dat[i] = fadd(dat[i], v);
  }
};

template<typename D>
struct MapZ {
  vector<D> dat;
  map<D, int> mp;
  MapZ(const vector<D> &d) : dat(d) {
    sort(dat.begin(), dat.end());
    dat.erase(unique(dat.begin(), dat.end()), dat.end());
    for (int i = 0; i < dat.size(); ++i) mp[dat[i]] = i;
  }
  int operator()(const D &x) { return mp[x]; }
  int operator[](int x) { return dat[x]; }
  int size() { return dat.size(); }
};

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

  int N;
  cin >> N;
  
  vector<int> H(N);
  for (int i = 0; i < N; ++i) cin >> H[i];

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

  MapZ<int> mp(H);

  Ftree<int64_t, (int64_t) 0> tree(N, [](int64_t a, int64_t b) { return max(a, b); });
  for (int i = 0; i < N; ++i) {
    tree.add(mp(H[i]), tree(mp(H[i])) + A[i]);
  }

  cout << tree(N - 1) << endl;

  return 0;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    std::deque<string> deq;
    while (cin>>s) {
        if (s.at(s.size()-1)=='.'||s.at(s.size()-1)==',') {
            s=s.substr(0,s.size()-1);
        }
        if (s.size()>=3&&s.size()<=6) {
            deq.emplace_back(s);
        }
    }
    for (int i=0;i<deq.size();i++) {
        if (i==deq.size()-1) {
            cout<<deq[i]<<endl;
        } else {
            cout<<deq[i]<<" ";
        }
    }
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define int long long int
using namespace std;

signed main()
{
    string a;
    cin>>a;
    int n=a.length();
    int s[n+1]={0};
    s[0]=1;
    int mod=1e9+7;
    for (int i = 1; i <=n ; ++i) {
        s[i]=(s[i-1]*3)%mod;
    }
    int x[n+1]={0};
    x[0]=1;

    for (int i = 1; i <=n ; ++i) {
        x[i]=(x[i-1]*2)%mod;
    }

    int ans=0;

    int count=0;
    int cnt;
    for (int i = 0; i < n; ++i) {
        cnt=1;
        if(a[i]=='1')
        {
            cnt=(cnt*s[n-i-1])%mod;
            cnt=(cnt*x[count])%mod;
            ans=(ans+cnt)%mod;
            count++;
        }

        else
        {
            while (a[i]=='0')
            {
                i++;
                if(i==n)
                    break;
            }
            i--;
        }

    }

    ans=(ans+x[count])%mod;
    cout<<ans;

}

Measured memory_bytes: 2048
#include<stdio.h>

int main(void) {

	int D ;
	int T ;
	int S ;
	
	scanf("%d",&D);
	scanf("%d",&T);
	scanf("%d",&S);

	
	
	if (T * S >= D) {
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	return 0;

}

Measured memory_bytes: 2140
//int a = s - '0'; 文字から数字
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//過半数：N/2.0で判定
//優先度付きキュー
//priority_queue<
//ll,
//vector<ll>
//> q;
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
#define PI 3.14159265358979323846264338327950L
using namespace std;

//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

ll RS(ll N, ll P, ll M) {
	if (P == 0) return 1;
	if (P % 2 == 0) {
		ll t = RS(N, P / 2, M);
		return t * t % M;
	}
	return N * RS(N, P - 1, M);
}

vector<int> IntegerToVector(int bit, int N) {
    vector<int> S;
    for (int i = 0; i < N; ++i) {
        if (bit & (1 << i)) {
            S.push_back(i);
        }
    }
    return S;
}

int main() {
	ll N;cin >> N;
	int D[N][N];
	rep(i,N) cin >> D[i][0] >> D[i][1];

	ll cnt = 0;
	rep(i, N){
		if(D[i][0] == D[i][1]) {
			cnt++;
			if(cnt == 3){
				cout << "Yes" << endl;
				return 0;
			}
		}
		else{
			cnt = 0;
		}
	}

	cout << "No" << endl;
}	

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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

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

map<ll, ll> primefact(ll n) {
    map<ll, ll> res;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;
    return res;
}

ll N;
VL L;

int main() {
    cin >> N;
    L.resize(2 * N);
    VECCIN(L);
    sort(All(L), greater<ll>());
    ll sum = 0;
    REP(i, N) { sum += L[2 * i + 1]; }
    cout << sum << "\n";
    return 0;
}


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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	int a,b,c,d;

	cin>>a>>b>>c>>d;

	deque<int>dq;

	dq.pb(a+c);
	dq.pb(a+d);
	dq.pb(b+c);
	dq.pb(b+d);

	f(i,0,dq.size()-1){
        mini=min(mini,dq[i]);
	}

	cout<<mini<<endl;



}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC093_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var num = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var A = num[0];
            var B = num[1];
            var X = num[2];

            for (var i = A; i <= B; i++)
            {
                if (i - A < X || B - i < X)
                {
                    Console.WriteLine(i);
                }
            }
        }
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
// sort(a.begin(), a.end(), std::greater<int>());

/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/

int main()
{
    int t, d, l;

    while (cin >> t >> d >> l)
    {
        if (t == 0 && d == 0 && l == 0)
            break;
        int ans = 0;
        int hoge = 0;
        int data;
        rep(i, t)
        {
            cin >> data;
            if (hoge > 0)
            {
                ans++;
                hoge--;
            }
            if (data >= l)
                hoge = d;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2960
#include<bits/stdc++.h>
using  namespace std;
typedef long long ll;
int main()
{
string s;
cin>>s;
int ans=0;
int f=0;
for(int i=0;i<=2;i++)
{
    if(s[i]=='R')
        f++;
    else
        ans=max(ans,f);
}
if(ans==0)
ans=max(ans,f);
cout<<ans<<endl;
}


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

using ll = long long;
using Pi = pair < int, int >;

constexpr int INF = (1 << 30) - 1;
constexpr int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
constexpr int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

template < typename T > T gcd(T a, T b) { return ( b ? gcd(b, a % b) : a ); }
template < typename T > T lcm(T a, T b) { return ( a / gcd(a, b) * b ); }

int main()
{
	ll N, P;
	ll ans = 1;
	cin >> N >> P;

	for ( ll i = 2; i * i <= P; i++ ) {
		int cnt = 0;
		while ( P % i == 0 ) {
			P /= i;
			cnt++;
		}
		cnt /= N;
		for ( int j = 0; j < cnt; j++ ) {
			ans *= i;
		}
	}
	
	if ( N == 1 ) {
		ans *= P;
	}

	cout << ans << endl;

	return ( 0 );
}


Measured memory_bytes: 256
#!/usr/bin/python3

def isPalindrome(s):
    for i in range(len(s) // 2):
        if s[i] != s[- (i + 1)]:
            return False
    return True


s = input()
l = len(s)
if isPalindrome(s) and isPalindrome(s[:l // 2]) and isPalindrome(s[l // 2 + 1:]):
    print('Yes')
else:
    print('No')


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

int main() {
  ll x;
  cin >> x;
  ll sum = 0;
  ll i   = 1;
  while (sum < x) {
    sum += i;
    if (sum >= x) break;
    i++;
  }
  cout << i << endl;
}

Measured memory_bytes: 256
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		int n,k;
		int cnt = 0;
		scanf("%d%d",&n,&k);
		while(n>0)
		{
			n/=k;
			cnt++;
		}
		printf("%d",cnt);
		return 0;
}  


Measured memory_bytes: 3852
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const auto mod=1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  int n,x; cin >> n >> x;
  vector<int> l(n);
  int d=0,ans=1;
  rep(i,0,n){
  	int l; cin >> l;
  	d+=l;
  	if(d<=x) ans++;
  }
  cout << ans << endl; 

 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
struct sam{
    int len[maxn],next[maxn][26],fail[maxn],L,last;
    sam(){
        init();
    }
    void init(){
        L=0;
        last=newnode(0,-1);
    }
    int newnode(int l,int pre)
    {
        fail[L]=pre;
        for(int i=0;i<26;i++)next[L][i]=-1;
        len[L]=l;
        L++;
        return L-1;
    }
    void add(int x,int l)
    {
        int pre=last,now=newnode(l+1,-1);
        last=now;
        while(~pre&&next[pre][x]==-1){
            next[pre][x]=now;
            pre=fail[pre];
        }
        if(pre==-1)fail[now]=0;
        else{
            int bro=next[pre][x];
            if(len[bro]==len[pre]+1){
                fail[now]=bro;
            }
            else{
                int fa=newnode(len[pre]+1,fail[bro]);
                for(int i=0;i<26;i++){
                    next[fa][i]=next[bro][i];
                }
                fail[bro]=fa,fail[now]=fa;
                while(~pre&&next[pre][x]==bro){
                    next[pre][x]=fa;
                    pre=fail[pre];
                }
            }
        }
    }
    void build(std::string s)
    {
        int n=s.length();
        for(int i=0;i<n;i++){
            add(s[i]-'a',i);
        }
    }
}SAM;
int sum[maxn];

int main()
{
    string s;
    while(cin >> s){
        SAM.init();
        SAM.build(s);
        memset(sum, 0, sizeof sum);
        int n = s.length();
        for(int i = 1; i < SAM.L; i ++) {
            if (~SAM.fail[i])
                sum[SAM.len[SAM.fail[i]] + 1] ++;
            else
                sum[1] ++;
            sum[SAM.len[i] + 1] --;
        }
        int ans = 0;
        for(int i = 1; i <= n; i ++) {
            sum[i] += sum[i - 1];
            ans = max(ans, sum[i]);
        }
        printf("%d\n", ans);

    }
    return 0;
}


Measured memory_bytes: 22016
#include <bits/stdc++.h>
using namespace std;
int main()
{

    long long int n, sum = 0;
    cin >> n;
    string s;
    map<string, long long int> mp;

    for (int i = 0; i < n; i++)
    {
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }

    for (auto it = mp.begin(); it != mp.end(); ++it)
    {
        long long int s = it->second;
        sum += ((s) * (s - 1)) / 2;
    }
    cout << sum;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    long long x,n;
    cin>>x>>n;
    while(n--)
    {
        long long y;
        cin>>y;
        x-=y;
    }
    if(x<0)cout<<-1<<endl;
    else cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
  int n,count,min_a = 0;
  min_a = 1000000000;
  ll sum = 0;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) {
    int b;
    cin >> b;
    if(b < 0) {
      count++;
      b = -b;
    }
    a[i] = b;
    sum += b;
    min_a = min(min_a,b);
  }
  count = count%2;
  if(count == 0) {
    cout << sum << endl;
  }else {
    sum -= min_a*2;
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
ll n;
cin>>n;
string s;
cin>>s;
ll c=1;
  for(ll i=1;i<s.length();i++){
    if(s[i]!=s[i-1])c++;
  }
  cout<<c<<endl;
return 0;}


Measured memory_bytes: 512
N = int(input())
A = sorted(map(int, input().split()))
INF = 10 ** 9 + 7

S = []
if N % 2 == 0:
    for i in range(N//2):
        S.extend([2*i+1] * 2)
else:
    S.append(0)
    for i in range(N//2):
        S.extend([2*i+2] * 2)

if A != S:
    print(0)
    exit()

print((2 ** (N//2)) % INF)


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

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> num(N);
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		cin >> num[i];
	}
	for (int i = 0; i < N - 2; ++i) {
		if ((num[i] < num[i + 1] && num[i + 1] < num[i + 2]) ||
		    (num[i + 2] < num[i + 1] && num[i + 1] < num[i])) {
			ans++;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

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

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {

  ll N;
  cin>>N;
  ll ans;
  ll max=100000;
  ll ck[100][max+1];
  FOR(i,0,99){
    FOR(j,0,max){
      ck[i][j]=0;
    }
  }
  ll stack[]={1,6,36,216,1296,7776,46656,9,81,729,6561,59049};
  ck[0][0]=1;
  ans=1;
  //cout<<ans<<endl;

  FOR(i,0,98){
    FOR(j,0,max){

      if(ck[i][N]==1){
        cout<<i<<endl;
        return 0;
      }

      if(ck[i][j]==1){
        FOR(l,0,11){
          if((j+stack[l])<=max){
            ck[i+1][j+stack[l]]=1;
          }
        }
      }
    }
    FOR(j,0,max){
      //cout<<ck[i][j];
    }
    //cout<<endl;


  }

  return 0;
}
 


Measured memory_bytes: 78464