akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the iterator to kth largest element.(0-based)
typedef long long int lli;
#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pair<int,int>>
#define vc vector<char>
#define vs vector<string>
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define fastio	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
/*-------CONSTANTS------- */
const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI=acos(-1);
const int INF = 1000000000;
const int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
/*-----------------------------MATH STUFF----------------------------- */
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
int mulmod(int a, int b, int c){lli res=(lli)a*b;return(res>=c?res%c:res);}
template<typename T>T power_mod(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mulmod(x,p,m);p=mulmod(p,p,m);n>>=1;}return x;}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
//Factorials upto 1e5%MOD,nCr%MOD,nPr%MOD
lli fact[100000+5],fact_modinv[100000+5];
void fact_init(){
    fact[0] = 1ll;
    fact_modinv[0] = mod_inverse(fact[0],1ll*MOD);
    for(int i = 1;i<=100000;i++){
        fact[i] = mulmod(fact[i-1],i,1ll*MOD);
        fact_modinv[i] = mod_inverse(fact[i],1ll*MOD);
    }
}
lli choose(int n,int r){
    return mulmod(fact_modinv[n-r],mulmod(fact[n],fact_modinv[r],MOD),MOD);
}
lli P(int n,int r){
    return mulmod(fact[n],fact_modinv[n-r],1ll*MOD);
}
/*-----------------------------START----------------------------- */

int n,q;
lli lazy[200000+5];
vector<int> adj[200000+5];
lli val[200000+5];

void dfs(int u,int p){
    val[u] += lazy[u];
    for(auto x: adj[u]){
        if(x != p){
            lazy[x] += lazy[u];
            dfs(x,u);
        }
    }
}
int main(){
    fastio;
    cin>>n>>q;
    for(int i = 0;i<n-1;i++){
        int x,y;
        cin>>x>>y;
        adj[x].pb(y);
        adj[y].pb(x);
    }

    while(q--){
        int p,x;
        cin>>p>>x;
        lazy[p] += 1ll*x;
    }

    dfs(1,-1);
    for(int i =1;i<=n;i++)
        cout<<val[i]<<" ";
    
    
    return 0;
}



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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
#define HYPP(x) hypot(x.first,x.second)

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;



int main() {
	int A, B, K;
	cin >> A >> B >> K;
	for (int i = A; i < min(A + K,B+1); i++)cout << i << endl;
	for (int i = max(B-K +1,A+K); i < B+1; i++)cout << i << endl;
	return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tp3 = tuple<int, int, int>;
using Mat = vector<vector<ll>>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
class UnionFind {
public:
    vector<int>rank, parent, sizes;
    //初期化
    UnionFind(int size) {
        rank.resize(size, 0);
        parent.resize(size, 0);
        sizes.resize(size, 1);
        rep(i, size)parent[i] = i;
    }
    //木の根を求める
    int find(int x) {
        if (parent[x] == x)return x;
        else return find(parent[x]);
    }
    //xとyの属する集合を併合 return [parent, child]
    pii unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)return { -1,-1 };
        if (rank[x] < rank[y]) {
            parent[x] = y;
            sizes[y] += sizes[x];
            return { y,x };
        }
        else {
            parent[y] = x;
            sizes[x] += sizes[y];
            if (rank[x] == rank[y])rank[x]++;
            return { x,y };
        }
    }
    //xとyが同じ集合に属するか否か
    bool same(int x, int y) {
        return (find(x) == find(y));
    }
};
// ============ template finished ============

pair<int, vector<vector<int>>> make_edges(vector<int>& parent) {
    const int N = parent.size();
    int root = -1;
    vector<vector<int>> edges(N);
    rep(i, N) {
        if (i == parent[i]) {
            root = i;
        }
        else {
            edges[i].push_back(parent[i]);
            edges[parent[i]].push_back(i);
        }
    }
    return { root,edges };
}

void dfs(
    const vector<vector<int>>& edges,
    const vector<ll>& funs,
    vector<ll>& sumfuns,
    const int now,
    const int par
) {
    sumfuns[now] = funs[now] + (par == -1 ? 0 : sumfuns[par]);
    for (auto child : edges[now]) if (child != par) {
        dfs(edges, funs, sumfuns, child, now);
    }
}

int main()
{
    ll N;
    cin >> N;
    vector<tuple<ll, ll, ll>> cabs;
    rep(_, N - 1) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        cabs.push_back(make_tuple(c, a, b));
    }
    sort(cabs.begin(), cabs.end(), greater<tuple<ll, ll, ll>>());

    UnionFind uf(N);
    vector<ll> funs(N, 0);
    for (auto cab : cabs) {
        ll c, a, b;
        tie(c, a, b) = cab;
        assert(!uf.same(a, b));
        int par, child;
        tie(par, child) = uf.unite(a, b);
        funs[child] += c * (uf.sizes[par] - 2 * uf.sizes[child]) - funs[par];
        funs[par] += c * uf.sizes[child];
    }
    int root;
    vector<vector<int>> edges;
    tie(root, edges) = make_edges(uf.parent);

    vector<ll> res(N, 0);
    dfs(edges, funs, res, root, -1);
    for (auto num : res)cout << num << endl;
    return 0;
}


