akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x,2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
using vd = vector<long double>;
#define co(x) cout << x << endl;
#define cins(n,v) rep(i,n){cin >> v.at(i);}
#define couts(v) rep(i,v.size()){cout << v.at(i) << endl;}
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  ll n,ans=0;
  cin >> n;
  vector<ll> a(n);
  cin >> a[0];
  rep(i,n-1){
    cin >> a[i+1];
    if(a[i+1]-a[i]<0){
      ans+=a[i]-a[i+1];
      a[i+1]=a[i];
    }
  }

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


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

typedef long long ll;;

vector<ll> divs(ll n) {
	vector<ll> res;
	ll j = 0;
	for (ll i = 1; i * i <= n; i++)
		if (n % i == 0) {
			j = i;
			res.push_back(i);
			res.push_back(n / i);	
		}
	if (j * j == n)
		res.pop_back();
	return res;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	ll n, ans = 0;
	cin >> n;
	vector<ll> vec1 = divs(n), vec2 = divs(n - 1);
	ans += vec2.size() - 1;
	for (auto i: vec1)
		if (i != 1) {
			ll m = n;
			while (m % i == 0)
				m /= i;
			if (m % i == 1)
				ans++;
		}
	return cout << ans << endl, 0;
}


Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author MaxHeap
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        LukasNumber solver = new LukasNumber();
        solver.solve(1, in, out);
        out.close();
    }

    static class LukasNumber {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            long[] lukas = new long[87];
            lukas[0] = 2L;
            lukas[1] = 1L;
            for (int i = 2; i <= 86; i++) lukas[i] = lukas[i - 1] + lukas[i - 2];
            int n = in.nextInt();
            out.println(lukas[n]);
        }

    }

    static class FastReader {
        BufferedReader reader;
        StringTokenizer st;

        public FastReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            st = null;
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String line = reader.readLine();
                    if (line == null) {
                        return null;
                    }
                    st = new StringTokenizer(line);
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23508
N = int(input())
button = [int(input()) for _ in range(N)]
current_button = button[0]
ans = 1
while True:
    if current_button == 2:
        print(ans)
        exit()
    current_button = button[current_button-1]
    ans += 1
    if ans >= 10**5 + 10:
        print(-1)
        exit()

Measured memory_bytes: 49496
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
//#include <bits/stdc++.h>

#define all(v) v.begin(), v.end()
typedef long long ll;
#define rep(i, z, n) for(ll i = z; i < n; i++)
//const int INF = 1<<29;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, 0, N) cin >> A.at(i);
    ll ans = 0;
    rep(j, 0, 60){
        ll count_1 = 0;
        rep(i, 0, N){
            if((A.at(i)>>j)&1){
                count_1++;
                //cout << "i " << i << " A.at(i) " << A.at(i) << " j " << j << endl;
            }
        }
        ll count_0 = N - count_1;
        ll pro = (count_0 * count_1) % MOD;
        rep(k, 0, j){
            pro *= 2;
            pro %= MOD;
        }
        ans += pro;
        ans %= MOD;
        //cout << count_0 << " " << count_1 << " " << ans << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5584
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}

int main(){
  int X, Y, Z;
  cin >> X >> Y >> Z;
  cout << Z << " " << X << " " << Y << endl;
}

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

from math import ceil

def main():
  n, k = map(int, input().strip().split())
  la = list(map(int, input().strip().split()))
  la.sort()
  
  def check(x):
    cnt = 0
    for a in la:
      cnt += ceil(a / x) - 1
      if cnt > k:
        return False
    return True
 
  def bs(s, t):
    while ceil(s) != ceil(t):
      x = (s + t) / 2
      if check(x):
        t = x
      else:
        s = x
    return ceil(x)
  
  s, t = 0, 10 ** 9
  print(bs(s, t))
  
if __name__=='__main__':
  main()



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

int main() {
    int n;
    cin >> n;
    string ans = "hon";
    if(n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) ans = "pon";
    else if(n % 10 == 3) ans = "bon";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = 2e9;
int main(){ 
  int n;
  cin >> n;
  set<string> st;
  rep(i,n) {
    string s;
    cin >> s;
    st.insert(s);
  }
  cout << st.size() << endl;
  return 0;
} 

Measured memory_bytes: 19068
#include <iostream>

using namespace std;

int main(){
	int w, h, x, y, r;

	cin >> w >> h >> x >> y >> r;
	
	int ax = x + r;
	int ay = y + r;
	int sx = x - r;
	int sy = y - r;
	if (sx<0 || ax > w || sy < 0 || ay > h){ cout << "No" << endl; }
	else { cout << "Yes" << endl; }
	 

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
int main(){
    int n,Q;cin >> n >> Q;
    vector<int> to[n+1];
    for(int i=0; i<n-1; i++){
        int a,b;cin >> a >> b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    vector<int> v(n+1);
    for(int i=0; i<Q; i++){
        int p,x;cin >> p >> x;
        v[p]+=x;
    }
    queue<int> q;
    q.push(1);
    vector<bool> used(n+1,false);
    used[1]=true;
    while(!q.empty()){
        int now=q.front();q.pop();
        for(auto next: to[now]){
            if(used[next]) continue;
            used[next]=true;
            v[next]+=v[now];
            q.push(next);
        }
    }
    for(int i=1; i<=n; i++) cout << v[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 15604
from collections import deque
import sys
input = sys.stdin.readline

_ = int(input())
S = [int(i) for i in input().strip().split()]
_ = int(input())
T = [int(i) for i in input().strip().split()]

ans = 0
for t in T:
    if t in S:
        ans += 1

print(ans)



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

int main() {
  int N, K, Q;
  scanf("%d%d%d", &N, &K, &Q);

  vector<int> A(N, K);
  vector<int> b(N, Q);
  for (int i = 0; i < Q; i++) {
    int ca = 0;
    scanf("%d", &ca);
    b.at(ca - 1)--;
  }

  for (int i = 0; i < N; i++) {
    if (A.at(i) - b.at(i) > 0)
      printf("Yes\n");
    else
      printf("No\n");
  }
  return 0;
}


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

int main() {
  int K,A,B,X;
  cin >> K >> A >> B;
  X =B-A+1;
  
  for(int i=0;i<X;i++){
    if(A%K == 0){
      cout << "OK" << endl; 
      return 0;
    } 
    A += 1;
  }
  {
    cout << "NG" << endl;
  }
  }


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N, Alice, Bob;
	Alice = 0;
	Bob = 0;
	int a[100];
	cin >> N;
	for (int i = 0; i < N; ++i) cin >> a[i];
	sort (a ,a + N, greater<int>());
    for (int i = 0; i < N; ++i) {
        if (i % 2 == 0) Alice += a[i];		
        else Bob += a[i];
	}
    cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
class Main {
    public static void main(String[] args) {
      
        Scanner sc = new Scanner(System.in);
        int sous = sc.nextInt();
      	int kazu = sc.nextInt();
       	int C = sc.nextInt();
        int flag = 0;
        int sam = 0;
      int b[] = new int[kazu];
      
      for(int i=0;i<kazu;i++){b[i] = sc.nextInt();}
      for(int j=0;j<sous;j++){
        sam = 0;
        for(int k=0;k<kazu;k++){
          sam += sc.nextInt()*b[k];
        } if(sam+C>0){flag++;}
      }
      
       System.out.print(flag);
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
ll n,d,a,b;
cin>>n>>d;
vector<double>v;
while(n--)
{
    cin>>a>>b;
   double c=(double)(a*a)+(double)(b*b);
c=sqrt(c);
    v.push_back(c);
}
ll x=0;
for(ll i=0;i<v.size();i++)
{
    //cout<<v[i]<<" ";
   if(v[i]<=d)x++;
}
cout<<x;
    return 0;
}


Measured memory_bytes: 5416
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;

// Begin Template IO/Utility
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
void dbg_out(){
	cerr<<endl;
}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){
	cerr<<' '<< H; 
	dbg_out(T...);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &V){
	os<<'[';
	for(int i=0;i<(int)V.size();i++)
		os<<V[i]<<",]"[i==(int)V.size()-1];
	return os;
}
template<typename T> istream& operator>>(istream &is, vector<T> &V){
	for(T &x:V)
		is>>x;
	return is;
}
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T,U> &p){
	os<<'{'<<p.first<<','<<p.second<<'}';
	return os;
}
template<typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){
	is>>p.first>>p.second;
	return is;
}
template<typename T> void minself(T &a, T &b){
	a=min(a,b);
}
template<typename T> void maxself(T &a, T &b){
	a=max(a,b);
}
// End Template IO/Utility
int main(){
	cin.tie(0),cin.sync_with_stdio(0),cout.tie(0),cout.sync_with_stdio(0);
	cout<<setprecision(10);
	int r;
	cin>>r;
	cout<<r*2*M_PI;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
int a,b,c,k;
int main()
{
	cin>>a>>b>>c>>k;
	if (a<c) swap(a,c);
	if (a<b) swap(b,a);
	while (k--) a*=2;cout<<a+b+c;return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rep2(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rev(i, n) for (int (i) = (n)-1; (i) >= 0; (i)--)
#define rev2(i, a, b) for (int (i) = (a)-1; (i) >= (b); (i)--)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pll = pair<long long, long long>;
template<class T> using Vec = vector<T>;
template<class T> using VVec = vector<vector<T>>;
long long TEN(int i) {return !i ? 1 : TEN(i-1)*10LL;}
template<class T, class U> 
bool chmin(T& a, const U& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T, class U> 
bool chmax(T& a, const U& b) {if (a < b) {a = b; return 1;} return 0;}

struct IoSetup {
	IoSetup() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} iosetup;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

string S;

void solve() {
	for (char c = 'a'; c <= 'z'; c++) {
		bool ok = true;
		for (int i = 0; i < S.size(); i++) if (S[i] == c) ok = false;
		if (ok) {
			cout << c << endl;
			return;
		}
	}
	cout << "None" << endl;
}

int main() {
	cin >> S;
	solve();
	
	return 0;
}

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

signed main() {
  int A, B;
  cin >> A >> B;
  
  int count = 0;
  for( int i = A; i <= B; i++ ){
    int man = i / 10000;
    int sen = (i / 1000) % 10;
    int zyu = (i / 10) % 10;
    if( man == i % 10 && sen == zyu ){
      count++;
    }
  }
  cout << count << endl;
  
}


Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = 0;
    if(a >= 10){
      System.out.println(b);
    } else {
     c = 100 * (10 - a);
      int d = b + c;
      System.out.println(d);
    }
    
 }
}

Measured memory_bytes: 21844
#include <iostream>
#include <map>
using namespace std;
int main(){
  int n; cin >> n;
  map<long long int, bool> cnt;
  for(int i=0;i<n;i++){
    long long int a; cin >> a;
    cnt[a]^=true;
  }
  int ans=0;
  for(auto c:cnt) ans+=c.second;
  cout << ans << endl;
}


Measured memory_bytes: 6528
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int main(){
	int n, m;
	cin >> n >> m;
	vector<ll> h(n);
	rep(i, n) cin >> h[i];
	ll ans = 0;
	vector<vector<int>> r(n);

	rep(i, m)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		r[a].push_back(b);
		r[b].push_back(a);
	}
	rep(i,n){
		int f = 1;
		for (auto x : r[i])
		{
			if(h[i] <= h[x])
				f = 0;

		}
		ans += f;
	}
	cout << ans << endl;

	return 0;
}

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

int main(){
  int N;
  string S;
  cin >> N >> S;
  int c = 0;
  for(int i = 0; i < 1000; i++){
    int k = 0;
    string I = to_string(i);
    if(i < 10){
      I = "00"+I;
    }else if(i < 100){
      I = "0"+I;
    }
    for(int j = 0; j < N; j++){
      if(S[j] == I[k]){
        k += 1;
      }
    }
    if(k == 3){
      c += 1;
    }
  }
  cout << c << endl;
}

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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int x[15][15];
    for(int i = 0; i < 15; i++) {
        for(int j = 0; j < 15; j++) {
            x[i][j] = -1;
        }
    }
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        for(int j = 0; j < a[i]; j++) {
            int tmp;
            cin >> tmp;
            cin >> x[i][tmp - 1];
        }
    }
    int ans = 0;
    for(int i = 1; i < (1 << n); i++) {
        int flg = 0;
        for(int j = 0; j < n; j++) {
            //trust
            if(i & (1 << j)) {
                for(int k = 0; k < n; k++) {
                    //dbg
                    //cout << i << ' ' << j << ' ' << k << ' ' << x[j][k] << endl;
                    if((x[j][k] == 0 && (i & (1 << k))) || (x[j][k] == 1 && !(i & (1 << k)))) {
                        flg = 1;
                        break;
                    }
                }
            }
            if(flg) break;
        }

        if(!flg) {
            int bf = 0;
            for(int cn = 0; cn < n; cn++) {
                if((i >> cn) & 1) bf++;
            }
            //dbg
            //cout << "update" << bf << endl;
            ans = bf > ans ? bf : ans;
        }
    }
    cout << ans << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, n;
    cin >> a >> b >> n;
    vector<bool> reserve(1001, false);
    for (int i = 0; i < n; i++)
    {
        int s, f;
        cin >> s >> f;
        for (int j = s; j < f; j++)
        {
            reserve[j] = true;
        }
    }
    for (int i = a; i < b; i++)
    {
        if (reserve[i])
        {
            cout << "1" << endl;
            return 0;
        }
    }
    cout << "0" << endl;
}


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

int main()
{
	int64_t n, k, s;
	cin >> n >> k >> s;

	vector<int64_t> ans(n, 1);

	int64_t mod = 1000000000;

	random_device rnd;

	auto f = [&] {
		int64_t ret = 0;
		for (int64_t l = 0, r = 0, tmp = 0; r < n;)
		{
			while (r < n && tmp < s)
			{
				tmp += ans[r];
				r++;
			}
			while (l < r && s <= tmp)
			{
				if (tmp == s)
				{
					ret++;
				}
				tmp -= ans[l];
				l++;
			}
		}
		return ret;
	};

	while (f() != k)
	{
		for (int64_t i = 0; i < k; i++)
		{
			ans[i] = s;
		}
		for (int64_t i = k; i < n; i++)
		{
			ans[i] = rnd() % mod + 1;
		}
	}

	for (auto &&a : ans)
	{
		cout << a << ' ';
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define ll long long
#define rep(i,a) for(ll i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>

ll n;
vector<P>G[111111];
ll ans[111111];
bool visit[111111];

void dfs(ll pos,ll score){
  
  //cout<<pos<<" "<<score<<endl;

  if(visit[pos]){
    return ;
  }


  ans[pos]=score;

  ll s=G[pos].size();
  rep(i,s){
    ll to=G[pos][i].first,w=G[pos][i].second;

    if(visit[to])
      continue;
    
    ll nscore=score+w;
    //ans[pos]=score;
    //cout<<nscore<<endl;
    visit[pos]=true;
    dfs(to,nscore);
  }

}

int main(){

  cin>>n;


  rep(i,n-1){
    ll a,b,w;
    cin>>a>>b>>w;
    a--;b--;
    G[a].pb(mp(b,w));
    G[b].pb(mp(a,w));
  }

  dfs(0,0);

  rep(i,n){
    cout<<ans[i]%2<<endl;
  }


	return 0;
}


Measured memory_bytes: 9088
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>

using std::list;
using std::max;
using std::min;
using std::vector;

int main()
{
  char buf1[0x100];
  char buf2[0x200];
  fgets(buf1, sizeof(buf1), stdin);
  fgets(buf2, sizeof(buf2), stdin);
  char* p1 = strchr(buf1, '\n');
  *p1 = '\0';
  char* p2 = strchr(buf2, '\n');
  *p2 = '\0';
  if(strlen(buf1) != strlen(buf2)) {
    puts("No");
    return 0;
  }
  size_t len = strlen(buf2);
  memcpy(p2, buf2, len);
  p2[len] = '\0';
  if(strstr(buf2, buf1)) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			Deque<Character> stack = new ArrayDeque<>();
			char[] s = in.nextString().toCharArray();
			int len = s.length;

			stack.add(s[0]);
			for (int i = 1; i < len; i++) {
				if (s[i-1]==s[i]) {
					continue;
				}
				stack.add(s[i]);
			}
			int count = -1;
			while (!stack.isEmpty()) {
				stack.pop();
				count++;
			}
			out.println(count);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 26324
#include <bits/stdc++.h>
 
using namespace std;
 
#define mP make_pair
#define pB push_back
#define ll long long
#define X first
#define Y second
 
int main(){
	ll n,h;
	cin >> n >> h;
 
	vector<pair<ll , ll> > vp;
 
	ll mmax = 0;
	ll mmaxb = 0;
	ll maxi = 0;
 
	for(int i = 0 ; i < n ; ++i){
		ll x , y;
		cin >> x >> y;
		vp.pB(mP(y , x));
		if(x >= mmax){
			if(x > mmax){
				mmax = x;
				maxi = i;
			}
			else if(x == mmax && y <= vp[maxi].X){
				mmax = x;
				mmaxb = y;
				maxi = i;
			}
		}
	}
 
	ll ans = 0;
 
	sort(vp.begin() , vp.end());
        reverse(vp.begin() , vp.end());
 
	bool flag = false;
	for(int i = 0 ; i < n ; ++i){
		if(h - mmaxb <= 0){
			cout << ans + 1 << endl;
			return 0;
		}
		if(vp[i].X == mmaxb && vp[i].Y == mmax && !flag){
			flag = true;
			continue;
		}
		if(vp[i].X > mmax){
			h -= vp[i].X;
			++ans;
			if(h <= 0)
				break;
		}
	}
 
	if(h <= 0){
		cout << ans << endl;
	}else{
		if(h - mmaxb <= 0){
			cout << ans + 1 << endl;
			return 0;
		}
		if(mmaxb > mmax){
			ans = (h - mmaxb) / mmax + ans + 2;
			if((h - mmaxb) % mmax == 0)
				--ans;
		}
		else{
			ans = (h) / mmax + ans + 1;
			if((h) % mmax == 0)
				--ans;
		}
		
		cout << ans << endl;
	}
 
	return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("INP.txt", "r", stdin);
	//freopen("OUT.txt", "w", stdout);
	ll n, m, q;
	cin >> n >> m >> q;
	vector<ll> hold(n + 10);
	for (ll i = 0; i < n; i++) {
		hold[i] = 0;
	}
	while (q--) {
		ll player;
		cin >> player;
		hold[1]++;
		hold[player]--;
		hold[player + 1]++;
	}
	for (ll i = 1; i <= n; i++) {
		hold[i] += hold[i - 1];
		if (hold[i] >= m) {
			cout << "No" << '\n';
		}
		else {
			cout << "Yes" << '\n';
		}
	}
	return 0;
}	

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

using namespace std;

typedef pair <int ,int > p;
p a[100005];
int cmp(p a,p b)
{
    if(a.first > b.first) return 0;
    if(a.first < b.first) return 1;
    else
    {
        return a.second<b.second;
    }
}
int main()
{
    int n,m,x,y;

    int sum;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)
    {
        scanf("%d%d",&a[i].first,&a[i].second);
    }
    //printf("%d ",a[1].first);
    sort(a,a+m,cmp);
    //printf("%d ",a[4].first);
//    for(int i=0;i<m;i++)
//        printf(" %d %d\n",a[i].first,a[i].second);
    sum=0;
    int l=a[0].first;
    int r=a[0].second;
    for(int i=1;i<m;i++)
    {
//        printf("l=%d,r=%d\n",l,r);
//        printf("%d  %d\n",a[i].first,a[i].second);
        if(l<=a[i].first && r>=a[i].second)
        {
//            printf("c");
            l=a[i].first,r=a[i].second;
        }
        else if(r>a[i].first && r<a[i].second)
        {
//            printf("b");
            l=a[i].first;
        }
        else if(a[i].first >= r)
        {
//            printf("a");
            l=a[i].first,r=a[i].second;
            sum++;
        }
    }
    printf("%d\n",sum+1);
    return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main{
    public static void main(String args[]) {
        FastReader sc = new FastReader();
        int x = sc.nextInt();
        int ans = 0;
        int sum = 0;
        while (sum < x) {
            ans++;
            sum = ans * (ans + 1) / 2;
        }
        System.out.println(ans);
}

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 23124
#include <cstdio>
#include <algorithm>

#define maxn 100000
#define ll long long



int main() {
    ll x, y;
    scanf("%lld%lld", &x, &y);
    ll t = x - y;
    if (t == 0 || t == -1 || t == 1)
        printf("Brown");
    else
        printf("Alice");
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char a[111],b[111];
int main()
{
    cin>>a;
    cin>>b;
    int U=strlen(a),V=strlen(b);
    int A=min(U,V),K=max(U,V);
    for(int i=0;i<=A-1;i++) cout<<a[i]<<b[i];
    if(U>V) for(int i=A;i<=K-1;i++) cout<<a[i];
    else for(int i=A;i<=K-1;i++) cout<<b[i];
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#define ll long long int
using namespace std;

ll calc(int n, int* c){
		if(c[n] > -1)return c[n];
		int result = n;
		for(int i = 1; pow(6, i) <= n; i++){
				int this_result = calc(n - pow(6, i), c) + 1;
				if(this_result < result)result = this_result;
		}
		for(int i = 1; pow(9, i) <= n; i++){
				int this_result = calc(n - pow(9, i), c) + 1;
				if(this_result < result)result = this_result;
		}
		c[n] = result;
		return result;
}

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	int *c = new int[n + 1];
	for(int i = 0; i < n + 1; i++)c[i] = -2;
	c[0] = 0;
	c[1] = 1;
	cout << calc(n, c) << endl;
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define pair<int, int> pi;
#define MOD 1000000007
#define INF 2000000001

using namespace std;

int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int n, m, a, x, y, A[200001];
int main() {
	cin >> n;
	if (n == 3 || n == 7 || n == 5)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 764
#include<stdio.h>

int main(void){
	
	int n,m,i,j,count=0,lastone=0,finish=0,num[1000]={0};
	
	while(1){
		scanf("%d%d",&n,&m);
		if(m==0 && n==0)break;
	for(i=0;i<=n;i++)num[i]=1;

	for(j=0;;j++){
		if(lastone==n){finish=j; break;}
		if(num[j]!=0)count++;
		if(count==m){num[j]=0; count=0; lastone++;}
		if(j==n)j=0;
	}
	printf("%d\n",finish);
	finish=0;
	lastone=0;
	count=0;
	}
return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cassert>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

struct pos {
    double x, y;
    pos(double x, double y):x(x), y(y) {}
};

struct line {
    double slope, intercept;
    line(double slope, double intercept):slope(slope), intercept(intercept) {}
    double getX(double y) {
        return slope * (y - intercept);
    }
    double getY(double x) {
        return slope * x + intercept;
    }
    static pos getCrossPos(line l1, line l2) {
        double x = (l2.intercept - l1.intercept) / 2;
        double y = (l1.intercept + l2.intercept) / 2;
        return {x, y};
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<double> T(N), V(N);
    for (auto& t : T) {
        cin >> t;
    }
    for (auto& v : V) {
        cin >> v;
    }
    V.push_back(0);
    vector<double> cumsum(N, 0);
    rep(i, 0, N) {
        cumsum[i] = T[i] + (i ? cumsum[i - 1] : 0);
    }
    vector<line> L;
    rep(i, 1, N + 1) {
        L.emplace_back(-1, V[i] + cumsum[i - 1]);
    }
    double elapsed = 0;
    double now_v = 0;
    double ans = 0;
    rep(i, 0, N) {
        int idx = -1;
        line now(1, now_v - elapsed);
        double last_x = elapsed + T[i];
        double max_v = now.getY(last_x);
        rep(j, i, N) {
            pos cross_pos = line::getCrossPos(now, L[j]);
            if (cross_pos.x <= last_x && chmin(max_v, cross_pos.y)) {
                idx = j;
            }
        }
        if (idx < 0) {
            double x = last_x;
            if (chmin(max_v, V[i])) {
                x = now.getX(V[i]);
            }
            ans += (x - elapsed) * (now_v + max_v) / 2;
            ans += (last_x - x) * max_v;
            now_v = max_v;
        } else {
            double x1 = line::getCrossPos(now, L[idx]).x;
            double x2 = x1;
            double next_v = L[idx].getY(last_x);
            if (chmin(max_v, V[i])) {
                x1 = now.getX(V[i]);
                x2 = L[idx].getX(V[i]);
                if (chmin(x2, last_x)) {
                    next_v = V[i];
                }
            }
            ans += (x1 - elapsed) * (now_v + max_v) / 2;
            ans += (x2 - x1) * max_v;
            ans += (last_x - x2) * (max_v + next_v) / 2;
            now_v = next_v;
        }
        elapsed += T[i];
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b)cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
/*
author : seryu
title : AGC019A_"Ice Tea Store"
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
typedef long long ll;
typedef pair<int, int> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{
	ll q, h, s, d, n;
	cin >> q >> h >> s >> d >> n;
	chmin(s,4*q);
	chmin(s,2*h);
	chmin(d,2*s);
	ll ans = n/2*d+(n%2)*s;
	cout << ans << endl;
	return;	
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		System.out.println(countHug(s));
		sc.close();
	}
	
	static int countHug(char[] s) {
		int cnt = 0;
		for (int i = 0; i < s.length / 2; i++) {
			if (s[i] != s[s.length - 1 - i])
				cnt++;
		}
		return cnt;
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,w,h) rep(j,h)rep(i,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main() { 
    int x,y;
    std::cin >> x>>y;
    if(x==3)x=100000;
    if(x==2)x=200000;
    if(x==1)x=300000;
    if(y==3)y=100000;
    if(y==2)y=200000;
    if(y==1)y=300000;
    if(x+y==600000)x+=400000;
    if(x<100000)x=0;
    if(y<100000)y=0;
    std::cout << x+y << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<map>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define maxn 3010
using namespace std;

int main(){
	int x,y;
	cin>>x>>y;
	for(int i=y-x+1;i<=y+x-1;i++) printf("%d ",i);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <cmath>
#include <stdio.h>
#include <sstream>
#define int_inf 1000000000 //1e9
#define ll_inf  1000000000000000000 //1e18
using namespace std;
template <typename T> std::string to_string(const T& t){
	std::ostringstream os; os<<t; return os.str();
}

int main(){
	int n[3];
	cin>>n[0]>>n[1]>>n[2];
	sort(n, n+3);
	cout<<n[0]+n[1]<<endl;
	return 0;
}




Measured memory_bytes: 256
#include <cstdio>
#include <deque>
#include <algorithm>
using namespace std;
int n, x, rev;
deque<int> ans;
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &x);
        if (rev) ans.push_front(x);
        else ans.push_back(x);
        rev ^= 1;
    }
    if (rev) reverse(ans.begin(), ans.end());
    for (auto &i : ans) printf("%d ", i);
}


Measured memory_bytes: 2944
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
bool ar[1000000]={0};
int main()
{
     ios_base::sync_with_stdio(false);cin.tie(NULL);
     ll int i,n,j=0,p,x,a=0,b,l=0,r=0,y,k,m,d;
     cin>>n;
     int ara[n];
     for(i=0;i<n;i++){
        cin>>ara[i];
        ar[ara[i]]=1;
     }
     sort(ara,ara+n);
     if(n==1){
        cout<<1<<endl;return 0;
     }
     if(ara[0]==1){
        if(ara[1]==1){
            cout<<0<<endl;
        }
        else{
            cout<<1<<endl;
        }
        return 0;
     }
     for(i=0;i<n;i++){
            j=0;x=0;m=2;
        while(m<=sqrt(ara[i])){
            if(i+1!=n){
                if(ara[i]==ara[i+1]){
                    x=1;break;
                }
            }
            if(i!=0){
                if(ara[i]==ara[i-1]){
                    x=1;break;
                }
            }
            if(ara[i]%m==0){
                if(ar[m]==1){
                    x=1;break;
                }
                if(ar[ara[i]/m]==1){
                    x=1;
                    break;
                }
            }
            m++;
        }
        if(x==0){
            l++;
        }
     }
     cout<<l<<endl;


     return EXIT_SUCCESS;
}


Measured memory_bytes: 5408
import bisect


class UnionFind():
    
    def __init__(self, n):
        self.n = next
        self.parent = [-1 for i in range(n)]
    
    def find(self, x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        else:
            if self.parent[x] > self.parent[y]:
                x, y = y, x
            self.parent[x] += self.parent[y]
            self.parent[y] = x
            return True
    
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def size(self, x):
        return -self.parent[self.find(x)]
    
    def __str__(self):
        return str(self.parent)



def read():
    N, M, K = list(map(int, input().strip().split()))
    uf = UnionFind(N)
    friends = [list() for i in range(N+1)]
    blocked = [list() for i in range(N+1)]
    for i in range(M):
        a, b = list(map(int, input().strip().split()))
        friends[a].append(b)
        friends[b].append(a)
        uf.unite(a-1, b-1)
    for i in range(K):
        c, d = list(map(int, input().strip().split()))
        blocked[c].append(d)
        blocked[d].append(c)
    return N, M, K, friends, blocked, uf


def solve(N, M, K, friends, blocked, uf):
    n_friendships = [0 for i in range(N)]
    for i in range(1, N+1):
        n = uf.size(i-1)
        m = len(friends[i])
        k = 0
        for b in blocked[i]:
            if uf.same(i-1, b-1):
                k += 1
        n_friendships[i-1] = n-1-m-k
    return ' '.join(map(str, n_friendships))


if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs)))


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

using namespace std;

int a[100005];

struct dat {
	int x, y;
	bool operator < (const dat& T) const {
		return y > T.y;
	}
}b[100005];

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	
	sort(a, a + n);
	
	for (int i = 0; i < m; i++) scanf("%d%d", &b[i].x, &b[i].y);
	
	sort(b, b + m);
	
	int p = 0;
	
	for (int i = 0; i < n; i++) {
		if (p < m && b[p].y > a[i]) {
			a[i] = b[p].y;
			b[p].x--;
			if (b[p].x == 0) p++;
		}
	}
	
	long long res = 0;
	
	for (int i = 0; i < n; i++) res += a[i];
	
	printf("%lld\n", res);
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <numeric>

using namespace std;

using ll =long long;

int main()
{
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    ll ans = 0;
    if(K <= A)
    {
        ans = K;
    }
    else if(K <= A + B)
    {
        ans = A;
    }
    else 
    {
        ans = A - (K - (A + B));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, long long m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

const int N=1e6+5;

int n;
char s[N];
int E[N], W[N];

int32_t main()
{
    IOS;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s[i];
		E[i]=E[i-1] + (s[i]=='E');
		W[i]=W[i-1] + (s[i]=='W');
	}
	int ans=n-1;
	for(int i=1;i<=n;i++)
	{
		ans=min(ans, W[i-1] + E[n] - E[i]);
	}
	cout<<ans;
    return 0;
} 

Measured memory_bytes: 10496
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) rep2(i,0,n-1)
int MOD=1000000000+7;
int INF=1e6;
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    ll int n,a,b;
    cin>>n>>a>>b;
    ll int x[110000]={};
    rep(i,n){
        cin>>x[i];
    }
    ll int sum=0;
    rep(i,n-1){
        if(a*(x[i+1]-x[i])<b) sum+=a*(x[i+1]-x[i]);
        else sum+=b;
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 1152
import sys

def solve():
    input = sys.stdin.readline
    N, L = map(int, input().split())
    sumT, minT = 0, 100000000000
    pm = 0
    for i in range(N):
        sumT += L + i
        if abs(L + i) < minT:
            minT = abs(L + i)
            if L + i < 0: pm = 1
    print(sumT - minT * (-1) ** pm)
        

    return 0

if __name__ == "__main__":
    solve()

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

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define fr(x,in,n,r) for(ll x=in;x<n;x+=r)
#define ifr(x,n) for(ll x=0;x<n;x++)
#define dfr(x,n) for(ll x=n-1;x>=0;x--)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define pof(a) pop_front(a)
#define pob(a) pop_back(a)
#define eb(a) emplace_back(a)
#define ef(a) emplace_front(a)
typedef long long ll;
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007

bool fun(pll a,pll b){
	return a.ss<b.ss;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt","r",stdin);
	ll a,b;
	cin>>a>>b;
	ll ans=(a*3+b)/2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string s;
    cin >> s;
    char prev = '-';
    int cnt = 0;
    for (const auto c : s)
    {
        if (prev != c)
        {
            ++cnt;
            prev = c;
        }
    }
    cout << cnt - 1 << endl;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    lint w, h, x, y;
    cin >> w >> h >> x >> y;

    cout << fixed << setprecision(10) << (double)(w * h) * 0.5 << " ";
    if(x * 2 == w && y * 2 == h){
        cout << "1" << endl;
    }else{
        cout << "0" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n,*l=map(int,open(0).read().split())
a=b=0
c=0
l+=[0]
while True:
	while l[a]<=l[a+1] and a!=n-1:
		a+=1
	while l[b]>=l[b+1] and b!=n-1:
		b+=1
	a=b=max(a,b)+1
	c+=1
	if a==n-1:
		c+=1
		break
	elif a==n:
		break
print(c)

Measured memory_bytes: 14052