akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <stack>

int n,ans=0,cnt=1,banana=0;
int a[100000];
int b[100000];

#define Fi for (i = 0; i < n; i++)

using namespace std;
int main()
{
	int i, j, l;
	cin >> n;
	Fi cin >> a[i];
	Fi {
		if (i == n - 1) {
			b[banana] = cnt;
		}
		if (a[i] != a[i + 1]) cnt++;
		else if (a[i] == a[i + 1]) {
			b[banana] = cnt;
			cnt = 1;
			banana++;
		}

	}
	banana++;
	b[banana] = a[n];
	if (banana == 1) ans = b[0];
	else if (banana == 2) ans = b[0] + b[1];
	else {
		for (j = 0; j < banana; j++) {
			l = b[j] + b[j + 1] + b[j + 2];
			if (ans < l) ans = l;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3684
// JAI SHREE RAM
#pragma GCC optimize("O3")
typedef long long int ll;
typedef unsigned long long int ull;
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define sec second
#define fir first
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repe(i,m,n) for(ll (i)=(m);(i)<(n);(i)++)
#define pb push_back
#define pii pair<int,int>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int pre_sum[5000009] ;
void solve()
{
int  k;
cin>>k;
string s;
cin>>s;
if(s.length()<=k)
{
	cout<<s<<endl;
	return;
}
else
{
	int i=0;
	while(k--)
	{
		cout<<s[i];
		i++;
	}
	cout<<"...\n";
}
}


int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fast
	int T;
	T = 1;
	// cin >> T;
	while (T--)
	{
		solve();
	}
	return 0;
}


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

#define fi first
#define se second
#define show(x) cerr << #x << "=" << "\n"
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int n, a, b;
int x[100001];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  FILE *stream2;
  stream1 = freopen("in.txt", "r", stdin);
  stream2 = freopen("out.txt", "w", stdout);
  if (stream1 == NULL) return 0;
  if (stream2 == NULL) return 0;
#endif
  cin >> n >> a >> b;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  ll ans = 0;
  for (int i = 1; i < n; i++) {
    ll dis = x[i] - x[i - 1];
    if (dis * a >= b) {
      ans += b;
    } else {
      ans += dis * a;
    }
  }
  cout << ans << endl;
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  fclose(stream1);
  fclose(stream2);
#endif
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000

int D;
vector<int> c(26);
vector<vector<int>> s;

struct Data{
	vector<int> t;
	vector<vector<int>> penalty;
	int score;
	
	Data(){
		t.resize(D,0);
		penalty.resize(D+1,vector<int>(26,0));
		score = 0;
	}
};

void init(){
	cin>>D;
	for(int i=0;i<26;i++)scanf("%d",&c[i]);
	
	s.resize(D,vector<int>(26));
	for(int i=0;i<D;i++){
		for(int j=0;j<26;j++)scanf("%d",&s[i][j]);
	}
}

Data generate(vector<int> t){
	Data ret;
	ret.t = t;
	vector<int> last(26,0);
	for(int i=0;i<t.size();i++){
		int temp = t[i];
		ret.score += s[i][temp];
		last[temp] = i+1;
		
		for(int j=0;j<26;j++){
			ret.penalty[i+1][j] = ret.penalty[i][j] + c[j];
			if(temp==j)ret.penalty[i+1][j] = 0;
			ret.score -= ret.penalty[i+1][j];
		}
	}
	return ret;
}

int change(Data &d,int ind,int nv){
	int o_score = d.score;
	int ov = d.t[ind];
	d.score += s[ind][nv];
	d.score -= s[ind][ov];
	d.t[ind] = nv;
	for(int i=ind+1;i<=D;i++){
		d.score += d.penalty[i][nv];
		d.score += d.penalty[i][ov];
		if(i==ind+1){
			d.penalty[i][nv] = 0;
			d.penalty[i][ov] = d.penalty[i-1][ov] + c[ov];
		}
		else{
			if(d.penalty[i][nv]!=0){
				d.penalty[i][nv] = d.penalty[i-1][nv]+c[nv];
			}
			if(d.penalty[i][ov]!=0){
				d.penalty[i][ov] = d.penalty[i-1][ov]+c[ov];
			}
		}
		d.score -= d.penalty[i][nv];
		d.score -= d.penalty[i][ov];
	}
	
	return d.score - o_score;
}

int main(){
	
	init();
	
	vector<int> t;
	for(int i=0;i<D;i++){
		int x;
		cin>>x;
		x--;
		t.push_back(x);
	}
	Data d = generate(t);

	int M; 
	cin>>M;
	
	for(int i=0;i<M;i++){
		int x,y;
		cin>>x>>y;
		change(d,x-1,y-1);
		cout<<d.score<<endl;
	}
	
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  int x = tx - sx, y = ty - sy;
  string res = "";
  for (int i = 0; i < y; i++) res += 'U';
  for (int i = 0; i < x; i++) res += 'R';
  for (int i = 0; i < y; i++) res += 'D';
  for (int i = 0; i < x; i++) res += 'L';
  res += 'L';
  for (int i = 0; i < y + 1; i++) res += 'U';
  for (int i = 0; i < x + 1; i++) res += 'R';
  res += "DR";
  for (int i = 0; i < y + 1; i++) res += 'D';
  for (int i = 0; i < x + 1; i++) res += 'L';
  res += 'U';
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
s=input()
u=s.count('RL')
if u>k:
  print(n-(u-k)*2-(s[0]=='L')-(s[n-1]=='R'))
else:
  print(n-1-(s[0]=='L')*(s[n-1]=='R')*(u==k))

Measured memory_bytes: 3316
// (c) 2020, redotter
// The grass was greener...

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#pragma comment(linker, "/stack:200000000")
#endif

#define pb push_back
#define the(a) (a).begin(), (a).end()
#define ft first
#define sd second
#define endl "\n"
#define forn(i, n) for (int i = 0; i < (n); i++)

using i64 = long long;
using i32 = int;
using f64 = long double;

template <class T> using vec = vector<T>;
using str = string; using p64 = pair<i64, i64>;
using v64 = vec<i64>; using vv64 = vec<v64>;
using s64 = set<i64>; using m64 = map<i64, i64>;
template <size_t Size1> using a64 = array<i64, Size1>;
template <size_t Size1, size_t Size2> using aa64 = array<a64<Size2>, Size1>;
template <class T> using hash_set = unordered_set<T>;
template <class T, class U> using hash_map = unordered_map<T, U>;

mt19937 gen(998244353);
const i64 inf = numeric_limits<i64>::max() / 2;

template <class T> inline i64 len(const T& a) { return (i64)(a.size()); }
inline void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }
template <class T, class S>
inline bool check_min(T& a, S b) { if (a > b) return a = b, 1; return 0; }
template <class T, class S>
inline bool check_max(T& a, S b) { if (a < b) return a = b, 1; return 0; }

void read() {}
template<class T, class ...U>
void read(T& a, U& ...b) { cin >> a; read(b...); }
void print() {}
template<class T, class ...U>
void print(const T& a, const U& ...b) { cout << a << " "; print(b...); }
void println() { cout << "\n"; }
template<class T, class ...U>
void println(const T& a, const U& ...b) { cout << a << " "; println(b...); }

struct Problem {
	void files(str in, str out) {
#ifdef ONLINE_JUDGE
		freopen(in.c_str(), "r", stdin), freopen(out.c_str(), "w", stdout);
#endif
	}
	void solve(), input();
	void many() { i64 t; cin >> t; while (t--) input(), solve(); }
	void make(bool mt = 0) { if (mt) many(); else input(), solve(); }
} problem;

signed main() {
	fast();
	problem.make();
#ifdef _DEBUG
	println(); println("[finished]"); system("pause > nul");
#endif
	return 0;
}

i64 n;
v64 a, b;

void Problem::solve() {
	sort(the(a)), sort(the(b));
	if (n % 2 == 1) {
		i64 ans = b[n / 2] - a[n / 2] + 1;
		println(ans);
	} else {
		f64 m1 = (a[n / 2] + a[(n - 1) / 2]) / 2.0;
		f64 m2 = (b[n / 2] + b[(n - 1) / 2]) / 2.0;
		i64 ans = 2 * (m2 - m1) + 1;
		println(ans);
	}
}

void Problem::input() {
	read(n);
	a.resize(n), b.resize(n);
	forn(i, n) {
		read(a[i], b[i]);
	}
}


Measured memory_bytes: 6316
def relation(xa, ya, ra, xb, yb, rb)
	d = ((xa - xb) ** 2 + (ya - yb) ** 2) ** 0.5
	return 0 if ra + rb < d

	return 2 if d + rb < ra
	return -2 if d + ra < rb
	return 1
end

$<.gets.to_i.times do
	p relation(*$<.gets.split.map(&:to_f))
end

Measured memory_bytes: 6168
/*
* @Author: 王文宇
* @Date:   2017-11-24 00:54:05
* @Last Modified by:   王文宇
* @Last Modified time: 2017-11-24 01:22:06
*/
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main(int argc, char const *argv[])
{
	char a[55],b[55];
	cin>>a>>b;
	int n = strlen(b);
	int m = strlen(a);
	int ok=0;
	int h;
	for(int i=0;i<m;i++)
	{
		int k=i;
		for(int j=0;j<n;j++)
		{
			if(a[k]=='?')
			{
				k++;
				if(j!=n-1)continue;
			}
			else if (a[k]==b[j])
			{
				k++;
				if(j!=n-1)continue;
			}
			else break;
			if(j==n-1)
			{
				ok=1;
				h=i;
		 		break;
			}
		}
	}
	if(ok)
		{
			for(int i=0;i<h;i++)
			{
				if(a[i]=='?')cout<<'a';
				else cout<<a[i];
			}
			for(int i=h;i<h+n;i++)cout<<b[i-h];
			for(int i=h+n;i<m;i++)
			{
				if(a[i]=='?')cout<<'a';
				else cout<<a[i];
			}
			cout<<endl;
		}
	else cout<<"UNRESTORABLE"<<endl;
	return 0;
}

Measured memory_bytes: 256
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    return ret;
}

vector<bool> sieve(long long max){ // 0 <= x <= max までの素数を調べ、返す。
    vector<bool> isPrime;
    isPrime.resize(max+1,true); // isPrimeに必要な要素数を確保
    isPrime[0] = false; // 0は素数ではない
    isPrime[1] = false; // 1は素数ではない

    for(int i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(isPrime[i])
            for(int j=2; i*j<=max; ++j)
                isPrime[i*j] = false;

    return isPrime;
}



int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	ll N; cin >> N;
	ll ans = 0;

	vector<ll> v(N+1);

	rep(i, N){
		// ans += N / (i+1);
		ll x = i + 1;
		ll k = 1;
		while(x <= N){
			x = (i + 1) * k;
			k++;
			if(x > N) break;
			v[x]++;
		}
	}

	rep(i, N){
		ans += (i + 1) * v[i + 1];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 81408
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 1e9+7;
int t,n,m,k,x,y;
int z;
 
int main()
{
	IOS;
	cin>>x>>y>>z;
	if(x+y+z >= 22){
		cout<<"bust"<<ln;
	}
	else{
		cout<<"win"<<ln;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 62;
int main() {
  //
  ll l;
  cin >> l;
  ll r = 1;
  while ((1LL << (r + 1)) <= l) r++;
  ll n = r + 1;
  ll m = 2 * (n - 1);
  vector<tuple<int, int, ll>> edges;
  rep(i, n - 1) {
    edges.emplace_back(i, i + 1, 0);
    edges.emplace_back(i, i + 1, (1LL << i));
  }
  for (int t = n - 2; t >= 0; t--) {
    if (l - (1LL << t) >= (1LL << r)) {
      // cout << t << r << endl;
      edges.emplace_back(t, n - 1, l - (1LL << t));
      m++;
      l -= (1LL << t);
    }
  }
  cout << n << " " << m << endl;
  for (auto& e : edges) {
    cout << get<0>(e) + 1 << " " << get<1>(e) + 1 << " " << get<2>(e) << endl;
  }
  return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<functional>
#include<vector>
#include<string>
#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 >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
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;}

template<typename T>
class ConvecHullTrick {
private:
	std::vector<std::pair<T, T>> lines;
	bool isMonotonicX;
	std::function<bool(T l, T r)> comp;

public:
	ConvecHullTrick(bool flagX = false, std::function<bool(T l, T r)> compFunc = [](T l, T r) {return l >= r; })
		:isMonotonicX(flagX), comp(compFunc)  {
		lines.emplace_back(0, 0);
	};

	bool check(std::pair<T, T> l1, std::pair<T, T> l2, std::pair<T, T> l3) {
		if (l1 < l3) std::swap(l1, l3);
		return (l3.second - l2.second) * (l2.first - l1.first) >= (l2.second - l1.second) * (l3.first - l2.first);
	}

	void add(T a, T b) {
		std::pair<T, T> line(a, b);
		while (lines.size() >= 2 && check(*(lines.end() - 2), lines.back(), line))
			lines.pop_back();
		lines.emplace_back(line);
	}

	T f(int i, T x) {
		return lines[i].first * x + lines[i].second;
	}

	T f(std::pair<T, T> line, T x) {
		return line.first * x + line.second;
	}

	T get(T x) {
		if (isMonotonicX) {
			static int head = 0;
			while (lines.size() - head >= 2 && comp(f(head, x), f(head + 1, x)))
				++head;
			return f(head, x);
		}
		else {
			int low = -1, high = lines.size() - 1;
			while (high - low > 1) {
				int mid = (high + low) / 2;
				(comp(f(mid, x), f(mid + 1, x)) ? low : high) = mid;
			}
			return f(high, x);
		}
	}
};

const ll INF = 1LL << 60;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, C;
    cin >> N >> C;
    vector<ll> H(N);
    for (auto& h : H) {
        cin >> h;
    }
    ConvecHullTrick<ll> cht;
    vector<ll> dp(N, INF);
    dp[0] = 0;
    cht.add(-2 * H[0], H[0] * H[0]);
    rep(i, 1, N) {
        dp[i] = cht.get(H[i]) + H[i] * H[i] + C;
        cht.add(-2 * H[i], dp[i] + H[i] * H[i]);
    }
    cout << dp[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 9584
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl '\n'
#define ld long double
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (int i=(n);i>=(a);--i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
 
/*
░░░░░░░░░░░░░░░░░░░░░░░░░
░░█▀▀▄░░░░░░░░░░░▄▀▀█░░░░
░░█░░░▀▄░▄▄▄▄▄░▄▀░░░█░░░░
░░░▀▄░░░▀░░░░░▀░░░▄▀░░░░░
░░░░░▌░▄▄░░░▄▄░▐▀▀░░░░░░░
░░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█░
░░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█░
░▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█░
░█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀░
░░▀▄░░▀░░▀▀▀░░▀░░░▄█▀░░░░
░░░░█░░░░░░░░░░░▄▀▄░▀▄░░░
░░░░█░░░░░░░░░▄▀█░░█░░█░░
░░░░█░░░░░░░░░░░█▄█░░▄▀░░
░░░░█░░░░░░░░░░░████▀░░░░
░░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░
*/
 
// I want to be the very best, like no one ever was, I will battle everyday to claim my rightful place
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
// I am questioning life and universe and 
// everything else after looking at this

const ll MAXN = 1e5 + 10;
ll a[MAXN];
ll max_a[MAXN];

void solve(){
    ll n; cin>>n;

    FOR(i,1,n) cin>>a[i];

    max_a[n] = a[n];

    RFOR(i,1,n-1){
        max_a[i] = min(max_a[i+1],a[i]);
    }

    bool flag = true;

    FOR(i,1,n){
        ll diff = a[i] - max_a[i];
        if(diff > 1) flag = false; 
    }

    if(!flag) cout<<"No\n";
    else cout<<"Yes\n";
} 
 
signed main(){
 
   FastRead;    
 
    ll t;
    t = 1; 
    //cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstring>
typedef long long ll;
using namespace std;
int n;
ll l,m,r;
ll a[1000010];
bool dfs(int step,ll mn,ll mx) {
    if(step == n) return true;
    if(mn + r * a[step] <= m) {
        if( dfs(step+ 1 , mn + r *a[step] , min(mx + a[step] *l ,m) )) return true;
    }
    if(mx - r *a[step] >= -m){
        if(dfs(step+ 1, max(mn - a[step] * l , -m) , mx - r *a[step])) return true;
    }
    return false;
}
void solve(){
    cin>>n>>l>>m>>r;
    if( 2 * r > l) {
        cout<<"No\n";
        return ;
    }
    for(int i = 0; i <n ;++i) {
        cin>>a[i];
    }
    r *= 2;m *= 2;
    if(dfs(0 , 0 ,0)){
        cout<<"Yes\n";
    }
    else cout<<"No\n";

}
int main(){
    //freopen("input.txt","r",stdin);
    solve();
    return 0;
}

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

int main(void){
    string S;
    cin>>S;
    int len=S.size();
    if(S[len-1]=='s'){
        cout<<S<<"es"<<endl;
    }
    else{
        cout<<S<<'s'<<endl;
    }
   
}


Measured memory_bytes: 3632
//============================================================================
// Name        : AOJ.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>

using namespace std;
typedef long long ll;
int main(){


	int n;
	int m;
	int o;

	cin>>n;

	m=800*n;

	if(n>=15){
		o=n/15;
	}
	o=o*200;

	cout<<m-o<<endl;

	return 0;



}


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

typedef long long ll;
typedef long double ld;
typedef vector<ll> v1;
typedef vector<v1> v2;
typedef vector<v2> v3;

typedef unordered_map<ll, unordered_map<ll, ll>> graph;

const ll INF = 1ll << 50;
const ll mod = 1000000007;

v2 a(3, v1(3, 0));
v2 c(3, v1(3, 0));
ll n;
ll b;
void yes(){
    cout << "Yes" << endl;
    exit(0);
}

void no(){
    cout << "No" << endl;
    exit(0);
}

int main(){
    for(ll i = 0;i < 3;i++){
        for(ll j = 0;j < 3;j++){
            cin >> a[i][j];
        }
    }
    cin >> n;
    for(ll i = 0;i < n;i++){
        ll b;
        cin >> b;
        for(ll j = 0;j < 3;j++){
            for(ll k = 0;k < 3;k++){
                if(a[j][k] == b) c[j][k] = 1;
            }
        }
    }
    for(ll i = 0;i < 3;i++){
        ll flag = 1;
        for(ll j = 0;j < 3;j++){
            if(c[i][j] == 0) flag = 0;
        }
        if(flag == 1){
            yes();
        }
    }
    for(ll i = 0;i < 3;i++){
        ll flag = 1;
        for(ll j = 0;j < 3;j++){
            if(c[j][i] == 0) flag = 0;
        }
        if(flag == 1){
            yes();
        }
    }
    ll flag = 1;
    for(ll i = 0;i < 3;i++){
        if(c[i][i] == 0) flag = 0;
    }
    if(flag == 1){
        yes();
    }
    flag = 1;
    for(ll i = 0;i < 3;i++){
        if(c[i][2-i] == 0) flag = 0;
    }
    if(flag == 1){
        yes();
    }
    no();

}


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

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=a;i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(a>b)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

const int inf=LLONG_MAX/3;

//負辺あったら壊れるからBellman-Fordとかやるといいんじゃない？
template<class D>
struct mincf{
	using P=pair<D,int>;
	struct E{int to,rev,cap;D cost;};
	int n;
	vvc<E> g;
	vc<D> h,d;
	vi pv,pe;
	mincf(int nn):n(nn),g(n),h(n),d(n),pv(n),pe(n){}
	void ae(int a,int b,int cap,D cost){
		g[a].pb({b,(int)g[b].size(),cap,cost});
		g[b].pb({a,(int)g[a].size()-1,0,-cost});
	}
	P go(int s,int t,int f){
		priority_queue<P,vc<P>,greater<P>> q;
		fill(all(d),inf);
		d[s]=0;
		q.push(P(0,s));
		while(q.size()){
			D a;
			int v;
			tie(a,v)=q.top();q.pop();
			if(d[v]<a)continue;
			rep(i,(int)g[v].size()){
				E e=g[v][i];
				if(e.cap>0){
					D w=d[v]+e.cost+h[v]-h[e.to];
					if(w<d[e.to]){
						d[e.to]=w;
						q.push(P(w,e.to));
						pv[e.to]=v;
						pe[e.to]=i;
					}
				}
			}
		}
		if(d[t]==inf)return P(0,0);
		rep(i,n)
			h[i]+=d[i];
		int a=f;
		for(int v=t;v!=s;v=pv[v])
			chmin(a,g[pv[v]][pe[v]].cap);
		for(int v=t;v!=s;v=pv[v]){
			E& e=g[pv[v]][pe[v]];
			e.cap-=a;
			g[e.to][e.rev].cap+=a;
		}
		return P(a*h[t],a);
	}
	D calc(int s,int t,int f){
		D res=0;
		while(f>0){
			P w=go(s,t,f);
			if(w.b==0)
				return inf;
			f-=w.b;
			res+=w.a;
		}
		return res;
	}
};

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	
	int n;cin>>n;
	mincf<ll> mcf(1+n+4+n+1);
	
	const int V=2000000000;
	
	int m=0;
	rep(i,n){
		int x,y,c;cin>>x>>y>>c;
		mcf.ae(0,1+i,c,0);
		mcf.ae(1+i,1+n+0,c,V-(x+y));
		mcf.ae(1+i,1+n+1,c,V-(x-y));
		mcf.ae(1+i,1+n+2,c,V-(-x+y));
		mcf.ae(1+i,1+n+3,c,V-(-x-y));
		m+=c;
	}
	rep(i,n){
		int x,y,c;cin>>x>>y>>c;
		mcf.ae(1+n+4+i,1+n+4+n,c,0);
		mcf.ae(1+n+0,1+n+4+i,c,V-(-x-y));
		mcf.ae(1+n+1,1+n+4+i,c,V-(-x+y));
		mcf.ae(1+n+2,1+n+4+i,c,V-(x-y));
		mcf.ae(1+n+3,1+n+4+i,c,V-(x+y));
	}
	
	cout<<V*2*m-mcf.calc(0,1+n+4+n,m)<<endl;
}


Measured memory_bytes: 1500
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;

void END(){
  cout<<-1<<endl;
  exit(0);
}

int a[1<<21],n;
bool used[1<<21];
bool usd2[1<<21];
int sum;

int dfs(int S){
  if(used[S])return 0;
  int res=0;
  used[S]=1;
  r(i,n){
    if(!(S&(1<<i)))continue;
    if(a[S]==0 &&  a[S-(1<<i)])END();
    else dfs(S-(1<<i));
  }
  return 0;
}
int dfs2(int S){
  if(used[S])return 0;
  int res=0,res2=0;
  used[S]=1;
  r(i,n){
    if(!(S&(1<<i)))continue;
    if(a[S-(1<<i)]==0)res++;
    res2++;
    dfs2(S-(1<<i));
  }

  if(res==res2 && a[S])sum++;
  
  return 0;
}

int main(){
  cin>>n;
  r(i,1<<n)cin>>a[i];
  dfs((1<<n)-1);
  memset(used,0,sizeof(used));
  dfs2((1<<n)-1);
  cout<< sum <<endl;
}



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

int main()
{
    int n, m;
    cin >> n >> m;
    int ans = 1;
    while(n--)
    {
        if(ans * 2 >= ans + m)
            ans += m;
        else
            ans <<= 1;
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    ll n,x,y;
    cin>>n>>x>>y;
    ll ans = (n/(x+y));
    cout<<ans*x+ min(x,n%((x+y)));
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

  int a,b;
  cin>>a>>b;
  if(a<= 0 && b >= 0) {
    cout << "Zero" << endl;
  } else if(b < 0){
    if((b - a + 1) % 2 == 0) {
      cout << "Positive" << endl;
    } else {
      cout << "Negative" << endl;
    }
  } else {
    cout << "Positive" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int tree[200001];
void build(int n)
{
    for(int i=n-1;i>0;i--)tree[i]=__gcd(tree[i<<1],tree[(i<<1)^1]);
}
int query(int l,int r,int n)
{
    l+=n;
    r+=n;
    int ans=tree[l];
    while(r>l)
    {
        if(l&1)ans=__gcd(ans,tree[l++]);
        if(r&1)ans==__gcd(ans,tree[--r]);
        
        l/=2;r/=2;
    }
    return ans;
}

int main() {
	int k;
	cin>>k;
	string s = "ACL";
	string ans = "";
	for(int i=0;i<k;i++) ans+=s;
		cout<<ans;
	// 	cout<<__gcd(2,3);
	return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N=in(),H=in();
	vector<pair<int,int>> P(N);
	int MA=0;
	REP(i,N){
		P[i].first=in();
		P[i].second=in();
		MA=max(MA,P[i].first);
	}

	sort(ALL(P),PAIRCOMP(second,>));

	int num=0;
	REP(i,N){
		if(P[i].second>=MA){
			H-=P[i].second;
			num++;
			if(H<=0){
				out(num);
				return 0;
			}
		}
		if(P[i].second<MA) break;
	}

	num += (H+MA-1)/MA;

	out(num);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
const ll MOD = 1000000007;
int n, m, q;
int a[50], b[50], c[50], d[50];
int ans;
void dfs(vector<int> &vec) {
	if (vec.size() == n) {
		int now = 0;
		rep(i, q) {
			if (vec[b[i]] - vec[a[i]] == c[i]) now += d[i];
		}
		ans = max(ans, now);
		return;
	}
	int p;
	if (vec.size() == 0)
		p = 1;
	else
		p = vec[vec.size() - 1];
	repl(i, p, m + 1) {
		vec.push_back(i);
		dfs(vec);
		vec.pop_back();
	}
	return;
}
int main() {
	cin >> n >> m >> q;
	rep(i, q) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--, b[i]--;
	}
	vector<int> vec;
	dfs(vec);
	cout << ans << endl;
	return 0;
}


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

int main()
{
	int n,k;
	int r;
	string s="";
	char c;
	cin>>n>>k;
	
	while(n>0)
	{
		r=n%k;
		n=n/k;
		c=r+48;
		s=c+s;
	}
	cout<<s.size()<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 100000000;
const int MAX_N = 100;
typedef pair<int , int> P;
typedef long long ll;
 
int main () {
  int N, count, ans;
  cin >> N;
  count = ans = 0;
  for (int i = 0; i < N; ++i) {
    int A, B;
    cin >> A >> B;
    if (A == B) {
      ++count;
    } else {
      count = 0;
    }
    if (count >= 3) {
      ans = 1;
    }
  }
  if (ans == 1) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 3632
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main(){
    input!{
        N: i32,
        S: String,
    }

    let mut x: i32 = 0;
    let mut ans: i32 = 0;

    for c in S.chars() {
        if c == 'I' {
            x += 1;
        }else{
            x -= 1;
        }
        ans = std::cmp::max(ans, x);
    }

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

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

int main() {
  int N;
  cin >> N;
  int ac = 0, wa = 0, tle = 0, re = 0;
  for (int i = 0; i < N; ++i) {
    string str;
    cin >> str;
    if (str == "AC") ++ac;
    else if (str == "WA") ++wa;
    else if (str == "TLE") ++tle;
    else ++re;
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
/*
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <set>
#include <cmath>
#include <cstring>

#include <stdio.h>
#include <string.h>
#include <sstream>
#include <stdlib.h>
#include <vector>
#include <iomanip>
#include <ctime>
*/
#define nl "\n"
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define p_un(a) ((void)a)
#define p_st(a) string(a)
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define naj ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define NL cout << endl;
#define sqr(x) (sqrt(x) * 1LL)
#define pcnt(i) __builtin_popcount(i)
#define up_b upper_bound
#define low_b lower_bound
#define lcm(a,b) (a * b) / __gcd(a, b)
#define REVERSE(a, n) reverse(a + 1, a + n + 1);
#define SORT(a, n) sort(a + 1, a + n + 1);
#define rsz resize

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ul;
typedef vector <ll> vl;
typedef vector <bool> vb;
typedef vector <char> vc;
typedef vector <int> vi;
typedef vector <string> vs;
typedef pair <ll, ll> pll;
typedef map <ll, ll> mll;
typedef set <ll> sl;
typedef set <char> sc;
typedef map <string, ll> msl;
typedef map <string, bool> msb;
typedef map <char, ll> mcl;
typedef map <string, string> mss;
typedef vector <vl> vvl;

const ll mxn = 1e6 + 1;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
const ld eps = 1e-9;
const ld PI = acos(-1);

#define FLN "LOL"

//int dx[]= {1,0,-1,0}; int dy[]= {0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1}; int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2}; int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={-1,-1,+0,+1,+1,+0}; int dy[]={-1,+1,+2,+1,-1,-2}; //Hexagonal Direction

inline void joji(bool ok = 0) {naj;if(ok){freopen(FLN".in","r",stdin);freopen(FLN".out","w",stdout);}}

ll h[mxn];
              
main () {

	joji();        	
	ll n, k, ans = 0, sum = 0;
	cin >> n >> k;
	for(int i = 1; i <= n; i++) {
		cin >> h[i];
		sum += h[i];
	}	
	sort(h + 1, h + n + 1);
	reverse(h + 1, h + n + 1);
	for(int i = 1; i <= k; i++) ans += h[i];
	cout << sum - ans;
	return 0;
}





        
                                                             


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    rep(i, abs(tx - sx)){
        cout << "R";
    }
    rep(i, abs(ty - sy)){
        cout << "U";
    }
    rep(i, abs(tx - sx)){
        cout << "L";
    }
    rep(i, abs(ty - sy)){
        cout << "D";
    }
    
    cout << "D";
    rep(i, abs(tx - sx) + 1){
        cout << "R";
    }
    rep(i, abs(ty - sy) + 1){
        cout << "U";
    }
    cout << "L";
    cout << "U";
    rep(i, abs(tx - sx) + 1){
        cout << "L";
    }
    rep(i, abs(ty - sy) + 1){
        cout << "D";
    }
    cout << "R";
    
    return 0;
}


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

const int INF = 1001001000;
const int MOD = (int)1e9 + 7;

using ll = long long;

using namespace std;

typedef pair<int,int> P;

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

int main(){
  int n;
  vector<int> a;

  cin >> n;
  a.resize(n);
  for( int i = 0; i < n; ++i){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  reverse( a.begin(), a.end());
  int x,y;
  x = 0;
  y = 0;
  for( int i = 0; i*2 < n; ++i){
    x += a[i*2];
  }
  for( int i = 0; i*2+1 < n; ++i){
    y += a[i*2+1];
  }
  cout << x-y << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#define rep(a,b,c) for(int a=b;a<=c;a++)
const int maxn=1e5+1;
#define int long long
inline int max(int a,int b) { return a>b?a:b; }
inline int min(int a,int b) { return a<b?a:b; }
int n,m,q,mine,maxe,a[maxn],b[maxn],c[maxn],fa[maxn],fx,fy,ltk,num;
inline int find(int x) { return (fa[x]==x)?x:fa[x]=find(fa[x]); }
signed main() {
	scanf("%lld %lld %lld",&n,&m,&q);
	rep(i,1,n) fa[i]=i; ltk=n;
	rep(i,1,q) {
		scanf("%lld %lld %lld",&a[i],&b[i],&c[i]);
		a[i]++; b[i]++;
		if(!c[i]) {
			num++; fx=find(a[i]); fy=find(b[i]);
			if(fx==fy) continue;
			fa[fy]=fx; ltk--; mine++; maxe++;
		}
	}
	if(m==(n-1)) {
		if(num==q) puts("Yes");
		else puts("No");
		return 0;
	}
	if(m<(n-1)) { puts("No"); return 0; }
	rep(i,1,q) {
		if(c[i]) {
			fx=find(a[i]); fy=find(b[i]);
			if(fx==fy) { puts("No"); return 0; }
		}
	}
	mine+=ltk; maxe+=(((ltk-1)*ltk)>>1);
	if(mine<=m&&maxe>=m) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 4760
using System;
using static System.Math;

class Program
{
    static int n, k;
    static int[] a;
    static bool[,] dp;
    static int before = 0;

    static void Main()
    {
        string[] s = Console.ReadLine().Split();
        n = int.Parse(s[0]);
        k = int.Parse(s[1]);
        a = new int[n];
        s = Console.ReadLine().Split();
        for (int i = 0; i < n; i++) a[i] = int.Parse(s[i]);
        Array.Sort(a);
        dp = new bool[n + 1, k];
        dp[0, 0] = true;
        if (Need(0))
        {
            Console.WriteLine(0);
            return;
        }
        if (!Need(n - 1))
        {
            Console.WriteLine(n);
            return;
        }
        int l = 0;
        int r = n - 1;
        while (r - l > 1)
        {
            int m = l + (r - l) / 2;
            if (Need(m))
            {
                r = m;
                continue;
            }
            l = m;
        }
        Console.WriteLine(r);
    }

    static bool Need(int x)
    {
        for (int i = Min(before, x) + 1; i <= n; i++)
        {
            for (long j = 0; j < k; j++)
            {
                if (j >= a[i - 1] && i - 1 != x)
                    dp[i, j] = dp[i - 1, j] || dp[i - 1, j - a[i - 1]];
                else
                    dp[i, j] = dp[i - 1, j];
            }
        }
        bool f = false;
        for (long j = Max(0, k - a[x]); j < k; j++)
            f = f || dp[n, j];
        before = x;
        return f;
    }
}


Measured memory_bytes: 36052
#include <stdio.h>
#include <iostream>
using namespace std;
int main(){
    double N,sum=0,min;
    double a[101]={};
    int flag=0;
    
    cin >>N;
    for(int i=0;i<N;i++){
        cin >>a[i];
        sum+=a[i];
    }
    sum=sum/N;
    for(int i=0;i<N;i++){
    a[i]=a[i]-sum;
    if(a[i]<0)
        a[i]=a[i]*(-1);
    }
    min=a[0];
    flag=0;
    for(int i=1;i<N;i++){
        if(a[i]<min){
        flag=i;
         min=a[i];
        }
      
    }
    cout <<flag;
}
        


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

  int n;
  cin>>n;
  int ans = 0;
  FOR(i,1,n + 1) {
    int cnt = 0;
    for(int j = 1; j<= i; j++)
    {
      if(i % j == 0) cnt++;
    }
    if(cnt == 8 && i % 2 == 1) ans++;
  }
  cout << ans << endl;
  
  

  return 0;
}


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

using ll = long long;
using ld = long double;

int main () {

    ll n; cin >> n;
    vector<pair<ll, ll>> ab(n);
    for (ll i = 0; i < n; i++) {
        cin >> ab[i].first >> ab[i].second;
    }

    sort(ab.begin(), ab.end(), [](auto x, auto y) -> bool {
        return x.second == y.second
            ? x.first < y.first
            : x.second < y.second;
    });

    ll ans = 0;
    vector<bool> watched(32, false);
    for (ll i = 0; i < n; i++) {
        for (ll day = ab[i].first; day <= ab[i].second; day++) {
            if (!watched[day]) {
                watched[day] = true;
                ans++;
                break;
            }
        }
    }    

    cout << (ans + 31) * 50 << endl;

}


Measured memory_bytes: 3128
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int g[100005];
int calgrundy(int k,int n,int a[]){
  if(k==0)
    return 0;
  if(k<0)
    return 1;
  if(g[k]!=-1)
    return g[k];
  int ans=0;
  for(int i=0;i<n;i++)
    if(calgrundy(k-a[i], n, a)==0){
      ans=1;
      break;
    }
  g[k]=ans;
  return g[k];
}
int main() {
  int n,k;
  cin>>n>>k;
  int a[n];
  memset(g,-1,sizeof(g));
  for(int i=0;i<n;i++)
    cin>>a[i];
  if(calgrundy(k,n,a))
    cout<<"First\n";
  else
    cout<<"Second\n";
}

Measured memory_bytes: 5376
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Stack;

class Node {
	public int id;
	public LinkedList<Node> sources;
	public LinkedList<Node> targets;
	
	public Node(int id) {
		this.id = id;
		sources = new LinkedList<>();
		targets = new LinkedList<>();
	}
}

public class Main {
	public static boolean[] visited = null;
	
	public static Stack<Integer> topologicalSort(Stack<Node> nodes, int overallLength) {
		Stack<Integer> result = new Stack<Integer>();
		boolean[] visited = new boolean[overallLength];
		
		//go up the graph
		while (!nodes.isEmpty()) {
			Node currentNode = nodes.pop();
			result.push(currentNode.id);
			visited[currentNode.id] = true;
			
			//go through sources. If we have visited all the targets, we can add it to stack
			for (int i = 0; i < currentNode.sources.size(); i++) {
				Node currentSource = currentNode.sources.get(i);
				boolean isGood = true;
				for (int j = 0; j < currentSource.targets.size(); j++) {
					if (!visited[currentSource.targets.get(j).id]) {
						isGood = false;
						break;
					}
				}
				
				if (isGood) nodes.push(currentSource);
			}
		}
		
		return result;
	}
	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int numVerticies = scanner.nextInt();
		int numEdges = scanner.nextInt();
		Node[] nodes = new Node[numVerticies];
		visited = new boolean[numVerticies];
		
		//creating all nodes as empty
		for (int i = 0; i < numVerticies; i++) {
			nodes[i] = new Node(i);
		}
		
		//creating all relations to nodes
		for (int i = 0; i < numEdges; i++) {
			int source = scanner.nextInt();
			int target = scanner.nextInt();
			
			nodes[source].targets.add(nodes[target]);
			nodes[target].sources.add(nodes[source]);
		}
		scanner.close();
		
		//create Stack with only nodes that doesn't point to anything
		Stack<Node> rootNodes = new Stack<>();
		for (int i = 0; i < nodes.length; i++) {
			if (nodes[i].targets.isEmpty()) {
				rootNodes.push(nodes[i]);
			}
		}
		
		//topological sort
		Stack<Integer> results = topologicalSort(rootNodes, nodes.length);
		while (!results.isEmpty()) {
			System.out.println(results.pop());
		}
	}
}



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

int main() {
  int a[4];
  for (int i = 0; i < 4; i++)
    cin >> a[i];

  for (int i = 0; i < 4; i++)
    for (int j = i; j > 0; j--)
      if (a[j - 1] > a[j]) {
	int t = a[j - 1];
	a[j - 1] = a[j];
	a[j] = t;
      }

  if (a[0] == a[1] && a[2] == a[3]) cout << "yes" << endl;
  else cout << "no" << endl;

  return 0;
}

Measured memory_bytes: 3048
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
import queue
import copy
import bisect
import heapq


def dfs(s, prev, pre):
  val[s] += Ope[s] + prev
  for i in G[s]:
    if(i == pre):
      continue
    dfs(i, val[s], s)

def bfs(sx, sy, n):
  que = deque([[sy,sx]])
  while que:
    y,x = que.popleft()
    for i,j in D:
      if(x+i<0 or y+j<0 or x+i>W-1 or y+j>H-1):
        continue
      dist = G[y+j][x+i]
      if(G[y+j][x+i] != "X"):
        if(type(G[y+j][x+i]) is str):
          G[y+j][x+i] = G[y][x]+1
          que.append([y+j,x+i])
        elif(dist>G[y][x]+1):
          G[y+j][x+i] = G[y][x]+1
          que.append([y+j,x+i])
        

def combinations_count(n, r):
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#V, E, r = map(int, input().split())
#INF = V * 10001

L = int(input())
#L = L*100
#dp = [[[0] for i in range(L)] for j in range(L)]
ans = (L/3)**3

#for i in range(math.floor(L/3), math.ceil(2*L/3)):
#  for j in range(math.floor(L/3)-1, L-i):
#    ans = max(ans, i*j*(L-i-j))



print(ans)


Measured memory_bytes: 38616
a = list(map(int, input()))
ans = ""
for i in range(2 ** 3):
  b = [i for i in a]
  for j in range(3):
    if (i >> j) & 1:
      b[j + 1] *= -1
  if sum(b) == 7:
    ans += (str)(b[0])
    for j in range(1, 4):
      if b[j] >= 0:
        ans += "+" + (str)(b[j])
      else:
        ans += (str)(b[j])
    ans += "=7"
    break
else:
  print("none")
print(ans)

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<long double, long double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int MOD = 1000000007;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    ll n; cin >> n;
    ll k; cin >> k;
    vector<int> ar(n);
    repl(i,n){
        cin >> ar[i];
        ar[i]--;
    }
    int a = 0;
    if (k < 1000000){
        rep(i,k){
            a = ar[a];
        }
        cout << a+1 << endl;
        return 0;
    }
    vector<int> ki(n,-1);
    ll ima = 0;
    ll sh;
    ll st;
    ll ba;
    repl(i,2*n){
        if (ki[ima] == -1) ki[ima] = i;
        else {
            sh = i-ki[ima];
            st = ki[ima];
            ba = ima;
            break;
        }
        ima = ar[ima];
    }
    k -= st;
    k %= sh;
    repl(i,k){
        ba = ar[ba];
    }
    cout << ba+1 << endl;
}

Measured memory_bytes: 4844
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int A[4];
    for(int i = 0; i < 3; ++i) { cin >> A[i]; }
    sort(A, A + 3);
    //for(int i = 0; i < 3; ++i) { cout << A[i] << " ";}
    //cout << endl;
    cout << A[0] + A[1] << endl;
    return 0;
}

Measured memory_bytes: 256