akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
typedef long long ll;
using namespace std;
ll tree[1'500'001];
ll sum(int l, int r, int n, int s, int e){
    if(l<=s&&r>=e) {
        return tree[n];
    }
    if(l>e||r<s) return 0;
    int mid=s+e>>1;
    return max(sum(l,r,n<<1,s,mid),sum(l,r,n<<1|1,mid+1,e));
}
void update(int n, int s, int e, int t, long long diff){
    if(e<t||s>t)return;
    if(s==e){
        tree[n]=max(diff,tree[n]);
        return;
    }
    int mid=s+e>>1;
    update(n<<1,s,mid,t,diff);update(n<<1|1,mid+1,e,t,diff);
    tree[n]=max(tree[n<<1],tree[n<<1|1]);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,a,k;
    cin>>n>>k;
    int ans=0;
    for(int i=1;i<=n;i++){
        cin>>a;
        int t=sum(max(0,a-k),min(300'000,a+k),1,0,300'010)+1;
        update(1,0,300'010,a,t);
        if(ans<t)ans=t;
    }
    cout<<ans;
}

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


int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
   }
    sort(a, a + n);
    int b=a[n - 1] - a[0];
    abs(b);
    cout << b << endl;
    return 0;
}

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

typedef long long int lli;
const int inf = 1<<30;

int Ai[100010];

int main(){
  int N;
  cin>>N;
  for(int i=0;i<N;++i){
    cin>>Ai[i];
  }
  lli ans = 0;
  for(int i=0,carry=0;i<N;++i){
    if(Ai[i] == 0) carry = 0;
    if(carry){
      Ai[i]--;
      carry = 0;
      ans++;
    }
    if(Ai[i]%2) carry++;
    ans += Ai[i]/2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
typedef long long ll;
struct edge{int to; ll cost;};
typedef pair<ll, int> P;
const ll INF = 1e17;
const ll f = 1e15;
const int MAX_V = 1e5;

vector<edge> GY[MAX_V];
vector<edge> GS[MAX_V];
ll dy[MAX_V], ds[MAX_V];
int V;

void dijkstra_y(int s){
  priority_queue<P, vector<P>, greater<P>> que;
  rep(i, V) dy[i] = INF;
  dy[s] = 0;
  que.push(P(0, s));
  while(!que.empty()){
    P p = que.top();
    que.pop();
    int v = p.second;
    if(dy[v] < p.first) continue;
    rep(i, GY[v].size()){
      edge e = GY[v][i];
      if(dy[e.to] > dy[v] + e.cost){
        dy[e.to] = dy[v] + e.cost;
        que.push(P(dy[e.to], e.to));
      }
    }
  }
}

void dijkstra_s(int s){
  priority_queue<P, vector<P>, greater<P>> que;
  rep(i, V) ds[i] = INF;
  ds[s] = 0;
  que.push(P(0, s));
  while(!que.empty()){
    P p = que.top();
    que.pop();
    int v = p.second;
    if(ds[v] < p.first) continue;
    rep(i, GS[v].size()){
      edge e = GS[v][i];
      if(ds[e.to] > ds[v] + e.cost){
        ds[e.to] = ds[v] + e.cost;
        que.push(P(ds[e.to], e.to));
      }
    }
  }
}

int main(){
    int k, s, t;
    cin >> V >> k >> s >> t;
    s--; t--;
    rep(i,k) {
        int u, v; ll a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        GY[u].push_back({v,a});
        GY[v].push_back({u,a});
        GS[u].push_back({v,b});
        GS[v].push_back({u,b});
    }
    dijkstra_y(s);
    dijkstra_s(t);
    ll m[V];
    rep(i,V) m[i] = f - dy[i] - ds[i];
    ll ans[V];
    ans[V-1] = m[V-1];
    for(int i = V-2; i >= 0; i--) ans[i] = max(m[i],ans[i+1]);
    rep(i,V) cout << ans[i] << endl;
    return 0;
} 

Measured memory_bytes: 20996
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	int res = 0;
	REP(i, n) {
		cin >> h[i];
		if (h[i] >= k)res++;
	}
	put(res);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int a,p;
  cin >> a>> p;
  int ans = (a*3+p)/2;
  print(ans);

  return 0;
}

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

long long n, h, a[200001];
int main(){
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> h;
		a[i] = a[i-1]+h;
	}
	h = INT_MAX;
	for(int i = 1; i < n; i++) h = min(h, abs(a[i]-(a[n]-a[i])));
	cout << h;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

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

    if(n == 1) {
        cout << 1 << endl;
    } else if(n % 2 == 1) {
        cout << (double)(n / 2 + 1) / (double)n << endl;
    } else {
        cout << fixed << setprecision(15) << 0.5 << endl;
    }
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		Map<String, String> t = new HashMap<String, String>();
		t.put("101", " ");
		t.put("000000", "\'");
		t.put("000011", ",");
		t.put("10010001", "-");
		t.put("010001", ".");
		t.put("000001", "?");
		t.put("100101", "A");
		t.put("10011010", "B");
		t.put("0101", "C");
		t.put("0001", "D");
		t.put("110", "E");
		t.put("01001", "F");
		t.put("10011011", "G");
		t.put("010000", "H");
		t.put("0111", "I");
		t.put("10011000", "J");
		t.put("0110", "K");
		t.put("00100", "L");
		t.put("10011001", "M");
		t.put("10011110", "N");
		t.put("00101", "O");
		t.put("111", "P");
		t.put("10011111", "Q");
		t.put("1000", "R");
		t.put("00110", "S");
		t.put("00111", "T");
		t.put("10011100", "U");
		t.put("10011101", "V");
		t.put("000010", "W");
		t.put("10010010", "X");
		t.put("10010011", "Y");
		t.put("10010000", "Z");
		Map<Character, String> r = new HashMap<Character, String>();
		r.put('A', "00000");
		r.put('B', "00001");
		r.put('C', "00010");
		r.put('D', "00011");
		r.put('E', "00100");
		r.put('F', "00101");
		r.put('G', "00110");
		r.put('H', "00111");
		r.put('I', "01000");
		r.put('J', "01001");
		r.put('K', "01010");
		r.put('L', "01011");
		r.put('M', "01100");
		r.put('N', "01101");
		r.put('O', "01110");
		r.put('P', "01111");
		r.put('Q', "10000");
		r.put('R', "10001");
		r.put('S', "10010");
		r.put('T', "10011");
		r.put('U', "10100");
		r.put('V', "10101");
		r.put('W', "10110");
		r.put('X', "10111");
		r.put('Y', "11000");
		r.put('Z', "11001");
		r.put(' ', "11010");
		r.put('.', "11011");
		r.put(',', "11100");
		r.put('-', "11101");
		r.put('\'', "11110");
		r.put('?', "11111");

		while (sc.hasNext()) {
			String s = sc.nextLine();
			String s2 = "";
			String s3 = "";

			for (int i = 0; i < s.length(); i++) {
				s2 += r.get(s.charAt(i));
			}
			int sIndex = 0;
			int eIndex = 1;
			while (eIndex <= s2.length()) {
				if (t.get(s2.substring(sIndex, eIndex)) == null) {
					eIndex++;
				} else {
					s3 += t.get(s2.substring(sIndex, eIndex));
					sIndex = eIndex;
					eIndex = sIndex + 1;
				}
			}
			System.out.println(s3);
		}
	}
}

