akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MAX 1000000001
int main() {
  int n;
  cin >> n;
  vector<int> R(n);
  for (int i = 0; i < n; i++) cin >> R[i];
  vector<int> max_v(n, 0);
  max_v[n - 1] = R[n - 1]-1;
  for (int i = n - 2; i >= 0; i--) {
    max_v[i] = max(R[i+1], max_v[i + 1]);
  }
  int ans = - MAX;
  for (int i = 0; i < n-1; i++) {
    ans = max(ans, max_v[i] - R[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int maxN = (int)1e5 + 10;
int a[maxN];
int cnt[maxN][2];
int n;
int main() {
    ios_base::sync_with_stdio(0);
     //freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        cnt[a[i]][i % 2]++;
    }
    vector < pair < int, int > > all[2];
    for (int i = 0; i < maxN; i++) {
        for (int j = 0; j < 2; j++) {
            all[j].push_back(make_pair(cnt[i][j], i));
        }
    }
    sort(all[0].begin(), all[0].end());
    sort(all[1].begin(), all[1].end());
    reverse(all[0].begin(), all[0].end());
    reverse(all[1].begin(), all[1].end());
    int mn = 5 * n;
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            if (all[0][i].second == all[1][j].second) continue;
            mn = min(mn, (n + 1) / 2 - all[0][i].first + (n / 2) - all[1][j].first);
        }
    }
    cout << mn;
    return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
int a,b;
int main()
{
	cin>>a>>b;
	if(b%2) re("No")
	if(a*4<b||a*2>b) re("No")
	re("Yes")
	return 0;}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int INF = 1e6;
using namespace std;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    vector<int> cnt(26, 0);
    char c;
    while(cin >> c){
        if('a' <= c && c <= 'z') cnt[c - 'a']++;
        else if('A' <= c && c <= 'Z') cnt[c - 'A']++;
    }
    rep(i,26) cout << (char)('a'+i) << ' ' << ':' << ' ' << cnt[i] << endl;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using P = pair<int, int>;

signed main() {

    string s;
    cin >> s;

    rep(i, 3){
        if(s[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n,m;
    cin >> n >> m;
    int kitai = pow(2,m);
    ll ans = (1900*m + 100*(n-m))*kitai;
    cout << ans << endl;
}

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

using namespace std;


int maxim(int a, int b, int c)
{
    if(a >= b && a>= c)
        return a;
    if(b >= a && b >= c)
        return b;
    if(c >= a && c >= b)
        return c;
}
int main()
{
   int a, b;
   cin >> a >> b;

   cout << maxim(a + b, a - b, a * b);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "

int main(void){
int n,m;cin>>n>>m;
n==m?co("Yes"):co("No");
}


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

int n;
double x[101], y[101], z[101], r[101], res;
struct Edge { int u, v; double cost; } tmp;
vector<Edge> edge;

bool comp(const Edge &e1, const Edge &e2)
{
    return e1.cost < e2.cost;
}

double sq(double x) { return x * x; }
double dis(int i, int j)
{
    return max(0.0, sqrt(sq(x[i] - x[j]) + sq(y[i] - y[j]) + sq(z[i] - z[j])) - r[i] - r[j]);
}

class UnionFind
{
private:
	int par[101];
	int rank[101];

public:
	void Init(int n)
	{
		for(int i = 0; i < n; ++i)
			par[i] = i, rank[i] = 0;
	}
	int Find(int x)
	{
		if(par[x] == x) return x;
		else return par[x] = Find(par[x]);
	}
	void Unite(int x, int y)
	{
		x = Find(x); y = Find(y);
		if(x == y) return;
		if(rank[x] < rank[y]) par[x] = y;
		else par[y] = x;
		if(rank[x] == rank[y]) ++rank[x];
	}
	bool Same(int x, int y)
	{
		return Find(x) == Find(y);
	}
} uft;

int main()
{
    while(cin >> n && n)
    {
		res = 0.0;
		uft.Init(n);
        edge.clear();
        for(int i = 0; i < n; ++i)
            cin >> x[i] >> y[i] >> z[i] >> r[i];
        for(int i = 0; i < n; ++i)
        {
            for(int j = i + 1; j < n; ++j)
            {
                tmp.u = i, tmp.v = j;
                tmp.cost = dis(i, j);
                edge.push_back(tmp);
            }
        }
		sort(edge.begin(), edge.end(), comp);
		for(int i = 0, c = 0; c < n - 1; ++i)
		{
			tmp = edge[i];
			if(!uft.Same(tmp.u, tmp.v))
			{
				uft.Unite(tmp.u, tmp.v);
				res += tmp.cost;
				++c;
			}
		}
		printf("%.3f\n", res);
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF=1e9+7;

template<typename T>
struct BIT{
  int n;
  vector<T> bit;
  //1-indexed
  BIT():n(-1){}
  BIT(int n_,T d):n(n_),bit(n_+1,d){}

  T sum(int i){
    T s=bit[0];
    for(int x=i;x>0;x-=(x&-x))
      s+=bit[x];
    return s;
  }
  void add(int i,T a){
    if(i==0) return;
    for(int x=i;x<=n;x+=(x&-x))
      bit[x]+=a;
  }

  int lower_bound(int w){
    if(w<=0) return 0;
    int x=0,r=1;
    while(r<n) r<<=1;
    for(int k=r;k>0;k>>=1){
      if(x+k<=n&&bit[x+k]<w){
        w-=bit[x+k];
        x+=k;
      }
    }
    return x+1;
  }

  T sum0(int i){
    return sum(i+1);
  }
  void add0(int i,T a){
    add(i+1,a);
  }

  T query(int l,int r){
    return sum(r-1)-sum(l-1);
  }

  T query0(int l,int r){
    return sum(r)-sum(l);
  }
};

signed main(){
  int N,k,ans;
  map<int,int> m;
  cin>>N;
  std::vector<int> a(N),w(N),v(N+1);
  for(int i=0;i<N;i++)cin>>a[i];
  set<int> s;
  for(int i=0;i<N;i++)s.insert(a[i]);
  std::vector<int> pa;
  for(int ww:s)pa.push_back(ww);
  int l=0,r=pa.size();
  while(r-l>1){
    int mi=(r+l)/2;
    for(int i=0;i<N;i++){
      if(a[i]>=pa[mi])w[i]=1;
      else w[i]=-1;
    }
    v[0]=0;
    for(int i=1;i<=N;i++)v[i]=v[i-1]+w[i-1];
    m.clear();
    for(int i=0;i<=N;i++)m[v[i]]=0;
    k=1;
    for(auto &p:m)p.second=k++;
    ans=0;
    BIT<int> bit(131072,0);
    for(int i=0;i<=N;i++){
      ans+=bit.sum(m[v[i]]);
      bit.add(m[v[i]],1);
    }
    if(ans>=((N*(N+1)/2)+1)/2)l=mi;
    else r=mi;
  }
  cout<<pa[l]<<endl;
}


Measured memory_bytes: 13808
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

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

    int X;
    cin >> X;

    while (!isPrime(X)) ++X;
    cout << X << endl;

    return 0;
}


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

int main() {
  string S;
  int ans=0;
  cin >> S;
  int N = S.size();
  
  for(int i=0;i<N/2;i++){
    if(S[i]!=S[N-i-1]) ans++;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    long test=1;
    // cin>>test;
    while(test--)
    {
	long n,m,k,i,j,a,b,c,d,ans=0;
    cin>>n>>k;
    vector<pair<long,long>> vec;
    for(i=0;i<n;i++)
    {
        cin>>a>>b;
        vec.push_back({a,b});
    }
    sort(vec.begin(),vec.end());
    long sum=0;
    for(i=0;i<n;i++)
    {
        sum+=vec[i].second;
        if(sum>=k)
        {
            cout<<vec[i].first;
            return 0;
        }
    }
    }
}

Measured memory_bytes: 2420
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf
import Debug.Trace

readInt = ( readLn :: IO Int )
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = readInt >>= print . uncurry (*) . ( ( `div` 2 ) &&& ( ( `div` 2 ) . succ ) )

Measured memory_bytes: 508
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int k,s;
  cin >> k >> s;
  
  int cnt = 0;
  
  for(int x = 0; x <= k;x++){
    for(int y = 0; y <= k;y++){
      if(s-x-y <= k && s-x-y >= 0){
        cnt++;
      }
    }
  }
  
  cout << cnt;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
S = []
P = []
for i in range(N):
    x, y = [str(i) for i in input().split()]
    S.append(x)
    P.append(int(y))
c = zip(S, P, range(1, N + 1))
c = sorted(c, key=lambda x: (x[0], -x[1]))
for _ in range(N):
    print(c[_][2])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

ll mod_pow(ll x, ll n, ll mod) {
	if (n == 0) return 1;
	ll res = mod_pow(x * x % mod, n / 2, mod);
	if (n & 1) res = res * x % mod;
	
	return res;
}

int N, K;
int A[2000];

int main() {
	cin >> N >> K;
	REP(i, N) scanf("%d", A + i);
	
	int cnt[2001] = {};
	REP(i, N) cnt[A[i]]++;
	
	int sum[2001] = {}; // i以下の個数
	FOR(i, 1, 2001) sum[i] = sum[i - 1] + cnt[i];
	
	ll ans = 0;
	REP(i, N) FOR(j, i + 1, N) if (A[i] > A[j]) ans++;
	ans = ans * K % MOD;
	
	REP(i, N) (ans += (ll)sum[A[i] - 1] * K % MOD * (K - 1) % MOD * mod_pow(2, MOD - 2, MOD)) %= MOD;
	
	cout << ans << endl;
	
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;
//const ll mod = 1e9 + 7;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

map< ll, int > prime_factor(ll n) {
    map< ll, int > ret;
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1) ret[n] = 1;
    return ret;
}

mint comb(ll k, ll n) {
    mint ans = 1;
    if (k - n < n)return comb(k, k - n);
    mint ansMul = 1, ansDiv = 1;
    rep(i, n) {
        ansMul *= (k - i);
        ansDiv *= (i + 1);
    }
    ans = ansMul / ansDiv;
    //ans = ansMul / ansDiv;
    return ans;
}

int main() {
	ll n, m;
    mint ans = 1;
	cin >> n >> m;
	ans = (mint(10)).pow(n) + (mint(8).pow(n)) - (mint(9).pow(n) * 2LL);
    cout << ans<< endl;
	return 0;
}



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

public class Main {

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

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

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

			String s1 = in.nextString();
			String s2 = in.nextString();
			String s3 = in.nextString();

			String str = (s1.substring(0, 1) + s2.substring(0, 1) + s3.substring(0, 1)).toUpperCase();
			out.println(str);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

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

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

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

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

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

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

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

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

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

}


Measured memory_bytes: 22864
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < int(n); ++i)
#define all(c) (c).begin(), (c).end()

template <class T, class U>
inline bool chmin(T& t, const U& f) { return t > f ? t = f, true : false; }

struct UnionFind {
    vector<int> data;
    int g;
    UnionFind(int n) : data(n, -1), g(n) {}
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        g--;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }
    int groups() { return g; }
};

struct Edge {
    int src, dst, wt;
    Edge(int s, int d, int w) : src(s), dst(d), wt(w) {}
};

using Edges = vector<Edge>;

const int INF = 1 << 16;

int solve(int n, int m, const Edges& E) {
    int small = INF;
    rep(i, m) {
        UnionFind uf(n);
        for (int j = i; j < m; ++j) {
            if (small <= E[j].wt - E[i].wt) break;
            if (!uf.unite(E[j].src, E[j].dst)) continue;
            if (uf.groups() == 1) chmin(small, E[j].wt - E[i].wt);
        }
    }
    return small == INF ? -1 : small;
}

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

    for (int n, m; cin >> n >> m, n | m;) {
        Edges E;
        rep(i, m){
            int a, b, w; cin >> a >> b >> w; a--; b--;
            E.emplace_back(a, b, w);
        }
        sort(all(E), [](const Edge& e1, const Edge& e2) { return e1.wt < e2.wt; });
        cout << solve(n, m, E) << endl;
    }
}

Measured memory_bytes: 3352
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int main() {
    long long n, a, sum = 0;
    cin >> n;
    map<long long, long long> cnt;
    map<int, int> used;
    vector<long long> s(n);
    for (int i = 0; i < n; i++){
        cin >> a;
        cnt[a]++;
        s[i] = a;
    }
    for (int i = 0; i < n; i++){
        if (used[s[i]] < 1){
            sum = sum + cnt[s[i]] % 2;
            used[s[i]]++;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 12032
/* 
	Author: ankrypt
*/
#include <bits/stdc++.h>

using namespace std;

double R;
double G;
int ans;

int main()
{
	scanf("%lf %lf", &R, &G);
	ans = (2 * G) - R;	
	printf("%d\n", ans);

	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

int main () {
  
  int N; cin >> N;
  
  vector<int> B(N + 1);
  
  B[0] = 100000;
  B[N] = 100000;
  
  for (int i = 0; i < N - 1; i++) {
    cin >> B[i + 1];
  }
  
  int ans = 0;
  
  for (int i = 0; i < N; i++) {
    ans += min(B[i], B[i+1]);
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 1e5 + 10, M = N;
const ll inf = 1e18 + 42;

int l[M], r[M], c[M];
vector<int> ent[N], ext[N];
ll dp[N];

int main() {
	fast_cin();
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= m; ++i) {
		cin >> l[i] >> r[i] >> c[i];
		ent[r[i]].pb(i);
		ext[l[i]].pb(i);
	}
	for (int i = 1; i < n; ++i) {
		dp[i] = inf;
	}
	multiset<pll> options;
	for (int i = n; i >= 1; --i) {
		if (!options.empty()) {
			dp[i] = min(dp[i], options.begin()->first);
		}
		for (auto &id : ent[i]) {
			options.insert({dp[r[id]] + c[id], id});
		}
		for (auto &id : ext[i]) {
			options.erase({dp[r[id]] + c[id], id});
		}
	}
	if (dp[1] >= inf) {
		cout << -1 << '\n';
	} else {
		cout << dp[1] << '\n';
	}
}

Measured memory_bytes: 13312
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      a: usize,
      b: usize,
    }
    if a < 10 && b < 10 {
        puts!("{}\n", a*b);
    } else {
        puts!("{}\n", -1);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main()
{
    long A, B, V, W, T;
    cin >> A >> V >> B >> W >> T;
    long vel, dist;
 
    vel = V - W;
    dist = labs(A - B);
 
    if (vel > 0 && dist <= T*vel)
    {
        cout << "YES\n";
    }
    else
    {
        cout << "NO\n";
    }
    return 0;
}

Measured memory_bytes: 3564
#include<iostream>
#include<cstdio>
#include<string>

using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  char a,b;
  cin >> a >> b;
  if(a < b) cout << '<';
  else if(a > b) cout << '>';
  else cout << '=';
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256
# /user/bin/python
# -*- coding: utf-8 -*-
import sys
 

class UnionFind():
  def __init__(self, size):
    self.par = [-1] * size

  def root(self, x):
    if self.par[x] < 0:
      return x
    else:
      return self.root(self.par[x])

  def issame(self, x, y):
    if self.root(x) == self.root(y):
      return True
    else:
      return False
  
  def merge(self, x, y):
    x, y = [self.root(x), self.root(y)]
    if x == y:
      return False
    if self.par[x] > self.par[y]:
      x, y = y, x
    self.par[x] += self.par[y]
    self.par[y] = x
    return True

  def size(self, x):
    return -self.par[self.root(x)]


if __name__ == "__main__":
  n,m = map(int, sys.stdin.readline().rstrip().split())
  A = [0] * m
  B = [0] * m
  for i in range(m):
    A[i], B[i] = list(map(int, sys.stdin.readline().rstrip().split()))

  uf = UnionFind(n)
  ans = []
  cur = n * (n-1) // 2

  for i in range(m):
    ans.append(cur)
    a, b = [A[m-i-1]-1, B[m-i-1]-1]

    if not uf.issame(a, b):
      sa = uf.size(a)
      sb = uf.size(b)
      cur -= sa * sb
      uf.merge(a, b)

  ans.reverse()
  for i in ans:
    print(i)

Measured memory_bytes: 18476
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e15;

int main(){
  int N; cin>>N;
  vector<ll> d(N+1,0);
  for(int i=0;i<N;i++){
    ll x; cin>>x;
    d.at(i+1)=d.at(i)+x;
  }
  ll SUM=d.at(N);
  ll ans=BIG;
  for(int i=0;i<N;i++) ans=min(abs(SUM-2*d.at(i)),ans);
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
s = input()
n = len(s)

def dfs(i, f):
  if i == n - 1:
#    print(f)
    total = sum(list(map(int, f.split('+'))))
    if total == 7:
      print((f + '=7').replace('+-', '-'))
      exit()
    return total
    # 式 f の末尾に "+" を追加するかしないかして次の数字を追加
  return dfs(i + 1, f + '+' + s[i + 1]) + dfs(i + 1, f + '+-' + s[i + 1])

dfs(0, s[0])


Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<utility>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<string>
#include<cctype>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define pq priority_queue
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
#define init(x) memset(x,0,sizeof(x))
int n,ans;
string s;
int a[300005],cnt[300005];
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    cin>>s;
    for (int i=0;i<n;++i) a[i+1]=(s[i]=='E'?1:0);
    for (int i=1;i<=n;++i) cnt[i]=cnt[i-1]+a[i];
    ans=n;
    for (int i=1;i<=n;++i){
    	ans=min(ans,i-1-cnt[i-1] + cnt[n]-cnt[i]);
	}
	cout<<ans;
    return 0; 
}

Measured memory_bytes: 2964
#include <bits/stdc++.h>
using namespace std;
/* * * *   * * *   	* * * */
#define ll long long
#define ld long double
#define ms(a,v) memset(a,v,sizeof a)
#define pii pair<int, int>
/* * * *   * * *   	* * * */
/* *
 *
 * Author: Hamkor
 *
 * */
int main(){
	int k, x; scanf("%d %d", &k, &x);
	for (int i = max(-1000000, x-k+1); i<=min(1000000, x+k-1); ++i)
		printf("%d ", i);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int N = 1e5 + 7;

int used[N];
vector<int> g[N];

void dfs(int cur) {
	used[cur] = 1;
	for (auto t : g[cur]) {
		if (!used[t]) {
			dfs(t);
		}
	}
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);	

	int n, m;
	cin >> n >> m;
	while (m--) {
		int u, v, kek;
		cin >> u >> v >> kek;
		u--;
		v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (!used[i]) {
			dfs(i);
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 9216
n, m = map(int, input().split())
posi = [tuple(map(int, input().split())) for _ in range(n)]
goal = [None]+[tuple(map(int, input().split())) for _ in range(m)]
for i in range(n):
    table = [0, float("inf")]
    for j in range(1, m+1):
        d = abs(posi[i][0]-goal[j][0])+abs(posi[i][1]-goal[j][1])
        if d < table[1]:
            table = [j, d]
    print(table[0])


Measured memory_bytes: 3064
l=int(input())
dp=[0]*5
for i in range(l):
	a,b,c,d,e,f=dp+[int(input())]
	p=int(f==0)*2
	dp=[a+f,min(a,b)+f%2+p,min(a,b,c)+(f+1)%2,min(b,c,d)+f%2+p,min(b,c,d,e)+f]
print(min(dp))

Measured memory_bytes: 3064
#include <stdio.h>
#include<string>
#include<string.h>
#include <math.h>
#include<iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>
using namespace  std;


/*
//my header
#include "define.h"
#include "geometry.h"*/

#define MyAbs(a) ((a)>0?(a):-(a))
#define MyEqualDoule(a,b) (MyAbs(a-b)<1e-6)

#define foreach(i,n) for(i=0;i<n;++i)
#define foreachd(i,n) for(int i=0;i<n;++i)
#define printfInt1(n) printf("%d\n",n)
#define scanfInt1(n) scanf("%d",&n)
#define scanfInt2(a,b) scanf("%d%d", &a, &b)
#define scanfInt3(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define scanfFloat2(a,b) scanf("%f%f", &a,&b)


void init()
{
#ifdef _WIN32
	freopen("1.txt", "r", stdin);
#endif
}

void func();

int main()
{
	init();
	func();

	return 0;
}

class CNumberTheory
{
public:
	static int gcd(int a, int b)
	{
		int t;
		while (b) {
			t = a % b;
			a = b;
			b = t;
		}
		return a;
	}
	static int lcm(int a,int b)
	{
		return a / gcd(a,b) * b;
	}
};

void func()
{
	int a, b;
	while(~scanfInt2(a,b))
	{
		printf("%d %d\n", CNumberTheory::gcd(a,b), CNumberTheory::lcm(a,b));
	}
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll a, b, c, d; cin >> a >> b >> c >> d;

    if(a+b > c+d){
        print("Left")
    }
    if(a+b == c+d){
        print("Balanced")
    }
    if(a+b < c+d){
        print("Right")
    }
    return 0;
}

Measured memory_bytes: 256
n, h = map(int, input().split())

alist = []
blist = []

for i in range(n):
  a, b = map(int, input().split())
  alist.append(a)
  blist.append(b)

alist = sorted(alist)[::-1]
blist = sorted(blist)[::-1]

ans = 0
i = 0

while i < len(blist):
  if alist[0] >= blist[i]:
    break
  h -= blist[i]
  ans += 1
  if h <= 0:
    print(ans)
    exit()  
  i += 1

if h % alist[0] == 0:
  ans += h // alist[0]
  print(ans)
else:
  ans += (h // alist[0]) + 1
  print(ans)

Measured memory_bytes: 12572
n, k = map(int, input().split())
f = [list(map(int, input().split())) for _ in range(n)]
f.sort()
ans = 1145141919810893364364
for i in range(n - k + 1):
    for j in range(i + k - 1, n):
        a = [f[l][1] for l in range(i, j + 1)]
        a.sort()
        for l in range(j - i - k + 2):
            ans = min(ans, (f[j][0] - f[i][0]) * (a[l + k - 1] - a[l]))
print(ans)

Measured memory_bytes: 71400
n,m = map(int,input().split())
map_li = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a,b = a-1,b-1
    map_li[a].append(b)
    map_li[b].append(a)

ans_li = [-1]*n
queue=[0]
visited = [False]*n

while queue:
    x = queue.pop(0)
    for g in map_li[x]:
        if visited[g]==False:
            queue.append(g)
            if ans_li[g]==-1:
                ans_li[g]=x
                visited[g]=True 
if -1 in ans_li[1:]:
    print('No')
else:
    print('Yes')
    for ans in ans_li[1:]:
        print(ans+1)

Measured memory_bytes: 35348
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
d=Counter(a)
m=int(input())
b=list(map(int,input().split()))
dd=Counter(b)
for i in dd:
  if i not in d:
    print("NO")
    exit()
  if d[i]<dd[i]:
    print("NO")
    exit()
print("YES")

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

int main(void){
  string str;
  int count_a,count_b,count_c;
  count_a=count_b=count_c=0;
  cin>>str;
  for(int i=0;i<str.size();i++){
    if(str[i]=='a'){
      count_a++;
    }else if(str[i]=='b'){
      count_b++;
    }else{
      count_c++;
    }
  }
  if(abs(count_a- count_b)>1||abs(count_a- count_c)>1
  	||abs(count_b- count_c)>1){
  	cout<<"NO"<<endl;
  }else{
  	cout<<"YES"<<endl;
  } 
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}

using namespace std;
int main(){
    long n; std::cin >> n;
    
    std::vector<long> a(n);int k=0;
    std::vector<int> b(n);
    
    long mx=0;
    long sum=0;
    long orr=0;
    rep(i,n){std::cin >> a[i];k=k^a[i];mx=max(mx,a[i]);sum+=a[i];orr=(orr|a[i]);}
    int keta=1;
  sort(a.begin(),a.end());
    if(a[n-1]==0){
        std::cout << "Yes" << std::endl;
        return 0;
    }if(n%3!=0){std::cout << "No" << std::endl;return 0;}
    while(true){
        if(mx/2==0)break;
        else mx=mx/2;keta++;
    }
    if(k!=0){
        std::cout << "No" << std::endl;
        return 0;
    }
    std::cout << ((sum==2*n*orr/3)?"Yes":"No") << std::endl;
    
    
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    bool kawaisou = false;
    if(A==B)
        kawaisou = true;
    if(A==C)
        kawaisou = true; 
    if(C==B)
        kawaisou = true;
    if(A==B&&B==C)
        kawaisou = false;
    puts(kawaisou ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string S;
  cin >> S;
  int N = S.size();
  rep(i, N) cout << 'x';
  cout << endl;

    return 0;
}

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

double p,e,t;

double search(int step, double l, double r){
    double mid = (l+r)*0.5;
    if(step==0){
        if(fabs(mid-t) <= e) return 1;
        else return 0;
    }

    double pr[2], lr[2]={l, r};
    for(int i=0; i<2; i++){
        if(fabs(lr[i]-t)<=e && fabs(mid-t)<=e){
            pr[i]=1;
        }else if((lr[i]-t)*(mid-t)>0 && fabs(lr[i]-t)>e && fabs(mid-t)>e){
            pr[i]=0;
        }else{
            pr[i]=search(step-1, min(mid,lr[i]), max(mid,lr[i]));
        }
    }

    double lrate = (mid>=t)? 1-p: p;
    return lrate*pr[0] + (1-lrate)*pr[1];
}

int main(){
    int k,l,r;
    cin >> k >> l >> r;
    cin >> p >> e >> t;

    cout << fixed;
    cout << setprecision(10);
    cout << search(k, l, r) << endl;
    return 0;
}

Measured memory_bytes: 3280
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 1e9 + 7;
const int IMAX = 2000010;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}
class unko {
public:
	int fac[IMAX + 1], ifac[IMAX + 1], inv[IMAX + 1];
	unko() : fac(), ifac(), inv() {
		fac[0] = 1;
		rep1(i, IMAX) fac[i] = ll(fac[i - 1]) * i % mod;
		ifac[IMAX] = modpow(fac[IMAX], mod - 2);
		for (int i = IMAX; i > 0; i--) ifac[i - 1] = ll(ifac[i]) * i % mod;
		inv[0] = 1;
		rep1(i, IMAX) inv[i] = ll(ifac[i]) * fac[i - 1] % mod;
	}
	int comb(int A, int B) {
		return ll(fac[A]) * ifac[B] % mod * ifac[A - B] % mod;
	}
} f;

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


	int R1, C1, R2, C2;
	cin >> R1 >> C1 >> R2 >> C2;


	ll kotae = 0;
	ll mod = 1e9 + 7;

	for (int i = C1 + 1; i <= C2 + 1; i++) {
		kotae += f.comb(i + R2, i);
		kotae -= f.comb(i + R1 - 1, i);
	}

	co((kotae % mod + mod) % mod);

	Would you please return 0;
}

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

using namespace std;

#define int long long
#define ll long long
//#define int unsigned long long

const int mod = 1e9 + 7;





signed main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //------<<<<>>>>-----//
  // freopen ("C:\\Users\\Andrey\\CLionProjects\\untitled1\\input.txt","r",stdin);
    //freopen ("C:\\Users\\Andrey\\CLionProjects\\untitled1\\output.txt","w",stdout);
    int n;
    cin>> n;
       int ans = 1e18;
    for(int i =1;i * i <= n;i++){
        if(n % i == 0){
            ans = min(ans,i + n / i - 1);
        }
    }
    cout << ans - 1;
}

Measured memory_bytes: 256
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
from Queue import Queue
 
 
def main():
    num = int(stdin.readline())
 
    L = []
    for _ in xrange(num):
        L.append([int(s) for s in stdin.readline().split()[2:]])
 
    d = [-1] * num
    d[0] = 0
    q = Queue(100)
    q.put(0)
    while not q.empty():
        u = q.get()
        for v in L[u]:
            if d[v-1] < 0:
                d[v-1] = d[u] + 1
                q.put(v-1)
 
    for i, v in enumerate(d):
        print(i+1, v)
 
 
main()

Measured memory_bytes: 7036
//abc073_a.cpp
//Sat Sep  1 20:33:37 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	string s;
	cin >> s;

	int flag = 0;
	for (int i=0;i<2;i++){
		if (s[i]=='9'){
			flag = 1;
			break;
		}
	}

	if (flag == 1){
		cout << "Yes" << endl;
	}else{
		cout << "No"<< endl;
	}
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}
int main() {
    ll n; cin >> n;
    ll a[100001]; INITA(a, 0, 100000, 0);
    ll tmp;
    map<ll, ll> m;
    REP(i, n) {
        cin >> tmp;
        if (m.find(tmp) == m.end()) {
            m[tmp] = 0;
        }
        m[tmp]++;
    }

    if ((m.size() == 1) && (m.find(0) != m.end())) {
        // 0のみの場合はOK
        cout << "Yes" << endl;
    } else if ((m.size() == 2) && (m.find(0) != m.end()) && (n == 3 * m[0])) {
        // 0の個数をaとして、それ以外の値が1種類で2a個存在すればOK
        cout << "Yes" << endl;
    } else if (m.size() > 3) {
        // 数字の異なり数が3を超えると成り立たない
        cout << "No" << endl;
    } else if (m.size() == 3) {
        // 3種類それぞれの個数が一致していて、かつそれぞれのxor関係が成り立てばOK
        vector<ll> v;
        set<ll> st;
        for (auto e: m) {
            v.push_back(e.first);
            st.insert(e.second);
        }
        if (st.size() != 1) {
            cout << "No" << endl;
        } else {
            if ((v[0] ^ v[1]) == v[2] && (v[0] ^ v[2]) == v[1] && (v[1] ^ v[2]) == v[0]) {
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        }
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 8216
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
	"strings"
)

func solve(sum int, elem []int, idx, limit int) bool {
	if sum == 0 {
		// 合計が一致
		return true
	}
	if idx >= limit {
		return false
	}

	//     使わないパターン               || 使うパターン
	return solve(sum, elem, idx+1, limit) || solve(sum-elem[idx], elem, idx+1, limit)
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	n := eGetInt(reader)
	a := eGetInts(reader)
	eGetInt(reader)
	ms := eGetInts(reader)
	for _, m := range ms {
		if solve(m, a, 0, n) {
			fmt.Println("yes")
		} else {
			fmt.Println("no")
		}
	}
}
func eGetLine(r *bufio.Reader) string {
	s, err := r.ReadString(byte('\n'))
	if err != nil {
		if err != io.EOF {
			log.Fatal(err.Error())
		}
		return s
	}
	return strings.TrimRight(s, "\r\n")
}
func eGetInt(r *bufio.Reader) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInts(r *bufio.Reader) []int {
	line := eGetLine(r)
	fields := strings.Split(line, " ")
	var ints []int
	for _, f := range fields {
		ints = append(ints, eAtoi(f))
	}
	return ints
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}



Measured memory_bytes: 1180
import sys


def main():
    N = int(input())
    P = map(int, input().split())

    Kcost = [min(row, N - 1 - row, clm, N - 1 - clm) for row in range(N) for clm in range(N)]

    Sitting = [1] * (N * N)
    Kcount = 0


    def Kcheck(qsn, cdsn):
        if Kcost[cdsn] > Kcost[qsn] + Sitting[qsn]:
            Kcost[cdsn] = Kcost[qsn] + Sitting[qsn]
            queue.append(cdsn)


    for sn in P:
        csn = sn - 1
        Kcount += Kcost[csn]
        Sitting[csn] = 0
        queue = [csn]

        while queue:
            qsn = queue.pop()
            div, mod = divmod(qsn, N)
            if mod: Kcheck(qsn, qsn - 1)
            if mod != N - 1: Kcheck(qsn, qsn + 1)
            if div: Kcheck(qsn, qsn - N)
            if div != N - 1: Kcheck(qsn, qsn + N)

    print(Kcount)

if __name__ == '__main__':
    main()

sys.exit()


Measured memory_bytes: 132924
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)

//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#pragma endregion RegionDefs

ll m = 1000005LL;
ll dp[1000005LL][2][2];

std::string trim(const std::string& string, const char* trimCharacterList = "0")
{
    std::string result;
    std::string::size_type left = string.find_first_not_of(trimCharacterList);
    if (left != std::string::npos)
    {
        std::string::size_type right = string.find_last_not_of(trimCharacterList);
        result = string.substr(left, right - left + 1);
    }
    return result;
}

void solve()
{
    string str; cin >> str;
    str = trim(str);
    vector<int> n;
    rep(i, str.size())
    {
        n.push_back(str[i] - '0');
    }
    rep(i, m)
    {
        rep(j, 2)
        {
            rep(k, 2) dp[i][j][k] = 2LL << 30;
        }
    }
    dp[0][0][0] = n[0];
    dp[0][1][0] = (n[0] == 9) ? 2 : (n[0] + 1);
    dp[0][1][1] = (n[0] == 9) ? 1 : (n[0] + 1);
    chmin(dp[0][1][0], 1LL+10-n[0]);
    chmin(dp[0][1][1], 1LL+9-n[0]);
    reps(i, 1, n.size())
    {
        rep(k, 10)
        {
            if (k > n[i])  chmin(dp[i][1][1], min(dp[i-1][0][0], dp[i-1][1][0]) + k + (k - 1 - n[i]));
            if (k >= n[i]) chmin(dp[i][k>n[i]][0], min(dp[i-1][0][0], dp[i-1][1][0]) + k + (k - n[i]));
            chmin(dp[i][1][0], dp[i-1][1][1] + k + (10 + k - n[i]));
            chmin(dp[i][1][1], dp[i-1][1][1] + k + (9 + k - n[i]));
        }
    }
    cout << min(dp[n.size()-1][0][0], dp[n.size()-1][1][0]) << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 38596
n = input().split()
a = int(n[0])
b = int(n[1])
k = int(n[2])

if a < k:
  k -= a
  a = 0
else:
  a -= k
  k = 0
  
if b > k:
  b -=k
else:
  b = 0

  
print(str(a)+" "+str(b))



    

Measured memory_bytes: 3060
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);

int main() {
	string s;
	while (getline(cin, s)) {
		bool update = true;
		while (update) {
			for (int i = 0; i < s.size(); i++) {
				if (s.substr(i, 3) == "the") {
					cout << s << endl;
					update = false;
					break;
				}
				if (s.substr(i, 4) == "this") {
					cout << s << endl;
					update = false;
					break;
				}
				if (s.substr(i, 4) == "that") {
					cout << s << endl;
					update = false;
					break;
				}
			}
			for (int i = 0; i < s.size(); i++) {
				if (!('a' <= s[i] && s[i] <= 'z')) {
					continue;
				}
				if (s[i] == 'z')s[i] = 'a';
				else s[i] = char(s[i] + 1);
			}
			//cout << s << endl;
		}
	}
}

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

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
  	int a, b, ans = 0;
	cin >> a >> b;
	ans = max(0, a-2*b);
	cout << ans << endl;
}


Measured memory_bytes: 888
N = int(input())

ans = N
for i in range(N+1):
    x = 0
    y = i
    while y:
        x += y%6
        y //= 6
    y = N-i
    while y:
        x += y%9
        y //= 9
    ans = min(x, ans)

print(ans)

Measured memory_bytes: 9020
n = gets.to_i
a = n.times.map{gets.to_i}

sum = a.last
now_v = a.last

(n-2).downto(0) do |i|
  if a[i] == a[i+1] - 1
    now_v = a[i]
  elsif a[i] >= a[i+1]
    sum += a[i]
    now_v = a[i]
  else
    puts -1
    exit
  end
end

unless now_v == 0
  puts -1
  exit
end

puts sum


Measured memory_bytes: 16240
#include <stdio.h>
int main()
{
	int m, n, i, j;
	scanf("%d %d", &n, &m);
	int a[n][m], b[m];
	int c[n];
	for(i=0; i<n; i++){
		for(j=0; j<m; j++){
			scanf("%d", &a[i][j]);
		}
		c[i]=0;
	}
	for(i=0; i<m; i++){
		scanf("%d", &b[i]);
	}
	for(i=0; i<n; i++){
		for(j=0; j<m; j++){
			c[i]+=a[i][j]*b[j];
		}
		printf("%d\n", c[i]);
	}
	return 0;
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
 /* freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);*/
  long long n,d,x,y;cin>>n>>d;
  long long count=0,sum;
  for(int i=0;i<n;i++){
  	cin>>x>>y;
  	sum=(x*x)+(y*y);
  	if(sqrt(sum)<=d){
  		count++;
  	}
  }
  cout<<count<<endl;

  return 0;
}

Measured memory_bytes: 3696