Measured memory_bytes: 16624
N, K = map(int, input().split())
X = list(map(int, input().split()))

# left point = i
ans = 1e9
for i in range(N-K+1):
    if X[i] >= 0:
      dist = X[i+K-1]
    elif X[i+K-1] <= 0:
      dist = abs(X[i])
    else:
      dist = min(X[i+K-1] * 2 - X[i], X[i+K-1] - 2 *X[i]) 
    #print(dist)
    ans = min(ans, dist)

print(ans)

Measured memory_bytes: 14568
#include <stdio.h>
#include <stdlib.h>

struct Node {
    int key;
    struct Node *parent,*left,*right;
};

void insert(int);
struct Node *find(struct Node *,int);
void inorder(struct Node *);
void preorder(struct Node *u);

struct Node *root,*NIL;

int main(){
  int m,i,k;
  char com[20];

  scanf("%d",&m);

  for(i=0;i<m;i++){
  scanf("%s",com);
 
  if(com[0]=='i'){
    scanf("%d",&k);
    insert(k);
  }
  else if(com[0]=='f'){
    scanf("%d",&k);

    struct Node *u=find(root,k);
    
    if(u==NIL) printf("no\n");
    else printf("yes\n");
  }
  else if (com[0]=='p'){
  inorder(root);
  printf("\n");
  preorder(root);
  printf("\n");
    }
  }
  return 0;
}


void insert(int k){
  struct Node *y=NIL;
  struct Node *x=root;
  struct Node *z;

  z=(struct Node *)malloc(sizeof(struct Node));

  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;

    if(z->key < x->key)   x=x->left;
    else  x=x->right;
  }
  z->parent=y;
    
  if(y==NIL)  root=z;
  else{
    if(z->key < y->key) y->left=z;
    else y->right=z;
  }
}

struct Node *find(struct Node *u, int k){
  while(u!=NIL && k!=u->key){
    if(k<u->key) u=u->left;
    else u=u->right;
  }
  return u;
}

void inorder(struct Node *u){
if(u==NIL)  return;

inorder(u->left);
printf(" %d",u->key);
inorder(u->right);

}

void preorder(struct Node *u){
if(u==NIL)  return;

printf(" %d",u->key);
preorder(u->left);
preorder(u->right);
}





Measured memory_bytes: 20604
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

int N, A[100005];

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

  int mn = N, col = 0, cnt = 0;
  
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &A[i]);
    mn = min(mn, A[i]);
  }

  col = mn + 1;

  for (int i = 1; i <= N; ++i) {
    if (A[i] == mn) col--, cnt++;
    if (A[i] > mn + 1) {
      puts("No");
      return 0;
    }
  }

  if (N == cnt) {
    if (mn * 2 > N && mn != N - 1) puts("No");
    else puts("Yes");
  } else {
    if (col <= 0 || (N - cnt) < col * 2) {
      puts("No");
      return 0;
    }
    puts("Yes");
  }
  
  return 0;
}


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

int main(void){
    int n;
    cin >> n;
    pair<int, int> times[100100]; //クラス定義

    for(int i = 0; i < n; i++){
        cin >> times[i].second >> times[i].first; //sortは第１要素を昇順に並べる為、終了時刻を昇順に並べたいならば、firstに終了時刻が入るように標準入力すれば良い
    }

    sort(times, times + n); //第１要素を昇順に並べる

    // for(int i = 0; i < n; i++){
    //     cout << "@" << times[i].first << "@@" << times[i].second << endl;
    // }

    int cnt = 0, t = -1; //１番目の活動は必ず選ばれるようにする為。tは前の活動の開始時刻で１番目の活動の前はない為−１に初期化する
    for(int i = 0; i < n; i++){
        if(t < times[i].second){ //次の活動の開始時刻が前の活動の終了時刻とかぶっていなければ
            cnt++;
            t = times[i].first;
        }
    }
    cout << cnt << endl;
}



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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef tuple<ll,ll,ll> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.141592653589793238462643383279;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

typedef tuple<ll, int, ll> P;

bool operator>(P a, P  b){
    return get<0>(a) > get<0>(b);
}


