akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
	int N;
	cin >> N;

	unsigned long long counter = 0;
	unsigned long long Acnt = 0, Bcnt = 0, ABcnt = 0;
	vector<string> v( N );
	for ( int i = 0; i < N; i++ )
	{
		cin >> v[i];

		bool Afind = false;
		string::size_type index, beforeIndex = 0;
		while ( ( index = v[i].find( "AB", beforeIndex ) ) != string::npos )
		{
			counter++;
			beforeIndex = index + 1;
		}

		if ( v[i].back() == 'A' )
		{
			Afind = true;
			++Acnt;
		}
		if ( v[i][0] == 'B' )
		{
			++Bcnt;
			if ( Afind )
			{
				ABcnt++;
			}
		}
	}

	// 出現頻度が少ない方に合わせる
	if ( Acnt > Bcnt )
	{
		counter += Bcnt;
	}
	else if ( Bcnt > Acnt )
	{
		counter += Acnt;
	}
	else
	{
		if ( Acnt == ABcnt )
		{
			if ( Acnt == 0 )
			{
				// 候補なし
			}
			else
			{
				counter += ( ABcnt - 1 );
			}
		}
		else
		{
			counter += Acnt;
		}
	}


	cout << counter << endl;

	return ( 0 );
}


Measured memory_bytes: 512
let rec gcd x y = if y = 0 then x else gcd y (x mod y);;

let (n, x) = Scanf.scanf "%d %d" (fun x y -> (x, y)) in
let xs = Array.make n 0 in
for i = 0 to n - 1 do
  xs.(i) <- Scanf.scanf (if i = 0 then "\n%d" else " %d") (fun x -> x)
done;
print_int (xs |> Array.to_list |> List.map ((-) x) |> List.map abs |> List.fold_left gcd 0);
print_newline ()


Measured memory_bytes: 10496
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << (a-b+1)*(a-c+1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
const long long int mod = 1e9 + 7;
int m[100];
int main()
{
    ll N,X,res=0;
    ll sum=0;
    cin  >> N >> X;
    rep(i,0,N){
        cin >> m[i];
        sum += m[i];
    }
    res = N;
    X -= sum;
    int mi = *min_element(m, m+N);
    while(X>=mi){
        res++;
        X-=mi;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e12)
#define PI (acos(-1))

#define amari(x) ((x) % 1000000007)

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end());
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<int>());
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin();
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin();