Measured memory_bytes: 55808
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

typedef long long ll;

const int MAX_N = 1e5 + 5;

set<ll> remain;
map<ll, int> orig;
ll arr [MAX_N];
ll pos [MAX_N];

vector<ll> ans;

ll L;
void try_del (ll cur) {
  auto it = remain.find(cur);
  if (it == remain.end()) return;
  if (it == remain.begin()) return;
  if (next(it) == remain.end()) return;

  ll nxt = *next(it);
  ll prv = *prev(it);
  if (nxt - prv < L) return;

  remain.erase(it);
  ans.push_back(cur);
  try_del(nxt);
  try_del(prv);
}

int main () {
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n >> L;

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

  for (int i = 1; i <= n; i++) {
    pos[i] = pos[i - 1] + arr[i];
    orig[pos[i]] = i;
  }
  
  for (int i = 0; i <= n; i++) {
    remain.insert(pos[i]);
  }

  for (int i = 1; i < n; i++) {
    try_del(pos[i]);
  }

  if ((int) remain.size() != 2) {
    cout << "Impossible" << endl;
    exit(0);
  }

  cout << "Possible" << endl;
  reverse(ans.begin(), ans.end());
  for (ll x : ans) {
    cout << orig[x] << '\n';
  }
}


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

using namespace std;

//#define FILE_IO

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    int A, B, C;
    scanf("%d%d%d", &A, &B, &C);

    for(int i = 0; i <= 10000; i++)
    {
        if(A % 2 == 1 || B % 2 == 1 || C % 2 == 1)
        {
            printf("%d\n", i);
            return 0;
        }

        int _A = A, _B = B, _C = C;
        A = (_B + _C) / 2;
        B = (_A + _C) / 2;
        C = (_A + _B) / 2;
    }

    printf("-1\n");

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>

#define SHIRO 0
#define USUI  1
#define ATSUI 2

using namespace std;

int l, k;
double array[200];
void print (int *pole)
{
	for (int i = 0; i < l; i++)
		printf ("%d ", pole[i]);
	printf("\n");
}

bool check (int *pole, int len)
{
	// l ?????????????¶????????????????
	if (l < len)
		return false;
	// ???????????\?????????
	if (pole[0] == SHIRO)
		return false;
	// ???????????\?????????
	if (pole[len-1] == SHIRO)
		return false;
	return true;
}

/* copy array */
void copy (int *tmp, int *pole)
{
	for (int i = 0; i < l; i++)
		tmp[i] = pole[i];
}