int main(void){
    ll N,M,S; cin >> N >> M >> S;
    vector<tpl> edge[N];
    ll mxa = 0;
    REP(i,M){
        ll u,v,a,b; cin >> u >> v >> a >> b; u--; v--;
        edge[u].emplace_back(v, a, b);
        edge[v].emplace_back(u, a, b);
        chmax(mxa, a);
    }
    VL C(N), D(N); REP(i,N) cin >> C[i] >> D[i];

    ll K = mxa*(N-1);
    ll dp[N][K+1]; REP(i,N)REP(j,K+1) dp[i][j] = LINF;

    priority_queue<tpl,vector<tpl>,greater<tpl>> q;

    q.push(tpl(0, 0, min(K, S)));
    while(q.size()){
        tpl p = q.top(); q.pop();
        ll n = get<0>(p), city = get<1>(p), s = get<2>(p);
        if(chmin(dp[city][s], n)){
            for(auto e : edge[city]){
                int c = get<0>(e);
                ll cost = get<2>(e), news = s - get<1>(e);
                if(news >= 0) q.push(tpl(dp[city][s] + cost, c, news));
            }
            q.push(tpl(dp[city][s] + D[city], city, min(K, s + C[city])));
        }
    }

    REP(i,N-1){
        ll ans = LINF;
        REP(j,K+1) chmin(ans, dp[i+1][j]);
        cout << ans << en;
    }
    return 0;
}

Measured memory_bytes: 10528
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tp3 = tuple<int, int, int>;
using Mat = vector<vector<ll>>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
template<typename T>
T chmin(T& l, T r) {
    return l = min(l, r);
}
template<typename T>
T chmax(T& l, T r) {
    return l = max(l, r);
}
// ============ template finished ============

int main()
{
    int H, W, N;
    cin >> H >> W >> N;
    map<int, set<int>> blocks;
    rep(i, N) {
        int X, Y;
        cin >> X >> Y;
        X--; Y--;
        blocks[X].insert(Y);
    }
    rep(w, W + 1) blocks[H].insert(w);

    int nowx = 0;
    int maxy = 0;
    bool clump = false;
    while (true) {
        const auto& row = blocks[nowx + 1];
        auto itr = row.upper_bound(maxy);

        if (row.empty()) {
            // pass
        }
        else if (itr == row.begin()) {
            // pass
        }
        else {
            break;
        }

        if (row.find(maxy + 1) == row.end())maxy++;
        nowx++;
    }
    cout << nowx + 1 << endl;
    return 0;
}


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

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

