akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> v(n);
    long long int out =0;
    for(int &x:v)cin>>x;
    for(int i=1;i<n;i++)
    {
		if(v[i]>=v[i-1])
		{
			continue;
		}
		else
		{
			out = out + (v[i-1]-v[i]);
			v[i] = v[i-1];
		}
	}
	cout<<out<<endl;
    return 0;
}


Measured memory_bytes: 3972
#include <iostream>

using namespace std;

int main() {
	string S;
	cin >> S;
	if((S[0] == S[1]) or (S[1] == S[2]) or (S[2] == S[3]) ){
		std::cout << "Bad" << std::endl;
		return 0;
	}
	std::cout << "Good" << std::endl;
	return 0;
}

Measured memory_bytes: 256
S=list(input())

ACGT=['A','C','G','T']
tmp=''
MAX1=0
MAX2=0

for moji in S:
    if((moji in ACGT)==True):
        tmp+=moji
        MAX2=len(tmp)
    else:
        if(MAX1 < MAX2):
            MAX1=MAX2
        MAX2=0
        tmp=''

if(MAX1==0 or MAX1 < MAX2):
    MAX1=MAX2

print(MAX1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  int n, q;
  cin >> n;
  vector<int> A(n);
  REP(i, n) cin >> A.at(i);
  cin >> q;
  vector<int> m(q);
  REP(i, q) cin >> m[i];
  map<int, int> ans{};
  for (int i = 0; i < 1 << n; i++) {
    ll num = 0;
    REP(j, n+1) {
      if (i & 1 << j) {
        num += A[j];
      }
    }
    ans[num] = 1;
  }
  REP(i,q){
    if(ans[m[i]]==1){
      puts("yes");
    }else{
      puts("no");
    }
  }
}


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed _main(){
  string s; cin >> s;
  unordered_map<int,int> mp;
  int index=0;
  int ans=0;
  mp[index]=0;
  string s1="";
  rep(i,s.size()){
    if(s[i]=='x'){
      mp[index]++;
    }
    else{
      s1+=s[i];
      index++;
    }
  }
  string s2=s1;
  reverse(s2.begin(),s2.end());
  if(s1!=s2){
    cout << -1 << endl;
    return 0;
  }
  int right=index,left=0;
  while(left<right){
    ans+=abs(mp[right]-mp[left]);
    right--;
    left++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4724
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (input) {
    var num = input.split(' ');
    //??????????????°??????????????????
    var a = parseInt(num[0]);
    var b = parseInt(num[1]);
    var relation = ' == ';
    if(a < b){
        relation = ' < ';
    }
    else if(a > b){
        relation = ' > ';
    }
    console.log("a"+relation+"b");
});

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

int main () {
  int A, B, x, x_10001, x_1010, PN = 0;
  cin >> A >> B;
  x = A;
  
  for (int i = 0; i < B - A + 1; i++) {
    x_10001 = (x - (x % 10000) + (x % 10)) % 10001;
    x_1010 = ((x % 10000) - (x % 1000) + (x % 100) - (x % 10)) % 1010;
    
    if (x_10001 == 0 && x_1010 == 0) 
      PN++;
    
    x++;
  }
  
  cout << PN << endl;
}

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

int main() {
	while (1) {
		int n, m; cin >> n >> m;
		if (n==0 && m==0) return 0;
		multiset<int> s;
		int ans = 0;
		for (int i = 0; i < n; ++i)
		{
			int c; cin >> c;
			s.insert(c);
			ans += c;
		}
		for (int i = 0; i < m; ++i)
		{
			int c; cin >> c;
			if (s.find(c) != s.end()) s.erase(s.find(c));
			else ans += c;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3092
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.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;
}

int main(void) {
    int X;
    cin >> X;
    if (X >= 1800) {
        cout << 1 << endl;
    } else if (X >= 1600) {
        cout << 2 << endl;
    } else if (X >= 1400) {
        cout << 3 << endl;
    } else if (X >= 1200) {
        cout << 4 << endl;
    } else if (X >= 1000) {
        cout << 5 << endl;
    } else if (X >= 800) {
        cout << 6 << endl;
    } else if (X >= 600) {
        cout << 7 << endl;
    } else {
        cout << 8 << endl;
    }
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  //input
  int n, m;
  cin >> n >> m;
  vector<int> s(m), c(m);
  REP(i,m) {
    int sx, cx;
    cin >> sx >> cx;
    sx--;
    s[i] = sx;
    c[i] = cx;
  }
  debug(s);
  debug(c);

  vector<int> a(n, -1);
  debug(a);

  REP(i,m){
    // if((s[i] == 0) && (c[i] == 0)){
    //     cout << -1 << endl;
    //     return 0;
    // }
    if((a[s[i]] != -1) && (a[s[i]] != c[i])){
      cout << -1 << endl;
      return 0;
    }
    a[s[i]] = c[i];
    debug(a);
  }

  if(n == 1){
    if(a[0] == -1) a[0] = 0;
    cout << a[0] << endl;
    return 0;
  }

  if(a[0] == 0){
    cout << -1 << endl;
    return 0;
  }

  REP(i,n){
    if(a[i] == -1){
      if(i == 0) a[i] = 1;
      else a[i] = 0;
    }
  }

  int ans = 0;
  REP(i,n){
    ans *= 10;
    ans += a[i];
  }

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

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

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

    if(A == C){
        cout << B << endl;
    }
    else if(A == B){
        cout << C << endl;
    }
    else if(B == C){
        cout << A << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2};
const int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1};
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif

int main(){
  fastIO();
  string s;
  cin>>s;
  if(s[s.length()-1]=='s'){
    s+="es";
  }else{
    s+="s";
  }
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 3676
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        Room[] map = new Room[N+1];
        for (int i = 0; i < M; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            Room A = map[a] == null ? new Room(a) : map[a];
            Room B = map[b] == null ? new Room(b) : map[b];
            A.addNeighbor(B);
            B.addNeighbor(A);
            map[a] = A;
            map[b] = B;
        }
        boolean result = constructSign(map);
        if(result){
            System.out.println("Yes");
            for(int i = 2; i < N+1; i++){
                System.out.println(map[i].sign);
            }
        }else{
            System.out.println("No");
        }
    }

    public static boolean constructSign(Room[] map){
        HashSet<Integer> visited = new HashSet<>();
        ArrayDeque<Room> queue = new ArrayDeque<>();
        queue.add(map[1]);
        visited.add(1);
        int counter = 1;
        while(!queue.isEmpty()){
            Room r = queue.poll();
            for(Room n: r.neighbor) {
                if(!visited.contains(n.num)){
                    n.sign =  r.num;
                    queue.offer(n);
                    visited.add(n.num);
                    counter++;
                }
            }
        }
        return  counter + 1 == map.length;
    }
}

class Room {
    int num;
    List<Room> neighbor;
    int sign;
    public Room(int num){
        this.num = num;
        this.neighbor = new ArrayList<>();
    }

    public void addNeighbor(Room room){
        if(room.num == 1) this.sign = 1;
        this.neighbor.add(room);
    }
}


Measured memory_bytes: 76824
#include<bits/stdc++.h>
using namespace std;
# define m1 1000000007
int main()
{ int n,m;
cin>>n>>m;
char ch;
    int arr[n][m];
    for(int i=0;i<n;i++)
    { for(int j=0;j<m;j++)
        { cin>>ch;
            if(ch=='#')
                arr[i][j]=-1;
            else
                arr[i][j]=0;
        }

    }
    int i;
    arr[0][0]=1;
    for( i=1;i<m;i++)
    { if(arr[0][i]==-1)
        break;
        arr[0][i]=arr[0][i-1]%m1;
    }
    while(i<m)
    { arr[0][i]=-1;
        i++;
    }
    for(i=1;i<n;i++)
    { if(arr[i][0]==-1)
        break;
        arr[i][0]=arr[i-1][0]%m1;
    }
    while(i<n)
    {
        arr[i][0]=-1;
        i++;
    }
    for(int i=1;i<n;i++)
    { for(int j=1;j<m;j++)
        { if(arr[i][j]==-1)
            continue;
            else if(arr[i-1][j]==-1&&arr[i][j-1]==-1)
                arr[i][j]=-1;
            else
            { arr[i][j]=0;
                if(arr[i-1][j]!=-1)
                    arr[i][j]+=arr[i-1][j];
                    arr[i][j]%=m1;
                if(arr[i][j-1]!=-1)
                    arr[i][j]+=arr[i][j-1];
                arr[i][j]%=m1;
            }
        }
    }
if(arr[n-1][m-1]==-1)
    arr[n-1][m-1]=0;
cout<<arr[n-1][m-1]<<endl;
}


Measured memory_bytes: 4096
from collections import defaultdict


n = int(input())
a = list(map(int, input().split()))

money = 1000
min_v = a[0]
max_v = a[0]

for i in range(1,n):
    if max_v > a[i]:
        money = money//min_v * max_v + money % min_v
        min_v = a[i]
        max_v = a[i]
    
    max_v = a[i] if a[i] > max_v else max_v
    min_v = a[i] if a[i] < min_v else min_v

    if i == n-1 and a[i] > min_v:
        money = money//min_v * max_v + money % min_v

    # print(i,max_v,min_v,money)

print(money)

Measured memory_bytes: 9408
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

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


Measured memory_bytes: 256
import math
a, b, deg = map(int, input().split())
c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(deg)))
s = (a+b+c) / 2
area = (s * (s-a) * (s-b) * (s-c))**0.5
h = area * 2 / a