double kuro(int *pole, int len);
// ???????????????OK?????£????????°
double shiro (int *pole, int len)
{
	if (array[len] != -1){
	//	printf("%d\n", array[len]);
		return array[len];
	}
	int tmp[l]; /* pole ???????????? */
	double count = 0;
	//??????????????\??????
	//????????\????????????????????§???????????????????????????
	//?????????????????????????????§???????????????????????????????????????
	copy(tmp, pole);
	tmp[len] = SHIRO;
	if (len + 1 <= l) {
		count = kuro(tmp, len+1);
	}
	array[len] = count;
	return count;
}
// ???????????????OK?????£????????°
double kuro (int *pole, int len)
{
	int tmp[l]; /* pole ???????????? */
	double count = 0;
	//??????????????\??????
	copy(tmp, pole);
	tmp[len] = USUI;
	//check ??????????????????????????????????????°????????????
	if (check(tmp, len+1)) {
		// print(tmp);
		count += 1 + shiro(tmp, len+1);
	}
	//??????????????\??????	
	copy(tmp, pole);
	if (len + k <= l) {
		for (int i = 0; i < k; i++)
			tmp[len + i] = ATSUI;
		if (check(tmp, len+k)) {
			// print(tmp);
			count += 1 + shiro(tmp, len+k);
		}
	}
	return count;
}


int main (void)
{
	cin >> l >> k;
	int pole[l];
	int len = 0; /* len of disks */
	for (int i = 0; i < l; i++)
	{
		pole[i] = -1;
	}
	for (int i = 0; i < 200; i++)
		array[i] = -1;
	//cout << kuro(pole, 0) << endl;
	printf("%.0lf\n", kuro(pole, 0));	

	return 0;
}

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

