akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;


vector<int> union_find_parent;
int union_find_init(int n);
int union_find_unite(int a,int b);
int union_find_root(int a);


int main()
{

	int v,e;
	cin >> v >> e;

	vector<tuple<int,int,int>> edge(e);
	for (int i=0;i<e;++i)
	{
		int s,t,w;
		cin >> s >> t >> w;
		edge[i]=make_tuple(w,s,t);
	}
	sort(edge.begin(),edge.end());

	for (int i=0;i<e;++i)
	{
		int s,t,w;
		tie(w,s,t)=edge[i];
		//fprintf(stderr,"%d %d %d\n",s,t,w);
		
	}

	union_find_init(v);
	int total=0;
	for (int i=0;i<e;++i)
	{
		int w,s,t;
		tie(w,s,t)=edge[i];
		if (union_find_root(s)!=union_find_root(t))
		{
			union_find_unite(s,t);
			total+=w;
		}
	}

	cout << total << endl;

}


int union_find_init(int n)
{
	for (int i=0;i<n;++i)
	{
		union_find_parent.push_back(i);
	}
	return 0;
}

int union_find_unite(int a,int b)
{
	a=union_find_root(a);
	b=union_find_root(b);
	if (a!=b)
	{
		union_find_parent[a]=b;
	}
	return 0;
}

int union_find_root(int a)
{
	if (union_find_parent[a]==a)
	{
		return a;
	}
	else
	{
		return union_find_parent[a]=union_find_root(union_find_parent[a]);
	}
}





Measured memory_bytes: 4200
X = 1
Y = 0

class Editor
  def initialize
    @text = []
    @buffer = ''
    @cursor = [0, 0]
  end

  def line_start?
    @cursor[Y] == 0
  end

  def line_end?
    @cursor[Y] == @text.size - 1
  end

  def str_start?
    @cursor[X] == 0
  end

  def str_end?
    y = @cursor[Y]
    @cursor[X] == @text[y].size
  end

  def character?
    (not str_end?)
  end

  attr_accessor :text, :buffer, :cursor
end

class CommandA
  def self.execute editor
    editor.cursor[X] = 0
  end
end

class CommandE
  def self.execute editor
    y = editor.cursor[Y]
    editor.cursor[X] = editor.text[y].size
  end
end

class CommandP
  def self.execute editor
    editor.cursor[Y] -= 1 unless editor.line_start?
    editor.cursor[X] = 0
  end
end

class CommandN
  def self.execute editor
    editor.cursor[Y] += 1 unless editor.line_end?
    editor.cursor[X] = 0
  end
end

class CommandF
  def self.execute editor
    y = editor.cursor[Y]
    if not editor.str_end?
      editor.cursor[X] += 1
    elsif not editor.line_end?
      editor.cursor[Y] += 1
      editor.cursor[X] = 0
    end
  end
end

class CommandB
  def self.execute editor
    if not editor.str_start?
      editor.cursor[X] -= 1
    elsif not editor.line_start?
      editor.cursor[Y] -= 1
      y = editor.cursor[Y]
      editor.cursor[X] = editor.text[y].size
    end
  end
end

class CommandD
  def self.execute editor
    x = editor.cursor[X]
    y = editor.cursor[Y]

    if editor.character?
      editor.text[y].slice!(x)
    elsif editor.str_end? and not editor.line_end?
      editor.text[y] << editor.text[y+1]
      editor.text.slice!(y+1)
    end
  end
end

class CommandK
  def self.execute editor
    x = editor.cursor[X]
    y = editor.cursor[Y]

    if editor.character?
      editor.buffer = editor.text[y].slice!(x..-1)
    elsif editor.str_end? and not editor.line_end?
      editor.buffer = '\n'
      editor.text[y] << editor.text[y+1]
      editor.text.slice!(y+1)
    end
  end
end

class CommandY
  def self.execute editor
    unless editor.buffer.empty?
      x = editor.cursor[X]
      y = editor.cursor[Y]

      if editor.buffer == '\n'
        str = editor.text[y].slice!(x..-1)
        editor.text.insert(y+1, str)
        editor.cursor[X] = 0
        editor.cursor[Y] += 1
      else
        editor.text[y].insert(x, editor.buffer)
        editor.cursor[X] += editor.buffer.size
      end
    end
  end
end

def main
  editor = Editor.new
  loop do
    line = gets.chomp
    break if line == 'END_OF_TEXT'
    editor.text << line
  end

  command_list = []
  loop do
    command = gets.chomp
    break if command == '-'
    command_list << command
  end

  command_list.each do |command|
    eval("Command#{command.upcase}").execute(editor)
  end

  editor.text.each {|line| puts line}
end

main