print(area)
print(a+b+c)
print(h)


Measured memory_bytes: 5728
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h, w, n,m; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}

int main() {
	cin >> n >> m;
	ll a = n - (m - 1);
	if (m == 1) {
		a = 1;
	}
	cout << a-1 << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>

int main(){
    long double const pi = 3.14159265359;
    long double a,b;
    long double c;
    
    long double S;
    long double L;
    long double h;
    
    std::cin >> a >> b >> c;
    h = b * std::sin(c/180*pi);
    S = 0.5 * a * h;
    L = a + b + std::sqrt( a * a + b * b - 2*a*b*std::cos(c/180*pi));
    
    
    std::cout << std::setprecision(20);
    std::cout << S << std::endl;
    std::cout << L << std::endl;
    std::cout << h << std::endl;
    
    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define endl        '\n'
#define pi          2*acos(0.0)
#define pb(a)       push_back(a)
#define db          double
#define ld          long double
#define ll          long long
#define ull         unsigned long long
#define mod         1000000007
#define inf         1000000000000000001
#define sqr(x)      (x) * (x)
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)   ((a/gcd(a,b)) * b)
#define debug(x) 	cerr << #x << " = " << (x) <<endl
#define all(x)      (x).begin(), (x).end()
#define unsyncIO    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)


using namespace std;

int main()
{
    //freopen("/home/taalpatar_shepai/Documents/my_codes/out.txt", "w", stdout);
    int k, x;
    cin >> k >> x;
    if((k*500) >= x)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3592
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!int;
  
  bool f;
  foreach (i; 1..10) {
    foreach (j; 1..10) {
      if (i * j == n) {
        f = true;
      }
    }
  }
  if (f) {
    writeln("Yes");
  } else {
    writeln("No");
  }
}


Measured memory_bytes: 256
void main() {
	auto ip = readAs!(string[]), S = ip[0], T = ip[1];
	writeln(T ~ S);
}

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

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: 256
using System;
using System.Collections.Generic;
using System.Linq;

public static class Common
{
    public static void Increment<T>(this Dictionary<T, long> dict, T key)
    {
        if (dict.ContainsKey(key))
        {
            dict[key]++;
        }
        else
        {
            dict[key] = 1;
        }
    }

    public static void Decrement<T>(this Dictionary<T, long> dict, T key)
    {
        if (dict.ContainsKey(key))
        {
            dict[key]--;
        }
        else
        {
            dict[key] = -1;
        }
    }

    public static long Get<T>(this Dictionary<T, long> dict, T key)
    {
        long count = 0;
        dict.TryGetValue(key, out count);
        return count;
    }
}

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = vals[0];
        var K = vals[1];
        var A = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var acc = new long[N + 1];
        for (int i = 1; i <= N; i++)
        {
            acc[i] += acc[i - 1] + A[i - 1];
        }
        var mods = new long[N + 1];
        for (int i = 0; i <= N; i++)
        {
            mods[i] = (acc[i] - i) % K;
        }

        var dict = new Dictionary<long, long>();
        long count = 0;
        for (int j = 1; j <= N; j++)
        {
            var prevLeft = j - 1 - K + 1;
            if (prevLeft >= 0)
            {
                dict.Decrement(mods[prevLeft]);
            }

            var i = j - 1;
            dict.Increment(mods[i]);
            count += dict.Get(mods[j]);
        }

        Console.WriteLine(count);
    }
}