int main(){
  int k;
  cin >> k;
  int ans = 0;
  for(int a=1; a<=k; a++)for(int b=1; b<=k; b++)for(int c=1; c<=k; c++){
    int mx = 0;
    mx = min(a, b);
    mx = min(mx, c);
    for(int i=mx; i>=1; i--){
      if(a%i==0 && b%i==0 & c%i==0){
        ans += i;
        break;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3644
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

//#define DEBUG
#ifdef DEBUG
    #define IFD(...) __VA_ARGS__
    #define IFN(...)
    #define L cout<<__LINE__<<"\n";
    #define PRINT(...) __VA_ARGS__ cout<<__LINE__<<" : "<<#__VA_ARGS__<<"\n"
    #define PRT(x) cout<<__LINE__<<" : "<<#x<<" = "<<x<<"\n"
#else // DEBUG
    #define IFD(...)
    #define IFN(...) __VA_ARGS__
    #define L
    #define PRINT(...) __VA_ARGS__
    #define PRT(x)
#endif // DEBUG

#define it iterator
#define rit reverse_iterator
#define mp make_pair
#define mems(a,b) memset(a,b,sizeof(a))
#define mem0(a) mems(a,0)
#define mem1(a) mems(a,1)
#define mem255(a) mems(a,255)
#define halt(s) cout<<s,exit(0)IFD(,cout<<"\n\nTIME: "<<runtime<<" sec\n\n")
#define all(c) (c).begin() , (c).end()
#define sz(c) ((long long)((c).size()))
#define phb push_back
#define ppb pop_back
#define phf push_front
#define ppf pop_front
#define fort0(i,a,b) for(ll i=a,i##_TO=b;i<i##_TO;i++)
#define for0(i,n) fort0(i,0,n)
#define fort1(i,a,b) for(ll i=a,i##_TO=b;i<=i##_TO;i++)
#define for1(i,n) fort1(i,1,n)
#define ford(i,a,b) for(ll i=a,i##_TO=b;i>=i##_TO;i--)
#define loop(n) for0(LOOP_COUNTER,n)
#define runtime (clock()*1.0/CLOCKS_PER_SEC)
#define x first
#define y second

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define int ll

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template
<
    class key,
    class val=null_type, /// null_mapped_type
    class comp=less<key>
>
using ord_set=tree /// find_by_order(), order_of_key()
<
    key,
    val,
    comp,
    rb_tree_tag,
    tree_order_statistics_node_update
>;

typedef trie
<
    string,
    null_type,
    trie_string_access_traits<>,
    pat_trie_tag,
    trie_prefix_search_node_update
>
pref_trie; /// insert(), prefix_range()

template<class T,class U>
ostream&operator<<(ostream&out,pair<T,U> p)
{
    return out<<"("<<p.x<<","<<p.y<<")";
}

template<class Iter>
struct rng
{
    Iter from,to;
    rng(Iter from,Iter to):from(from),to(to){}
};

template<class Iter>
rng<Iter> range(Iter from,Iter to)
{
    return rng<Iter>(from,to);
}

template<class Iter>
ostream&operator<<(ostream&out,rng<Iter> r)
{
    out<<distance(r.from,r.to)<<":";
    for(Iter i=r.from;i!=r.to;i++)
        out<<" "<<*i;
    return out;
}

ll ppow(ll x,ll y,ll mod)
{
    ll res=1;
    while(y)
    {
        if(y&1)
            res=res*x%mod;
        y>>=1;
        x=x*x%mod;
    }
    return res;
}

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

    int n;
    cin>>n;
    int p=0,ans=0;
    while(n--)
    {
        int x;
        cin>>x;
        if(x==p)
            x=0,ans++;
        p=x;
    }
    cout<<ans;

    IFD(cout<<"\n\nTIME: "<<runtime<<" sec\n\n";)
}


Measured memory_bytes: 256
use std::io::stdin;

#[allow(dead_code)]
fn input_strs() -> Vec<String> {
    let mut s = String::new();
    match stdin().read_line(&mut s) {
        Ok(_) => s.split_whitespace().map(|s| s.to_string()).collect(),
        Err(_) => panic!("err"),
    }
}

#[allow(dead_code)]
fn input_ints() -> Vec<u32> {
    let mut s = String::new();
    match stdin().read_line(&mut s) {
        Ok(_) => s.split_whitespace().map(|s| s.parse().unwrap()).collect(),
        Err(_) => panic!("err"),
    }
}

#[allow(unused_variables)]
fn solve() {
    let l = input_ints();
    let n = l[0] as usize;

    let a = input_ints();

    let mut cnt = 0;
    let mut all_cnt = 0;
    for i in 1..(n + 1) {
        if i as u32 == a[i - 1] {
            cnt += 1;
        } else {
            all_cnt += cnt / 2 + cnt % 2;
            cnt = 0;
        }
    }

    all_cnt += cnt / 2 + cnt % 2;

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

fn main() {
    solve();
}


Measured memory_bytes: 4352
#Reading input
def read_input():
  first_line = [int(item) for item in input().split()]
  n = first_line[0]
  m = first_line[1]
  c = first_line[2]
  b = [int(item) for item in input().split()]
  A =[]
  for i in range(n):
    A.append([int(item) for item in input().split()])
  return(n,m,c,b,A)

def validate(c,b,a):
  total = 0
  for i in range(len(a)):
    total += b[i]*a[i]
  if total + c>0:
    return 1
  else:
    return 0

def main():
  N,m,c,b,A = read_input()
  total = 0
  for n in range(N):
    total += validate(c,b,A[n])
  print(total)
if __name__ == '__main__':
  main()
  

Measured memory_bytes: 3064
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
    	Scanner sc = new Scanner(System.in);

		char Alpa = sc.next().charAt(0);
		char judge;
		
		if(Character.isUpperCase(Alpa))
			judge = 'A';
		else
			judge = 'a';
			
		System.out.println(judge);

	}

}

Measured memory_bytes: 35660
n=int(input())
lis=[]
for i in range(n):
    lis.append(list(map(int,input().split())))

ans=0
for i in range(n-1):
    for j in range(n-1-i):
        x=(lis[i][0]-lis[n-1-j][0])**2
        y=(lis[i][1]-lis[n-1-j][1])**2
        l=(x+y)**0.5
        #print(l)
        ans+=l

ans=ans*2/n

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
 


struct LazySegmentTree {
private:
    int n;
    vector<LL> node, lazy;
    vector<bool> lazyFlag;
 
public:
    LazySegmentTree(vector<LL> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, -1);
        lazyFlag.resize(2*n-1, false);
 
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = max(node[i*2+1], node[i*2+2]);
    }
 
    void lazyEvaluate(int k, int l, int r) {
        if(lazyFlag[k]) {
            node[k] = lazy[k];
            if(r - l > 1) {
                lazy[k*2+1] = lazy[k*2+2] = lazy[k];
                lazyFlag[k*2+1] = lazyFlag[k*2+2] = true;
            }
            lazyFlag[k] = false;
        }
    }
 
    void update(int a, int b, LL x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        lazyEvaluate(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] = x;
            lazyFlag[k] = true;
            lazyEvaluate(k, l, r);
        }
        else {
            update(a, b, x, 2*k+1, l, (l+r)/2);
            update(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = max(node[2*k+1], node[2*k+2]);
        }
    }
 
    LL find(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        lazyEvaluate(k, l, r);
        if(b <= l || r <= a) return -1;
        if(a <= l && r <= b) return node[k];
        LL vl = find(a, b, 2*k+1, l, (l+r)/2);
        LL vr = find(a, b, 2*k+2, (l+r)/2, r);
        return max(vl, vr);
    }
};


int main(){
    int n,q;cin >> n >> q;
    vector<LL> s(n),t(n),x(n),d(q);
    vector<pair<LL,P>> v(n);
    LazySegmentTree seg( vector<LL>(q+1, -1) );
    for (int i = 0; i < n; i++) {
        cin >> s[i] >> t[i] >> x[i];
        v[i]=mp(x[i],mp(s[i],t[i]));
    }
    sort(ALL(v));
    for (int i = 0; i < q; i++) {
        cin >> d[i];
    }
    for (int i = n-1; i >= 0; i--) {
        int l = lower_bound(ALL(d),v[i].sc.fs-v[i].fs)-d.begin();
        int r = lower_bound(ALL(d),v[i].sc.sc-v[i].fs)-d.begin();
        seg.update(l,r,v[i].fs);
    }
    for (int i = 0; i < q; i++) {
        LL t = seg.find(i,i+1);
        cout << t << endl;
    }
    return 0;
}


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

int main()
{
  string S,T,U;
  int A,B;

  cin >> S;

  cin >> T;

  cin >> A;

  cin >> B;

  cin >> U;

  if (U == S) {
      A -= 1;
      cout << A << " " << B;
  }
  if (U == T) {
        B -= 1;
        cout << A << " " << B;
  }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main
{
	public static void main(String[] args)
	{
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int[][] arr = new int[2][n];

		for(int i =0;i<2;i++)
		{
			for(int j =0;j<n;j++)
			{
				arr[i][j] = s.nextInt();
			}
		}

		int[] sumarr = new int[n];
		int row =0 ;
		for(int i =0;i<n;i++)
		{
			int sum =0 ;
			row =0 ;
			for(int j = 0;j<n;j++)//1)start from 0 index of first row
			{
				if(j == i)//3)then horizontal  sum for row = 1;
				{
					sum+=arr[row][j];
					row++;
					sum+=arr[row][j];
					
				}
				else//2) sum until j != i i.e horizontal sum  for row =0 ;
				{
					sum+=arr[row][j];
				}
			}
			// System.out.println(sum);
			sumarr[i] = sum;
		}

		Arrays.sort(sumarr);
		System.out.println(sumarr[n-1]);

	}
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
const int MAXN=(int)2e5+10;
ll a[MAXN],sum;
int main()
{
	int n;
	scanf("%d",&n);
	ll sum=0,ans=0;
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		sum+=a[i];
		ans+=abs(a[i]);
	}
	ll  step=0;
	for(int i=1;i<n;i++){
		step+=a[i];
		ans=min(ans,abs(sum-2*step));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
using System;
class aizu{
    public static int Main(){
        int i;
        int[] n = new int[3];
        string[] str = new string[100];
        str = Console.ReadLine().Split(' ');
        for(i=0;i<3;i++)
           n[i] = int.Parse(str[i]);
        Array.Sort(n);
        Console.WriteLine("{0} {1} {2}",n[0],n[1],n[2]);
        return 0;
    }
}

Measured memory_bytes: 9220
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N, A, B := ReadInt(), ReadInt(), ReadInt()
	fmt.Println(Min(A, B), Max(A+B-N, 0))
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1840
import heapq

N, M = map(int, input().split())
jobs = [[] for i in range(M)]

for i in range(N):
    A, B = map(int, input().split())
    if A - 1 < M:
        jobs[A-1].append(B)

q = []
heapq.heapify(q)
ans = 0
for i in range(M):
    for j in jobs[i]:
        heapq.heappush(q, -j)
    if len(q) != 0:
        ans += -heapq.heappop(q)

print(ans)

Measured memory_bytes: 18452
#include<bits/stdc++.h>
using namespace std;
const int maxn=1010,mod=1000000007;
inline void Add(int &a,int b){a=a+b>=mod?a+b-mod:a+b;}
inline int ksm(int a,int b)
{
	int res=1;
	for(;b;b>>=1,a=1ll*a*a%mod) if(b&1) res=1ll*res*a%mod;
	return res;
}
int n,a[maxn],k,f[maxn],g[maxn],fac[maxn],invfac[maxn];
inline int C(int n,int m){return 1ll*fac[n]*invfac[m]%mod*invfac[n-m]%mod;}
int main()
{
	for(int i=fac[0]=1;i<maxn;i++) fac[i]=1ll*fac[i-1]*i%mod;
	invfac[maxn-1]=ksm(fac[maxn-1],mod-2);
	for(int i=maxn-2;i>=0;i--) invfac[i]=1ll*invfac[i+1]*(i+1)%mod;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=k;i++) scanf("%d",a+i);
	f[0]=fac[n];
	for(int i=1;i<=k;i++)
	{
		for(int j=0;j<=n;j++) g[j]=0;
		for(int lst=0;lst<=n;lst++) for(int nxt=0;nxt<=n-lst&&nxt<=a[i];nxt++)
			Add(g[lst+nxt],1ll*f[lst]*C(n-nxt,a[i]-nxt)%mod*invfac[nxt]%mod);
		for(int j=0;j<=n;j++) f[j]=g[j];
	}
	cout<<f[n]<<endl;
}

Measured memory_bytes: 3684
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
const double k =9.8*9.8/4.9;
double vmax;
bool judge(int n)
{
    if(k*(5*n-5)>=vmax*vmax)
        return true;
    else
        return false;
}

int main()
{
    while(cin>>vmax)
    {
        int l=0,r=10000;
        int ans;
        while(r-l>=0)
        {
            int m=(l+r)/2;
            if(judge(m))
            {
                ans=m;
                r=m-1;
            }
            else
                l=m+1;
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> P;

template <typename T> T gcd(T x, T y) { return( y ? gcd(y, x % y) : x); }
template <typename T> T lcm(T x, T y) { return( x / gcd(x, y) * y); }
template <typename T> void printVec(vector<T> &vec) {
  cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    cout << *it << " ";
  }
  cout << endl;
}

int main() {
  int a;

  cin >> a;

  cout << a + a * a + a * a *a << endl;

	return 0;
}


Measured memory_bytes: 3620
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD!string;

	writeln(N[0] == '9' || N[1] == '9' ? "Yes" : "No");
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
// {{{ by unolight
#pragma region
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define RALL(x) rbegin(x),rend(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

namespace { namespace unolight {
// Read Input
template<class T> void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( int64_t &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }
void R() {}
template<class T, class... U> void R( T& head, U&... tail ) { _R(head); R(tail...); }
// Write Output
template<class T> void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
void _W( const int64_t &x ) { printf("%" PRId64,x); }
void _W( const double &x ) { printf("%.16f\n",x); }
void _W( const char &x ) { putchar(x); }
void _W( const char *x ) { printf("%s",x); }
template<class T> void _W( const vector<T> &x ) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W( const T& head, const U&... tail ) { _W(head); putchar(sizeof...(tail)?' ':'\n'); W(tail...); }

#ifdef UNOLIGHT
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}
#pragma endregion
// }}}

void main() {
    string s;
    cin >> s;
    if ( s.back()=='s' ) s+="es";
    else s+="s";
    cout << s << '\n';
}

}} // {{{ main
int main() { unolight::main(); return 0; }
// }}}


Measured memory_bytes: 3596
N, K = map(int, input().split())
LR = [tuple(map(int, input().split())) for _ in range(K)]

D = [1]
M = 100
memo = []
memo2 = []
for i in range(1, N):
  count = 0
  for l, r in LR:
    if l <= i:
      l1 = i - min(i, r)
      r1 = i - l + 1
      l2 = (l1 + M - 1) // M
      r2 = r1 // M
      l3 = (l2 + M - 1) // M
      r3 = r2 // M
      if r3 > l3:
        count += sum(D[l1:l2*M]) + sum(memo[l2:l3*M]) + sum(memo2[l3:r3]) + sum(memo[r3*M:r2]) + sum(D[r2*M:r1])
      elif r2 > l2:
        count += sum(D[l1:l2*M]) + sum(memo[l2:r2]) + sum(D[r2*M:r1])
      else:
        count += sum(D[l1:r1])
  D.append(count % 998244353)
  if len(D) % M == 0:
    memo.append(sum(D[-M:]))
    if len(memo) % M == 0:
      memo2.append(sum(memo[-M:]))
print(D[-1])

Measured memory_bytes: 86828
#include<stdio.h>

int judge(char X[],char Y[])
{
  int x=0,y=0,count=0,i,j,MAX=0;
  int A[1005][1005];
  while(count==0)
    {
      if(X[x]!='\0')
        {
          x++;
        }
      else
        {
          count=1;
        }
    }
  count=0;
  while(count==0)
    {
      if(Y[y]!='\0')
        {
          y++;
        }
      else
        {
          count=1;
        }
    }
  for(i=1;i<x+1;i++)
    {
      A[i][0]=0;
    }
  for(j=1;j<y+1;j++)
    {
      A[0][i]=0;
    }

  for(i=1;i<x+1;i++)
    {
      for(j=0;j<y+1;j++)
        {
          if(X[i-1]==Y[j-1])
            {
              A[i][j]=A[i-1][j-1]+1;
            }
          else if(A[i-1][j]>=A[i][j-1])
            {
              A[i][j]=A[i-1][j];
            }
          else
            {
              A[i][j]=A[i][j-1];
            }
          if(MAX<A[i][j])
            MAX=A[i][j];
        }
    }
  return MAX;
}

int main()
{
  char X[1000],Y[1000];
  int n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%s",X);
      scanf("%s",Y);
      printf("%d\n",judge(X,Y));
    }
  return  0;
}



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


int main() {
  int n;
  cin >> n;
  vector<int> plus(n,0),low(n,0);
    vector<tuple<bool,int,int>> info;
  for(int i=0;i<n;i++){
    string s;
    cin >> s;
    for(int j=0;j<(int)s.size();j++){
      if(s[j]=='(') plus[i]++;
      else plus[i]--;
      low[i]=min(low[i],plus[i]);
    }
    info.push_back({plus[i]<0,(plus[i]<0?low[i]-plus[i]:-low[i]),plus[i]});
  }
  sort(info.begin(),info.end());
  int h=0;
  for(auto [a,b,c] : info){
    if(a && h+b+c<0 || !a && h-b<0){cout << "No" << endl;return 0;}
    else h+=c;
  }
  if(h!=0){cout << "No" << endl;return 0;}
  cout << "Yes" << endl;
}


Measured memory_bytes: 23216
#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_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}

const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

char BigAlphaToSmall(char a){
    if (a >= 65 && a <= 90){
        return a + 32;
    }
    return a;
}

char SmallAlphaToBig(char a){
    if (a >= 97 && a <= 122){
        return a - 32;
    }
    return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    list<int> hoge;
    int q, opt, x, d;
    cin >> q;
    list <int> :: iterator it;
    it = hoge.end();
    while(q--){
        cin >> opt;
        if(opt == 0){
            cin >> x;
            hoge.insert(it, x);
            it--;
        }else if(opt == 1){
            cin >> d;
            advance(it, d);
        }else if(opt == 2){
            it = hoge.erase(it);
        }
    }

    for (it = hoge.begin(); it != hoge.end(); it++){
            cout << *it << endl;
    }
    return 0;
}


Measured memory_bytes: 18688
//0053

#include<cstdio>
#include<algorithm>

int main(void)
{
	const int N = 104729+1;	//1000ÔÚÌfÍ104729
	bool isPrime[N];
	std::fill(isPrime, isPrime+N, true);
	isPrime[0] = isPrime[1] = false;
	int i, j;
	for(i = 2; i*i <= N; i++)
	{
		if(isPrime[i])
		{
			for(j = i*2; j < N; j+=i)
			{
				isPrime[j] = false;
			}
		}
	}

	int n;
	int s;
	int count;
	while(scanf("%d", &n), n)
	{
		i = 3;
		s = 2;
		count = 1;
		while(count != n)
		{
			if(isPrime[i])
			{
				count++;
				s += i;
			}
			i += 2;
		}
		printf("%d\n", s);
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main()
{
	int a[3];
	int f_count, s_count;
	int i, j;
	scanf("%d%d%d", &a[0], &a[1], &a[2]);
	for (i = 0, s_count=0, f_count=0; i < 3; i++) {
		if (a[i] == 5) {
			f_count++;
		}
		if (a[i] == 7) {
			s_count++;
		}
	}
	if (s_count == 1 && f_count == 2) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll MOD = 1000000007;

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int xd = x2 - x1;
    int yd = y2 - y1;

    printf("%d %d %d %d\n", x2 - yd, y2 + xd, x2 - yd - xd, y2 + xd - yd);

    return 0;
}

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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int K;
  cin >> K;
  if (A >= B && A >= C) {
    for (int i = 0; i < K; i++) {
      A *= 2;
    }
  } else if (B >= A && B >= C) {
    for (int i = 0; i < K; i++) {
      B *= 2;
    }
  } else {
    for (int i = 0; i < K; i++) {
      C *= 2;
    }
  }
  cout << A + B + C << endl;
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int ma = 0;

void dfs(int now, int prev, int parcol, const vvi &tr, map<P, int> &idx, vi &ans) {
  int nowcol = 1;
  for(int i=0;i<SZ(tr[now]);++i) {
    int nxt = tr[now][i];
    if(nxt == prev) continue;
    //cout << now << ":" << nxt << endl;
    if(nowcol == parcol) nowcol++;
    ma = max(ma, nowcol);
    ans[idx[make_pair(now, nxt)]] = nowcol;
    dfs(nxt, now, nowcol, tr, idx, ans);
    nowcol++;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vvi tr(n);
  map<P, int> idx;
  for(int i=0;i<n-1;++i) {
    int a, b; cin >> a >> b;
    a--; b--;
    tr[a].push_back(b);
    tr[b].push_back(a);
    idx[make_pair(a, b)] = i;
    idx[make_pair(b, a)] = i;
  }

  vi ans(n-1);
  dfs(0, -1, 0, tr, idx, ans);

  cout << ma << endl;
  for(int i=0;i<n-1;++i) {
    cout << ans[i] << endl;
  }

}


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int d, n;
    cin >> d >> n;
    if(n <= 99)
        cout << n;
    else
        cout << 101;
    if(d == 1)
        cout << "00";
    else if(d == 2)
        cout << "0000";
    return 0;
}

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

int main(){
    long long n, m ; cin >> n >> m;
    long long good[n];//1が良い
    long long h[n];
    int a, b;
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
        good[i]=1;
    }

    for (int i = 0; i < m; i++)
    {
        cin >> a >> b;
        if (h[a-1]<h[b-1])
        {
            good[a-1]=0;
        }else if(h[a-1]>h[b-1]){
            good[b-1]=0;
        }else if(h[a-1]==h[b-1]){
            good[a-1]=0;
            good[b-1]=0;
        }
        
    }

    int count =0;
    for (int i = 0; i < n; i++)
    {
        if (good[i])
        {
            count++;
        }
        
    }

    cout << count <<endl;
    
    

}

Measured memory_bytes: 5196
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut done: bool = false;
    while !done {
        let m: i8 = read();
        let f: i8 = read();
        let r: i8 = read();
        if m != -1 || f != -1 {
            if m == -1 || f == -1 {
                println!("F");
            } else {
                let score: i8 = m + f;
                if score >= 80 {
                    println!("A");
                } else if score >= 65 {
                    println!("B");
                } else if score >= 50 {
                    println!("C");
                } else if score >= 30 {
                    if r >= 50 {
                        println!("C");
                    } else {
                        println!("D")
                    }
                } else {
                    println!("F")
                }
            }
        } else {
            if r != -1 {
                println!("F");
            } else {
                done = true;
            }
        }
    }
}



Measured memory_bytes: 5024
import sys
input = sys.stdin.readline

class Unionfind:
    __slots__ = ["nodes","diff_weight"]

    def __init__(self, n):
        self.nodes = [-1]*n
        self.diff_weight = [0]*n

    def root(self, x):
        if self.nodes[x] < 0:
            return x
        else:
            root_x = self.root(self.nodes[x])
            self.diff_weight[x] += self.diff_weight[self.nodes[x]]
            self.nodes[x] = root_x
            return root_x
    
    def unite(self, x, y, w=0):
        w += self.weight(x); w -= self.weight(y)
        x = self.root(x); y = self.root(y)
        if x == y:
            return
        rank_x = -self.nodes[x]; rank_y = -self.nodes[y]
        if rank_x < rank_y:
            x, y = y, x; w = -w
        if rank_x == rank_y:
            self.nodes[x] -= 1
        self.nodes[y] = x
        self.diff_weight[y] = w

    def weight(self, x):
        self.root(x)
        return self.diff_weight[x]
    
    def diff(self, x, y):
        return self.weight(y) - self.weight(x)
    
    def same(self, x, y):
        return self.root(x) == self.root(y)
    
    def rank(self, x):
        return -self.nodes[self.root(x)]
    
N,M = map(int,input().split())
uf = Unionfind(N)
ans = "Yes"
for _ in range(M):
    L, R, D = map(int,input().split())
    L -= 1; R -= 1
    uf.unite(L, R, D)   
    if uf.diff(L, R) != D:
        ans = "No"
        break
print(ans)

Measured memory_bytes: 8812
import sys
n1 = [[0, 1], [1, 0], [-1, 0], [0, -1]]
n2 = n1 + [[a, b] for a in [-1, 1] for b in [-1, 1]]
n3 = n2 + [[a*2, b*2] for a, b in n1]
mas = [[0]*10 for i in range(10)]
for i in sys.stdin:
    try:
        x, y, a = list(map(int, i.split(",")))
        mas[y][x] += 1
        for k,l in eval("n"+str(a)):
            try:
                if y+l >= 0 and x+k >= 0:
                    mas[y+l][x+k] += 1
            except IndexError:
                continue
    except ValueError:
        break
print(len([i for x in mas for i in x if not i]))
print(max([max(v) for v in mas]))

Measured memory_bytes: 7648
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define ff first
#define ss second
#define prec(y,x) fixed<<setprecision(y)<<x
#define inf 1e18
#define pi 3.1415926535

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n;
	map<int, int> mp; ll sum = 0;
	int arr[n + 1] = {0};
	for (int i = 0; i < 1e5 + 3; i++)
		mp[i] = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> arr[i]; sum += arr[i];

		mp[arr[i]]++;
	}
	int q; int a, b; cin >> q;
	while (q--)
	{
		cin >> a >> b;
		ll ans1 = b - a;
		ans1 *= mp[a];
		mp[b] = mp[a] + mp[b];
		mp[a] = 0;
		sum += ans1;
		cout << sum << endl;
		//for (int i = 1; i <= 4; i++)
		//	cout << mp[i] << " ";
		//cout << endl;
	}
	return 0;
}


Measured memory_bytes: 8744
n = int(input())
A = list(map(int, input().split()))


def solve(start):
    acc = [0] * n
    acc[0] = A[0]
    for i in range(1, n):
        acc[i] = acc[i - 1] + A[i]

    cur = start
    ans = 0
    x = 0
    for i in range(n):
        acc[i] += x
        if cur > 0:
            if acc[i] >= 0:
                ans += acc[i] + 1
                x -= acc[i] + 1
                acc[i] = -1
        else:
            if acc[i] <= 0:
                ans += abs(acc[i]) + 1
                x += abs(acc[i]) + 1
                acc[i] = 1
        cur = acc[i]
    return ans

ans = min(solve(1), solve(-1))
print(ans)

Measured memory_bytes: 20144
#include <stdio.h>
int main()
{
    char ch;
    int x,c[26]= {0};

    while(scanf("%c",&ch)!=EOF)
    {
        if(ch>='A' && ch<='Z')
        {
            x=ch-'A';
            c[x]+=1;
        }
        else if(ch>='a' && ch<='z')
        {
            x=ch-'a';
            c[x]+=1;
        }
    }

    for(x=0,ch='a'; x<26; x++,ch++)
    {
        printf("%c : %d\n",ch,c[x]);
    }
    return 0;
}


Measured memory_bytes: 2088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, n) for (ll i = n-1; i >= 0; i--)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd2(i, s, n) for (ll i = n-1; i >= (s); i--)

int main() {
    ll n;
    cin >> n;
    vector<ll> L(n);
    rep(i, n) cin >> L[i];
    ll ans = 0;
    rep(i, n){
        rep2(j, i+1, n){
            rep2(k, j+1, n){
                ll a = L[i];
                ll b = L[j];
                ll c = L[k];
                if (a!=b&&b!=c&&c!=a&&a+b>c&&b+c>a&&c+a>b){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
// template version 1.11
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings {{{
#define infile "../test/sample-2.in"
#define int long long
const int INF=1e18;
const int MOD=1e9+7;
// }}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n,m;cin>>n>>m;

  vvi e(m, vi());
  rep(i, m){
    int k;cin>>k;
    rep(j, k){
      int s;cin>>s;
      s--;
      e[i].pb(s);
    }
  }
  dump(e);

  vi p(m,0);
  rep(i, m){
    cin>>p[i];
  }
  dump(p);

  int res=0;

  rep(i, 1<<n){  // fix switch
    bool result = true;
    rep(d, m){ // dがon
      int on = 0;
      each(sw, e[d]){
        if (i>>sw&1) on++;
      }
      if (on%2!=p[d]) result=false;
    }
    if (result) res++;
  }
  cout << res << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	std::string S;
	in >> S;

	std::sort(S.begin(), S.end());
	bool ans = false;
	if (S[0] == S[1] && S[2] == S[3] && S[0] != S[2]) ans = true;
	out << (ans ? "Yes" : "No") << std::endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
c = 0
for _ in range(n):
    for i in range(n-1,0,-1):
        if a[i] < a[i-1]:
            a[i],a[i-1] = a[i-1],a[i]
            c += 1
print(" ".join(map(str,a)))
print(c)


Measured memory_bytes: 5600