#define rep(i,n) for(int i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

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

  long x, y;

  cin >> x >> y;

  long res = INF;

  if (y - x >= 0 ) {
    res = min(res, y-x);
  }
  if (y + x >= 0) {
    res = min(res, y+x+1);
  }
  if (-y - x >= 0) {
    res = min(res, -y-x+1);
  }
  if (-y + x >= 0) {
    res = min(res, -y+x+2);
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
 
int main(){
    int N, K;
    string S;

    cin >> N >> K >> S;
    for(int i = 0; i < N; i++){
        if(i+1 == K){
            if(S[i] == 'A') S[i] = 'a';
            else if(S[i] == 'B') S[i] = 'b';
            else S[i] = 'c';
        }
    }
    cout << S << endl;

    return 0;
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define PI 3.1415926535898

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

int main() {
    int r, g;
    cin >> r >> g;
    cout << 2 * g - r << endl;

    return 0;
}



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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end

template<class Abel> struct UnionFind {
   vector<int> par,rank;
   vector<Abel> diff_weight;
   UnionFind(int n=1,Abel SUM_UNITY=0){init(n, SUM_UNITY);}
   void init(int n=1,Abel SUM_UNITY=0) {
      par.resize(n); rank.resize(n); diff_weight.resize(n);
      rep(i,0,n)par[i]=-1,rank[i]=0,diff_weight[i]=SUM_UNITY;
   }
   int root(int x){
      if(par[x]<0)return x;
      int r=root(par[x]); diff_weight[x]+=diff_weight[par[x]];
      return par[x]=r;
   }
   int size(int x){ return -par[root(x)]; }
   Abel weight(int x){root(x); return diff_weight[x];}
   bool issame(int x, int y){return root(x)==root(y);}
   bool merge(int x,int y,Abel w){
      w+=weight(x)-weight(y); x=root(x); y=root(y);
      if(x==y)return false;
      if(rank[x]<rank[y])swap(x,y),w=-w;
      if(rank[x]==rank[y])++rank[x];
      par[x]+=par[y]; par[y]=x; diff_weight[y]=w; return true;
   }
   Abel diff(int x,int y){return weight(y)-weight(x);}
};

vector<int> f[101000],g[101000];

int main(){
   int n,m,k; scanf("%d%d%d",&n,&m,&k);
   UnionFind<int> uni(n);
   rep(i,0,m){
      int a,b; scanf("%d%d",&a,&b); a--; b--;
      uni.merge(a,b,1);
      f[a].push_back(b); f[b].push_back(a);
   }
   rep(i,0,k){
      int a,b; scanf("%d%d",&a,&b); a--; b--;
      g[a].push_back(b); g[b].push_back(a);
   }
   rep(i,0,n){
      int res=uni.size(i)-1;
      for(int to:f[i])if(uni.root(i)==uni.root(to))res--;
      for(int to:g[i])if(uni.root(i)==uni.root(to))res--;
      printf("%d\n",res);
   }
   return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int WWW = 0;WWW < (n);WWW++)cerr << v[WWW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

//ａをbで割る
long long mod_div(ll a,ll b){
	if(a % b == 0)return a/b;
	long long tmp = MOD - 2,c = b,ret = 1;
	while(tmp > 0){
		if(tmp & 1){
			ret *= c;ret %= MOD;
		}
		c *= c;c %= MOD;tmp >>= 1;
	}
	return a*ret%MOD;
}
 
#define MAX_K 3333333
vector<long long> kaijo(MAX_K);
long long combination(long long n, long long r){
    if(n < r || n < 0 || r < 0)
        return 0;
	if(kaijo[0] != 1){
		kaijo[0] = 1;
		for(long long i = 1;i < MAX_K;i++)kaijo[i] = (kaijo[i-1] * i) % MOD;
	}
    long long ret = kaijo[n];
	long long tmp = (kaijo[r] * kaijo[n-r]) % MOD;
    return mod_div(ret,tmp);
}

int main(){
	ll a,b,c,x,y;
	
	while(cin >> a >> b >> c >> x >> y,a+b+c+x+y){
		
		ll ans = 0;
		for(ll i = 0;i <= min(x,y);i++){
			ll X = x-i-a;
			ll Y = y-i-b;
			if(X < 0 || y < 0)continue;
			if(a == 0 && X > 0)continue;
			if(b == 0 && Y > 0)continue;
			ll tmp = 1;
			tmp = (tmp * combination(a+b+c,c)) % MOD;
			tmp = (tmp * combination(a+b,b)) % MOD;
			if(a+b+c+i-1 >= i)tmp = (tmp * combination(a+b+c+i-1,i)) % MOD;
			if(a+X-1 >= X)tmp = (tmp * combination(a+X-1,X)) % MOD;
			if(b+Y-1 >= Y)tmp = (tmp * combination(b+Y-1,Y)) % MOD;
			ans = (ans+tmp) % MOD;
		}
		
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 28720
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

a1=a%10
b1=b%10
c1=c%10
d1=d%10
e1=e%10

if a1 != 0:
    a1=10-a1
if b1 != 0:
    b1=10-b1
if c1 != 0:
    c1=10-c1
if d1 != 0:
    d1=10-d1
if e1 != 0:
    e1=10-e1

x={'a1':a1,'b1':b1,'c1':c1,'d1':d1, 'e1':e1}

max=max(x,key=x.get)

if max == 'a1':
    print(b+b1+c+c1+d+d1+e+e1+a)
elif max == 'b1':
    print(a+a1+c+c1+d+d1+e+e1+b)
elif max == 'c1':
    print(a+a1+b+b1+d+d1+e+e1+c)
elif max == 'd1':
    print(a+a1+b+b1+c+c1+e+e1+d)
else:
    print(a+a1+b+b1+c+c1+d+d1+e)

Measured memory_bytes: 3064
E = Hash.new{|h, k| h[k] = []}
N, u, v = gets.chomp.split(" ").map(&:to_i)
(N - 1).times{
  a, b = gets.chomp.split(" ").map(&:to_i)
  E[a] << b
  E[b] << a
}

q = [[v, 0]]
V = Array.new(N + 1, -1)
until(q.empty?) do
  a, d = q.shift
  V[a] = d
  E[a].each{|b| q.push([b, d + 1]) if V[b] == -1}
end

ans = u
d = 0
q = [u]
VV = Array.new(N + 1, -1)
until(q.empty?) do
  nxt = []
  q.each{|a|
    ans = a
    VV[a] = d
    E[a].each{|b| nxt << b if V[b] > d + 1 && VV[b] == -1}
  }
  q = nxt
  d += 1 if not q.empty?
end

puts V.select.with_index{|a, idx| VV[idx] != -1}.max - 1


Measured memory_bytes: 20572
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		for(int i = 0 ; i < N ; i++) {
			A[i] = sc.nextInt();
			B[i] = sc.nextInt();
		}
		int ans = 2000000000;
		for(int i = 0 ; i < N ; i++) {
			ans = Math.min(ans, A[i] + B[i]);
		}
		System.out.println(ans);
	}
}

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

int main()
{
    int n,x;
    cin>>n;
    map<int,int>m;
    for(int i=0;i<n-1;i++)
    {
        cin>>x;
        m[x]++;
    }
    for(int i=1;i<=n;i++)
    {
        cout<<m[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 12980
/*input
1

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n) memset(n,0,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=2505;
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;
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;
}
int32_t main(){
    double n;
    cin>>n;
    double o=floor((n+1)/2);
    cout<<fixed<<setprecision(6)<<o/n;
}


Measured memory_bytes: 256
using System;
using System.Linq;

class p{
  static void Main(){
    string[] n = Console.ReadLine().Split().ToArray();
    int a = int.Parse(n[0]);
    int b = int.Parse(n[2]);
    
    Console.WriteLine(n[1] == "+" ? a + b : a - b);
  }
}

Measured memory_bytes: 13268
<?php
$n = (int)trim(fgets(STDIN));

$input = explode(' ', trim(fgets(STDIN)));
$h_list = [];
foreach ($input as $i => $v) {
	$h_list[$i+1] = (int)$v;
}

$dp = [];
$dp[1] = 0;
$dp[2] = abs($h_list[1] - $h_list[2]);

for ($i=3; $i <= $n; $i++) { 
	$dp[$i] = min($dp[$i-2] + abs($h_list[$i-2] - $h_list[$i]), $dp[$i-1] + abs($h_list[$i-1] - $h_list[$i]));
}
echo $dp[$n];

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

int log(int n) {
  int tmp = 0;
  while (n % 2 == 0) {
    n /= 2;
    ++tmp;
  }
  return tmp;
}

int main() {
  int n; cin >> n;
  int ans = 0;
  REP(i, n) {
    int tmp; cin >> tmp;
    ans += log(tmp);
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}



class Main {

        public static long gcd(long m, long n)
        {
                long tmp;
                while (m % n != 0)
                {
                        tmp = n;
                        n = m % n;
                        m = tmp;
                }
                return n;
        }

    public static void main(String[] args) {
        //Scanner sc = new Scanner(System.in);
        FastScanner sc = new FastScanner();
        long A = sc.nextLong();
        long B = sc.nextLong();
        if (B > A) {
            long tmp;
            tmp = B;
            B = A;
            A = tmp;
        }
        //System.out.println(A);
        //System.out.println(B);
        long g = gcd(A, B);

        System.out.println(A*B / g);
    }

}


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

int main() {
    int n, m;
    cin >> n >> m;

    const int nmmax = 50;
    char a[nmmax][nmmax], b[nmmax][nmmax];

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cin >> a[i][j];
        }
        
    }
    
    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> b[i][j];
        }
        
    }
    
    bool exist = false;

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (i + m - 1 >= n || j + m - 1 >= n) continue;

            bool match = true;
            for (int k = 0; k < m; k++)
            {
                for (int l = 0; l < m; l++)
                {
                    if (a[i + k][j + l] != b[k][l]) match = false;
                }
                
            }
            if (match) exist = true;
        }
        
    }
    if (exist)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
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 (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, k; cin >> n >> m >> k;
    UnionFind uf(n);
    vector<int> fri[n], blo[n];
    vector<int> num_fri(n), num_blo(n);
    rep (i, m) {
        int a, b; cin >> a >> b; a--; b--;
        fri[a].push_back(b); fri[b].push_back(a);
        num_fri[a]++; num_fri[b]++;
        uf.unite(a, b);
    }
    rep (i, k) {
        int a, b; cin >> a >> b; a--; b--;
        blo[a].push_back(b); blo[b].push_back(a);
        if (uf.find(a) == uf.find(b)) {
        num_blo[a]++; num_blo[b]++;

        }
    }
    rep (i, n) {
        eprintf("%d %d %d\n", uf.size(i), num_fri[i], num_blo[i]);
    }
    rep (i, n) {
        cout << uf.size(i) - num_fri[i] - num_blo[i] - 1 << (i != i_len - 1 ? ' ' : '\n');
    }
    return 0;
}

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

int main() {
  int N; cin >> N;
  string S; cin >> S;
  int r=0;
  for (char c : S) {
	if (c=='R') r += 1;
  }
  if (r > N-r) 
    cout << "Yes" << endl;
  else
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//for(int i = ; i < ; i++){}

int main(){
  ll x,y;
  cin>>x>>y;
  int ans = 0;
  while(x <= y){
    ans++;
    x*=2;
  }
  cout<<ans<<endl;
  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
string S;
int main(){
    cin >> S;
    if((sz(S)%2)^(S[0]==S.back())) cout << "First" << '\n';
    else cout << "Second" << '\n';
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

int n,m;
int d[222222];
int t[222222];

int judge(int dd);

int main(){
  ios_base::sync_with_stdio(false);

  int f = 1;

  cin >> n;
  for(int i=0;i<n;i++){
    cin >> d[i];  
  }   

  cin >> m;
  for(int i=0;i<m;i++){
    cin >> t[i];
  }

  sort(d, d+n); 
  sort(t, t+m);
  
  int cnt = 0;
  for(int i=0;i<m;i++){
    while(true){
      if(cnt == n)break;
      if(d[cnt] == t[i]){
        if(cnt != n-1)cnt++;
        break;
      }
      cnt++;
    }
    if(cnt>=n){
      cout << "NO" << endl;
      return 0;
    }
  }
  
  cout << "YES" << endl; 

  return 0;
}

int judge(int dd){
  int ok = 0;
  int ng = n;
  int mid;

  while(ng - ok > 1){
    mid = (ok + ng) / 2;
    if(d[mid] > dd){
      ng = mid;
    } else {
      ok = mid;
    }
  }
  
  if(d[ok] == dd){
    d[ok] = 0;
    sort(d, d+n); 
    return 1;
  }
  return 0;
}

Measured memory_bytes: 1792
import queue

H, W = list(map(int, input().split()))
s = [list(input()) + ['#'] for i in range(H)] + [['#' for i in range(W+1)]]
white = sum([s[i].count('.') for i in range(H)])

q = queue.Queue()
s[0][0] = 1
q.put((0,0))

while not q.empty():
    i, j = q.get()
    for x, y in [(i+1,j), (i-1,j), (i,j+1), (i,j-1)]:
        if s[x][y] == '.':
            s[x][y] = s[i][j]+1
            q.put((x, y))

if s[H-1][W-1] in ['.', '#']:
    print(-1)
else:
    print(white-s[H-1][W-1])

Measured memory_bytes: 3952
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 1 << 30;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
//ミョ(-ω- ?)
int main() {
    ll n,w;
    cin >> n >> w;
    vector<ll> weight(n,0);
    vector<ll> value(n,0);
    rep(i,n)cin >> weight[i] >> value[i];
    vector<vector<ll>> dp(n+5,vector<ll>(w+5,0));
    //i番目の荷物　jまで詰める
    rep(i,n){//荷物はn個
        rep(j,w+1){//0 <= j <= W(上限)
            if(j < weight[i])dp[i+1][j] = dp[i][j];
            else dp[i+1][j] = max(dp[i][j],dp[i][j - weight[i]]+value[i]);
        }
    }
    cout << dp[n][w] << "\n";
    return 0;
}

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

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

    int N, n;
    cin>>N;  //入力
    int count = N;

    for(int i = 0; i < N; i++) {
        cin>>n;

        for(int j = 2; j <= n/2  && j < 10000; j++) {
            if(n%j == 0) {
                count--;
                break;
            }
        }
    }
    cout<<count<<endl; //出力
    return 0;
}



Measured memory_bytes: 3104
/*************************************************************************
	> File Name: 1.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Blog: https://blog.csdn.net/Pig_cfbsl 
	> Created Time: 2020/7/5 20:08:07
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define LL long long
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
int h,w,k;
char s[20][20];
int x[20],y[20],ans=0;
bool check(){
	int num=0;
	For(i,1,h)
		For(j,1,w){
			if(s[i][j]=='#' && !x[i] && !y[j])
				++num;
			if(num>k) return false;
		}
	if(num==k) return true;
	return false;
}

void dfs2(int id){
	if(id==w+1){
		if(check()){
/*			For(i,1,h) cout<<x[i]<<" ";
			cout<<endl;
			For(j,1,w) cout<<y[j]<<" ";
			cout<<endl;
*/
			++ans;
		}
		return ;
	}
	y[id]=0;
	dfs2(id+1);
	y[id]=1;
	dfs2(id+1);
}

void dfs1(int id){
	if(id==h+1){
		dfs2(1);
		return ;
	}
	x[id]=0;
	dfs1(id+1);
	x[id]=1;
	dfs1(id+1);
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	cin>>h>>w>>k;
	For(i,1,h) scanf("%s",s[i]+1);
	dfs1(1);
	cout<<ans;
	return 0;

}


Measured memory_bytes: 3656
# frozen_string_literal: true

k, x = readline.split(' ').map(&:to_i)

if (x - (k - 1)) < -1000000
  puts Array(-1000000...(x + k)).join(' ')
elsif (x + (k - 1)) > 1000000
  puts Array((x - (k - 1))...1000001).join(' ')
else
  puts Array((x - (k - 1))...(x + k)).join(' ')
end


Measured memory_bytes: 1916
n, t = map(int, input().split())
a = [int(i) for i in input().split()]
b = [0 for i in range(n)]
m = a[0]
for i in range(n):
    m = min(m, a[i])
    b[i] = a[i] - m
m = b[0]
k = 0
for i in range(n):
    if b[i] >= m:
        m = b[i]
        k = i
ans1 = 1
for i in range(n):
    if b[i] == m and i != k:
        ans1 += 1
b = [0 for i in range(n)]
m = a[n - 1]
for i in range(n - 1, -1, -1):
    m = max(m, a[i])
    b[i] = a[i] - m
m = b[n - 1]
k = 0
for i in range(n - 1, -1, -1):
    if b[i] <= m:
        m = b[i]
        k = i
ans2 = 1
for i in range(n):
    if b[i] == m and i != k:
        ans2 += 1
print(min(ans1, ans2))

Measured memory_bytes: 14480
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(v) v.begin(), v.end()
#define sz size()
#define mp make_pair
#define pb push_back
#define rep(p, a, b) for (ll p = a; p < b; p++)
#define rap(p, a, b) for (ll p = a; p <= b; p++)
#define per(p, a, b) for (ll p = a; p >= b; p--)
#define F first
#define S second
using namespace std;

typedef vector<ll> vll;
typedef vector<ld> vld;
typedef pair<ll, ll> pll;

int main()
{
    ll t, i, j, k, ans, n;

    //cin>>t;
    t = 1;
    while (t--)
    {
        set<ll> s;
        cin>>n;
        rep(p,0,n)
        {
            cin>>k;
            if(s.count(k))
            {
                cout<<"NO";
                return 0;
            }
            s.insert(k);
        }
        cout<<"YES";
    }

    return 0;
}

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

int main(){
    int N;
    cin >> N;

    vector<int> vec(N);
    for(int i=0;i<N;i++){
        cin >> vec[i];
    }

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

    int count=0;
    int max=0;

    for(int i=0; i<N; i++){
        if(max<vec[i]){
            max=vec[i];
            count++;
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <sstream>

#define fi first
#define se second
#define pb push_back
#define fore(i, a, b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i, a, b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i, a, b) for (int i = (a), _b = (b); i >= (_b); --i)

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

const int INF = 1e9 + 3;
const int MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
	int n, l; cin >> n >> l;
	int s = 0, t;
	vi a(n); fore(i, 0, n) {
		a[i] = i + l;
		s += a[i];
	}
	ii res(INF, INF);
	fore(i, 0, n) {
		t = 0;
		fore(j, 0, n) if (i != j) {
			t += a[j];
		}
		res = min(res, ii(abs(s - t), t));
	}
	cout << res.se << '\n';
    return 0;
}


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

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, const char *argv[])
{
  int n;
  cin >> n;

  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }

  // 1 2 2 1
  bool ans = true;
  int min_n = h[0] - 1;
  for (int i = 0; i < n - 1; i++) {
    min_n = max(min_n, h[i] - 1);
    if (h[i] <= h[i + 1] || min_n <= h[i + 1]) {
      continue;
    }

    ans = false;
    break;
  }


  cout << (ans ? "Yes" : "No") << "\n";
  return 0;
}


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

using namespace std;

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

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
const long long INF = 1LL << 60;

struct Edge {
  int to;
  ll cost;
};
using Graph = vector<vector<Edge>>;

vector<bool> can_reach(const Graph& G, int start) {
  ll n = G.size();
  vector<bool> ans(n);
  queue<int> que;

  que.push(start);
  ans[start] = true;

  while (!que.empty()) {
    int index = que.front();
    que.pop();
    for (const auto& it : G[index]) {
      if (ans[it.to] == false) {
        que.push(it.to);
        ans[it.to] = true;
      }
    }
  }

  return ans;
}

// Bellman Ford
// G: グラフ
// rev: 逆辺のグラフ(負の閉路検出用)
// start: 始点
// goal: 終点
// 戻り値: goalに行くまでの最小コスト。負の閉路が存在する場合は-INFとなる。
ll bellman_ford(const Graph& G, const Graph& rev, const int start, const int goal) {
  const int n = G.size();

  // 始点からそこまで行くのにかかるのコスト
  vector<ll> cost(n, INF);
  cost[start] = 0;

  for (int i = 0; i < n; i++) {
    // すべての辺を走査
    for (int from = 0; from < n; from++) {
      if (cost[from] == INF) {
        continue;
      }
      for (auto e : G[from]) {
        // 更新
        if (cost[e.to] > cost[from] + e.cost) {
          cost[e.to] = cost[from] + e.cost;
        }
      }
    }
  }

  vector<ll> cost_middle = cost;
  // 閉路検出用にもう一回更新
  for (int from = 0; from < n; from++) {
    if (cost[from] == INF) {
      continue;
    }
    for (auto e : G[from]) {
      // 更新
      if (cost[e.to] > cost[from] + e.cost) {
        cost[e.to] = cost[from] + e.cost;
      }
    }
  }

  // 始点から到達できるか
  auto can_reach_from_start = can_reach(G, start);
  // 各点が終点へ到達できるか
  auto can_reach_from_goal = can_reach(rev, goal);

  for (int i = 0; i < n; i++) {
    if (can_reach_from_start[i] && can_reach_from_goal[i]) {
      // 始点から終点へ移動できるノードの内、値が更新されるものが存在したら負のループが存在する。
      if (cost_middle[i] != cost[i]) {
        return -INF;
      }
    }
  }

  return cost[goal];
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n, m, p;
  cin >> n >> m >> p;

  Graph G(n + 1), rev(n + 1);

  rep(i, m) {
    int a, b;
    ll c;
    cin >> a >> b >> c;
    G[a].push_back((Edge){b, -c + p});
    rev[b].push_back((Edge){a, -c + p});
  }

  ll ans = bellman_ford(G, rev, 1, n);
  ans *= -1;
  chmax(ans, 0ll);
  if (ans == INF) {
    ans = -1;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int n, *a, b=0, ans=0;
    cin >> n;
    a=new int[n];
    for(int i=0; i<n; i++)
    {
        cin >> a[i];
        ans=max(ans,a[i]);
        if(ans<=a[i])
            b++;
    }
    cout << b <<'\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
typedef  long long ll;
using namespace std;

int main(void) {
	string s, p;
	cin >> s >> p;

	s += s;
	
	if (s.find(p) == string::npos) cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
map <char,bool> mp;
int main(){
    string s;
    cin>>s;

    for(int i=0;i<s.size();i++){
        if(mp[s[i]]){
            cout<<"no"<<"\n"; 
            return 0;
        }else mp[s[i]]=true;     
    }
    cout<<"yes"<<"\n";
    return 0;
}


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

long long gcd(long long a,long long b){
  return b ? gcd(b,a%b) : a;
}

int main(){
  long long n,m;
  cin >> n >> m;
  string s,t;
  cin >> s;
  cin >> t;
  long long g=gcd(n,m);
  long long ans=n/g*m;
  bool ok=true;
  n=n/g;
  m=m/g;
  for(int i=0;i<g;++i){
    if(s[i*n]!=t[i*m]) ok=false;
  }

  if(ok==true){
    cout << ans << endl;
  }else{
    cout << "-1" << endl;
  }
  return 0;

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }

};

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

  int m = n*(n-1)/2 - n/2;

  cout << m << endl;
  for(int i = 1; i < n+1; i++) {
    for(int j = i+1; j < n+1; j++) {
      if(n%2 == 0 && i+j == n+1) continue;
      if(n%2 == 1 && i+j == n) continue;
      printf("%d %d\n", i, j);
    }
  }
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace _0524
{
    class Program
    {
        static void Main()
        {
            while (true)
            {
                int m = int.Parse(Console.ReadLine());
                if (m == 0) break;
                int[,] seiza = new int[m, 2];
                for (int i = 0; i < m; i++)
                {
                    int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    seiza[i, 0] = x[0]; seiza[i, 1] = x[1];
                }
                int n = int.Parse(Console.ReadLine());
                int[,] picture = new int[n, 2];
                for (int i = 0; i < n; i++)
                {
                    int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    picture[i, 0] = x[0]; picture[i, 1] = x[1];
                }
                for (int i = 0; i < n; i++)
                {
                    int[] sa = new int[] { seiza[0, 0] - picture[i, 0], seiza[0, 1] - picture[i, 1] };
                    bool found = true;
                    for (int j = 1; j < m && found; j++)
                    {
                        found = false;
                        for (int k = 0; k < n; k++)
                        {
                            if (seiza[j, 0] == picture[k, 0] + sa[0] && (seiza[j, 1] == picture[k, 1] + sa[1])) found = true;
                        }
                    }
                    if (found) Console.WriteLine(-sa[0] + " " + -sa[1]);
                }
            }
        }
    }
}

Measured memory_bytes: 9708
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll H,W;
ll AllH(){
    if(H%3==0){
        return 0;
    }
    return W;
}
ll AllW(){
    if(W%3==0) return 0;
    return H;
}
ll TinH(){
    ll ret=INF;
    for(ll i=1;i<H;i++){
        ll upper=i*W;
        ret=min(ret,max(upper,(H-i)*((W+1)/2))-min(upper,(H-i)*(W/2)));
    }
    return ret;
}
ll TinW(){
    ll ret=INF;
    for(ll i=1;i<W;i++){
        ll upper=i*H;
        ret=min(ret,max(upper,(W-i)*((H+1)/2))-min(upper,(W-i)*(H/2)));
    }
    return ret;

}
int main(){
    cin>>H>>W;
    cout<<min({AllH(),AllW(),TinH(),TinW()});

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
vector<int> pos,nag; 
ll zero = 0;int n;ll k;
ll check(ll m){
		ll cnt = 0;	
		if(m>=0)cnt += 1LL*nag.size()*pos.size();
		if(m>=0)cnt += zero*(n-zero)+zero*(zero-1)/2;
	//	cout<<"!"<<cnt<<endl;
		if(m>0){
			ll tmp = 0;
			for(int x:pos){
				ll val = m/x;
	//			cout<<x<<"->"<<val<<endl;
				if(1LL*x*x<=m)tmp--;
				tmp += upper_bound(pos.begin(),pos.end(),val)-pos.begin();
	//			cout<<"!"<<lower_bound(pos.begin(),pos.end(),val)-pos.begin()<<endl;
			}
			for(int x:nag){
				ll val = -(m/(-x));
//				cout<<x<<"->"<<val<<endl;
				if(1LL*x*x<=m)tmp--;
				tmp += nag.end()-lower_bound(nag.begin(),nag.end(),val);
	//			cout<<"!"<<nag.end()-lower_bound(nag.begin(),nag.end(),val)<<endl;
			}
	//		cout<<"!!!!!!!!"<<tmp<<endl;
			cnt += tmp/2;
		}
		if(m<0){
			for(int x:pos){
				ll val = -((-m)+x-1)/(x);
	//			cout<<"!"<<x<<" "<<val<<endl;
				if(nag.size()&&nag[0]>val)cnt+=0;
				else cnt += upper_bound(nag.begin(),nag.end(),val)-nag.begin();
//				cout << upper_bound(nag.begin(),nag.end(),val)-nag.begin() << endl;
			}
		}
//		cout<<"!"<<m<<" "<<cnt<<endl;
		return cnt;
		
}
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		int x;scanf("%d",&x);
		if(x>0)pos.pb(x);
		if(x==0)zero++;
		if(x<0)nag.pb(x);
	}
	sort(pos.begin(),pos.end());
	sort(nag.begin(),nag.end());
//	check(9);
	ll l = -2e18,r = 2e18;
	while(r-l>1){
		ll m = (l+r)/2;m++;
//		cout<<l<<" "<<r<<" "<<m<<"****************************************"<<endl;
		if(check(m)>=k)r = m-1;
		else l = m;
	//	system("pause");
	}
//	cout<<"!"<<l<<" "<<check(l+1)<<endl;
//	cout<<"!"<<check(0)<<endl;
	if(check(l+1)<k)cout << l+2 << endl;
	else if(check(l)<k)cout << l+1 <<endl;
	else cout << l << endl;
	return 0;
}


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

int main() {
  long long count=0;
  long long W,H,x,y;
  cin>>W>>H>>x>>y;
  cout<<double(W)*double(H)/2<<" ";
  if(W==x*2 and H==y*2) cout<<1;
  else cout<<0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	ll N, L, T;
	cin>>N>>L>>T;
	vector<ll> x1(0);
	vector<ll> x2(0);
	vector<ll> ter(N);
	ll fx;
	ll fw;
	ll terfx;
	cin>>fx>>fw;
	ll met = 0;
	if(fw == 1) {
		ter[0] = terfx = (fx + T) % L;
	} else {
		if(fx - T < 0) {
			if((fx - T) % L == 0) ter[0] = terfx = 0;
			else ter[0] = terfx = L + ((fx - T) % L);
		}
		else ter[0] = terfx = (fx - T) % L;
	}
	REP(i, N - 1) {
		ll x, w;
		cin>>x>>w;
		if(w == 1) x1.pb(x);
		else x2.pb(x);
		if(w == 1) {
			ter[i + 1] = (x + T) % L;
		} else {
			if(x - T < 0) {
				if((x - T) % L == 0) ter[i + 1] = 0;
				else ter[i + 1] = L + ((x - T) % L);
			}
			else ter[i + 1] = (x - T) % L;
		}
	}
	sort(ALL(ter));
	ll lmt = T % L;
	if(fw == 1) {
		met += T / L * x2.size() * 2;
		REP(i, x2.size()) {
			if((x2[i] - fx) / 2 + (x2[i] - fx) % 2 <= lmt) ++met;
			if((x2[i] - fx + L) / 2 + (x2[i] - fx + L) % 2 <= lmt) ++met;

		}
	} else {
		met += T / L * x1.size() * 2;
		REP(i, x1.size()) {
			if((fx + L - x1[i]) / 2 + (fx + L - x1[i]) % 2 <= lmt) ++met;
			if((fx + 2 * L - x1[i]) / 2 + (fx + 2 * L - x1[i]) % 2 <= lmt) ++met;
		}
	}

	if(fw == 1) {
		ll stt = INF;
		REP(i, N) {
			if(ter[i] == terfx) {
				if(i != N - 1 && ter[i + 1] == terfx) stt = i + 1;
				else stt = i;
				break;
			}
		}
		ll sttg = stt - met % N;
		if(sttg < 0) sttg = N + sttg;
		REP(i, N) {
			cout<<ter[(sttg + i) % N]<<endl;
		}
	} else {
		ll stt = INF;
		REP(i, N) {
			if(ter[i] == terfx) {
				stt = i;
				break;
			}
		}
		ll sttg = (stt + met) % N;
		REP(i, N) {
			cout<<ter[(sttg + i) % N]<<endl;
		}
	}
}


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

int main() {
	string s;
    cin >> s;
    string t;
    cin >> t;
    int size = s.size();
    int count = 0;
    for(int i=0;i<size;i++){
      if(s[i] != t[i]){
        count++;
      }
    }
    cout << count << endl;
}


Measured memory_bytes: 3852
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using BigInt = long long;
#define ALL(a)  (a).begin(),(a).end()

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    string S;
    cin >> S;
    int ok_count = 0;
    int ok_count_fore = 0;
    for (char s : S){
        if (s == 'a'){

            if (ok_count < A + B){
                cout << "Yes" << endl;
                ok_count ++;
            } else {
                cout << "No" << endl;
            }

        } else if(s == 'b'){

            if ((ok_count < A + B) && (ok_count_fore < B)) {
                cout << "Yes" << endl; 
                ok_count ++;
                ok_count_fore ++;
            } else {
                cout << "No" << endl;
            }

        } else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=200005;
deque<int> v[26];
int bit[N];
void update(int i,int val)
{
  while(i<N)
    {
      bit[i]+=val;
      i+=(i&(-i));
    }
}
int query(int i)
{
  int ans=0;
  while(i)
    {
      ans+=bit[i];
      i-=(i&(-i));
    }
  return ans;
}
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  string s;
  cin>>s;
  rep(i,0,sz(s))
    v[s[i]-'a'].pb(i+1);
  int cnt=0;
  rep(i,0,26)
    cnt+=(sz(v[i])&1);
  if(cnt>=2)
    {
      cout<<-1<<endl;
      return 0;
    }
  int n=sz(s);
  ll ans=0;
  rep(i,1,n+1) update(i,1); 
  while(n>0)
    {
      int type,mn=sz(s)+4;
      rep(i,0,26)
	{
	  if(v[i].empty()) continue;
	  int i1=v[i].front(),i2=v[i].back();
	  int t1=query(i1-1);
	  int t2=query(sz(s))-query(i2);
	  if(t1+t2<mn) type=i,mn=t1+t2;
	}
      ans+=mn;
      n-=2;
      int i1=v[type].front(),i2=v[type].back();
      update(i1,-1); update(i2,-1);
      v[type].pop_front();
      if(!v[type].empty())
	v[type].pop_back();
    }
  cout<<ans<<endl;
  return 0 ;
}


Measured memory_bytes: 2196
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	ll n;
	cin >> n;
	ll m=n;
	ll ans=0;
	while(m>0){
		ans+=m-((m/10)*10);
		m/=10;
	}
	cout << (n%ans==0 ? "Yes" : "No") << endl;

/////////////////////////////////////////////
}


Measured memory_bytes: 256