Measured memory_bytes: 53204
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> arr(n);
    for (int i=0; i<n; i++) {
        cin >> arr[i];
    }
    for (int i=n-1; i>0; i--) {
        if (arr[i] < arr[i-1]) arr[i-1]--;
    }
    for (int i=0; i<n-1; i++) {
        if (arr[i] > arr[i+1]) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}

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

namespace Program
{
    public class AGC033B
    {
        static class Console_
        {
            private static Queue<string> param = new Queue<string>();
            public static int NextInt() => int.Parse(NextString());
            public static long NextLong() => long.Parse(NextString());
            public static string NextString()
            {
                if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item);
                return param.Dequeue();
            }
        }

        static public void Main(string[] args)
        {
            var H = Console_.NextInt();
            var W = Console_.NextInt();
            var N = Console_.NextInt();
            var sr = Console_.NextInt();
            var sc = Console_.NextInt();
            var S = Console_.NextString().ToArray();
            var T = Console_.NextString().ToArray();

            var safeL = 1;
            var safeR = W;
            var safeU = 1;
            var safeD = H;
            for (int i = N - 1; i >= 0; --i)
            {
                if (i < N - 1)
                {
                    if (T[i] == 'L' && safeR < W) ++safeR;
                    else if (T[i] == 'R' && safeL > 1) --safeL;
                    else if (T[i] == 'U' && safeD < H) ++safeD;
                    else if (T[i] == 'D' && safeU > 1) --safeU;
                }
                if (S[i] == 'L') ++safeL;
                else if (S[i] == 'R') --safeR;
                else if (S[i] == 'U') ++safeU;
                else if (S[i] == 'D') --safeD;
                if (safeL > safeR || safeU > safeD)
                {
                    Console.WriteLine("NO");
                    return;
                }
            }

            if (safeL <= sc && sc <= safeR && safeU <= sr && sr <= safeD)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


Measured memory_bytes: 16992
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main()
{
	int i;
	int len;
	char str[1001];
	char answer[1001] = "\0";
	char a = 'a',
	     c = 'c',
	     e = 'e',
	     h = 'h',
	     l = 'l',
	     p = 'p';
	fgets(str, sizeof(str), stdin);
	len = strlen(str);
	for(i=0; i<len-5; i++){
		if(str[i]==a){
			if(str[i+1]==p){
				if(str[i+2]==p){
					if(str[i+3]==l){
						if(str[i+4]==e){
							str[i]   = p;
							str[i+1] = e;
							str[i+2] = a;
							str[i+3] = c;
							str[i+4] = h;
						}
					}
				}
			}
		}
		else if(str[i]==p){
			if(str[i+1]==e){
				if(str[i+2]==a){
					if(str[i+3]==c){
						if(str[i+4]==h){
							str[i]   = a;
							str[i+1] = p;
							str[i+2] = p;
							str[i+3] = l;
							str[i+4] = e;
						}
					}
				}
			}
		}
	}
	printf("%s", str);
	return 0;
}

Measured memory_bytes: 524
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<map>
using namespace std;
char a[200010];
map<char,int> p;
int main()
{
    int i,j,k,t1,t2;
    long long s;
    while(scanf("%s",a)!=EOF)
    {
        s=1;
    k=strlen(a);
    p[a[0]]=1;
    for(i=1;i<k;i++)
    {
      if(p[a[i]]==0)
      s=s+i;
      else
      s=s+i-p[a[i]];
      p[a[i]]++;
    }
    printf("%lld\n",s);
    }
    return 0;
}


Measured memory_bytes: 384
n, m, c = gets.chomp.split.map(&:to_i)
b = gets.chomp.split.map(&:to_i)
z = 0
n.times do |i|
  a = gets.chomp.split.map(&:to_i)
  s = c
  m.times do |j|
    s += a[j] * b[j]
  end
  z += 1 if s > 0
end
p z

Measured memory_bytes: 1788
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
#define X real()
#define Y imag()
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
#define prev(P, i) P[(i+P.size()-1) % P.size()]
#define diff(P, i) (next(P, i) - curr(P, i))
const double EPS = 1e-8;
const double INF = 1e12;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}

typedef vector<P> G;

double compare_x(const P &a, const P &b){
  return a.X != b.X ? a.X < b.X : a.Y < b.Y;
}

double compare_y(const P &a, const P &b){
  return a.Y != b.Y ? a.Y < b.Y : a.X < b.X;
}

double convex_radius(P *a, int n){
    if(n<=1)return INF;
    int m=n/2;
    double x=a[m].X;
    double d=min(convex_radius(a, m), convex_radius(a+m, n-m));
    sort(a, a+n, compare_y);
    vector<P> b;
    for(int i=0; i<n; i++){
        if(fabs(a[i].X-x)>=d)continue;
        for(int j=0; j<b.size(); j++){
            double dx=a[i].X-b[b.size()-j-1].X;
            double dy=a[i].Y-b[b.size()-j-1].Y;
            if(dy>=d)break;
            d=min(d,sqrt(dx*dx+dy*dy));
              
        }
        b.push_back(a[i]);
    }
    return d;
}

int main() {
  int N; cin >>N;
  G g(N);
  REP(i, N){
    double x, y; cin >>x >>y;
    g[i] = P(x, y);
  }
  sort(g.begin(), g.end(), compare_x);
  printf("%.10lf\n", convex_radius(&g[0], N));
  return 0;
}

Measured memory_bytes: 5616
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import re
import string

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

ans = 0
if Ps[-1] == N:
    Ps[-1], Ps[-2] = Ps[-2], Ps[-1]
    ans += 1

for i in range(N-1):
    if Ps[i] == i + 1:
        Ps[i], Ps[i+1] = Ps[i+1], Ps[i]
        ans += 1
print(ans)


Measured memory_bytes: 15956
#include<iostream>
using namespace std;
using LL = long long;

int main() {
	LL N;
	cin >> N;
	LL t1 = N / 500;
	LL t2 = (N % 500) / 5;
	cout << t1 * 1000 + t2 * 5 << endl;
	return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>
main(){
  double heikin;
  int gokei=0,sum=0,a,b,i=0;

  while(scanf("%d,%d",&a,&b)!=EOF){
    gokei=gokei+a*b;
    sum+=b;
    i++;
  }
  heikin=(double)(sum)/(double)(i)+0.5;
  printf("%d\n%.0f\n",gokei,heikin);
  return 0;
}

Measured memory_bytes: 628
a,b,= map(int,input().split())
import math
c=[a,b]
sum=0

for i in range(0,2):
    if c[i]==3:
        sum+=100000
    elif c[i]==2:
        sum+=200000
    elif c[i]==1:
        sum+=300000

if c[0]==1 and c[1]==1:
    sum+=400000

print(int(sum))

Measured memory_bytes: 3064
#include <string>
#include <vector>
#include <cstring>
#include <algorithm>
#include <iostream> 
#include <cmath>
#include <map>
#include <queue>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
const ll MOD=ll(1e9+7);
 
//repetition
#define REP(i,n)  for(ll i=0;i<n;i++)
 
ll P_POW(ll i, ll n) {
  if(n==0) return 1;
 
  n--;
  ll rep = i;
 
  while(n) {
    rep = rep * i;
    n--;
  }
  return rep;
} 
 
unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
 
unsigned binarySearch(ll target, ll max, ll min) {
  while((max - min) > 1) {
      if((max + min)/2 > target) {
        max = (max + min)/2;
        min = min;
      } else {
        max = max;
        min = (max + min)/2;
      }
    }
}
 
ll solve(ll n) {
    if (n % 2 == 1) return 0;
 
    ll res = 0;
    n /= 2;
    int c = 1;
 
    while ((ll) n/((ll)pow(5,c))) {
      res += n/P_POW(5,c);
      c++;
    }
    return res;
}
 
void f(int rest, string s) {
  char abc[] = "abc";
  if(rest == 0) {
    cout << s << endl;
  } else {
    for(int i=0; i < 3; i++) {
      f(rest - 1, s+abc[i]);
    }
  }
} 


ll h, w;

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

// origin (ox, oy) destination (dx, dy)
ll dfs(ll ox, ll oy, vector<vector<char>> v, vector<vector<int>> dist) {

  int m = 0;
  for (int i = 0; i < 4; i++) {
    int nx = ox+dx[i], ny = oy + dy[i];
    if(nx < 0 || nx >= w || ny < 0 || nx >= h) continue;
    if(v[nx][ny] != '.') continue;

    if(dist[nx][ny] == -1) {
      dist[nx][ny] = dist[ox][oy] + 1;

      dist[nx][ny] = min(dist[ox][oy], dist[nx][ny]);

      cout << "v[nx][ny]: " << dist[nx][ny] << endl;
      /*
      cout << "dx: " << dx << endl;
      cout << "dy: " << dy << endl;
      cout << "v[ox][oy]: " << v[ox][oy] << endl;
      cout << "(nx, ny)" << "("<< nx << "," << ny << ")"<< endl;
      */
      dfs(nx, ny, v, dist);
    }
    m = max(m, dist[nx][ny]);
  }
  return m;
}

int bfs2(const vector<string> &v, int x, int y) {
    int H = v.size(), W = v[0].size();
    vector<vector<int>> dist(H, vector<int>(W, -1));
    queue<pair<int,int>> que;

    int res = 0;
    que.push({x, y});
    dist[x][y] = 0;
    while (!que.empty()) {
        int x = que.front().first, y = que.front().second;
        res = max(res, dist[x][y]);
        que.pop();
        cout << "-------" << endl;
        //cout << "(nx, ny)" << "("<< nx << "," << ny << ")"<< endl;
        cout << "(x, y)" << "("<< x << "," << y << ")"<< endl;
        for (int dir = 0; dir < 4; ++dir) {
            int nx = x+ dx[dir], ny = y + dy[dir];
            //cout << "v[nx][ny]: " << v[nx][ny] << endl;
            if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            if (v[nx][ny] == '#') continue;
            if (dist[nx][ny] == -1) {
                cout << "(nx, ny)" << "("<< nx << "," << ny << ")"<< endl;
                dist[nx][ny] = dist[x][y] + 1;
                que.push({nx, ny});
            }
        }
    }
    return res;
}
 
int main() {
  ll n, m;
  cin >> n >> m;
  if(n == m) cout << "Yes";
  else cout << "No";
}



Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	int i;
	int A,B,C;
	cin >> A >> B >> C;
	cout << A << ' ' << B << ' ' << 3*C-A-B << endl;
	cout << 4*C-2*A-B << ' ' << C << ' ' << 2*A+B-2*C << endl;
	cout << A+B-C << ' ' << 2*C-B << ' ' << 2*C-A << endl;

	return 0;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 924844033LL;

int N, K;
int cur[2010][2], nxt[2010][2];

signed main() {
    cin >> N >> K;

    vector<int> order, state;
    for(int i=0; i<2*K; i++) {
        if(i >= N) continue;
        for(int j=i; j<N; j+=2*K) {
            order.push_back(j);

            // state について
            // 0 bit: 左が取れる
            // 1 bit: 右が取れる
            // 2 bit: 最初の要素
            bool b1 = (j - K >= 0);
            bool b2 = (j + K <  N);
            bool b3 = (i == j);
            int s = (b3 << 2) | (b2 << 1) | b1;
            state.push_back(s);
        }
    }

    cur[0][0] = 1;
    for(int i=0; i<N; i++) {
        int s = state[i];
        for(int j=0; j<=i; j++) {
            // 左を取って増やす
            // ・最初の要素なら常に可能
            // ・そうでなければ前で右を取っていないなら可能
            if(s & 1) {
                if(s & 4) nxt[j+1][0] += cur[j][0] + cur[j][1];
                else nxt[j+1][0] += cur[j][0];
            }
            // 右を取って増やす (要素があるなら常に可能)
            if(s & 2) nxt[j+1][1] += cur[j][0] + cur[j][1];
            // なにも取らない
            nxt[j][0] += cur[j][0] + cur[j][1];

            while(nxt[j+1][0] >= MOD) nxt[j+1][0] -= MOD;
            while(nxt[j  ][0] >= MOD) nxt[j  ][0] -= MOD;
            while(nxt[j+1][1] >= MOD) nxt[j+1][1] -= MOD;
            while(nxt[j  ][1] >= MOD) nxt[j  ][1] -= MOD;

            cur[j][0] = cur[j][1] = 0;
        }
        swap(cur, nxt);
    }

    vector<int> fact(N+1); fact[0] = 1;
    for(int i=1; i<=N; i++) {
        fact[i] = (fact[i-1] * i) % MOD;
    }

    int ans = 0;
    for(int i=0; i<=N; i++) {
        int val = (cur[i][0] + cur[i][1]);
        if(val >= MOD) val -= MOD;
        
        (val *= fact[N-i]) %= MOD;
        if(i % 2) ans += MOD - val;
        else ans += val;
    }
    ans %= MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream> 
#include <vector> 
#include <algorithm> 
#include <bits/stdc++.h> 
#include <stdlib.h> 
#include <stdio.h> 
#include <functional> 
#include<math.h> 
#include<cstring>
using namespace std;
int main(void){
    // Your code here!
    int n;
    string s;
    cin >> s;
    n = s.size();
    int count_0 = 0,count_1 = 0;
    for(int i = 0; i < n; i++){
        if(s.at(i) == '0'){
            count_0++;
        }
        else{
            count_1++;
        }
    }
    int m;
    m = min(count_0,count_1);
    cout << 2 * m << endl;
    
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <queue>
#include <numeric>
#include <iomanip>
#define ll long long
using namespace std;
const int MAXN = 100005;
ll arr[MAXN],brr[MAXN];
int main(){
    int n; cin>>n;
    ll sa = 0,sb=0;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
        sa+=arr[i];
    }
    for(int i=1;i<=n;i++){
        cin>>brr[i];
        sb+=brr[i];
    }
    //a + 2x , b + y
    if(sa > sb){
        cout<<"No"; exit(0);
    }
    long long d1 = 0,d2 = 0;
    for(int i=1;i<=n;i++){
        int low = 0;
        int high = 1e9;
        ll ans = 2e9;
        ll b = brr[i];
        ll a = arr[i];
        while(low<=high){
            int mid = (low+high)/2;
            if(mid * 2 + a - b >= 0){
                high = mid - 1;
                ans = mid;
            }
            else{
                low = mid + 1;
            }
        }
        ll x = ans;
        ll y = a + 2 * x - b;
        d1 = d1 + x;
        d2 = d2 + y;
    }
    if(d1 >= d2){
        cout<<"Yes";
    }
    else cout<<"No";
    
    return 0;
}


/*
 
 */


Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<utility>
using namespace std;

#define EPS 1.0e-10

int main()
{
	double xa,ya,xb,yb,xc,yc,xd,yd;
	while(cin>>xa>>ya>>xb>>yb>>xc>>yc>>xd>>yd){
		if(abs((xb-xa)*(xd-xc)+(yb-ya)*(yd-yc)) < EPS) cout<<"YES"<<endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
X=int(input())
k=breaknum=1
while(True):
    for n in range(-118,120):
        x=n**5-(n-k)**5
        if X==x:
            print("{0} {1}".format(n,n-k))
            breaknum=-1
            break
    k+=1
    if breaknum==-1:
        break

Measured memory_bytes: 9112
fun main(args: Array<String>) {
    val (n, m) = readInputLine().split(" ").map { it.toInt() }
    
    val anqList = mutableMapOf<Int, Int>()
    
    // 初期化
    for (i in 1..m) {
        anqList.put(i, 0)
    }
    
    for (i in 0 until n) {
        val inputs = readInputLine().split(" ").map { it.toInt() }
        
        val k = inputs[0]
        
        for (j in 1..k) {
            anqList.put(inputs[j], anqList.get(inputs[j])!! + 1)
        }
    }
    
    var ans = 0
    
    for (i in 1..m) {
        if (anqList.get(i)!! == n) {
            ans++
        }
    }
    
    println(ans)
}
 
fun readInputLine(): String {
    return readLine()!!
}

Measured memory_bytes: 37932
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //昇順
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a+b+c >= 22){
    cout << "bust" << endl;
  }else{
    cout << "win" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	char s[5000];
	scanf("%s", s);
	int k;
	scanf("%d", &k);
	int n=strlen(s);
	set<string> st;
	for(int j=1; j<=k; j++){
		for(int i=0; i<=n-j; i++){
			string str;
			for(int t=0; t<j; t++){
				str+=s[i+t];
			}
			st.insert(str);
		}
	}
  int m=0;
	for(auto itr=st.begin(); itr!=st.end(); itr++){
      if(m==k-1) cout << *itr << endl;
      m++;
    }
	
	return 0;
}

Measured memory_bytes: 1664
/**
 *    author:  tourist
 *    created: 01.08.2019 14:06:11       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, a, b;
  cin >> n >> a >> b;
  if (a % 2 == b % 2) {
    cout << abs(a - b) / 2 << '\n';
  } else {
    long long up = ((a - 1) + (b - 1) + 1) / 2;
    long long down = ((n - a) + (n - b) + 1) / 2;
    cout << min(up, down) << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL
#define MAX 500001
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;

Node treeMinimum(Node x){
while(x->left!=NIL){
  x=x->left;
}
return x;
}

Node treeMaximum(Node x){
while(x->right!=NIL){
  x=x->right;
}
return x;
}

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

Node treeSuccessor(Node x){
Node y;
if(x->right !=NIL) return treeMinimum(x->right);

y=x->parent;
while ( y !=NIL && x == y->right) {
  x=y;
  y=y->parent;
}
return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
if(z->left == NIL || z->right ==NIL){
  y=z;
}
else y= treeSuccessor(z);

if(y->left != NIL) x=y->left;
else x=y->right;

if(x !=NIL) x->parent=y->parent;
if(y->parent==NIL) root=x;
else if(y==y->parent->left) y->parent->left=x;
else y->parent->right=x;

if(y!=z) z->key=y->key;
}

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==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 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");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20484
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int H[200005];
int main(void)
{
	int  N , A;
	cin >> N >> A;
	for(int i=0;i<N;i++)
	{
		cin >> H[i];
	}
	sort(H, H+N);
	long long sum=0;
	for(int i=0;i<N-A;i++)
	{
		sum+=H[i];
	}
	cout << sum;

	return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
vector<P> v;
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		v.emplace_back(A, i);
	}
	sort(v.begin(), v.end());
	int sum = 0;
	for (int i = 0; i < N; i++) {
		if (i % 2 != v[i].second % 2) sum++;
	}
	cout << sum / 2 << endl;
}

Measured memory_bytes: 1400
n = int(input())
route, ans = [], []
for i in range(n-1):
    a = list(map(int, input().split()))
    route.append(a)

for i in range(n-1):
    c = route[i][0]+route[i][1]
    for j in range(i+1, n-1):
        if c < route[j][1]:
            c = route[j][0]+route[j][1]
        elif (c-route[j][1])%route[j][2] == 0:
            c += route[j][0]
        else:
            c += route[j][0]+route[j][2]-(c-route[j][1])%route[j][2]
    ans.append(c)
ans.append(0)
for i in ans:
    print(i)


Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
template <class T> T input() {T t; cin>>t; return t;}
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define CHMAX(a,b) a = max(a,b)
#define CHMIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define PRINT_ARRAY_H(i,a) REPALL(i,a) {cout<<a[i]<<(i != a.size()-1 ? " " : "");} newline;
#define e1 first
#define e2 second
#define newline putchar('\n')
#define cspace ' '
#define sspace " "
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;
const VI dx = {1, 0, -1, 0};
const VI dy = {0, 1, 0, -1};

priority_queue<pair<int, int>> pq;

int main()
{
    ll n,ans=0;
    cin>>n;
    VI a(n);
    REP(i,n) {
        cin>>a[i];
    }
    SORT(a);
    pq.push(make_pair(a[n-2], a[n-1]));
    pq.push(make_pair(a[n-2], a[n-1]));
    ans += a[n-1];

    REP(i,n-2) {
        auto p = pq.top();
        pq.pop();
        ans += p.e1;
        pq.push(make_pair(a[n-3-i], p.e1));
        pq.push(make_pair(a[n-3-i], p.e2));
        //cout<<p.e1<<sspace<<p.e2<<endl;
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 6052
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
void in(){}
template<typename F, typename... R>
bool in(F& f, R&... r){
    if(cin >> f){in(r...);return true;}
    else return false;
}
#define out(x) cout << (x)
#define space() cout << " "
#define indent() cout << '\n'
void print(){}
template<typename F, typename... R>
void print(F f, R... r){out(f), indent(), print(r...);}
#define debughead(x) cerr << "Line " << __LINE__ << ": " << #x << ": "
#define debugout(x) cerr << (x) << " "
#define debugindent() cerr << '\n'
#define debug(x) debughead(x), debugout(x), debugindent()
const int INF = 1e18, MOD = 1e9 + 7;
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

main(){
    INCANT;
    int n, q, l, r, res = 0;
    string s;
    in(n, q, s);
    int sum[n] = {};
    rep(i, 1, s.size()){
        sum[i] = sum[i - 1];
        if(s[i] == 'C' && s[i - 1] == 'A'){
            sum[i]++;
        }
        debug(sum[i]);
    }
    rep(i, q){
        in(l, r);
        l--, r--;
        print(sum[r] - sum[l]);
    }
}


Measured memory_bytes: 1872