akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> P(N);
  rep(i, N) { cin >> P[i]; }

  int64_t step = 1e9 / 3e4;
  vector<int> A(N);
  vector<int> B(N);
  A[0] = 1;
  B[N - 1] = 1;
  rep(i, N - 1) {
    A[i + 1] = A[i] + step;
    B[N - 1 - i - 1] = B[N - 1 - i] + step;
  }
  rep(i, N) { A[P[i] - 1] += i; }

  rep(i, N) {
    if (i != 0) cout << " ";
    cout << A[i];
  }
  cout << endl;

  rep(i, N) {
    if (i != 0) cout << " ";
    cout << B[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <queue>

using namespace std;

const int INFTY=1<<29;

int calc(vector<string>& grid,int i,int j,char d)
{
	int h=grid.size(),w=grid[0].size();
	vector<vector<int> > cost(h,vector<int>(w,INFTY));
	queue<pair<int,int> > q;
	cost[i][j]=0;
	q.push(make_pair(i,j));
	while(q.size()){
		int ci=q.front().first,cj=q.front().second; q.pop();
		if(grid[ci][cj]==d)
			return cost[ci][cj];
		int di[]={-1,1,0,0},dj[]={0,0,-1,1};
		for(int k=0;k<4;k++){
			int ni=ci+di[k],nj=cj+dj[k];
			if(ni<0 || h<=ni || nj<0 || w<=nj)
				continue;
			if(grid[ni][nj]=='X' || cost[ni][nj]<=cost[ci][cj]+1)
				continue;
			cost[ni][nj]=cost[ci][cj]+1;
			q.push(make_pair(ni,nj));
		}
	}
	return INFTY;
}

int main()
{
	for(int h,w,n;cin>>h>>w>>n && h|w|n;){
		vector<string> grid(h);
		for(int i=0;i<h;i++)
			cin>>grid[i];
		int res=0;
		for(int k=0;k<n;k++){
			char s=k?'0'+k:'S';
			char d='1'+k;
			for(int i=0;i<h;i++)
				for(int j=0;j<w;j++)
					if(grid[i][j]==s)
						res+=calc(grid,i,j,d);
		}
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 5848
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,d;cin>>d>>t;
    set<int>s;
    while(t--)
    {
        int n;cin>>n;
        for(int i=0;i<n;i++)
        { int m;
            cin>>m;
            s.insert(m);
        }

    }
    cout<<d-s.size()<<endl;
}


Measured memory_bytes: 3568
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<ctime>
#define rep(i,n) for (int i=0;i<n;i++)
//#include <bits/stdc++.h>
using namespace std;
const int D=365;

int main(){
    int d;
    cin>>d;
    vector<long int> c(26);
    rep(i,26) cin>>c[i];
    vector<vector<long int> > s(D,vector<long int>(26));
    rep(i,D){
        rep(j,26) cin>>s[i][j];
    }
   /* 
    vector<int> last(26,-1);
    vector<long int> ans(D+1);
    for(int i=0;i<D;i++){
        ans[i+1]=ans[i]+s[i][t[i]];
        rep(j,26){
            if (t[i]==j) last[j]=i; 
            ans[i+1]-=c[j]*(i-last[j]);
        }
    }
    for (int i=1;i<D+1;i++)  cout<<ans[i]<<endl;
    */
    rep(i,D){
        cout<<((i+4)*i)%26+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 3708
import java.util.*;

public class Main {


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

        int n = s.nextInt();
        int m = s.nextInt();
        String[] ss = new String[n];
        for (int i = 0;i < n;i++) {
            ss[i] = s.next();
        }

        Arrays.sort(ss,(s1,s2) -> {
            for (int i = 0;i < m;i++) {
                if (s1.charAt(i) == s2.charAt(i)) continue;
                return s1.charAt(i) - s2.charAt(i);
            }
            return 0;
        });
        StringBuilder sb = new StringBuilder();
        for (String si:ss) {
            sb.append(si);
        }
        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 27292
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;

bool ban[11];
int n, k, d;
bool ok(int x){
  if(x == 0)return true;
  if(ban[x % 10])return false;
  return ok(x/10);
}

int main(){
  cin >> n >> k;
  for(int i= 0;i < k;i++){
    cin >> d;
    ban[d] = true;
  }
  while(!ok(n))n++;
  cout << n << endl;return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    ll n,m,q; cin >> n >> m >> q;
    VL a(q), b(q), c(q), d(q);
    rep(i,q) cin >> a[i] >> b[i] >> c[i] >> d[i];

    ll max=0;
    
    ll all = 2 << (m+n-1);
    rep(bit,all){
        VL A;
        ll cur = 1;
        rep(i,m+n-1){
            if(bit & (1 << i)){
                cur++;
            }else{
                A.push_back(cur);
            }
        }
        if(A.size() != n) continue;

        ll score = 0;
        rep(i,q){
            if(A.at(b[i]-1) - A.at(a[i]-1) == c[i]) score += d[i];
        }
        chmax(max, score);
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int N,M,u,v,D,c,d[10010];
struct E{
	int to,dist,cost;
	E(){}
	E(int a,int b,int c):to(a),dist(b),cost(c){}
};
vc<E> e[10010];

void f(int s){
	fill(d,d+N,INF);
	multimap<int,int> Q;
	d[s]=0;
	Q.insert(pi(0,s));
	while(Q.sz){
		pi p=*(Q.begin());
		Q.erase(Q.begin());
		int v=p.sec;
		if(d[v]<p.fir)continue;
		rep(i,e[v].sz){
			E f=e[v][i];
			if(d[f.to]>d[v]+f.dist){
				d[f.to]=d[v]+f.dist;
				Q.insert(pi(d[f.to],f.to));
			}
		}
	}
}

int main(){
	while(cin>>N>>M&&N){
		rep(i,N)e[i].clear();
		rep(i,M)cin>>u>>v>>D>>c,u--,v--,e[u].pb(E(v,D,c)),e[v].pb(E(u,D,c));
		f(0);
		int a=0;
		rep2(i,1,N){
			int m=INF;
			rep(j,e[i].sz){
				E f=e[i][j];
				if(d[i]==d[f.to]+f.dist&&f.cost<m)m=f.cost;
			}
			a+=m;
		}
		cout<<a<<endl;
	}
}

Measured memory_bytes: 2756
#include <iostream>
	#include <iomanip>
	#include<math.h>
	#include<list>
	#include <algorithm>
	#include<set>
	#include<vector>
	#include<math.h>
	#include<map>
	#include<string>
	#include <numeric>
	#include <queue>
	#include <sstream>
	#include <bitset>
	#include<stack>

	using namespace std;
	using ll = long long;
	using vll = vector<long long>;
	using sll = set<long long>;


	template<typename T>
	T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
	template<typename T>
	T lcm(T a, T b) { return a / gcd(a, b) * b; }

	template<typename T>
	map<T, T> getPrimeFactor(T n) {
		map<T, T> res;
		for (T i = 2; i * i <= n; ++i) {
			while (n % i == 0) {
				res[i] ++;
				n /= i;
			}
		}
		if (n != 1) res[n] = 1;
		return res;
	}

	template<typename T>
	bool IsPrimeNumber(T num)
	{
		if (num <= 2) return true;
		else if (num % 2 == 0) return false;

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

		return true;
	}

	long long modinv(long long a, long long m) {
		long long b = m, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= m;
		if (u < 0) u += m;
		return u;
	}

	// 繰り返し二乗法
	ll pow2(ll n, ll p, ll mod) {
		if (p == 0 || n == 1) {
			return 1;
		}
		else {
			ll ret = pow2(n * n % mod, p / 2, mod);
			if (p % 2 == 1) {
				ret *= n;
			}
			return ret % mod;
		}
	}


	#define rep(i,s,e) for(ll i=s;i<e;i++)
	#define repeq(i,s,e) for(ll i=s;i<=e;i++)

	int main() {
		ll X;
		cin >> X;
		if (X >= 30) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
		return 0;
		

	}


Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <set>
#include <tuple>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <map>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>

int main() {
	long long int x; std::cin >> x;
	for (long long int a = 0; a <= 1000; ++a) {
		for (long long int b = -a; b <= a; ++b) {
			if (a * a * a * a * a - b * b * b * b * b == x) {
				std::cout << a << ' ' << b << '\n';
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3640
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

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

int gcd(int a, int b) {
  while (b) {
    int c = a;
    a = b;
    b = c % b;
  }
  return a;
}

int main() {
  int n;
  cin >> n;
  int64 ret = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      for (int k = 1; k <= n; ++k) {
        ret += gcd(gcd(i, j), k);
      }
    }
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 3664
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#define nl "\n"
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;
#define mt make_tuple
#define vec vector

#define int long long

const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;

typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

void solve() {

	int n,k ; cin >> n >> k ;

	int ps[n+1] = {} ;
	int l[k], r[k] ;

	rep(i,0,k) cin >> l[i] >> r[i] ;
	
	int dp[n+1] = {} ;
	dp[1] = ps[1] = 1; 

	for(int i = 2 ; i <= n ; ++i ) {
		for(int j = 0 ; j < k ; ++j ) {
			if(i-l[j] > 0) dp[i] = (dp[i] + ps[i-l[j]]) % MOD ; 
			if(i-r[j] > 0) dp[i] = (dp[i] - ps[i-r[j]-1] + MOD) % MOD; 
		}
		ps[i] = (ps[i-1] + dp[i]) %MOD ; 
	}

	// rep(i,1,n+1) cout << dp[i] << " " ;

	cout << dp[n] ;
}

int32_t main() {

#ifdef LOCAL
    freopen("error.txt", "w", stderr);
#endif

    fast;

	// int t; cin >> t; while(t--)
		solve() ;

	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}


Measured memory_bytes: 6736
#include <iostream>
using namespace std;
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  long long a, b, c;
  cin >> a >> b >> c;
  long long d = c - a - b;
  if(d > 0 && d * d > 4LL * a * b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#define rep(i,n) for (int i = 0; i < n; i++)
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;
const ll INF = 1e18;


int main() {
	int n, m;
	cin >> n >> m;
	string s; cin >> s;
	vector<char> a(m), b(m);
	rep(i, m) {
		cin >> a[i] >> b[i];
	}
	int l = 0, r = n - 1, lmax = 0, rmax = 0;
	while (l <= r) {
		int mid = (l + r) / 2;
		int now = mid; bool flag = true;
		rep(i, m) {
			if (s[now] == a[i]) {
				if (b[i] == 'L') now--;
				else now++;
				if (now < 0) {
					flag = false;
					break;
				}
				if (now>n - 1) break;
			}
		}
		if (!flag) {
			l = mid + 1;
		}
		else r = mid-1;
	}
	lmax = l;
	l = 0, r = n - 1;
	while (l <= r) {
		int mid = (l + r) / 2;
		int now = mid; bool flag = true;
		rep(i, m) {
			if (s[now] == a[i]) {
				if (b[i] == 'L') now--;
				else now++;
				if (now < 0) break;
				if (now > n - 1) {
					flag = false;
					break;
				}
			}
		}
		if (!flag) {
			r = mid - 1;
		}
		else l = mid + 1;
	}
	rmax = r;
	cout << max(0, rmax - lmax + 1) << endl;
	return 0;
}


Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
signed main(){
    string s,t;cin>>s>>t;
    ll cnt=0;
    rep(i,s.size()){
        if(s[i]!=t[i])cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3920
#include <iostream>

using namespace std;

int main()
{
    char a;
    cin>>a;

    if(a=='a' || a=='e' || a=='i' || a=='o' || a=='u')
    {
        cout<<"vowel"<<endl;
    }
        else
     {


    cout<<"consonant"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
/* author   : mpily :-()
title : Competing.cpp
time :Sun Nov 24 07:40:23 2019

*/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	int N, T;
	cin>>N>>T;
	vector<pair<int,int>>meal(N);
	for(int i = 0; i < N; i++){
		cin>>meal[i].first;
		cin>>meal[i].second;
	}
	sort(meal.begin(),meal.end());
	long long ans = 0;
	map<int,long long>highest;
	highest[0] = 0;
	for(int i = 0; i < N; i++){
		//cout<<"while doing for "<<meal[i].first<<"\n";
		vector<pair<int,long long>> toadd;
		for (auto a : highest){
			//cout<<"\tchecking at "<<a.first<<"\n";
			if(a.first < T){
				//cout<<"\t\tadding for "<<a.first+meal[i].first<<" to "<<a.second+meal[i].second<<"\n";
				int nfinalt = a.first+meal[i].first;
				toadd.push_back(make_pair(nfinalt,a.second+meal[i].second));
				if(a.second+meal[i].second > ans){
					ans = a.second+meal[i].second;
				}
			}
		}
		for(auto b : toadd){
			if(b.second>highest[b.first])
			highest[b.first] = b.second;
		}
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
using namespace std;
int main() {
  string S;
  cin >> S;
  for(int i=0; i<S.size(); i+=2) {
    if(S[i]=='L'||S[i+1]=='R') {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;     
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm(a, b) (a)/__gcd((a),(b))*(b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector<int> Div(int n) {
    vector<int> ret;
    for(int i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);

            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int n, K;
    cin >> n >> K;
    vector<LP> v(n);
    for(int i = 0; i < n; ++i) {
        cin >> v[i].F >> v[i].S;

    }

    LL res = LINF;
    for(int i = 0; i < v.size(); ++i) {
        for(int j = 0; j < v.size(); ++j) {
            for(int k = 0; k < v.size(); ++k) {
                for(int l = 0; l < v.size(); ++l) {
                    LL ymax, ymin, xmax, xmin;
                    ymax = max({v[i].S, v[j].S, v[k].S, v[l].S});
                    ymin = min({v[i].S, v[j].S, v[k].S, v[l].S});
                    xmax = max({v[i].F, v[j].F, v[k].F, v[l].F});
                    xmin = min({v[i].F, v[j].F, v[k].F, v[l].F});
                    int c = 0;
                    for(int m = 0; m < n; ++m) {
                        if(xmin <= v[m].F && v[m].F <= xmax &&
                            ymin <= v[m].S && v[m].S <= ymax) {
                            ++c;
                        }
                    }
                    if(c >= K) {
                        res = min(res, (ymax - ymin) * (xmax - xmin));
                    }
                }
            }
        }
    }
    cout << res << endl;
    return 0;
}


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

using namespace std;


int main(){
    
    int N,K;
    cin >> N >> K;
    
    vector<int> h(N);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
    
    sort(h.begin(), h.end());
    
    int ans = 1000000000;
    for (int i = K-1; i < N; i++) {
        ans = min(ans, h[i]-h[i-K+1]);
    }
    cout << ans << endl;
    
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll ans = 0, K;

ll GCD(ll A, ll B){
  if (A < B) swap(A, B);
  while (A % B != 0){
    A %= B; swap(A, B);
  }
  return B;
}

int DFS(ll G, int turn){
  if (turn == 3){
    ans += G; return 0;
  }
  if (turn == 0){
    for (int i = 1; i <= K; i++){
      DFS(i, 1);
    }
    return 0;
  }

  for (int i = 1; i <= K; i++){
    DFS(GCD(G, i), turn + 1);
  }

  return 0;
}

int main(){
  cin >> K;
  DFS(0, 0);
  cout << ans << endl;

  return 0;
}


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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef pair<ll, ll> PLL;

signed main() {
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,0,n)
        cin>>a[i];
    sort(begin(a),end(a));

    ll x = a[n-1];
    ll y = a[0];
    rep(i,1,n-1){
        if (abs(2*a[i]-x) < abs(2*y-x)) {
            y = a[i];
        }
    }
    cout<<x<<" "<<y<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define elnd endl //* missspell check

const ll INF = 1LL<<60;

//* dijkstra algorithm with adjacency matrix
void dijkstra(vector<vll> &G, vll &dist, ll s){
    fill(dist.begin(), dist.end(), INF);
    priority_queue<pll, vector<pll>, greater<pll> > que;
    dist[s] = 0;
    que.push(pll(0, s));
    while(!que.empty()){
        ll score = que.top().first;
        ll u = que.top().second;
        que.pop();
        for(ll v=0; v< G[u].size(); v++){
            if(dist[v] > score + G[u][v]){
                dist[v] = score + G[u][v];
                que.push(pll(dist[v], v));
            }
        }
    }
    return;
}

ll getIdx(ll i, ll j, ll W){
    return i*W+j;
}

int main(){
    ll H, W;  cin >> H >> W;
    vector<string> S(H);
    REP(i, H){
        cin >> S[i];
    }
    vll dx{0, 0, 1, -1}, dy{1, -1, 0, 0};
    vector<vll> G(H*W, vll(H*W, INF));
    ll numblack = 0;
    REP(i, H){
        REP(j, W){
            if(S[i][j]=='.'){
                ll here = getIdx(i, j, W);
                REP(k, 4){
                    ll i_to = i+dx[k], j_to = j+dy[k];
                    if(0<=i_to && i_to<H && 0<= j_to && j_to< W){
                        if(S[i_to][j_to] == '.'){
                            ll to = getIdx(i_to, j_to, W);
                            G[here][to] = 1;
                            G[to][here] = 1;
                        }
                    }
                }
            }
            else{
                numblack++;
            }
        }
    }
    vll dist(H*W); ll N = H*W;
    dijkstra(G, dist, 0);
    if(dist[N-1] >= INF){
        cout << -1 << endl;
    }
    else{
        cout << N - 2 - numblack - (dist[N-1]-1) << endl;
    }

    return 0;
}


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

int main() {
  int num;
  
  cin >> num;
  
  if(num >= 64) cout << 64;
  else if(num >= 32) cout << 32;
  else if(num >= 16) cout << 16;
  else if(num >= 8) cout << 8;
  else if(num >= 4) cout << 4;
  else if(num >= 2) cout << 2;
  else if(num >= 1) cout << 1;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.Vector (Vector, (!), (//))
import qualified Data.Vector as V

main :: IO ()
main = do
  [n, t, _, l] <- f
  solve n t l <$> (V.fromList <$> replicateM n (g <$> f)) >>= print
  where
    f = map read <$> words <$> getLine
    g [a, b] = (a, b)

solve :: Int -> Int -> Int -> Vector (Int, Int) -> Int
solve n t l dv = f 0 t 0 dv
  where
    f i ts rm dv =
      case dv ! i of
       (0, 0) -> i + 1
       (0, hi) -> let ch = rm + 1
                  in if ts < ch
                    then i + 1
                     else f ((i + 1) `mod` n) (ts - ch) 0 (dv // [(i, (ch, hi - 1))])
       (ti, hi) -> let rm' = rm + 1
                       ts' = ts + 1
                       ch = rm' - 9
                   in if ts' > l
                      then i + 1
                      else if rm' >= 9
                           then if ts' < ch
                                then i + 1
                                else f ((i + 1) `mod` n) (ts' - ch) 0 (dv // [(i, (ti - 1 + ch, hi))])
                           else f ((i + 1) `mod` n) ts' rm' (dv // [(i, (ti - 1, hi))])



Measured memory_bytes: 4836
# https://atcoder.jp/contests/abc088/tasks/abc088_d

H, W = map(int, input().split())
s = [input() for _ in range(H)]
d = [[-1] * W for _ in range(H)]

# 0,0 to h-1, w-1
d[0][0] = 0

queue = []
queue.append([0, 0])

while len(queue) > 0:
    p = queue.pop(0)
    y, x = p[0], p[1]

    dx4 = [0, 0, 1, -1]
    dy4 = [1, -1, 0, 0]

    for dx, dy in zip(dx4, dy4):
        next_y = y + dy
        next_x = x + dx
        if 0 <= next_y < H and 0 <= next_x < W and s[next_y][next_x] != "#" and d[next_y][next_x] == -1:
            d[next_y][next_x] = d[y][x] + 1
            queue.append([next_y, next_x])

count = 0
for l in s:
    for c in l:
        if c == ".":
            count += 1

if d[H-1][W-1] == -1:
    print(-1)
else:
    print(count - d[H-1][W-1] - 1)

# [print(l) for l in s]
# [print(l) for l in d]


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

int main() {
    int a,b;
    cin>>a>>b;
    if(a>b)swap(a,b);
    for (int i = 0; i < b; i++){
        cout<<a;
    }
    cout<<endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const int N=1e5+50;
int x,n,m,a[N];
ll dp[N];
int main(void){
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
        scanf("%d",&x);
        dp[x]=-1;
    }
    dp[0]=1;
    for(int i=1;i<=n;i++){
        if(dp[i]==-1){
            continue;
        }
        if(i>=1 && dp[i-1]!=-1){
            dp[i]+=dp[i-1];
            dp[i]%=mod;
        }
        if(i>=2 && dp[i-2]!=-1){
            dp[i]+=dp[i-2];
            dp[i]%=mod;
        }
        //printf("%d %d\n",i,dp[i]);
    }
    printf("%lld\n",dp[n]%mod);
    return 0;
}

Measured memory_bytes: 1024
import java.util.*

fun main(args: Array<String>){

    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()

    when (a) {
        in 0..5 -> println("0")
        in 6..12 -> println("${b/2}")
        else -> println("$b")
    }

}

Measured memory_bytes: 29356
#include<bits/stdc++.h>
using namespace std;
int main(){
string s,t;
bool b=0,c=0;
cin>>s>>t;
int counter=0;
int n = s.length() , m = t.length();
char x[n+1],y[m+1];
strcpy(x,s.c_str());strcpy(y,t.c_str());
for(int i=0;i<n;i++)
    {if(x[i]>=65&&x[i]<=90)
        b=1;
    if(y[i]>=65&&y[i]<=90)
        c=1;}
if(n>=1&&n<=(2*pow(10,5))&&m>=1&&m<=(2*pow(10,5))&&m==n&&b==0&&c==0){
    for(int i=0;i<n;i++)
        if(x[i]!=y[i])
            counter+=1;
}
cout<<counter<<endl;

return 0;}


Measured memory_bytes: 4120
//you never give up.
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define v32 vector<int>
#define v64 vector<ll>

using namespace std;

void solve()
{
    int n;
    cin >> n;
    if (n >= 400 && n <= 599)
        cout << 8 << endl;
    else if (n >= 600 && n <= 799)
        cout << 7 << endl;
    else if (n >= 800 && n <= 999)
        cout << 6 << endl;
    else if (n >= 1000 && n <= 1199)
        cout << 5 << endl;
    else if (n >= 1200 && n <= 1399)
        cout << 4 << endl;
    else if (n >= 1400 && n <= 1599)
        cout << 3 << endl;
    else if (n >= 1600 && n <= 1799)
        cout << 2 << endl;
    else if (n >= 1800 && n <= 1999)
        cout << 1 << endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t = 1;
    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 1e5 + 5;
ll x[N], val[N], mx[N], pref[N];
ll len;
    int n;

ll solve() {
    ll ans = 0;

    for (int i = 1; i <= n; i++) {
        pref[i] = pref[i - 1] + val[i];
        mx[i] = max(mx[i - 1], pref[i] - x[i] * 2);
    }

    // for (int i = 0; i <= n; i++) {
    //     cout << x[i] << " ";
    // }
    // cout << "\n";

    ll sum = 0;
    for (int i = n; i > 0; i--) {
        sum += val[i];
        ans = max(ans, sum + mx[i - 1] - len + x[i]);
    }

    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    
    cin >> n >> len;

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

    ll ans = 0;

    ans = max(solve(), ans);
    reverse(x + 1, x + n + 1);
    for (int i = 1; i <= n; i++) {
        x[i] = len - x[i];
    }
    reverse(val + 1, val + n + 1);
    ans = max(solve(), ans);

    cout << ans << "\n";

    return 0;
}

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

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

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

    auto res = divisor(n);
    sort(res.begin(), res.end());
    ll ans = 1e10;
    for (auto r : res) {
        ll a = to_string(r).size();
        ll b = to_string(n / r).size();
        ans = min(ans, max(a, b));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3748
#include<iostream>
#include<vector>
#include<algorithm>

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int j=i;j<n;j++)
#define in(a) cin>>a
#define out(a) cout<<a<<endl

using namespace std;

int main(){
    long long int n;
    in(n);
    vector<int> a(n);
    rep(i,n) in(a[i]);

    sort(a.begin(),a.end());

    long long int ans = 0;

    rep(i,n){
        REP(i+1,n){
            int x;
            //lower_boundはa[i]+a[j]以上のうち一番左のイテレータを返す
            int  t = lower_bound(a.begin(),a.end(), a[i]+a[j]) - a.begin();
            ans += max(t-j-1,0);
        }
    }

    out(ans);

}

Measured memory_bytes: 256
package main

import (
	"fmt"
//	"strconv"
//	"sort"
//	"math"
//	"regexp"
)


var X,A,B int


func main(){
	fmt.Scan(&X,&A,&B)
	if 0 <= A-B {
		fmt.Println("delicious")
	}else if B<=X+A {
		fmt.Println("safe")
	}else{
		fmt.Println("dangerous")
	}

}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
long long n,m,ans=0;
int main(){
cin>>n>>m;
for(long long i=1;i*i<=m;++i) {
if(m%i==0) {
if(m/i>=n) {
ans=max(ans,i);
}
if(i>=n) {
ans=max(ans,m/i);
}
}
}
cout<<ans<<endl;
}


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


int main() {
    long long x;
    cin >> x;
    long long y = x/2;
    if(x%2 == 0){
        cout << y;
    }
    else{
        y += 1;
        cout << y;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;

// x以下のsで，最もxに近い（最も大きい)sの添え字を求める x以下のsが存在しない場合，最もxに近い（最も小さい）sの添え字を求める
int leftnear_place_num(long long x, vector<long long> s, int N){
  int left = -1;
  int right = N;
  int center;
  while(right - left > 1){
    center = (right + left) / 2;
    if(x <= s[center]){
      right = center;
    }else{
      left = center;
    }
  }

  return max(left,0);
}


int main(){
  int A, B, Q;
  scanf("%d %d %d", &A, &B, &Q);

  vector<long long> s(A);
  vector<long long> t(B);
  for(int i=0;i<A;i++){
    scanf("%lld", &s[i]);
  }
  for(int i=0;i<B;i++){
    scanf("%lld", &t[i]);
  }

  long long max_dist = pow(10,10)*2;
  for(int i=0;i<Q;i++){
    long long x;
    scanf("%lld", &x);

    long long route1, route2, route3, route4, route5, route6, route7, route8;

    decltype(s)::iterator rpns = lower_bound(s.begin(), s.end(), x);
    decltype(t)::iterator rpnt = lower_bound(t.begin(), t.end(), x);
    decltype(s)::iterator lpns;
    decltype(t)::iterator lpnt;
    if(rpns != s.begin()){
      lpns = rpns--;
    }else{
      lpns = rpns;
    }
    if(rpnt != t.begin()){
      lpnt = rpnt--;
    }else{
      lpnt = rpnt;
    }

    route1 = abs(x - *lpns) + abs(*lpns - *lpnt);
    route2 = abs(x - *lpns) + abs(*lpns - *rpnt);
    route3 = abs(x - *lpnt) + abs(*lpnt - *lpns);
    route4 = abs(x - *lpnt) + abs(*lpnt - *rpns);
    route5 = abs(*rpns - x) + abs(*rpns - *lpnt);
    route6 = abs(*rpns - x) + abs(*rpns - *rpnt);
    route7 = abs(*rpnt - x) + abs(*rpnt - *lpns);
    route8 = abs(*rpnt - x) + abs(*rpnt - *rpns);

    long long result = max_dist;
    result = min(result, route1);
    result = min(result, route2);
    result = min(result, route3);
    result = min(result, route4);
    result = min(result, route5);
    result = min(result, route6);
    result = min(result, route7);
    result = min(result, route8);

    printf("%lld\n", result);
  }

  return 0;
}


Measured memory_bytes: 2944
/* */

#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
typedef vector< int > vi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< ll > vll;
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
#else
	#define errp(...)
#endif
#define dbg(x) errp("%s = %s\n", #x, to_string(x).data())
string to_string (string s) { return "\"" + s + "\""; }
template<typename T> string to_string (vector<T>);
template<typename U, typename V> string to_string (pair<U, V> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template<typename T> string to_string (vector<T> v) {
	string res = "["; for (int i = 0; i < (int)v.size() - 1; i++) res += to_string(v[i]) + ", ";
	if (!v.empty()) res += to_string(v.back());	res += "]"; return res; }

int main () { 
#ifdef XVENOM
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
#endif

	vi a, b, c;
	int n;
	scanf("%d", &n);
	a.assign(n, 0);
	b.assign(n, 0);
	c.assign(n, 0);

	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	for (int i = 0; i < n; i++) scanf("%d", &b[i]);
	for (int i = 0; i < n - 1; i++) scanf("%d", &c[i]);

	int ans = 0;
	for (int i = 0; i < n; i++) ans += b[i];
	for (int i = 0; i < n - 1; i++) if (a[i] + 1 == a[i + 1]) ans += c[a[i] - 1];
	printf("%d\n", ans);
}

Measured memory_bytes: 256
from operator import itemgetter

a= int(input())
task = []
for i in range(a):
    task.append(list(map(int,input().split())))
task.sort(key=itemgetter(1))

now = 0
flag = 0
for i in range(a):
    now += task[i][0]
    if now > task[i][1]:
        flag =1
if flag == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 53720
#include <bits/stdc++.h> 
 
#define INF (1<<31) - 1 //INT_MAX/2
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;

int main(int argc, char *argv[])
{
    int A, B, C, X, Y;
    std::cin >> A >> B >> C >> X >> Y;

    int max = std::max(X, Y);
    int min = INF;
    for (int i = 0; i <= max; i++) {
        int sum = i*2*C + std::max(0, X - i) * A + std::max(0, Y - i) * B;
        if (min > sum) {
            min = sum;
        }
    }

    std::cout << min << std::endl;
    return 0;
}

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

const int INF = pow(2, 31) - 1;
#define ll long long
#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> x(N);
  REP(i, N) {
    cin >> x[i];
  }
  x.push_back(X);
  sort(x.begin(), x.end());
  int ans = x[1] - x[0];
  REP(i, N) {
    ans = gcd(ans, x[i + 1] - x[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){

	int a,b,c,l;
	cin>>l;
	for(int i=0;i<l;i++){

	while(cin>>a>>b>>c){
		if(a*a == b*b+c*c || b*b == a*a+c*c || c*c == b*b+a*a )cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}}

return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    char C;
    scanf("%c",&C);
    if (C=='a' ||C=='i' || C=='u' || C=='e'  || C=='o'){cout<<"vowel"<<endl;}
    else{cout<<"consonant"<<endl;}
    return 0;
} 


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

int main(){
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    int ans = 0;
    if(e-a > k){
        ans += 1;
    }    
    if(ans == 0){
        cout << "Yay!" << endl;
    }
    else{
        cout << ":(" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n,m = gets.split.map &:to_i
$node = Array.new(n){ [] }
m.times do
  a,b = gets.split.map(&:to_i).sort
  $node[a-1] << b - 1
  $node[b-1] << a - 1
end

link = Array.new(n){ nil }

def bfs(link)
  q = [0]
  while !q.empty?
    visit = q.shift
    $node[visit].each do |i|
      next_node = i 
      next unless link[next_node].nil?
      link[next_node] = visit
      q.push next_node 
    end
  end
end

bfs(link)
link.shift

if link.any?{|v| v.nil?}
  puts 'No'
else
  puts 'Yes'
  link.each do |v|
    puts v + 1
  end
end




Measured memory_bytes: 32476
#include<iostream>
using namespace std;
void output(int*, int);

int main()
{
    int num;
    cin >> num;
    int* T = new int[num];
    for (int i = 0; i < num; i++)
    {
        cin >> T[i];
    }
    output(T, num);
    for (int i = 1; i < num; i++)
    {
        int pivot = T[i];
        int j = i - 1;
        while (T[j] > pivot && j >= 0)
        {
            T[j + 1] = T[j];
            T[j] = pivot;
            j--;
        }
        output(T, num);
    }
}

void output(int* T, int num)
{
    for (int i = 0; i < num; i++)
    {
        cout << T[i] << (i == num - 1 ? '\n' : ' ');
    }
}


Measured memory_bytes: 3088
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ost;

const ll maxN = 1e7;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

void build(ll node, ll start, ll end){
	if(start == end)
		segtree[node] = A[start];
	else{
		ll mid = (start + end)/2;
		build(left(node), start, mid);
		build(right(node), mid+1, end);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

void update(ll node, ll start, ll end, ll l, ll r, ll val){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(start > end or l > start or r < end)
		return ;
	else if(start >= l and r >= end){
		segtree[node] += val;
		if(start != end){
			lazy[left(node)] += val;
			lazy[right(node)] += val;
		}
	}
	else{
		ll mid=(start + end)/2;
		update(left(node), start, mid, l, r, val);
		update(right(node), mid+1, end, l, r, val);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

ll sums(ll node, ll start, ll end, ll l, ll r){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(l > end or r < start or start > end)
		return 0;
	if(l <= start and r >= end)
		return segtree[node];
	ll mid = (start+end)/2;
	return sums(left(node), start, mid, l , r) + sums(right(node), mid + 1, end, l , r);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	bool ns = false;
	for(ll i=0; i<=25; i++){
		for(ll j=0; j<=15; j++){
			if(i*4 + j*7 == n)
				ns=1;
		}
	}
	if(ns)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define rep3(i, x, n) for(int i = x; i > n; i--)
const long long MOD = 1e9+7;
const long long INF = 1e15;
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    ll S;
    cin >> S;
    ll x0, y0, x1, x2, y1, y2;
    x0 = 0; y0 = 0; x2 = 1; y2 = 1e9;
    if(S%y2 == 0) x1 = S/y2, y1 = 0;
    else x1 = (S/y2)+1, y1 = x1*y2 - S;
    cout << x0 << endl;
    cout << y0 << endl;
    cout << x1 << endl;
    cout << y1 << endl;
    cout << x2 << endl;
    cout << y2 << endl;
}

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

using namespace std;

int main() {
  long long n, m, a[100000];
  scanf("%lld", &n);
  for (long long i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }                 
  sort(a, a + n);
  double f = a[n - 1] / 2.0, d = 1000000000; 
  for (long long i = 0; i < n - 1; i++) { 
    if (abs(f - a[i]) < d) {
      d = f - a[i];
      m = a[i];
    }
  }
  printf("%lld %lld\n", a[n - 1], m);
  return 0;
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N; cin >> N;
    string S; cin >> S;
    S.erase(unique(S.begin(), S.end()), S.end());
    cout << S.size() << "\n";
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<string>
#include<stdio.h>
#include<cmath>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define all(x) (x).begin(), (x).end()
#define lint long long


int main(){
    int n; cin>>n;
    if(n==1){
        cout<<"Hello World"<<endl;
    }
    else{
        int a,b; cin>>a>>b;
        cout<<a+b<<endl;
    }
}

Measured memory_bytes: 888
input = gets.chomp;
inputs = [];
while input.length >= 3
  inputs.push(input.scan(/\d\d\d/)[0]);
  input.slice!(0)
end

#p inputs
min = 753
inputs.each {|n|
  if (n.to_i - 753).abs < min
    min = (n.to_i - 753).abs
  end
}

puts min

Measured memory_bytes: 1788
import java.util.Scanner

class UnionFindTree(n: Int) {
  val par: Array[Int] = init(n)

  def init(n: Int): Array[Int] = {
    val a = new Array[Int](n)
    for (i <- 0 until n) {
      a(i) = i
    }
    a
  }

  def root(x: Int): Int = {
    if (par(x) == x) {
      x
    } else {
      par(x) = root(par(x))
      par(x)
    }
  }

  def same(x: Int, y: Int): Boolean = {
    root(x) == root(y)
  }

  def unite(x: Int, y: Int): Unit = {
    val (xx, yy) = (root(x), root(y))
    if (!(xx == yy)) {
      par(xx) = yy
    }
  }

  def isParent(x: Int): Boolean = {
    par(x) == x
  }
}

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val a, b = sc.nextInt()

    println(f(a, b, 1))
  }

  def f(a: Int, b: Int, acc: Int): Int = {
    if (acc >= b) {
      0
    } else {
      1 + f(a, b, acc + a-1)
    }
  }
}

Measured memory_bytes: 25536
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, m, s, t, d[300009], u[100009], v[100009];
vector<int> vec[300009];
queue<int> qu;
bool vis[300009];
set<int> st;

void bfs()
{
	qu.push(s);
	vis[s] = true;
	d[s] = 0;
	while (!qu.empty()) {
		int cur = qu.front();
		qu.pop();
		for (auto iter : vec[cur]) {
			if (!vis[iter]) {
				qu.push(iter);
				d[iter] = d[cur] + 1;
				vis[iter] = true;
			}
		}
	}
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	memset(d, 0xff, sizeof(d));
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> u[i] >> v[i];
		u[i]--; v[i]--;
		u[i] = u[i] * 3; v[i] = v[i] * 3;
		vec[u[i]].pb(v[i] + 1);
		vec[u[i] + 1].pb(v[i] + 2);
		vec[u[i] + 2].pb(v[i]);
	}
	cin >> s >> t;
	s--; t--;
	s = s * 3; t = t * 3;
	bfs();
	if (vis[t] == false) {
		cout << "-1\n";
	}
	else {
		cout << d[t] / 3 << "\n";
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 18944