akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;

const int inf = 10000;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> s(h, vector<char>(w,'-'));
  rep(i,h) rep(j,w) cin >> s[i][j];

  int ans = 0;
  rep(i,h) rep(j,w) {
    if (s[i][j] == '#') continue;
    vector<vector<int>> dist(h,vector<int>(w,inf));
    queue<pair<int, int>> q;
    auto update = [&] (int li, int lj, int k) {
      if (dist[li][lj] != inf) return;
      dist[li][lj] = k;
      q.push(pair<int,int>(li,lj));
    };
    update(i, j, 0);
    while(!q.empty()) {
      int x = q.front().first;
      int y = q.front().second;
      q.pop();    
      rep(dir, 4) {
        int ni = x + di[dir];
        int nj = y + dj[dir];
        if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
        if (s[ni][nj] == '#') continue;
        update(ni,nj,dist[x][y]+1);
      }
     }
     rep(x,h) rep(y,w) {
       if (dist[x][y] == inf) continue;
       ans = max(ans, dist[x][y]);
     }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3576
def solve(a, v, b, w, t):
    if v <= w:
        return "NO"
    if abs(b - a) <= t * (v - w):
        return "YES"
    else:
        return "NO"


def main():
    a, v = map(int, input().split())
    b, w = map(int, input().split())
    t = int(input())
    res = solve(a, v, b, w, t)
    print(res)


def test():
    assert solve(1, 2, 3, 1, 3) == "YES"
    assert solve(1, 2, 3, 2, 3) == "NO"
    assert solve(1, 2, 3, 3, 3) == "NO"


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 9204
#137-d
import heapq as hp

n,m=[int(i) for i in input().split()]

lists=[[] for _ in range(m)]
for i in range(n):
    a,b = [int(i) for i in input().split()]
    if a<=m:
        lists[a-1].append(b)
        
h = []
hp.heapify(h)

ans= 0
for i in range(m):
    for v in lists[i]:
        hp.heappush(h,-v)
    if len(h)>0:
        ans -= hp.heappop(h)
print(ans)    


Measured memory_bytes: 20424
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll v[2][30], w[2][30];

int main() {
    init();
    ll N, W;
    cin >> N >> W;

    ll n[2] = {N / 2, (N + 1) / 2};
    rep(i, 2) rep(j, n[i]) cin >> v[i][j] >> w[i][j];

    vvc<pair<ll, ll>> dp(2, vc<pair<ll,ll>>(1 << 20));
    vc<pair<ll, ll>> A(1 << 20);

    rep(ni,2){
        ll nn = n[ni];
        rep(i, nn){
            ll dj = 0, ai = 0, ww = w[ni][i], vv = v[ni][i];
            rep(j,1<<i){
                while(dj < 1<<i and dp[ni][dj].first + ww <= dp[ni][j].first){
                    A[ai] = {dp[ni][dj].first + ww, dp[ni][dj].second + vv};
                    dj++, ai++;
                }
                A[ai] = dp[ni][j];
                ai++;
            }
            while(dj < 1<<i){
                A[ai] = {dp[ni][dj].first + ww, dp[ni][dj].second + vv};
                dj++, ai++;
            }
            swap(dp[ni], A);
        }

        ll tv = 0;
        rep(i,1<<nn){
            if (!chmax(tv, dp[ni][i].second)) dp[ni][i].second = tv;
        }
        
    }

    ll ans = 0, i1 = (1 << n[1]) - 1;
    rep(i, 1<<n[0]){
        ll ww = dp[0][i].first, vv = dp[0][i].second;
        if (ww > W) break;

        while (ww + dp[1][i1].first > W) i1--;

        chmax(ans, vv + dp[1][i1].second);
    }

    cout << ans << endl;

}


Measured memory_bytes: 52124
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>

using namespace std;

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

    vector<int> w;
    for(int i = 0; i < n; i++){
        int tmp;
        cin >>tmp;
        w.push_back(tmp);
    }

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

    for(int i = 0; i < n; i++){
        sum[i+1] = sum[i] + w[i];
    }

    int ans = INT_MAX;
    for(int i = 0; i < n; i++){
        ans = min(ans, abs((sum[i]-sum[0]) - (sum[n] - sum[i])));
    }

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

Measured memory_bytes: 256
void main() {
	auto ip = readAs!(int[]), N = ip[0], M = ip[1];
	writeln(N*M);
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename CommutativeMonoid>
class FenwickTree{
public:
	using value_type = CommutativeMonoid;

private:
	std::vector<value_type> tree;
	size_t N;

public:
	FenwickTree(){}
	FenwickTree(const size_t& N):N(N+10), tree(N+11, value_type()){}
	FenwickTree(const FenwickTree& bit):tree(bit.tree), N(bit.N){}

	void update(size_t k, const value_type& diff){
		for(;k <= N;k += k & -k){
			tree[k] = tree[k]+diff;
		}
	}

	value_type query(size_t k) const { // sum of [0, k)
		value_type res = value_type();
		for(;k > 0;k -= k & -k){
			res = res + tree[k];
		}
		return res;
	}

	void updatez(size_t k, value_type v){ // 0-indexed
		update(k+1, v);
	}

	size_t search(const std::function<bool(value_type)>& f) const { // Find k :[0, k) -> True, [0, k-1) -> False
		if(f(value_type()))
			return 0;
		if(!f(query(N)))
			return N+1;
		value_type x = value_type();
		size_t k = 1, idx = 0;
		while(k <= N) k <<= 1;
		k >>= 1;
		for(;k > 0;k >>= 1){
			if((idx|k) <= N && !f(tree[idx|k]+x))
				x = x + tree[idx|=k];
		}
		return idx+1;
	}

	size_t size() const {return N;}
};


int32 N;
vector<int64> a;


bool ok(int64 x){
	FenwickTree<int64> bit(2*N+10);
	vector<int64> b(N+1);
	REP(i, N){
		if(a[i] <= x) b[i+1] = 1;
		else b[i+1] = -1;
	}
	REP(i, N){
		b[i+1] += b[i];
		bit.update(b[i+1]+N+1, 1);
	}
	int64 cnt = 0;
	FOR(i, 1, N+1){
		cnt += (N-i+1)-bit.query(b[i-1]+N+1);
		bit.update(b[i]+N+1, -1);
	}
	return cnt > (N*(N+1))/2/2;
}


int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
	a = vector<int64>(N);
	REP(i, N) cin >> a[i];
	vector<int64> c = a;
	sort(all(c));
	int64 l = -1, r = N, m;
	while(r-l > 1){
		m = (l+r)/2;
		if(ok(c[m])){
			r = m;
		}else{
			l = m;
		}
	}
	cout << c[r] << endl;
}


Measured memory_bytes: 4224
S = input()
mod = [0] * 2019
mod[0] = 1 
d = 1
n = 0
for i in reversed(S):
  n += int(i) * d
  n %= 2019
  d *= 10
  d %= 2019
  mod[n % 2019] += 1
ans = 0
for j in range(2019):
  ans += mod[j] * (mod[j] - 1) // 2
print(ans)


Measured memory_bytes: 9068
N = int(input())
S1 = input()
S2 = input()

mod = 10 ** 9 + 7

i, cnt = 0, 0
prev = ''
if S1[i] == S2[i]:
    cnt += 3
    prev = '|'
    i += 1
else:
    cnt += 6
    prev = '='
    i += 2

while i < N:
    if S1[i] == S2[i]:
        currnet = '|'
        i += 1
    else:
        currnet = '='
        i += 2
    if prev == '|':
        cnt *= 2        
    elif prev == '=' and currnet == '=':
        cnt *= 3
    cnt %= mod
    prev = currnet
print(cnt % mod)

Measured memory_bytes: 3064
using System;
using System.Text;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using static System.Array;

namespace AtcoderExpress
{
    

    class Program
    {
        static long N;
        static long[] A;
        static long[] XorCum;
        static long[] Cum;
        static void Main(string[] args)
        {
            N = long.Parse(Console.ReadLine());
            A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            XorCum = new long[N + 1];
            Cum = new long[N + 1];

            for (int i = 1; i <= N; i++)
            {
                Cum[i] = Cum[i - 1] + A[i - 1];
                XorCum[i] = XorCum[i-1]^ A[i - 1];
            }

            var ans = 0L;
            for (int i = 1; i <= N; i++)
            {
                ans += Culculate(i);

                ////愚直
                //for (int j = i; j <= N; j++)
                //{
                //    if(Cum[j]-Cum[i-1] != (XorCum[j]^XorCum[i - 1]))
                //    {
                //        ans += j - i;
                //        Console.WriteLine(i+" "+j);
                //        break;
                //    }else if(j == N){
                //        ans += j - i + 1;
                //    }
                //}
            }
            Console.WriteLine(ans);
        }

        static long Culculate(long i)
        {
            var l = i;
            var r = N;
            var mid = l + (r - l) / 2;
            while (r-l > 1)
            {
                mid = (l+r) / 2;
                //Console.WriteLine(i+" "+mid);
                if (Cum[mid] - Cum[i - 1] == (XorCum[mid] ^ XorCum[i - 1]))
                {
                    l = mid;
                }
                else
                {
                    r = mid;
                }
            }

            if (Cum[r] - Cum[i - 1] == (XorCum[r] ^ XorCum[i - 1]))
            {
                l = r   ;
            }
            //Console.WriteLine(l);
            return l-i+1;

        }


    }
}


Measured memory_bytes: 34780
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using static Exter;
using console=System.Console;
namespace AtCoderTemplate
{
    public class App
    {
        public static void Main()
        {
var p = console.ReadLine().Split().Select(s=>short.Parse(s));
console.WriteLine(Max(p.Sum(v=>v),p.First()-p.Last(),p.First()*p.Last()));

        }
    }
}
public static class Exter
{
    public static int Max(params int[] p)=>p.Max();
    public static short Max(params short[] p)=>p.Max();
    public static long Max(params long[] p)=>p.Max();
}

Measured memory_bytes: 13396
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
#define pb push_back
int d[110000];
int belong[210000],cnt,sum,dfn[210000],low[210000],ist[210000];
vector<int>v[200010];
stack<int>a;
void tarjan(int x){
	  int i,j,k;
	  dfn[x]=low[x]=++cnt;
	  a.push(x);
	  ist[x]=1;
	  for(i=0;i<v[x].size();i++)
	     if(!dfn[v[x][i]]){
	     	tarjan(v[x][i]);
	     	low[x]=min(low[x],low[v[x][i]]);
	     }else if(ist[v[x][i]]){
	     	low[x]=min(low[x],dfn[v[x][i]]);
	     }
	 if(low[x]==dfn[x]){
	 	sum++;
	 	while(1){
	 		int u=a.top();
	 		a.pop();
	 		ist[u]=0;
	 		belong[u]=sum;
	 		if(u==x)break;
	 	}
	 }
}
int main()
{     int n,m,i,j,k,x,y;
      cin>>n>>m;
      for(i=1;i<=n;i++){
         cin>>d[i];
         v[i].pb(d[i]+n);
         v[d[i]+n].pb(i);
      }
      for(i=1;i<=m;i++){
      	 cin>>x>>y;
      	 v[x].pb(y);
      	 v[y].pb(x);
      }
      for(i=1;i<=2*n;i++)
         if(!dfn[i])tarjan(i);
      int ans=0;
      for(i=1;i<=n;i++){
         if(belong[i]==belong[i+n])ans++;
      }
      cout<<ans<<endl;
	  return 0;
}


Measured memory_bytes: 17664
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000LL;
constexpr auto MOD = 1000000007;
 
int main() {
 
	int n;
	cin >> n;
	vi a(n), b(n);
	rep(i, n)cin >> a[i] >> b[i];
 
	sort(all(a));
	sort(all(b));
 
	if (n % 2)cout << b[(n - 1) / 2] - a[(n - 1) / 2] + 1 << endl;
	else cout << b[(n - 2) / 2] + b[n / 2] - a[(n - 2) / 2] - a[n / 2] + 1 << endl;
 
}

Measured memory_bytes: 4712
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <memory.h>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


inline double det(const P &a, const P &b) {
	return (conj(a) * b).imag();
}

namespace std{
	bool operator<(const P &a, const P &b){
		return real(a)!=real(b)?real(a)<real(b):imag(a)<imag(b);
	}
}


vector<P> convexHull(vector<P> ps) {
	int n = ps.size(), k = 0;
	
	if (n <= 1) return ps;
	
	sort(all(ps));
	vector<P> qs(n * 2);
	for (int i = 0; i < n; qs[k++] = ps[i++]) {
		while (k > 1 && det(qs[k - 1] - qs[k - 2], ps[i] - qs[k - 1]) < EPS) k--;
	}
	for (int i = n - 2, t = k; i >= 0; qs[k++] = ps[i--]) {
		while (k > t && det(qs[k - 1] - qs[k - 2], ps[i] - qs[k - 1]) < EPS) k--;
	}
	
	vector<P> res(qs.begin(), qs.begin() + k - 1);
	return res;
}

int main() {
	for (int n; cin >> n, n != 0; ) {
		vector<P> ps;
		rep(i, n) {
			char c;
			double x, y; cin >> x >> c >> y;
			ps.pb(P(x, y));
		}
		cout << n - convexHull(ps).size() << endl;
	}
	return 0;
}

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

#define int long long

#define mod (int)1000000007
#define inf (int)1000000007

#define rep(i, n) for(int i = 0; i < (n); i++)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define trrep(i, n) for(int i = (n); i >= 0; i--)
#define For(i, s, t) for(int i = (s); i < (t); i++)
#define tfor(i, s, t) for(int i = (s); i <= (t); i++)
#define rfor(i, s, t) for(int i = (t) - 1; i >= (s); i--)
#define trfor(i, s, t) for(int i = (t); i >= (s); i--)

int pow(int x, int n) {
  int r = 1;
  while(n > 0) {
    if(n & 1) {
      r = r * x % mod;
    }
    x = x * x % mod;
    n >>= 1;
  }
  return r;
}

int inverse(int x) {
  return pow(x, mod - 2);
}

int dp[1111];
int dpw[1111];

int cc[1111];
int ccinv[1111];

signed main() {
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  trep(i, n) {
    dp[i] = 0;
  }
  trep(i, n) {
    if(i == 0) {
      cc[i] = 1;
    }
    else {
      cc[i] = (cc[i - 1] * i) % mod;
    }
  }
  trep(i, n) {
    ccinv[i] = inverse(cc[i]);
  }
  dp[n] = 1;
  tfor(i, a, b) {
    trep(j, n) {
      dpw[j] = dp[j];
    }
    tfor(j, c, min(d, n / i)) {
      trep(k, n) {
        if(k - j * i >= 0) {
          dpw[k - j * i] = (dpw[k - j * i] + dp[k] * ccinv[j] % mod * pow(ccinv[i], j)) % mod;
        }
      }
    }
    trep(j, n) {
      dp[j] = dpw[j];
    }
  }
  cout << dp[0] * cc[n] % mod << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <istream>
using namespace std;

static const int MAX_NUM = 2000001;

void MakeHeap(int elem[], int *pNum, int target)
{
    int left, right, largest;

    left    = target * 2;
    right   = left + 1;
    largest = target;

    if (right <= *pNum) {
        if (elem[right] > elem[largest]) {
            largest = right;
        }
        if (elem[left] > elem[largest]) {
            largest = left;
        }
    }
    else {
        if (left <= *pNum) {
            if (elem[left] > elem[largest]) {
                largest = left;
            }
        }
    }

    if (largest != target) {
        swap(elem[largest],elem[target]);
        MakeHeap(elem, pNum, largest);
    }

    return;
}

int ExtractMax(int elem[], int *pNum)
{
    int ret = elem[1];
    int now, left, right, target;

    if (*pNum >= 1) {
        swap(elem[1], elem[*pNum]);
        --(*pNum);

        MakeHeap(elem, pNum, 1);
    }
    else {
        ret = -(1 << 30);
    }

    return ret;
}

void Insert(int elem[], int *pNum, int target)
{
    int id;
    int parent;

    ++(*pNum);
    id = *pNum;
    elem[id] = target;

    parent = id / 2;
    while (parent > 0) {
        if (elem[id] > elem[parent]) {
            swap(elem[id], elem[parent]);
            id = parent;
            parent = id / 2;
        }
        else {
            break;
        }
    }

    return;
}

int main(void)
{
    int  elem[MAX_NUM];
    int  num = 0;
    int  key;
    char order[10];

    elem[1] = -1;

    for (;;) {
        scanf("%s", order);
        if (order[0] == 'e') {
            if (order[1] == 'n') {
                break;
            }
            else {
                key = ExtractMax(elem, &num);
                printf("%d\n", key);
            }
        }
        else if (order[0] == 'i') {
            scanf("%d", &key);
            Insert(elem, &num, key);
        }
    }

    return 0;
}

Measured memory_bytes: 5920
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main()
{
   int n,r,p,result;

   cin>>n>>r;
   if(n>=10){
    cout<<r<<endl;
   }
   else{
        p=100*(10-n);
        result=p+r;
        cout<<result<<endl;
   }

    return 0;
}


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

const long long N = 1e6 + 17;
ll cnt, ans, lnt, n, l1, x, y, a[N];
pair<ll,ll>pr[N];
vector<ll>v,v2,v3;
map<ll,ll>mp;
bool used[N], t1, t2;
vector<string>sv;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n;
    x = n / 100;
    y = n % 100;
    if(1 <= x and x <= 12)
    {
        if(1 <= y and y <= 12)
        {
            cout << "AMBIGUOUS";
        }
        else
        {
            cout << "MMYY";
        }
    }
    else
    {
        if(1 <= y and y <= 12)
        {
        cout << "YYMM";
        }
        else
        {
            cout <<"NA";
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    cin>>k;
    int even{0}, odd{0};
    for(int i=1; i<=k; i++)
    {
        if(i%2==0)
            even++;
        else
            odd++;
    }
    cout<< odd*even<< endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

using namespace std;

inline double sq(double x) {
  return x * x;
}

int main() {
  double v;
  while (scanf("%lf", &v) == 1)
    printf("%d\n", int(ceil(4.9 * sq(v / 9.8) / 5.0)) + 1);
  return 0;
}

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

int main() {
    string left = "qwert asdfg zxcvb";
    string right = "yuiop hjkl nm";
    map<char, bool> isLeft;
    for (char& c : left) isLeft[c] = true;
    for (char& c : right) isLeft[c] = false;

    while (true) {
        string s; cin >> s;
        if (s == "#") break;
        int n = s.length();
        vector<bool> a(n);
        for (int i = 0; i < n; i++) a[i] = isLeft[s[i]];
        int cnt = 0;
        for (int i = 0; i + 1 < n; i++) {
            if (a[i] != a[i + 1]) cnt++;
        }
        cout << cnt << endl;
    }

    return 0;
}


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

int main(){
    int n,x;
    int s_num=0,h_num=0,c_num=0,d_num=0;
    char Mark;
    //std::vector<int> s,h,c,d;
    int s[13] = {1,2,3,4,5,6,7,8,9,10,11,12,13};
    int h[13] = {1,2,3,4,5,6,7,8,9,10,11,12,13};
    int c[13] = {1,2,3,4,5,6,7,8,9,10,11,12,13};
    int d[13] = {1,2,3,4,5,6,7,8,9,10,11,12,13};

    cin >> n;
    for(int i=0;i<n;i++){
        cin >> Mark >> x;
        switch(Mark){
            case 'S':
                s[x-1] = 0;
                break;
            case 'H':
                h[x-1] = 0;
                break;
            case 'C':
                c[x-1] = 0;
                break;
            case 'D':
                d[x-1] = 0;
                break;
        }
    }
    
    for(int i=0;i<13;i++){
        if(s[i] != 0){
            cout << "S " << s[i] << endl;
        }
    }
    for(int i=0;i<13;i++){
        if(h[i] != 0){
            cout << "H " << h[i] << endl;
        }
    }
    for(int i=0;i<13;i++){
        if(c[i] != 0){
            cout << "C " << c[i] << endl;
        }
    }
    for(int i=0;i<13;i++){
        if(d[i] != 0){
            cout << "D " << d[i] << endl;
        }
    }
    
}


Measured memory_bytes: 3080
import java.util.*;

class aoj0001
{
    public void solve()
    {
        int[] list = new int[10];
        Scanner sc = new Scanner(System.in);
        for(int i=0; i<10; i++)
            list[i] = sc.nextInt();
        Arrays.sort(list);
        for(int i=0; i<3; i++)
            System.out.println(list[9-i]);
    }
}

class Main
{
    public static void main(String...args)
    {
        new aoj0001().solve();
    }
}

Measured memory_bytes: 17368
N, M = map(int, input().split())

if (N==1) & (M > 1):
    ans = M - 2
elif (M==1) & (N > 1):
    ans = N - 2
elif (N==1) & (M==1):
    ans = 1
else:
    ans = ((N - 2) * (M - 2))

print(ans)

Measured memory_bytes: 3060
N=int(input())
A=list(map(int,input().split()))
A2=[0]*N

for i in range(N):
    A2[i]=A[i]-i-1
    
A2.sort()

if N%2==1:
    med=A2[N//2]
else:
    med=(A2[N//2]+A2[N//2-1])//2


ans=10**20
for dx in [-1,0,1]:
    temp=0
    for i in range(N):
        temp+=abs(A[i]-(med+dx+i+1))
    ans=min(ans,temp)
print(ans)
        



Measured memory_bytes: 88404
#include<bits/stdc++.h>
#define vi vector<int>
#define vl vector<long int>
#define vll vector<long long int>
#define pi pair<int, int>
#define  ump unordered_map
#define us  unordered_set
 using namespace std;
  
   int main()
   {
   	int n;
   	 cin>>n;
   	 us<string>s1;
   	  for(int i=0; i<n; i++)
   	  {
   	  	  string s;
   	  	   cin>>s;
   	  	    s1.insert(s);
   	  	   
   	  	    
		 }
		  cout<<s1.size();
   }

Measured memory_bytes: 17788
#include <bits/stdc++.h>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl

using namespace std;

int main()
{
    int n, m, pena = 0, ans = 0;
    cin >> n >> m;
    vector<int> ac(n, 0), pe(n, 0);

    rep(i, m)
    {
        int p;
        string s;
        cin >> p >> s;
        if (ac[p - 1] == 0)
        {
            if (s == "WA")
            {
                pe[p - 1] += 1;
            }
            else
            {
                ac[p - 1] = 1;
            }
        }
    }
    rep(i, n)
    {
        if (ac[i] == 1)
        {
            pena += pe[i];
            ans++;
        }
    }
    cout << ans << " " << pena << endl;
    return 0;
}

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

namespace ABC123D
{
    class MainClass
    {

        static int[] xyzk;
        static long[] a;
        static long[] b;
        static long[] c;

        public static void Main(string[] args)
        {

            xyzk = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);
            a = Array.ConvertAll(Console.ReadLine().Split().ToArray(), long.Parse);
            b = Array.ConvertAll(Console.ReadLine().Split().ToArray(), long.Parse);
            c = Array.ConvertAll(Console.ReadLine().Split().ToArray(), long.Parse);


            var alst = a.ToList();
            var blst = b.ToList();
            var clst = c.ToList();

            //alst.Sort((x, y) => y.CompareTo(x));
            //blst.Sort((x, y) => y.CompareTo(x));
            //clst.Sort((x, y) => x.CompareTo(y));
            var ablst = new List<long>();
            for(int i = 0; i < xyzk[0]; i++)
            {
                for(int j = 0; j < xyzk[1]; j++)
                {
                    /*
                    if ((i + 1) * (j + 1) > xyzk[3])
                    {
                        break;
                    }
                    */
                    ablst.Add(alst[i] + blst[j]);
                }
            }

            ablst.Sort((x, y) => y.CompareTo(x));
            int ablen = Math.Min(ablst.Count, xyzk[3]);
            var abclst = new List<long>();
            for(int i = 0; i < ablen; i++)
            {
                for(int j = 0; j < xyzk[2]; j++)
                {
                    abclst.Add(ablst[i] + clst[j]);
                }
            }

            abclst.Sort((x, y) => y.CompareTo(x));
            for (int i = 0; i < xyzk[3]; i++)
            {
                Console.WriteLine(abclst[i]);
            }


        }
    }
}


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

using namespace std;

int game (int n, int p)
{
    int a[n]={0};
    bool ok;
    for (int i=0; i<n; i++)
    {
        if (p!=0)
        {
            a[i]++; p--;
            if (p==0)
            {
                ok=true;
                for (int j=0; j<n; j++)
                {
                    if (i==j) continue;
                    if (a[j]!=0) ok=false;
                }
                if (ok) return i;
            }
        }
        else { p+=a[i]; a[i]=0; }
        if (i==n-1) i=-1;
    }
}

int main()
{
    int n, p;
    vector<int> ans;
    while (1)
    {
        cin>>n>>p;
        if (n==0 && p==0) break;
        ans.push_back(game(n,p));
    }
    for (int i=0; i<ans.size(); i++) cout<<ans[i]<<'\n';
    return 0;
}



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

int main(){
  int S, h, m, s;
  cin >> S;
  h = S/3600;
  S -= 3600*h;
  m = S/60;
  S -= 60*m;
  s = S;
  cout << h << ":" << m << ":" << s << endl;
  
  
}

Measured memory_bytes: 1164
def ABC_45_B():
    A = list(input())
    B = list(input())
    C = list(input())

    turn = 0
    mozi = 'a'

    for i in range(300):
        if turn == 0:
            if len(A) == 0:
                print('A')
                break
            mozi = A[0]
            del A[0]


        elif turn == 1:
            if len(B) == 0:
                print('B')
                break
            mozi = B[0]
            del B[0]

        else:
            if len(C) == 0:
                print('C')
                break
            mozi = C[0]
            del C[0]


        if mozi == 'a':
            turn=0
        elif mozi =='b':
            turn=1
        else:
            turn=2


if __name__ == '__main__':

    ABC_45_B()

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>

using namespace std;
int main(){
	int masu[9000],n,m,iti,f;
	while(cin>>n>>m&&n){
		iti=f=1;
		for(int i=1;i<=n+m;i++){
			cin>>masu[i];
			if(i>n){
				iti+=masu[i];
				iti+=masu[iti];
				if(iti>=n&&f==1){
					printf("%d\n",i-n);
					f=0;
				}
			}
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
typedef long long ll;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<ll> H(N);
    for(int i=0;i<N;++i){
        cin >> H[i];
    }
    sort(H.begin(), H.end(), std::greater<ll>());

    ll ans = 0;
    for(int k=K;k<N;++k){
        ans += H[k];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<vector<double>> vvd;
typedef vector<double> vd;

#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x_, i_, j_) cerr << #x_ << "------------" << "\n";cerr << "from " << i_ << " to " << j_ << "\n";for(ll k_=i_; k_<=j_; k_++) cerr << x_[k_] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const int MAX_LOG = 21;
const int MAX_N = 1000*1001;

#define forn(i, n) for(int i = 0; i < n; i++)
#define forsn(i, s, n) for(int i = s; i < n; i++)
#define all(x) x.begin(), x.end()

const int maxh = 100 * 100 + 5, maxn = 1000 + 5;

int dp[maxn][maxh];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int h, n;
	cin >> h >> n;
	vi a(n), b(n);
	forn(i, n) cin >> a[i] >> b[i];
	dp[0][0] = 0;
	forsn(i, 1, h + 1){
		// cerr << "Hello" << endl;
		// trace2(i, a[i]);
		dp[0][i] = ((i + a[0] - 1) / a[0]) * b[0];
		// cerr << "Bye" << endl;
	}
	forsn(i, 1, n){
		forn(health, h + 1){
			int &it = dp[i][health];
			if(health == 0){
				it = 0;
			}
			else{
				if(health <= a[i]){
					it = min(dp[i - 1][health], b[i]);
				}
				else{
					it = min(dp[i - 1][health], dp[i][health - a[i]] + b[i]);
				}
			}
		}
	}
	cout << dp[n - 1][h] << endl;
}		


Measured memory_bytes: 39296
import bisect

N = int(input())
L_list = list(map(int, input().split()))

L_list = sorted(L_list)

total = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        total += bisect.bisect_left(L_list, L_list[i] + L_list[j]) - j -1

print(total)

Measured memory_bytes: 3188
#include<cstdio>
#include<cstdlib>
int main(void){
	int H,W,D;
	scanf("%d%d%d",&H,&W,&D);
	int A;
	int i,j;
	int ax[90001],ay[90001];
	for (i=0;i<H;i++){
		for (j=0;j<W;j++){
			scanf("%d",&A);
			ax[A]=i;ay[A]=j;
		}
	} 
	int Q;
	scanf("%d",&Q);
	int L,R;
	int ans;
	int d[90001];
	for(i=0;i<D;i++){
		d[i] = 0;
	}
	for(j=0;j+D<=H*W;j++){
		d[j+D] = d[j] + abs(ax[j+D] - ax[j]) + abs(ay[j+D] - ay[j]);
	}
	for(i=0;i<Q;i++){
		scanf("%d%d",&L,&R);
		printf("%d\n",d[R]-d[L]);
	}
	
	return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <string>

int main()
{
  std::string s;
  std::cin >> s;
  char week[][4] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  if (s == week[0])
    std::cout << 7 << std::endl;
  else if (s == week[1])
    std::cout << 6 << std::endl;
  else if (s == week[2])
    std::cout << 5 << std::endl;
  else if (s == week[3])
    std::cout << 4 << std::endl;
  else if (s == week[4])
    std::cout << 3 << std::endl;
  else if (s == week[5])
    std::cout << 2 << std::endl;
  else if (s == week[6])
    std::cout << 1 << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;


int main() {
	int n = 0;
	cin >> n;
	vector<int> h(n);
	rep(i, n) {
		cin >> h[i];
	}
	int dp[100010];
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for (int i = 2; i < n; i++) {
		int step1 = dp[i - 1] + abs(h[i] - h[i - 1]);
		int step2 = dp[i - 2] + abs(h[i] - h[i - 2]);
		dp[i] = min(step1, step2);
	}
	cout << dp[n - 1] << endl;

	return 0;
}

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

using namespace std;

int main() {
    long long int n,i,j,k;
    cin>>n;
    long long int a[n],b[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    b[0]=0;
    b[1]=abs(a[0]-a[1]);
    for(i=2;i<n;i++)
    {
        b[i]=min(b[i-1]+abs(a[i-1]-a[i]),b[i-2]+abs(a[i-2]-a[i]));
    }
    cout<<b[n-1];
    
}

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

using namespace std;

#define all(a) (a).begin(), (a).end()

template<typename T>
ifstream& operator>> (ifstream& in, vector<T> v) {
    for(int i = 0; i < v.size(); ++i) in >> v[i];
    return in;
}

template<typename T>
ofstream& operator<< (ofstream& out, vector<T> v) {
    for(int i = 0; i < v.size(); ++i) out << v[i];
    return out;
}

int32_t main() {
    string s; cin >> s;
    sort(all(s));
    if(s == "abc") cout << "Yes";
    else cout << "No";
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

//const ll INF=(ll)1e18;
const int INF=(1<<30);


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

  for(int i = S.size() - T.size(); i >= 0; i--){
    bool flag = true;
    REP(j,T.size()){
      if(S[i+j] != '?' && S[i+j]!=T[j]){
        flag = false;
        break;
      }
    }
    if(flag){
      REP(j,i){
        cout << (S[j]=='?' ? 'a' : S[j] );
      }
      cout << T;
      FOR(j,i+T.size(),S.size()){
        cout << (S[j]=='?' ? 'a' : S[j] );
      }
      cout << endl;
      exit(0);
    }

  }
  cout << "UNRESTORABLE" << endl;

}



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

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int sum;
	
	int AB = min(A, B);
	int CD = min(C, D);
	sum = AB + CD;
	
	cout << sum;
	

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define INF 0x3f3f3f3f
#define chmin(a,b)(a)=min((a),(b))
using namespace std;

int dp[5001][4], p[5000];
int main() {
	int n; scanf("%d", &n);
	rep(i, n)scanf("%d", &p[i]);
	memset(dp, 0x3f, sizeof(dp));
	rep(i, 4)dp[0][i] = i;
	rep(i, n)rep(j, 4)chmin(dp[i + 1][max(0, p[i] - j)], dp[i][j] + max(0, p[i] - j) * (i == n - 1 ? 1 : 2));
	printf("%d\n", *min_element(dp[n], dp[n] + 4));
}

Measured memory_bytes: 3304
#pragma warning(disable:4996)
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a, b;
	cin >> a >> b;
	reverse(a.begin(), a.end());
	if (a == b)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
/*
 * atcoder/abc117_2nd/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

int N, M;
vector<int> X, D;

/*
 * N >= M:    0
 * N - 1 = M: 座標間の最小距離   コマをすべて異なる座標に配置 -> 1つだけ+1移動
 * N - 2 = M: 座標間の最小距離２つの和
 * N - 3 = M: 座標間の最小距離3つの和
 */

void solve() {
  cin >> N >> M;
  int x;
  loop(m,0,M) {
    cin >> x;
    X.push_back(x);
  }
  sort(X.begin(), X.end());
  for (int n=0; n<M-1; n++) {
    D.push_back(X[n+1] - X[n]);
  }
  sort(D.begin(), D.end());
  ll total = 0;
  for (int n=0; n<max(M-N, 0); n++) {
    total += D[n];
  }
  cout << total << endl;
}
int main() {
  // cout.precision(15);
  // cout << fixed << double

  solve();

  return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
ll mod = 1e9+7;
ll hatena[123456];
ll sum[123456][2];
ll p3[123456];
int main(){
    string s;
    cin >> s;
    int n = (int) s.size();
    rep(i,n){
        hatena[i+1] = hatena[i] + (s[i] == '?' ? 1:0);
        sum[i+1][0] = sum[i][0] + (s[i] == 'A' ? 1:0);
        sum[i+1][1] = sum[i][1] + (s[i] == 'C' ? 1:0);
    }
    p3[0] = 1;
    rep(i,n)p3[i+1] = p3[i] * 3 % mod;
    ll ans = 0;
    for(int i = 1; i < n-1; i++){
        if(s[i] == 'B' or s[i] == '?'){
            int hoge = (s[i]=='?' ? 1:0);
            //?を使わない
            ans += sum[i][0]*(sum[n][1]-sum[i+1][1])%mod*p3[hatena[n]-hoge]%mod;
            ans %= mod;
            //?を使う
            if(hatena[n]>=1+hoge)ans += sum[i][0]*(hatena[n]-hatena[i+1])%mod*p3[hatena[n]-1-hoge]%mod;
            ans %= mod;
            if(hatena[n]>=1+hoge)ans += hatena[i]*(sum[n][1]-sum[i+1][1])%mod*p3[hatena[n]-1-hoge]%mod;
            ans %= mod;
            if(hatena[n]>=2+hoge)ans += hatena[i]*(hatena[n]-hatena[i+1])%mod*p3[hatena[n]-2-hoge]%mod;
            ans %= mod;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007

using namespace std;

int main(void){
  int n, k;

  cin >> n >> k;

  vector<double> p(n);

  for (int i = 0; i < n; i++)
    cin >> p[i];

  double m = 0;

  for (int i = 0; i < k; i++){
    m += (p[i] + 1)/2;
  }

  double s = m;

  for (int i = k; i < n; i++){
    s = s - (p[i - k] + 1)/ 2 + (p[i] + 1)/2;
    m = max(m, s);
  }

  printf("%.7lf\n", m);
  

  return 0;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

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

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct 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;
}


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

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

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  }
  return 0;
}

Measured memory_bytes: 19364
INT_MAX=10**18+7
MOD=10**9+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]
#################################################################################
n,K=INPUT()
ways=0
for k in range(K,n+2):
        ways+=(k*(2*n-k+1))//2 - ((k)*(k-1))//2 +1
print(ways%MOD)


Measured memory_bytes: 63596
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-9;
const int inf=1e8;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	ll n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	ll sum=0;
	rep(i,n)sum+=in[i];
	ll t=(n+1)*n/2;
	if(sum%t){
		cout<<"NO"<<endl;
		return 0;
	}
	ll co=0,T=sum/t;
	in.pb(in[0]);
	bool h=true;
	rep(i,n){
		if(in[i]+T==in[i+1]);
		else{
			ll a=in[i+1]-in[i];
			if(T-a<0)h=false;
			else if((T-a)%n)h=false;
			else co+=(T-a)/n;
		}
	}
	if(!h||co!=T)cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
}











Measured memory_bytes: 1792
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S;
    cin >> S;
    ll N=S.size();
    ll dp[2*N+1][2*N+1];//前から、青ボールの数
    rep(i,2*N+1){
        rep(j,2*N+1){
            dp[i][j]=0;
        }
    }
    vl acc(N+1,0),acc1(N+1,0);
    rep(i,N){
        acc[i+1]=acc[i]+(S[i]-'0');//青ボールの数
        acc1[i+1]=acc1[i]+('2'-S[i]);//赤ボールの数
    }
    if(S[0]=='0'){
        dp[1][0]=1;
    }
    else if(S[0]=='2'){
        dp[1][1]=1;
    }
    else{
        dp[1][0]=dp[1][1]=1;
    }
    FOR(i,2,N+1){
        //可能なjは、なるべく赤~青全部取るのパターンがある
        FOR(j,max((ll)0,i-acc1[i]),min(i+1,acc[i]+1)){
            //cout << i << ' ' << j << endl;
            if(j>0){
                dp[i][j]+=dp[i-1][j-1];
            }
            dp[i][j]+=dp[i-1][j];
            dp[i][j]%=MOD2;
        }
    }
    FOR(i,N+1,2*N+1){
        rep(j,2*N+1){
            if(j>0){
                dp[i][j]+=dp[i-1][j-1];
            }
            dp[i][j]+=dp[i-1][j];
            dp[i][j]%=MOD2;
        }
    }
    cout << dp[2*N][acc[N]] << endl;
}

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

using namespace std;

typedef long long ll;

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

    ll N;
    cin >> N;

    string ans;
    if (N == 0) {
        cout << 0 << endl;
        exit(0);
    } else {
        int i = 0;
        if (N > 0) i++;
        while (N != 0) {
            if (N == 1) {
                ans += '1';
                break;
            }
            if (N % 2 != 0) {
                ans += '1';
                N = N / (-2);
                if (i % 2 == 0 ) {
                    N++;
                }
            } else {
                ans += '0';
                N = N / (-2);
            }
            i++;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <cstring> // memset
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#define ALL(x) (x).begin(), (x).end()
#define INF 1e9
#define LOG(x) cout << #x << " = " << (x) << endl
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

int main() {
    int n, a, b;
    cin >> n >> a >> b;

    if (abs(a - b) % 2 == 0)
        cout << "Alice" << endl;
    else
        cout << "Borys" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;

int main() {
  //
  map<int, ll> unique_height;
  ll n;
  cin>>n;
  vl t(n),a(n);
  rep(i,n) cin>>t[i];
  rep(i,n) cin>>a[i];
  if (n == 1 && t[0] != a[0]) {
    cout << 0 << endl;
    return 0;
  }
  unique_height[0] = t[0];
  unique_height[n-1] = a[n-1];
  REP(i,1,n) {
    if (t[i] > t[i-1]) {
      unique_height[i] = t[i];
      if (t[i] > a[i]) {
        cout << 0 << endl;
        return 0;
      }
    }
  }
  for (int i = n-2; i >= 0; i--) {
    if (a[i] > a[i+1]) {
      if (unique_height.find(i) == unique_height.end()) {
        unique_height[i] = a[i];
        if (a[i] > t[i]) {
          cout << 0 << endl;
          return 0;
        }
      } else {
        if (a[i] != unique_height[i]) {
          cout << 0 << endl;
          return 0;
        }
      }
    }
  }

  ll ans = 1;
  rep(i, n) {
    if (unique_height.find(i) == unique_height.end()) {
      ans = ans * min(t[i], a[i]) % MOD;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8064
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll n,ans=0;
  cin>>n;
  ans=n*(n-1)/2;
  cout<<ans<<endl;
}


Measured memory_bytes: 256