int main(){
	int h,w;
	cin >> h >> w;
	
	vector<vector<char> > map(h+2, vector<char>(w+2, '#'));
	int sy, sx, dir;
	for(int i=1; i<=h; i++){
		for(int j=1; j<=w; j++){
			cin >> map[i][j];
			if(map[i][j]!='.' && map[i][j]!='#' && map[i][j]!='G'){
				sy=i; sx=j;
				if(map[i][j]=='>') dir = 0;
				if(map[i][j]=='^') dir = 1;
				if(map[i][j]=='<') dir = 2;
				if(map[i][j]=='v') dir = 3;
			}
		}
	}
	
	int count=1;
	map[sy][sx] = '.'+1;
	int x=sx,y=sy;
	while(1){
		for(int i=0; i<4; i++){
			if(map[y+dy[(dir+3+i)%4]][x+dx[(dir+3+i)%4]] != '#'){
				dir = (dir+3+i)%4;
				break;
			}
		}
		x += dx[dir];
		y += dy[dir];
		if(map[y][x]=='G'){
			count++;
			break;
		}
		if(map[y][x]=='.'){
			count++;
		}
		map[y][x]++;
		if((int)map[y][x]=='.'+5){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << count << endl;
	return 0;
}

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

int lsb(int x)
{
  if(x%2 == 0){
    return 0;
  } else {
    return 1;
  }
}

int *bin_ex(int x, int n)
{
  int *A;
  A = (int*)malloc(sizeof(int)*n);
  for(int i=0; i<n; i++)
  {
    A[i] = lsb(x/pow(2,i));
  }
  return A;
}

int mod_sum(int *A, int *B, int n)
{
  int tmp = 0;
  for(int i=0; i<n; i++)
  {
    tmp += A[i]*B[i];
    if(tmp == 2)
    {
      tmp = 0;
    }
  }
  return tmp;
}

ll each_pat(int **S, int *P, int n, int m, int *state)
{
  for(int i=0; i<m; i++)
  {
    if(mod_sum(S[i],state,n)!=P[i]){
      return 0;
    }
  }


  return 1;
}

int main()
{
  int n,m;
  cin >> n >> m;
  int **S;
  S = (int**)malloc(sizeof(int*)*m);
  for(int i=0; i<m; i++)
  {
    S[i] = (int*)malloc(sizeof(int)*n);
    int k;
    cin >> k;
    for(int j=0; j<n; j++)
    {
      S[i][j] = 0;
    }
    for(int j=0; j<k; j++)
    {
      int tmp;
      cin >> tmp;
      S[i][tmp-1] = 1;
    }
  }

  int *P;
  P = (int*)malloc(sizeof(int)*m);
  for(int i=0; i<m; i++)
  {
    cin >> P[i];
  }

  int tmp=0;
  for(int x=0; x<pow(2,n); x++)
  {
    int *X;
    X = bin_ex(x,n);
    tmp += each_pat(S,P,n,m,X);
  }
  cout << tmp << 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++)

int main() {
  int N;
  cin >> N;
  bool res = false;
  for (int a = 0; a <= 100; a++) {
    for (int b = 0; b <= 100; b++) {
      int total = 4*a + 7*b;
      if (total == N) res = true;
    }
  }

  if (res) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include<numeric>
using namespace std;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n);i++)
typedef long long ll;


int main(){
    int n, m; cin >> n >> m;
    vector<P> v;
    rep(i,n){
        int a; cin >> a;
        v.push_back({a, 1});
    }
    rep(i,m){
        int b,c; cin >> b >> c;
        v.push_back({c,b});
    }
    sort(v.begin(), v.end(), greater<P>());

    ll num=0;
    ll res=0;
    for(auto p : v){
        if(num + p.second <= n){
            res += p.first * p.second;
            num += p.second;
        }else{
            res += p.first * (n - num);
            num = n;
            break;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 2420
#include <cstdio>
#include <vector>
#include <algorithm>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<long double> p(N);
  for (size_t i = 0; i < N; ++i)
    scanf("%Lf", &p[i]);

  std::vector<std::vector<long double>> dp(N+1, std::vector<long double>(N+1));
  dp[0][0] = 1.0;
  for (size_t i = 0; i < N; ++i)
    for (size_t j = 0; j <= i+1; ++j) {
      if (j > 0) dp[i+1][j] += dp[i][j-1] * p[i];
      dp[i+1][j] += dp[i][j] * (1.0-p[i]);
    }

  long double res = 1.0;
  for (size_t i = 0; i <= N/2; ++i)
    res -= dp[N][i];

  printf("%.12Lf\n", res);
}


Measured memory_bytes: 141056
// ----------------------In the name of Allah-------------------------- \\

#include <bits/stdc++.h>
using namespace std;

#define ll long long

const ll MAXlog = 20, MAX = 1e5+1, mod = 1e9+7, inf = 2e9+2;

ll n, h, w, arr[200][200], t[MAX];

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> h >> w >> n;
	
	for (int i = 0; i < n; i++) cin >> t[i];
	int vx = 0, vy = 1, x = 0, y = 0;
	for (int i = 0; i < n; i++) {
		while (t[i]) {
			//cout << x << ' ' << y << endl;
			arr[y][x] = i+1;
			y += vy;
			if (y == h || y==-1)
				x ++, vy *= -1, y += vy;
			t[i]--;
		}
	}
	//cout << endl;
	for (int i = 0; i < h ; i++) {
		for (int j = 0; j < w; j++)
			cout << arr[i][j] << ' ';
		cout << endl;
	}
	return 0;
}


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

using ll = long long;

int bitcount(int a){
	int r = 0;
	while(a){
		a -= a & -a;
		r++;
	}
	return r;
}

int main(){
	int n, k;
	cin >> n >> k;
	ll a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	ll ans = 1e15;
	for(int i = 0; i < 1 << n; i++){
		if(bitcount(i) < k) continue;
		ll tmp = 0, maxi = -1;
		for(int j = 0; j < n; j++){
			if(i >> j & 1){
				if(maxi == -1){
					maxi = a[j] + 1;
					continue;
				}
				tmp += max(0ll, maxi - a[j]);
				maxi = max(maxi + 1, a[j] + 1);
			}
			maxi = max(maxi, a[j] + 1);
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;
}

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

int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    vector<bool> ans(k+1);
    for(int i=0;i<=k;i++)
    {
        for(auto x:a)
        {
            if(i>=x && ans[i-x]==false)
            ans[i]=true;
        }
    }
    if(ans[k]) cout<<"First\n";
    else cout<<"Second\n";
}


Measured memory_bytes: 256
/*input
31415 9265 3589
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
    out<<'('<<P.F<<','<<P.S<<')';
    return out;
}

//}}}
const ll maxn=1000005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        
        b>>=1;
    }
    return res;
}

ll inv(ll n){
    return mypow(n,MOD-2);
}

ll dp[maxn];
ll pre[maxn];
ll fac[maxn];
int main(){
    IOS;
    fac[0]=1;
    for(int i=1;i<maxn;i++)fac[i]=fac[i-1]*i%MOD;
    int n,h,d;
    cin>>n>>h>>d;
    dp[1]=1;
    for(int i=1;i<=n;i++) dp[1]=dp[1]*i%MOD;
    pre[0]=0;
    pre[1]=dp[1];

    ll x=0;
    for(int i=1;i<=n;i++){
        x+=fac[i];
        if(x>=MOD) x-=MOD;
    }
    for(int i=1;i<=h;i++){
        dp[i]=pre[i];
        if(i>=d){
            dp[i]-=pre[i-d];
            if(dp[i]<0) dp[i]+=MOD;
        }
        pre[i+1]=(pre[i]+dp[i]*x)%MOD;
        // cout<<dp[i]<<'\n';
    }
    ll ans=dp[h]%MOD;
    cout<<ans<<'\n';
    return 0;
}
    

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

int main() {
	double n;
	cin >> n;
	double ans =  2 * n * 3.141592;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3804
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];





int main(){
 int a;
 cin>>a;
 vector<int> vec(a);
 rep(i,a){
     cin>>vec.at(i);
 }
 long long ans=INF;
 rep(i,100){
     long long t=0;
     rep(j,a){
         t+=(vec.at(j)-(i+1))*(vec.at(j)-(i+1));
     }
     //cout<<t<<endl;
     if(t<ans&&t>=0){
         ans=t;
     }
 }
 cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
using namespace std;
struct _IO{_IO(){ios::sync_with_stdio(0);cin.tie(0);}}_io;
string str="abcdefghijklmnopqrstuvwxyz";
int main()
{
    ll g=0;
    string s;
    cin>>s;
    for(int i=1;i<s.size();i++)
    {
        if(s[i]==s[i-1])
        {
            cout<<i<<" "<<i+1<<endl;
            g=1;
            break;
        }
        else if(s[i]==s[i-2]&&i>1)
        {
            cout<<i-1<<" "<<i+1<<endl;
            g=1;
            break;
        }
    }
    if(g==0)
    {
        {
            cout<<-1<<" "<<-1<<endl;
        }
    }
}

Measured memory_bytes: 3748
#include <iostream>
#include<time.h>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include<cassert>
#include<cctype>
#include<iterator>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1<<30
#define INFTY 1000000000000000001LL
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
// g++ -o a a.cpp -Wall -lm -std=c++14

int main(){
    int n;cin>>n;
    LL a[MAX];
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]==0){cout<<0<<endl;return 0;}
    }
    LL s=1;
    LL M=pow(10,18);
    rep(i,n){
        if(a[i]<=M/s){
            s*=a[i];
        }
        else{
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<s<<endl;
    return 0;

}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    N--;

    vector<char> ans;
    for(ll i=1; i<=12; i++)
    {
        ans.push_back('a' + N%26);
        // cout << i << ' ' << N << ' ' << N%26 << endl;
        N -= 26;
        if(N < 0) break;
        N = N/26;
    }
    for(int i=ans.size()-1; i>=0; i--)
    {
        cout << ans[i];
    }
    cout << '\n';

    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;
int main(void){
    int n, a[100000], b[100000];
    P p[100000];
    long long ans = 0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
        p[i] = P(a[i] + b[i], i);
    }
    sort(p, p+n, greater<P>());
    for(int i=0;i<n;i+=2){
        ans += a[p[i].second];
    }
    for(int i=1;i<n;i+=2){
        ans -= b[p[i].second];
    }

    cout << ans << endl;
    
}


Measured memory_bytes: 1792
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int inputa = sc.nextInt();
		int inputb = sc.nextInt();
		int inputc = sc.nextInt();
		int inputk = sc.nextInt();

		int result = 0;
		if(inputk <= inputa) {
			result = inputk;
		}
		else if(inputk <= inputa + inputb) {
			result = inputa;
		}
		else if(inputk < inputa + inputb + inputc) {
			result = inputa - (inputk - inputa - inputb);
		}else {
			result = inputa - inputc;
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 35540
#include<stdio.h>
int sosuu(int a)
{
  int k,sw;
  k=0;
  for(int i=2;i<a/2;++i)
  {
  if(a%i==0) {k++;}
  }
  if(k>0) sw=1;
  else sw=0;
return sw;
}
int main()
{
int n,cc;
  cc=0;
  scanf("%d",&n);
  
  while(cc==0)
  {
  if(sosuu(n)==0) cc++;
  else n++;
  }
  printf("%d",n);
return 0;}

Measured memory_bytes: 1736
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)
#define FORR(i,n,m) for(ll i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define pi  3.14159265358979323846
 
int main(){
    ll r,c;
    cin >> r >> c;
    ll arr[100] = {0};
    REP(i,r){
        ll a;
        ll ans=0;
        REP(j,c){
            cin >> a;
            cout << a << " ";
            arr[j] += a;
            ans += a;
        }
        cout << ans << endl;
    }
    ll ans=0;
     REP(i,c){
        cout << arr[i] << " ";
        ans += arr[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3036
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int tonum(string s1) {
	int n1 = 0, p = 1;
	for (int i=0; i<(int)s1.size(); i++) {
		if ('2' <= s1[i] && s1[i]<= '9') p = s1[i] - '0';
		else if (s1[i] == 'm') {
			n1 += p * 1000;
			p = 1;
		} else if (s1[i] == 'c') {
			n1 += p * 100;
			p = 1;
		} else if (s1[i] == 'x') {
			n1 += p * 10;
			p = 1;
		} else if (s1[i] == 'i') {
			n1 += p;
			p = 1;
		}
	}
	return n1;
}

string tomcxi(int sum) {
	stringstream res;
	
	if (sum/1000 > 0) {
		if (sum/1000 != 1) res << sum/1000;
		res << "m";
	}
	sum %= 1000;
	if (sum/100 > 0) {
		if (sum/100 != 1) res << sum/100;
		res << "c";
	}
	sum %= 100;
	if (sum/10 > 0) {
		if (sum/10 != 1) res << sum/10;
		res << "x";
	}
	sum %= 10;
	if (sum > 0) {
		if (sum!=1) res << sum;
		res << "i";
	}
	return res.str();
}

int main() {
	int n; cin >> n;
	
	for (int rep = 0; rep < n; rep++) {
		
		string s1, s2; cin >> s1 >> s2;
		
		int n1 = tonum(s1), n2 = tonum(s2);
		
		int sum = n1 + n2;
		cout << tomcxi(sum) << endl;
	}
	
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin() x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin() x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	vi box(3);
	int n;
	rep(i, 3) cin >> box[i];
	cin >> n;
	sort(rall(box));

	ll ans=0;
	for(int i=0; i<=n/box[0]; i++){
		int n2 = n - i*box[0];
		for(int j=0; j<=n2/box[1]; j++){
			int n3 = n2 - j*box[1];
			if (n3 % box[2] == 0) ans++;
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<set>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
int dp[MAXN];
int l,r,n,sum,ans;
multiset<int> s;
vector<int> a[MAXN];
bool dfs(int x,int fa,int maxl){
    for(int i=0;i<a[x].size();i++)
        if(a[x][i]!=fa)
            if(dfs(a[x][i],x,maxl)==0)
                return 0;
    s.clear();
    for(int i=0;i<a[x].size();i++)
        if(a[x][i]!=fa){
            if(dp[a[x][i]]+1>maxl){
                return 0;
            }
            s.insert(dp[a[x][i]]+1);
        }
    int flag=0;
    if(s.size()%2==1)
        flag=1;
    if(x==1)
        flag--;
    /*if(x==83)
        for(int i=0;i<a[x].size();i++)
            if(a[x][i]!=fa)
                PF("{%d} ",dp[a[x][i]]+1);*/
    while(s.size()>1){
        int t=*s.rbegin();
        s.erase(s.find(t));
        multiset<int>::iterator it=s.lower_bound(maxl-t+1);
        if(it==s.begin()){
            if(flag==-1){
                return 0;
            }
            if(flag==1){
                dp[x]=t;
                flag=-1;
            }
            else{
                if(x!=1)
                    flag=1;
                else
                    flag=-1;
            }
        }
        else{
            it--;
            s.erase(it);
        }
    }
    if(s.size()==1){
        dp[x]=*s.begin();
        if(dp[x]>maxl){
            return 0;
        }
        s.erase(dp[x]);
    }
    return 1;
}
bool check(int maxl){
    memset(dp,0,sizeof dp);
    s.clear();
    if(dfs(1,0,maxl))
        return 1;
    return 0;
}
int u,v;
int main(){
    //freopen("data.in","r",stdin);
    //freopen("data.out","w",stdout);
    SF("%d",&n);
    for(int i=1;i<n;i++){
        SF("%d%d",&u,&v);
        a[u].push_back(v);
        a[v].push_back(u);
    }
    for(int i=1;i<=n;i++)
        if(a[i].size()%2==1)
            sum++;
    sum/=2;
    PF("%d ",sum);
    //PF("[%d]",check(6));
    l=1,r=n;
    while(l<=r){
        int mid=(l+r)>>1;
        if(check(mid)){
            ans=mid;
            r=mid-1;
        }
        else{
            l=mid+1;
        }
    }
    PF("%d",ans);
}


Measured memory_bytes: 14080
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  string s, t;
  cin >> s >> t;
  int sz = s.size();
  int ans = 0;
  rep(i, sz) if(s[i] != t[i]) ans++;
  cout << ans << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3740
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <climits>

#define int_max 2147483647;

int main(int argc, char const *argv[])
{
    int N, T;
    std::cin >> N >> T;
    // std::cout << "N " << N << "T" << T << std::endl;
    std::vector<std::vector<int>> vec(N, std::vector<int>(2));

    for(int i = 0; i < N ; i ++)
    {
        std::cin >> vec[i][0] >> vec[i][1] ;
    }
    int No;
    int min = int_max
    int check = 0;
    for(int i = 0; i < N ; i ++)
    {
        if(vec[i][1] <= T)
        {
            check = 1;
         if(min >= vec[i][0])
         {
             min = vec[i][0];
         }   
        }
    }
    if(check == 0)
    {
        std::cout<<"TLE"<<std::endl;
    }
    else 
    {
        std::cout<<min<<std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
// new day,new strength,new thougts
#include<bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define F first
#define S second
#define sz(c) int((c).size())
#define REP(i,n)  for(int i=0;i<int(n);i++)
#define REPD(i,n) for(int i=int(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=int(a);i<=int(b);i++)
#define FORD(i,a,b) for(int i=int(a);i>=int(b);i--)
#define all(s) (s).begin(),(s).end()
#define bit(num,i) ((num>>i)&1)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

const ll inf=4e18;
const ll maxn=2e5+10;
const ll mod=1e9+7;

int main(){
    string s;cin>>s;
    ll k;cin>>k;
    REP(i,sz(s)){
	if(i%k==0)
	    cout<<s[i];
    }
}


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


template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  
  vector<Int> cnt(n,0);
  for(Int i=1;i<n;i++){
    Int u,v,a;
    cin>>u>>v>>a;
    cnt[u]^=a;
    cnt[v]^=a;
  }
  
  vector<Int> bc(16,0);
  for(Int i=0;i<16;i++) bc[i]=__builtin_popcount(i);
  
  Int ans=0,res=0;
  for(Int i=0;i<n;i++){
    if(!cnt[i]) continue;
    ans+=bc[cnt[i]];
    if((res>>cnt[i])&1)
      ans-=(bc[cnt[i]]-1)*2;
    res^=1<<cnt[i];
  }
  ans/=2;
  
  auto calc=
    [&](Int k){
      Int res=0;
      for(Int i=0;i<16;i++)
	if((k>>i)&1) res+=bc[i];
      return res;
    };
  
  const Int INF = 1e9;
  vector<Int> dp(1<<16,-INF);
  using P = pair<Int, Int>;
  priority_queue<P> pq;
  dp[res]=0;
  pq.emplace(calc(res),res);
  
  while(!pq.empty()){
    Int b=pq.top().second;pq.pop();
    for(Int i=0;i<16;i++){      
      if((~b>>i)&1) continue;
      for(Int j=0;j<i;j++){
	if((~b>>j)&1) continue;
	if(!(i&j)) continue;
	{
	  Int dif=bc[i&j]-1;
	  Int nb=b^(1<<i)^(1<<j);
	  auto fix=
	    [&](Int y){
	      nb^=1<<y;
	      if((nb>>y)&1) return;
	      dif+=max<Int>(0,bc[y]-1);
	    };
	  fix(i^(i&j));
	  fix(j^(i&j));
	  assert(calc(nb)<=calc(b));
	  if(dp[nb]>=dp[b]+dif) continue;
	  dp[nb]=dp[b]+dif;
	  pq.emplace(calc(nb),nb);
	}
        {
	  Int dif=bc[i&j]-1;
	  Int nb=b^(1<<i)^(1<<j);
	  auto fix=
	    [&](Int y){
	      nb^=1<<y;
	      if((nb>>y)&1) return;
	      dif+=max<Int>(0,bc[y]-1);
	    };
	  fix(i^j);
	  fix(0);
	  assert(calc(nb)<=calc(b));
	  if(dp[nb]>=dp[b]+dif) continue;
	  dp[nb]=dp[b]+dif;
	  pq.emplace(calc(nb),nb);
	}
      }
    }
  }
  
  ans-=*max_element(dp.begin(),dp.end());
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;






int main() {
	int l;
	vi v(25, 0);
	int a = 32;
	while (cin >> l && l > 0) {
		rep(i, l)cin >> v[i];
		a = 32;
		for (int i = 0; a > 0; i = (i + 1) % l) {
			a -= (a - 1) % 5;
			cout << a << endl;
			a -= v[i];
			if (a < 0)a = 0;
			cout << a << endl;
		}
	}
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

ull squareRoot(ull n){
  ull lo = 0, hi = INT_MAX;
  while(1){
    ull mid = (lo + hi)/2;
    if (n < mid * mid){
      hi = mid;
    }else if ((mid+1)*(mid+1) <= n){
      lo = mid + 1;
    }else{
      return mid;
    }
  }
  return -1;
}

int main(void){
  int Q; cin >> Q;
  for(int i=0;i<Q;i++){
    ll a, b; cin >> a >> b;
    if (a > b) swap(a, b);
    ll r = squareRoot(a * b);
    ll ans = (a - 1) + max(0LL, r - a - 1) + (r - 1);
    if (r * r < a * b && a != r) ans++;
    if (r * (r+1) < a * b) ans++;
    cout << ans << endl;
  }
  return 0;
}
    

Measured memory_bytes: 256
#include<stdio.h>
#define max 100005

typedef struct process{
  char name[256];
  int time;
} p;

int  head = 0, tail = 0, n;
p Q[max];

void enqueue(p);
p dequeue(void);

int main(){
  int i, q, temp, passage = 0;
  p dq;

  scanf("%d%d", &n, &q);

  head = 1; 
  tail = n + 1;

  for(i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].time);
  }

  while( tail != head){
    dq = dequeue();
    if(q > dq.time)   temp = dq.time;
    else                    temp = q;
    passage += temp;
    dq.time -= temp;
    if(dq.time > 0)   enqueue(dq);
    else                     printf("%s %d\n", dq.name, passage);
  }
      
  return 0;
}

void enqueue(p x){
  Q[tail] = x;
  if(tail + 1 == max)    tail = 0;
  else                           tail++;
}

p dequeue(void){
  p x = Q[head];
  if(head + 1 == max)    head = 0;
  else                              head++;
  return x;
}

Measured memory_bytes: 25992
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  int sum = 0;
  int maximum = 0;
  for(int i = 0; i < N; i++) {
    cin >> vec.at(i);
    sum += vec.at(i);
    maximum = max(maximum, vec.at(i));
  }
  if(sum > maximum * 2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N, C;
int A[409], B[409];
ll ppow[409][409];
ll ppowS[409][409];
ll dp[409][409];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>C;
    rep(i,N) cin>>A[i];
    rep(i,N) cin>>B[i];
    
    ppow[0][0]=1;
    rep1(i,400){
        ppow[i][0]=1;
        rep(j,400) ppow[i][j+1]=ppow[i][j]*i%MOD;
    }
    rep(i,401)rep(j,401) ppowS[j+1][i]=(ppowS[j][i]+ppow[j][i])%MOD;
    
    dp[0][0]=1;
    rep(i,N)rep(x,C+1)for(int y=0;x+y<=C;y++){
        ll p=(ppowS[B[i]+1][y]-ppowS[A[i]][y])%MOD;
        if(p<0) p+=MOD;
        (dp[i+1][x+y]+=dp[i][x]*p)%=MOD;
    }
    cout1(dp[N][C]);
}

Measured memory_bytes: 4096
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)

int N,K;

signed main(){
	cin>>N>>K;
	double ans=0;
	for(int i=1;i<=N;i++){
		int t=i;
		int cnt=0;
		if(t>=K){
			ans+=1.0000000/N;
			continue;
		}
		while(1){
			t*=2;
			cnt++;
			if(t>=K){
				break;
			}
		}
		ans+=(1.000000000/N)*(1.0000000000/(double(1<<cnt)));
	}
	cout<<fixed<<setprecision(15)<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define rep(i,s,n)for(int i = s;i<n;i++)

int main() {
	int A, B; cin >> A >> B;
	int cnt = 0;
	rep(i, A, B + 1) {
		if (i / 10000 == i % 10
			&& i / 1000 % 10 == i / 10 % 10)
		{
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
//#include <algorithm>
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <list>
//#include <cmath>

using namespace std;



int main(void) {
	int N;
	cin >> N;
	int n = N % 10;

	if (n == 3) {
		cout << "bon" << endl;
	}
	else if (n == 0 || n == 1 || n == 6 || n == 8) {
		cout << "pon" << endl;
	}
	else {
		cout << "hon" << endl;
	}



	return 0;
}

Measured memory_bytes: 3632
import collections
from collections import Counter
N=int(input())
a=input().split()
A=[int(number) for number in a]
pluss=[]
minuss=[]
number=1
for a in A:
    plus=a+number
    minus=number-a
    pluss.append(plus)
    minuss.append(minus)
    number+=1

m=Counter(minuss)

answer=0
for p in pluss:
    if p in m.keys():
        answer+=m[p]
print(answer)


Measured memory_bytes: 134508
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

int par[100005];
int rnk[100005];
int n,m;

void init(int n){
  REP(i,n){
    par[i]=i;
    rnk[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(rnk[x]<rnk[y])par[x]=y;
  else{
    par[y]=x;
    if(rnk[x]==rnk[y])rnk[x]++;
  }
}
bool same(int x,int y){
  return find(x)==find(y);
}

signed main(){
  cin>>n>>m;
  vector<pair<int,int>> v(m);
  REP(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    v[i]=MP(a,b);
  }
  int ans=0;
  REP(i,m){
    init(n);
    REP(j,m){
      if(i==j)continue;
      int y=v[j].SEC;
      int x=v[j].FIR;
      unite(y,x);
    }
    int sum=0;
    REP(i,n){
      REP(j,n){
        if(i==j)continue;
        if(same(i,j))sum++;
      }
    }
    if(sum==n*(n-1))ans++;
  }
  cout<<m-ans<<endl;






  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7

def run():
    N, K = map(int, sysread().split())
    S = input()
    c = S[0]
    checkpoints = 0
    endpoints = 0
    for s in S:
        if c == 'L':
            if s == 'R':
                c = 'R'
                endpoints += 1
            else:
                continue
        elif c == 'R':
            if s == 'L':
                checkpoints += 1
                c = 'L'
            else:
                continue
    #print(checkpoints, endpoints)
    ans = N - 2 * checkpoints
    halfpoint = 0
    edge = 0
    if S[0] == 'R':
        edge += 1
    else:
        halfpoint += 1

    if S[-1] == 'L':
        edge += 1
    else:
        halfpoint += 1

    ans -= halfpoint
    val = min([checkpoints, endpoints, K])
    checkpoints -= val
    endpoints -= val
    K -= val
    ans += 2 * val

    if K > 0:
        if checkpoints > 0:
            if edge > 0:
                val = min([edge, checkpoints, K])
                K -= val
                edge -= K
                checkpoints -= K
                ans += val
    if K > 0:
        if halfpoint > 0 and endpoints > 0:
            val = min([K, halfpoint, endpoints])
            K -= val
            halfpoint -= val
            endpoints -= val
            ans += val

    print(ans)

if __name__ == "__main__":
    run()


Measured memory_bytes: 9388