Measured memory_bytes: 6232
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main(void)
{
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    int ans = 0, active = 0;
    rep(i,n){
        if(active >= h[i]) active = h[i];
        else{
            ans += h[i] - active;
            active = h[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
import sys
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
b = []

for _ in range(m):
    b += [list(map(int, input().split()))]
b = sorted(b, key=lambda x: x[1], reverse=True)

for i in range(m):
    for j in range(b[i][0]):
        if a[0] < b[i][1]:
            a.pop(0)
            a.append(b[i][1])
        else:
            print(sum(a))
            sys.exit()
print(sum(a))
            



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

multiset<int> PQ;

int N, Ans;

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

	cin >> N;
	for(int i = 0, c; i < N; i++) {
		cin >> c;
		PQ.insert(c);
	}

	for(int c; !PQ.empty();) {
		c = *prev(PQ.end());
		PQ.erase(prev(PQ.end()));
		for(int j = 1, t; j <= 31; j++) {
			t = (1ll<<j) - c;
			auto it = PQ.find(t);
			if(PQ.end() == it) continue;
			PQ.erase(it);
			Ans++;
			break;
		}
	}

	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int cnt = x / 100;
        int n = x % 100;
        cnt -= n / 5;
        n %= 5;
        cnt -= n / 4;
        n %= 4;
        cnt -= n / 3;
        n %= 3;
        cnt -= n / 2;
        n %= 2;
        if (cnt - n >= 0) {
            System.out.println(1);
            return;
        }
        System.out.println(0);
    }

}


Measured memory_bytes: 23764
#include<iostream>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef pair<int, int> P;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
bool solve(priority_queue<P, vector<P>, greater<P> > q) {
  int weight = 0;
  while (!q.empty()) {
    P p = q.top(); q.pop();
    weight += p.second;
    if (weight > 150) return false;
  }
  return true;
}

int main() {
  int n;
  while (cin >> n and n) {
    priority_queue<P, vector<P>, greater<P> > q;
    REP(i, n) {
      int m, a, b;
      cin >> m >> a >> b;
      q.push(P(a, m));
      q.push(P(b, -m));
    }

    cout << (solve(q) ? "OK" : "NG") << endl;
  }
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define x first
#define y second
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define plll pair <pair <ll, ll>, ll>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
#define psl pair <string, ll>
#define all(a) a.begin(), a.end()
#define vvl vector <vector <ll> >

typedef long long ll;

typedef long double ld;

using namespace std;

const ll maxn = 1e6;
const ll inf = 1e14;

ll n, m, k, t;

string s;

ll st2[maxn];

ll A[maxn];

ll leading_bit(ll x) {
    for (ll q = 62; q >= 0; q++) {
        if ((st2[q] & x) != 0) {
            return q;
        }
    }
    return -1;
}

int main() {
    pyshnapyshnakaa;
    ll q, w, e, a, b, c;
    st2[0] = 1;
    for (q = 1; q < 63; q++) {
          st2[q] = st2[q - 1] * 2;
    }
    cin >> t;
    for (e = 0; e < t; e++) {
        cin >> n;
        for (q = 0; q < n; q++) {
            cin >> A[q];
        }
        bool fail = 0;
        cin >> s;
        vector <ll> basis;
        for (q = n - 1; q >= 0; q--) {
            if (s[q] == '1') {
                ll x = A[q];
                for (auto y : basis) {
                    if ((x ^ y) < x) {
                        x = x ^ y;
                    }
                }
                if (x != 0) {
                    fail = 1;
                }
            }
            else {
                ll x = A[q];
                for (auto y : basis) {
                    if ((x ^ y) < x) {
                        x = x ^ y;
                    }
                }
                if (x != 0) {
                    basis.pb(x);
                    sort(all(basis));
                    reverse(all(basis));
                }
            }
        }
        if (fail) {
            cout << 1 << '\n';
        }
        else {
            cout << 0 << '\n';
        }
    }
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string.h>
#include <queue>
#include <functional>
const int INF =1e5;
const int MOD = 1e9 + 7;
using namespace std;
typedef pair<int,int> P;
typedef long long lint;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fill(x,y) memset(x,y,sizeof(x))
#define all(x) (x).begin(),(x).end()

int main(){
    int a,b,c,x;
    cin>>a>>b>>c>>x;
    int count=0;
    for(int i=a;i>=0;i--){
        for(int j=b;j>=0;j--){
             for(int k=c;k>=0;k--){
                if((500*i+100*j+50*k)==x){
                    count++;
                }
            }

         }
    }
    cout<<count<<endl;
    return 0;

}


Measured memory_bytes: 256
function Main(input) {
  var tmp = input.split(' ');
  var N = parseInt(tmp[0], 10);
  var L = parseInt(tmp[1], 10);
  var leastAbsTaste = Math.abs(L) + N;
  var pieTaste = 0;
  for(var i = 1; i <= N; i++) {
    var taste = L + i - 1;
    if ( Math.abs(taste) < Math.abs(leastAbsTaste)) {
      leastAbsTaste = taste;
    }
    pieTaste += taste;
  }
  pieTaste -= leastAbsTaste;
  console.log(pieTaste);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
#include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
typedef pair<int, int> P;
int W, H;
int X[102][102];
int dx1[6] = { -1, 0, 0, 1, 1, 1 };
int dy1[6] = { 0, -1, 1, -1, 0,1};
int dx2[6] = { -1, -1, -1, 0, 0, 1 };
int dy2[6] = { -1, 0, 1, -1, 1, 0 };
int main()
{
	scanf("%d%d", &W, &H);
	for (int i = 1; i <= H; i++){
		for (int j = 1; j <= W; j++){
			scanf("%d", &X[j][i]);
		}
	}
	
	for (int j = 1; j <= W; j++){
		for (int i = 1; i <= H; i++){
			if (X[j][i] == 0){
				bool F[102][102];
				for (int k = 0; k < 102; k++)for (int l = 0; l < 102; l++)F[k][l] = X[k][l]&1;
				priority_queue<P>que;
				que.push(make_pair(j,i));
				while (!que.empty()){
					P p = que.top(); que.pop();
					if (p.second == 0 || p.second == H + 1 || p.first == 0 || p.first == W + 1)goto aa;
					if (X[p.first][p.second]||F[p.first][p.second])continue;
					F[p.first][p.second] = true;
					if (p.second & 1){
						//if (i == 5 && j == 4)printf("%d %d\n", p.first, p.second);
						for (int k = 0; k < 6; k++){
							//if (i == 5 && j == 4)printf("%d %d %d\n", p.first + dx1[k], p.second + dy1[k], F[p.first+dx1[k]][p.second+dy1[k]]);


							if (!F[p.first + dx1[k]][p.second + dy1[k]]){
								que.push(make_pair(p.first + dx1[k], p.second + dy1[k]));
							}
						}
					}
					else{
						for (int k = 0; k < 6; k++){
							if (!F[p.first + dx2[k]][p.second + dy2[k]]){
								
								que.push(make_pair(p.first + dx2[k], p.second + dy2[k]));
							}
						}
					}
					//if (i == 5 && j == 4)printf("%d\n", que.size());
				}
				X[j][i] = 1; aa:;
			}
		}
	}
	
	int ans = 0;
	for (int i = 1; i <= W; i++){
		for (int j = 1; j <= H; j++){
			if (X[i][j] == 1){
				if (j & 1){
					for (int k = 0; k < 6; k++){
						if (!X[i + dx1[k]][j + dy1[k]])ans++;
					}
				}
				else{
					for (int k = 0; k < 6; k++){
						if (!X[i + dx2[k]][j + dy2[k]])ans++;
					}
				}
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1252
//#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);
    int n;
    cin >> n;
    map<ll,ll> cnt;
    rep(i,n){
        ll k;
        cin >> k;
        cnt[k]++;
    }
    int m;
    cin >> m;
    rep(i,m){
        ll l;
        cin >> l;
        cnt[l]--;
        if(cnt[l]<0){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 16100
N = int(input())
a = list(map(int, input().split()))
flag = 1
z = 0
while flag:
  flag = 0
  for j in range(N - 1, 0, -1):
    if a[j] < a[j - 1]:
      a[j - 1], a[j] = a[j], a[j - 1]
      flag = 1
      z += 1
print(*a)
print(z)

Measured memory_bytes: 7648
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define f first
#define s second
typedef long long ll;
typedef unsigned long long ull;

void IO(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("test.txt","r",stdin);
    #endif
}

const int N=1e6+3,M=1e3+5,mod=1e9+7,dx[]={1,-1,0,0},
                                    dy[]={0,0,1,-1};
const double eps=1e-9;

int tc,n,m,a[N],d,x,k,ans;

char s[N];

vector<int> g[N];

int main(){
    //IO();
    scanf("%d%d",&n,&m);
    for(int i = 0 ; i < n; i++)
        scanf("%d",&a[i]);
    while(m--){
        int u,v;
        scanf("%d%d",&u,&v);
        u--;v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for(int u = 0 ; u < n ; u++){
        bool ok = true;
        for(auto v : g[u])
            ok &= a[v] < a[u];
        ans += ok;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 30432
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<math.h>
#include <iomanip>

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

using namespace std;

const int INF = 1000;

int N;

int main()
{
	string S;

	cin >> S;

	string s[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

	int diff = 7;

	rep(i, sizeof(s)) {
		if (S == s[i]) {
			diff -= i;
			break;
		}
	}

	cout << diff << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
#define mREP(a,b) for (int i = a; i == (b); --i) 
typedef long long ll;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
/*
　　　　　 　 _... ..._
　　　　　 , ´⌒ ⌒ヽ
　　　 　 ﾉｨ（ノﾉ）ﾉ）ﾉ）
　　　 　 （（q|.ﾟ ヮﾟﾉ|ﾊ
　　　　　　△ﾑ,8ﾑﾌつ
　　　　　/(ﾝ_/＿ヽ＼
　　　　 ～～i_ﾌ_ﾌ～´
*/
	int n, q;
	ll ans = 0;
	cin >> n >> q;
	string s;
	cin >> s;
	vector<int>start(q);
	vector<int>end(q);
	vector<ll>count(n + 1);
	count[0] = 0;
	count[1] = 0;
	rep0(i, q - 1) {
		cin >> start[i] >> end[i];
	}
	REP(2, s.length()) {
		if (s[i - 2] == 'A' && s[i - 1] == 'C') {
			ans++;
		}
		count[i] = ans;

	}
	rep0(k, q - 1) {
		cout << count[end[k]] - count[start[k]] << endl;
	}
	return 0;
} 

Measured memory_bytes: 2752
N = int(input())
H = map(int, input().split())

counter = 0
answer = 0
prev_h = 0
for h in H:
    if h <= prev_h:
        counter += 1
    else:
        if answer < counter:
            answer = counter
        counter = 0
    prev_h = h

if answer < counter:
    answer = counter

print(answer)

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

using namespace std;

int main()
{
   int n;
   cin>>n;
   vector<int>v(n);
   for(int i=0;i<n;i++)
   {
       cin>>v[i];
   }
   int ans=0;
   for(int i=0;i<n;i++)
   {
       for(int j=i+1;j<n;j++)
       {
           ans+=(v[i]*v[j]);
       }
   }
   cout<<ans<<endl;
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll n, k, x, y;
	ll ans = 0;

	cin >> n >> k >> x >> y;

	if (n > k) {
		ans = x*k + y*(n - k);
	}
	else {
		ans = x*n;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
class UnionFind:
	def __init__(self, n):
		self.graph = [i for i in range(n)]

	def find(self, n):
		if self.graph[n] == n:
			return n
		self.graph[n] = self.find(self.graph[n])
		return self.graph[n]

	def union(self, n, m):
		self.graph[self.find(self.graph[m])] = self.find(self.graph[n])

N,M=map(int, input().split())
bridge=[[int(x) for x in input().split()] for _ in range(M)]

ans=0

for j in range(M):
	uf = UnionFind(N+1)
	for i in range(M):
		if i == j:
			continue
		uf.union(*bridge[i])
	if len(set([uf.find(n) for n in range(1, N+1)])) > 1:
		ans += 1

print(ans)


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

int n, m;
vector<bool> used(100010);
vector<int> p(100010, 1);

int main()
{
    cin >> n >> m;
    int x[m], y[m];
    used[0] = true;
    for (int i = 0; i < m; i++)
    {
        cin >> x[i] >> y[i];
        x[i]--, y[i]--;
        if (used[x[i]] == true)
        {
            used[y[i]] = true;
            if (p[x[i]] == 1)
                used[x[i]] = false;
        }
        p[x[i]]--, p[y[i]]++;
    }
    int ans = 0;
    for (int i = 0; i < used.size(); i++)
    {
        ans += used[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cctype>

#ifdef GONGKUNPENG
#include <cassert>
#endif

#define GG 1
#define GIO 1
#define uint unsigned
#define max(a, b) std::max((a), (b))
#define min(a, b) std::min((a), (b))
#define sort(...) std::sort(__VA_ARGS__)
#define ms(a, v) memset(a, v, sizeof(a))
#define sfor(i, n) for (int i = 1; i <= n; ++i)
#define tfor(i, n) for (int i = 0; i < n; ++i)

#if __cplusplus >= 201103L
using ll = long long;
using ull = unsigned long long;
#else
typedef long long ll;
typedef unsigned long long ull;
#endif

#if GIO
class GLIB
{
#define BUFSIZE 1 << 20
#define uns(x) (x == ' ' || x == '\t' || x == '\n' || x == '\r')
	char ruf[BUFSIZE], wuf[BUFSIZE], *p, *q, *r, rcha;
	bool rneg;

public:
#if GG
#else
	GLIB() : p(ruf), q(ruf), r(wuf), rcha(' ')
	{
	}

	~GLIB()
	{
		fwrite(wuf, 1, r - wuf, stdout);
	}
#endif
	inline void flush()
	{
		fwrite(wuf, 1, r - wuf, stdout), r = wuf;
	}

	inline int readc()
	{
#if GG
		return getchar();
#else
		return (p == q && (q = (p = ruf) + fread(ruf, 1, BUFSIZE, stdin), p == q) ? -1 : *p++);
#endif
	}

	template <typename T, typename... Args>
	void read(T &x, Args &... args)
	{
		read(x), read(args...);
	}

	inline void read() {}

	inline void read(char *s)
	{
		while (uns(rcha))
			rcha = readc();
		while (!uns(rcha) && rcha > 0)
			*s++ = rcha, rcha = readc();
		*s = '\0';
	}

	inline void readl(char *s)
	{
		while (uns(rcha))
			rcha = readc();
		while (rcha != '\n' && rcha > 0)
			*s++ = rcha, rcha = readc();
		*s = '\0';
	}

	template <typename T>
	inline void read(T &x)
	{
#ifdef GONGKUNPENG
		static_assert(std::is_integral<T>::value);
#endif
		x = rcha = rneg = 0;
		while (!isdigit(rcha) && rcha != '-')
			rcha = readc();
		rcha == '-' && (rneg = true, rcha = readc());
		while (isdigit(rcha))
			x = (x << 3) + (x << 1) - 48 + rcha,
			rcha = readc();
		rneg && (x = -x);
	}

	inline void writec(const char &c)
	{
#if GG
		putchar(c);
#else
		(r - ruf == BUFSIZE) && (fwrite(wuf, 1, BUFSIZE, stdout), r = wuf);
		*r++ = c;
#endif
	}

	template <typename T, typename... Args>
	void write(const T &x, const Args &... args)
	{
		write(x), write(args...);
	}

	inline void write() {}

	inline void write(const char &x)
	{
		writec(x);
	}

	template <typename T>
	void write(T x)
	{
#ifdef GONGKUNPENG
		static_assert(std::is_integral<T>::value);
#endif
		if (x < 0)
		{
			writec('-');
			write(-ll(x));
			return;
		}
		if (x > 9)
			write(x / 10);
		writec(x % 10 ^ 48);
	}

	inline void write(const char *s)
	{
		while (*s)
			writec(*s++);
	}
#undef BUFSIZE
} io;
#endif

const ll INF = 0x3f3f3f3f;
const uint MAXN =
#ifdef GONGKUNPENG
	15
#else
	1000005
#endif
	;

int main()
{
	int n, r;
	io.read(n, r);
	io.write(n > 9 ? r : 1000 - 100 * n + r, '\n');
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
const int maxn=105;
int n,a[maxn][5];
inline void solve()
{
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=2;++j)
			cin>>a[i][j];
	for(int i=1;i<=n-2;++i)
		if(a[i][1]==a[i][2]&&a[i+1][1]==a[i+1][2]&&a[i+2][1]==a[i+2][2])
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	cout<<"No"<<endl;
	return 0;
}


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

int n;
int a[200];

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n;
    n *= 2;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a+n);
    int ans = 0;
    for(int i = n - 2; i >= 0; i -= 2) ans += a[i];
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <math.h>
using namespace std;

int main(void){
    int n;

    cin >> n;
    int high[n];
    for(int i = 0; i < n; i++){
        cin >> high[i];
    }

    int res = 0;
    for(int i = 0; i < n; i++){
        bool flag = true;
        for(int j = 0; j < i; j++){
            if(high[i] < high[j]){
                flag = false;
                break;
            }
        }
        if(flag){
            res++;
        }
    }
    cout << res << endl;

    return 0;
}

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

long a[200000];
long b[200000];

int main(){
	int n;
	scanf("%d", &n);
	long ans = 0;
	bool flag = false;
	long keep = 0;
	for(int i = 0; i < n; i++){
		scanf("%ld%ld", &a[i], &b[i]);
		if(a[i] > b[i]){
			if(b[keep] > b[i]){
				keep = i;
			}
		}
		if(a[i] != b[i]){
			flag = true;
		}
	}
	if(!flag){
		printf("0\n");
		return 0;
	}
	for(int i = 0; i < n; i++){
		if(i != keep){
			ans += a[i];
		}else{
			ans += a[i] - b[i];
		}
	}
	printf("%ld\n", ans);
	return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if (a > b) {
            System.out.println("a > b");
        }else if(a < b) {
            System.out.println("a < b");
        }else if(a == b) {
            System.out.println("a == b");
        }
        
    }
}


Measured memory_bytes: 26224
#include<iostream>
using namespace std;
int main(){
  int h,r;
  cin>>h>>r;
  if(h<0 && h+r<0){
    cout<<-1<<endl;
  }
  else if(h<0 && h+r==0){
    cout<<0<<endl;
  }
  else{
    cout<<1<<endl;
  }
  return 0;
}



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

int N;
int K;
vector<int> p;
int main()
{
    cin>>N;
    cin>>K;
    for(int i=0;i<N;i++){
        int input=0;
        cin>>input;
        p.push_back(input);
    }
    int res=0;
    sort(p.begin(),p.end());
    for(int i=0;i<K;i++){
        res+=p[i];
    }
    cout<<res;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1010, P = 1e9 + 7;
char s[N][N];
ll k;
int n, m, d, c, S, col, row;
ll powmod(ll a, ll b, ll P) {
    ll t = 1;
    for (; b; b >>= 1, a = a * a % P)
        if (b & 1) t = t * a % P;
    return t;
}
int main() {
    scanf("%d%d%lld", &n, &m, &k);
    for (int i = 1; i <= n; i++) {
        scanf("%s", s[i] + 1);
        for (int j = 1; j <= m; j++)
            if (s[i][j] == '#') S++;
        if (s[i][1] == '#' && s[i][m] == '#') row++;
    }
    for (int i = 1; i <= m; i++)
        if (s[1][i] == '#' && s[n][i] == '#') col++;
    if (!row && !col) {
        printf("%d\n", powmod(S, k - 1, P));
        return 0;
    }
    if (!k || (row && col)) {
        puts("1");
        return 0;
    }
    if (row)
        for (int i = 1; i <= n; ++i)
            for (int j = 1; j < m; ++j)
                d += (s[i][j] == '#' && s[i][j + 1] == '#');
    else
        for (int i = 1; i < n; ++i)
            for (int j = 1; j <= m; ++j)
                d += (s[i][j] == '#' && s[i + 1][j] == '#');
    c = row ? row : col;
    int ans = (powmod(S, k - 1, P) - powmod(c, k - 1, P) + P) % P;
    ans = 1ll * ans * d % P;
    ans = 1ll * ans * powmod((S - c + P) % P, P - 2, P) % P;
    printf("%d\n", (powmod(S, k - 1, P) - ans + P) % P);
    return 0;
}

Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    string s;
    cin >> s;

    int cont = 0;
    // 出力
    for(int ct = 0; ct < s.size(); ct++)
    {
        if(s[ct] == '1')
        {
            cont++;
        }
    }
    cout << cont;
    
    return 0;
}


Measured memory_bytes: 256
# include <iostream>
using namespace std;
int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	if (A == 5 && B == 5 && C == 7)
	{
		cout << "YES" << endl;
	}
	else if (A == 5 && C == 5 && B == 7) 
	{
		cout << "YES" << endl;
		}
	else if (B == 5 && C == 5 && A == 7)
	{ 
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;
	return 0;
} 

Measured memory_bytes: 256
n,k=map(int,input().split())
arr=list(map(int,input().split()))
temp=[0]*n
temp[n-2]=abs(arr[n-2]-arr[n-1])
if n>=3:
    i=n-3
    while i>=0:
        idx=i
        count=0
        min1=999999999999
        for j in range(idx+1,n):
            min1=min(min1,abs(arr[j]-arr[idx])+temp[j])
            count+=1
            if count==k:
                break
        temp[idx]=min1
        i-=1
print(temp[0])

Measured memory_bytes: 52448
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        n: usize,
        s: Chars,
    }

    let s = s.into_iter().map(|c| c.to_digit(10).unwrap()).collect::<Vec<_>>();

    let mut count = 0;

    for i in 0..10 {
        for j in 0..10 {
            for k in 0..10 {
                let mut index = 0;
                while index < n {
                    if i == s[index] {
                        index += 1;
                        break;
                    }
                    index += 1;
                }
                while index < n {
                    if j == s[index] {
                        index += 1;
                        break;
                    }
                    index += 1;
                }
                while index < n {
                    if k == s[index] {
                        break;
                    }
                    index += 1;
                }
                if index < n {
                    count += 1;
                }
            }
        }
    }

    println!("{}", count);
}


Measured memory_bytes: 2348
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,n,a) for(int i=n;i>=a;i--)
#define endl '\n'
#define eps 0.000000001
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define IO ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const int INF=0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int maxn=1e5+5;
int main(){
	ll x;cin>>x;
	cout<<x+x*x+x*x*x<<endl;
}


Measured memory_bytes: 3620
a = []
d = {}

def decode():
    global a

    n = int(input())
    a = [int(x) for x in input().split()]

    q = int(input())
    ms = [int(x) for x in input().split()]

    return n, a, q, ms


def solve(i, m):
    global a, d

    if (i, m) in d:
        return d[(i, m)]

    if a[i] == m:
        d[(i, m)] = True
        return True
    else:
        if i < len(a) - 1:

            if solve(i+1, m) or (m - a[i] > 0 and solve(i+1, m-a[i])):
                d[(i, m)] = True
                return True
            else:
                d[(i, m)] = False
                return False

        else:
            d[(i, m)] = False
            return False


if __name__ == '__main__':

    n, a, q, ms = decode()
    for m in ms:
        if solve(0, m):
            print("yes")
        else:
            print("no")



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

using namespace std;

int main() {


    int N; cin >> N;
   
    int except = 0;
    int u = 1;
    for (; u <= N; u++) {
        int sum_zero_to_u = u * (u + 1) / 2;
        if (sum_zero_to_u >= N) {
            int temp = sum_zero_to_u - N;
            if (temp >= 0 and temp < u) {
                except = temp;
                break;
            }
        }
    }
    
    for (int i = 1; i <= u; i++) {
        if (i != except)
            cout << i << '\n';
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

int main(){
  ll N;
  cin >> N;
  ll dp[N+4][4][4][4] = {0};
  dp[0][2][2][2] = 1;
  for(int i = 0; i <= N+2; i++){
    for(int j = 0; j < 4; j++){
      for(int k = 0; k < 4; k++){
        for(int l = 0; l < 4; l++){
          for(int m = 0; m < 4; m++){
            if(k == 0 && j == 1 && m == 3) continue;
            if(k == 1 && j == 0 && m == 3) continue;
            if(k == 0 && j == 3 && m == 1) continue;
            if(l == 0 && j == 1 && m == 3) continue;
            if(l == 0 && k == 1 && m == 3) continue;
            dp[i+1][m][j][k] =  (dp[i+1][m][j][k] +  dp[i][j][k][l]) % mod;
          }
        }
      }
    }
  }
  int ans = 0;
  cout << dp[N+3][2][2][2] << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#define INF 2000000000
#define MAX 500000
//#define SIZE 40
//#define PI 3.14159265359
using namespace std;

int L[MAX / 2 + 2];
int R[MAX / 2 + 2];
int cnt;

void merge(int *A, int n, int left,int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	for (int i = 0; i < n1; i++) L[i] = A[left + i];
	for (int i = 0; i < n2; i++) R[i] = A[mid + i];
	L[n1] = INF;
	R[n2] = INF;
	int i = 0, j = 0;
	for (int k = left; k < right; k++) {
		cnt++;
		if (L[i] <= R[j]) {
			A[k] = L[i];
			i++;
		}
		else {
			A[k] = R[j];
			j++;
		}
	}
}

void mergeSort(int *A, int n, int left, int right) {
	if (left + 1 < right) {
		int mid = (right + left) / 2;
		mergeSort(A, n,left, mid);
		mergeSort(A, n, mid, right);
		merge(A, n, left, mid, right);
	}
}

int main() {
	int n;
	cnt = 0;
	scanf("%d", &n);
	int A[MAX];
	for (int i = 0; i < n; i++) scanf("%d", &A[i]);
	mergeSort(A, n, 0, n);
	for (int i = 0; i < n; i++)
	{
		if (i > 0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n%d\n", cnt);
	return 0;
}

Measured memory_bytes: 6972
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if  (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    string s;
    cin >> s;
    if(s=="Sunny") cout << "Cloudy\n";
    if(s=="Cloudy") cout << "Rainy\n";
    if(s=="Rainy") cout << "Sunny\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

int main(){
	int m,f,r;
	char grade;
	while(true){
		scanf("%d %d %d",&m,&f,&r);
		if(m == -1 && f == -1 && r == -1) break;
		if(m == -1 || f == -1){
			grade = 'F';
		}else if(m+f >= 80){
			grade = 'A';
		}else if(m+f >= 65){
			grade = 'B';
		}else if(m+f >= 50){
			grade = 'C';
		}else if(m+f >= 30){
			grade = (r >= 50)? 'C':'D';
		}else{
			grade = 'F';
		}
		printf("%c\n",grade);
	}
}



Measured memory_bytes: 2756
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rnfor(i,a,b) for(ll (i) = (a) - 1; (i) >= (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

bool check(ll x){
    for (ll i = 2; i * i <= x; ++i) {
        if(x % i == 0)return false;
    }
    return true;
}

int main(){
    ll n;
    cin >> n;
    ll cnt = 0;
    for (ll i = 2; cnt != n; ++i) {
        if(check(5 * i + 1)){
            cout << 5 * i + 1 << " ";
            ++cnt;
        }
    }
    return 0;
}


Measured memory_bytes: 256
/* ****devACE**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		int n,i,j,k;
		cin>>n;
		pair<int,int> p[n];
		for(i=0;i<n;i++){
			cin>>p[i].F;
			p[i].S=(i+1);
		}

		sort(p,p+n);
		for(i=0;i<n;i++)cout<<p[i].S<<" ";
	}
	return 0;
}

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

//i*2^X>=K
//2^X>=
int main() {
	cout << fixed << setprecision(10);
    int N, K;
	cin >> N >> K;
	long double ans = 0;
	for (size_t i = 1; i <= N; i++)
	{
		for (size_t j = 0; j <= 20; j++)
		{
			if (K  <=i* pow(2, j)) { ans += 1.0 / pow(2, j)/N; break; }
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int a,b;
  int c,d,f;
  scanf("%d%d",&a,&b);
  c=a+b;
  d=a-b;
  f=a*b;
  int max=c;
  if(max>d){
    if(max>f){
    }
    else if(max<f){
      max=f;
    }
  }
  else if(max<d){
    max=d;
    if(max>f){
    }
    else if(max<f){
      max=f;
    }
  }
  printf("%d",max);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "a", stdout);
    // #endif
    string s;
    cin >> s;
    int cnt = 0, sol = 0;
    bool flag = false;
    for(int i = 0; i < s.size(); i++) {
        if(!flag) {
            if(s[i] == 'R') {
                flag = true;
                cnt = 1;
            }
        }
        else {
            if(s[i] == 'R') cnt++;
            else {
                flag = false;
                sol = max(sol, cnt);
            }
        }
    }
    sol = max(sol, cnt);
    cout << sol << "\n";
    return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner;
import java.util.*;

public class Main{
    Main(){
	Scanner sc = new Scanner(System.in);
	int[] str;
	while(sc.hasNext()){
	    str = new int[10];

	    for(int i = 0; i < 10; i++)
		str[i] = sc.nextInt();

	    Arrays.sort(str);
	    for(int i = 1, l = str.length; i <= 3; i++)
		System.out.println(Integer.toString(str[l-i]));
	}
    }

    public static void main(String[] args){
	new Main();
    }
}

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

using namespace std;

typedef long long ll;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll MOD = 1e9 + 7, SIZ = 1e7;
vector<ll> fact;

ll binpow (ll a, ll n, ll md) {
	if (n == 0)
		return 1;
	if (n % 2 == 1)
		return (binpow (a, n-1, md) * a) % md;
	else {
		ll b = binpow (a, n/2, md);
		return (b * b) % md;
	}
}

ll cages(ll n, ll k) {
    return (fact[n] * binpow((fact[k] * fact[n - k]) % MOD, MOD - 2, MOD)) % MOD;
}

int main()
{
    fastInp;

    ll h, w, a, b;
    cin >> h >> w >> a >> b;
    ll cr = max(max(h, w), max(a, b));
    fact.push_back(1);
    for (ll i= 1; i <= SIZ; i++) fact.push_back((fact.back() * i) % MOD);

    ll ans = 0, s = 0;
    for (int i = a; i < h; i++) {
        ll cur = 0;
        cur += (cages(b + i - a - 1, i - a) * cages(h + w - (i - a) - b - 2, w - b - 1)) % MOD;

        ans += cur;
        ans += MOD;
        ans %= MOD;
    }

    cout << ans;
    return 0;    
}

Measured memory_bytes: 134460
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
//max=({});


int main() {
	int n, d, x;
	cin >> n >> d >> x;
	vector<int>A(n);
	int ans = x;
	rep(i, n) {
		cin >> A[i];
		ans += (d - 1) / A[i] + 1;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

bool flag(const int &a, const int &b) {
    if (a % 10 <= b % 10)
        return 1;
    else
        return 0;
}

int main() {
    vector<int> q(5);
    int ans = 0;
    for (int i = 0; i < 5; ++i)
        cin >> q[i];
    sort (q.begin(), q.end(), flag);
    int s = 0;
    while (q[s] % 10 == 0) {
        ans += q[s];
        ++s;
    }
    for (int i = 4; i >= s; --i) {
        ans += q[i];
        if (i != s) {
            while (ans % 10 != 0)
                ++ans;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <vector>
#include <functional>

using namespace std;

template<typename T>
class SegmentTree
{
    int n;
    function<T(T,T)> op;
    vector<T> V;

    T q(int l, int r)
    {
        if (l >= r)
            return V[0];
        T a = q((l+1)/2, r/2);
        if (l%2 != 0)
            a = op(a, V[l]);
        if (r%2 != 0)
            a = op(a, V[r-1]);
        return a;
    }

public:
    SegmentTree(int n_, function<T(T,T)> op, T init):
        op(op)
    {
        n = 1;
        while (n < n_)
            n *= 2;
        V = vector<T>(2*n, init);
        for (int i=n-1; i>0; i--)
            V[i] = op(V[i*2], V[i*2+1]);
    }

    T get(int p) const
    {
        return V[p+n];
    }

    void set(int p, T v)
    {
        p += n;
        V[p] = v;
        for (p/=2; p>0; p/=2)
            V[p] = op(V[p*2], V[p*2+1]);
    }

    //  init OP v[l] OP v[l+1] OP ... OP v[r-1]
    T query(int l, int r)
    {
        return q(l+n, r+n);
    }
};

#include <iostream>

int main()
{
    int N;
    cin>>N;
    vector<int> a(N);
    for (int &t: a)
        cin>>t;

    int ans = 0;
    for (int b=0x40000000; b>0; b/=2)
    {
        int m = ans + b;

        SegmentTree<long long> tree(
            2*N+1,
            [](long long a, long long b){return a+b;},
            0LL);
        tree.set(N, 1);

        long long c = 0LL;
        int ac = 0LL;
        for (int i=0; i<N; i++)
        {
            ac += a[i]>m ? 1 : -1;
            c += tree.query(0, ac+N+1);
            tree.set(ac+N, tree.get(ac+N)+1);
        }

        if (c >= ((long long)N*(N+1)/2+1)/2)
            ans += b;
    }
    cout<<ans+1<<endl;
}


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

int main() {
	int a;
	cin >> a;
	
	for (int i = 1; i <= 9; ++i) {
		for (int j = 1; j <= 9; ++j) {
			if (i * j == a) {
				cout << "Yes\n";
				return 0;
			}
		}
	}
	
	cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
int gi() { 
	int res = 0, w = 1; 
	char ch = getchar(); 
	while (ch != '-' && !isdigit(ch)) ch = getchar(); 
	if (ch == '-') w = -1, ch = getchar(); 
	while (isdigit(ch)) res = res * 10 + ch - '0', ch = getchar(); 
	return res * w; 
}
const int MAX_N = 1e5 + 5; 
int N, L, T; 
int x[MAX_N], dir[MAX_N]; 
long long sum; 
int main () { 
#ifndef ONLINE_JUDGE 
    freopen("cpp.in", "r", stdin);
	freopen("cpp.out", "w", stdout); 
#endif 
	N = gi(), L = gi(), T = gi(); 
	for (int i = 1; i <= N; i++) x[i] = gi(), dir[i] = gi(); 
	for (int i = 1; i <= N; i++) { 
		if (dir[i] == 1) { 
			int t = L - x[i]; 
			if (T >= t) sum += (T - t) / L + 1; 
		} else { 
			int t = x[i]; 
			if (T > t) sum -= (T - t - 1) / L + 1; 
		} 
		if (dir[i] == 1) x[i] = (x[i] + T) % L; 
		else x[i] = (x[i] - T % L + L) % L; 
	} 
	sort(&x[1], &x[N + 1]); 
	sum = (sum % N + N) % N; 
	for (int i = sum + 1; i <= N; i++) printf("%d\n", x[i]); 
	for (int i = 1; i <= sum; i++) printf("%d\n", x[i]); 
    return 0; 
} 

Measured memory_bytes: 4468
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb; 
typedef long long ll;  
typedef double db;                         
 
 
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, N = 3e5 + 48, mod = 1e9 + 7;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;
 

int n, m, v, u, dp[N], dp1[N];
vi g[N], pref[N], suff[N];


void dfs (int v, int p = 0) {
	dp[v] = 1;
	for (auto to : g[v])
		if (to != p) {
			dfs(to, v);
			dp[v] = dp[v] * 1ll * (dp[to] + 1) % m;
			pref[v].pb(dp[v]); 
		}                                                              

	reverse(all(g[v]));
	dp[v] = 1;
	for (auto to : g[v])
		if (to != p) {
			dp[v] = dp[v] * 1ll * (dp[to] + 1) % m;
			suff[v].pb(dp[v]); 
		}

	reverse(all(suff[v]));
	reverse(all(g[v]));
}


void dfs1 (int v, int p = 0, int id = -1) {
	dp1[v] = 1;
    if (p) { 
		dp1[v] = dp1[p] * 1ll * (id ? pref[p][id - 1] : 1) % m * (id == sz(suff[p]) - 1 ? 1 : suff[p][id + 1]) % m;
		(++dp1[v]) %= m;		    		
    }	

    int cur = 0;
	for (auto to : g[v])
		if (to != p)	
			dfs1(to, v, cur++);
}


main () {
	cin >> n >> m;
	forn (i, 2, n) {
		cin >> v >> u;
		g[v].pb(u);
		g[u].pb(v);
	}

	dfs(1);
	dfs1(1);
	forn (v, 1, n)
		cout << dp[v] * 1ll * dp1[v] % m << endl;
}          
 

Measured memory_bytes: 42368
//in the name of god
#include <bits/stdc++.h>
using namespace std;
#define MAX_N (int)1e5+20
#define INF 1e9+20
#define pb push_back
#define F first
#define S second
typedef long long LL;
typedef pair<int,int> pii;
const int delta=(int)1e9+7;
LL a[120],n;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin>>n; a[0]=2; a[1]=1;
	for(int i=2;i<=n;++i) a[i]=a[i-1]+a[i-2];
	cout<<a[n];
	return cout<<endl,0;
}

Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.format;
import std.math;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int generate()
{
  Mt19937 gen;
  string str = __DATE__ ~ __TIME__;
  uint hash;
  foreach (c; str)
  {
    hash = (hash * 9) + c;
  }
  gen.seed(hash);
  return uniform(1, 1_000_000_000 + 1, gen);
}

enum SUBMIT = true;

bool test(long n)
{
  static if (SUBMIT)
  {
    return query(n);
  }
  else
  {
    enum N = generate();
    pragma(msg, N);
    enum strN = N.to!string;
    string strn = n.to!string;
    return (n <= N && strn <= strN) || (n > N && strn >= strN);
  }
}

bool query(T)(T n)
{
  writeln("? ", n);
  stdout.flush;
  auto ans = readln;
  return ans[0] == 'Y';
}

void main()
{
  long l = 1;
  long zero = 1;
  for (; zero.test && zero <= 10_000_000_000L; zero *= 10, ++l)
  {
  }
  --l;
  zero /= 10;
  long l2 = 1;
  for (long z = 2;;)
  {
    if (z.test)
    {
      break;
    }
    z *= 10;
    ++l2;
  }
  if (l == 11)
  {
    long ans = 1;
    foreach (i; 1 .. l2)
    {
      ans *= 10;
    }
    writeln("! ", ans);
    stdout.flush;
    return;
  }
  long left = zero;
  long right = zero * 10;
  while (right - left > 1)
  {
    long mid = (left + right) / 2;
    bool res = test(10 * mid);
    if (res)
    {
      right = mid;
    }
    else
    {
      left = mid;
    }
  }

  writeln("! ", right);
  stdout.flush;
}


Measured memory_bytes: 1104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
struct UnionFind
{
  vector<ll> data;
  UnionFind(ll size) : data(size, -1) {}
  bool unionSet(ll x, ll y)
  {
    x = root(x);
    y = root(y);
    if (x != y)
    {
      if (data[y] < data[x])
        swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool findSet(ll x, ll y)
  {
    return root(x) == root(y);
  }
  ll root(ll x)
  {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  ll size(ll x)
  {
    return -data[root(x)];
  }
};
struct point {
    ll x,y,val;
    point() {}
    point(ll x, ll y, ll val) : x(x), y(y), val(val) {};
};
bool cmp(const point &a, const point &b)
{
  return a.val > b.val;
}
int main()
{
ll n , h , w ;
cin >> n >> h >> w ;
vector<point> v;
rep(i,n){
  ll r , c , a ;
  cin >> r >> c >> a ;
  v.emplace_back(r-1,c-1,a);
}
sort(v.begin(),v.end(),cmp);
vector<bool> ch(h+w); 
UnionFind arr(h+w);
rep(i,n){
  if(arr.findSet(v[i].x, v[i].y+h)){
    if(!ch[arr.root(v[i].x)]){
      ans+=v[i].val;
      ch[arr.root(v[i].x)]=1;
    }
  }
  else{
    bool t=ch[arr.root(v[i].x)]|ch[arr.root(v[i].y+h)];
    bool tt=ch[arr.root(v[i].x)]&ch[arr.root(v[i].y+h)];
    if(tt)continue;
    ans+=v[i].val;
    arr.unionSet(v[i].x, v[i].y+h);
    ch[arr.root(v[i].x)]=t;
  }
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 4980