akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> Grid;
  int dx[4] = {1, 0, -1, 0};
  int dy[4] = {0, 1, 0, -1};
  for (int i = 0; i < H; i++) {
    string tmp;
    cin >> tmp;
    Grid.emplace_back(tmp);
  }

  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      int cnt = 0;
      for(int d = 0; d < 4; d++) {
        int ni = i + dy[d];
        int nj = j + dx[d];
        if(ni < 0 or H <= ni) continue;
        if(nj < 0 or W <= nj) continue;
        if (Grid[i][j] == '#') {
          if (Grid[ni][nj] == '#') {
            cnt++;
          }
        }
      }
      if (Grid[i][j] == '#') {
        if (cnt == 0) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }


  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
def prime_factorization(N):
	'''
	return: [[2,3], [3,5]] (2^3 * 3^5)
	        [] if N==1
	O(sqrt{N}) (maybe)
	'''
	ans = []
	cnt=0
	while N%2==0:
		cnt+=1
		N//=2
	if cnt!=0:
		ans.append([2,cnt])

	f = 3
	while f*f<=N:
		cnt=0
		while N%f==0:
			N//=f
			cnt+=1
		if cnt!=0:
			ans.append([f,cnt])
		f+=2
	if N!=1:
		ans.append([N,1])
	return ans


N = int(input())
d = {}

for i in range(2,N+1):
	T = prime_factorization(i)
	for t in T:
		if t[0] not in d:
			d[t[0]] = t[1]
		else:
			d[t[0]] += t[1]
ans = 1
mod = 10**9+7
for i in d:
	ans = (ans*(d[i]+1))%mod

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define PI 3.14159265358979323846
using namespace std;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   /// https://ideone.com/Fd5s8n

  int a,b,k;

  cin>>k>>a>>b;
  for(int i=a;i<=b;i++){
    if((i%k)==0)
        return cout << "OK" << endl,0;
  }
  cout << "NG" << endl;
    return 0;

}


Measured memory_bytes: 3604
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
#define int long long
using ll = long long;
using namespace std;
const int INF = 1LL << 50;
using P       = pair<int, int>;

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

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

signed main() {
    int n, m;
    cin >> n >> m;
    vector<int> as(n);
    for (auto &a : as) {
        cin >> a;
    }
    vector<P> bc(m);
    rep(i, 0, m) {
        cin >> bc[i].first >> bc[i].second;
    }
    sort(all(as));
    sort(all(bc), [](P x, P y) { return x.second > y.second; });

    int left = 0;
    vector<P> ans;
    rep(i, 0, m) {
        int target  = bc[i].second;
        auto it     = lower_bound(as.begin() + left, as.end(), target);
        int pos     = it - as.begin();
        int elm_num = pos - left;
        if (elm_num <= 0) {
            continue;
        }
        chmin(elm_num, bc[i].first);
        ans.push_back(P(target, elm_num));
        left += elm_num;
    }

    int fuck = 0;
    // cout << "p" << endl;
    for (auto p : ans) {
        fuck += p.first * p.second;
        // cout << "p.0:" << p.first << " p.1:" << p.second << endl;
    }
    // cout << "p....end" << endl;
    // cout << "rem" << endl;
    for (int i = left; i < n; i++) {
        fuck += as[i];
        // cout << "as " << as[i] << endl;
    }
    // cout << "re.....end" << endl;
    cout << fuck << endl;
}


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

int main(){
  int i,h,n,soma=0;

  cin>>h>>n;

  vector<int> v(n);

  for(i=0;i<n;i++){
    cin>>v[i];
    soma += v[i];
  }
  cout<<(soma >= h ? "Yes" : "No")<<endl;

  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>
#include <stack>

using namespace std;
typedef long long ll;

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

  int maxs = 0, mine = INT_MAX;
  for (int i = 0; i < M; i++) {
    int s, e;
    cin >> s >> e;
    maxs = max(maxs, s);
    mine = min(mine, e);
  }
  
  if (maxs <= mine) {
    cout << mine - maxs + 1 << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
sx, sy, tx, ty = map(int,input().split())

w = tx - sx
h = ty - sy

ans = ['R'*w + 'U'*(h+1) + 'L'*(w+1) + 'D'*(h+1) + 'RD' + 'R'*(w+1) + 'U'*(h+1) + 'L'*(w+1) + 'D'*h]

print(*ans)


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

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

const ll mod = 1e9 + 7;

const ll INF = 1e15;

class Primes {
private:
	vector<int> Prime_Number;
	vector<bool> is_prime_;
public:
	Primes(int N) {
		is_prime_.resize(N + 1, true);
		is_prime_[0] = is_prime_[1] = false;
		for (int i = 0; i < N + 1; i++) {
			if (is_prime_[i]) {
				Prime_Number.push_back(i);
				for (int j = 2 * i; j <= N; j += i) is_prime_[j] = false;
			}
		}
	}
	int operator[](int i) { return Prime_Number[i]; }
	int size() { return Prime_Number.size(); }
	int back() { return Prime_Number.back(); }
	bool isPrime(int q) { return is_prime_[q]; }
};

int main() {
	ll n;
	cin >> n;
	vector<ll> all;
	Primes prime(55555);
	for (int i = 0; i < prime.size(); i++) {
		auto p = prime[i];
		if (p % 5 == 1) {
			all.push_back(p);
		}
	}
	rep(i, n) {
		cout << all[i] << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
//#define bint int1024_t
#define ld long double
#define vect vector<ll>
#define unmap unordered_map
#define pb push_back
#define F first
#define pll pair<ll,ll>
#define S second
#define pi 3.1415926536
#define mod int(1e9+7)
#define mp make_pair
//ios_base::sync_with_stdio(false);cin.tie(NULL);
#define testcases ll t; cin>>t; while(t--)

using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

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

    ll n;
    cin>>n;

    cout<< ((n/1000+1)*1000 - n)%1000;

	return 0;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

double cross_product(double x1,double y1,double x2,double y2){
	return x1*y2-x2*y1;
}

int main(){
	double x[4],y[4];
	while(~scanf("%lf,%lf",&x[0],&y[0])){
		rep(i,1,4) scanf(",%lf,%lf",&x[i],&y[i]);
		double c=1;
		rep(i,0,4){
			c*=cross_product(x[(i+1)%4]-x[i],y[(i+1)%4]-y[i],x[(i+2)%4]-x[(i+1)%4],y[(i+2)%4]-y[(i+1)%4]);
			//o(c[i]);
		}
		if(c>0) o("YES");
		else o("NO");
	}
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,j,k;
  while(cin>>n,n){
    int mat[n][n];
    fill(mat[0],mat[n],-1);
    int x=n/2,y=n/2+1;
    for(i=1;i<=n*n;i++){
      mat[y][x]=i;
      x++;y++;
      if(x>=n)x=0;
      if(y>=n) y=0;
      if(i==n*n) break;
      while(mat[y][x]!=-1){
	x--;
	y++;
	if(x<0) x=n-1;
	if(y>=n)y=0;
      }
    }
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	printf("%4d" ,mat[i][j]); 
      }
      cout << endl;
    }
  }
}


Measured memory_bytes: 3176
import java.util.Scanner;

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

		// 入力値の取得
		long X = sc.nextLong();

		// 結果の出力
		int count = 0;
		double deposit = 100;
		while (X > deposit) {
			count++;
			deposit = Math.floor(deposit * 1.01);
		}
		System.out.println(count);

		sc.close();
	}
}


Measured memory_bytes: 27024
///Can be optimized with radix sort to O(Nw)
///and the checker for the binary search can be done in O(1)

#include <bits/stdc++.h>

#define MAX_N 100000

using namespace std;

typedef long long lint;

lint a[MAX_N + 1];
lint b[MAX_N + 1];

lint mx;
lint rez;

lint n, m, v, p;

bool pos(lint poz)
{
    lint nr = a[poz];
    if(nr >= a[n - p + 1])
        return 1;

    int k = 0;
    for(int i = poz + 1; i <= n - p + 1; i ++)
        b[++ k] = a[i];

    nr += m;
    lint ramas = m * (v - poz - (p - 1));
    lint nx = a[n - p + 1];

    if(ramas <= 0)
        return (nr >= nx);

    lint sum = 0;
    for(int i = 1; i <= k; i ++)
    {
        if(b[i] > nr)
            return 0;

        sum += min(m, nr - b[i]);
    }

    return (ramas <= sum);
}

lint cautBin()
{
    if(pos(1))
        return a[1];

    lint i = 1;
    lint pas = 1 << 29;
    while(pas != 0)
    {
        if(i + pas <= n && pos(i + pas) == 0)
            i += pas;

        pas >>= 1;
    }

    return a[i + 1];
}

int main()
{
    cin >> n >> m >> v >> p;

    for(int i = 1; i <= n; i ++)
        cin >> a[i];

    sort(a + 1, a + n + 1);

    mx = cautBin();

    //cout << "REZ " << mx << "++++\n";

    for(int i = 1; i <= n; i ++)
    {
        if(a[i] >= mx)
            rez ++;
    }

    cout << rez << "\n";

    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, m, k;
ll ans;
int a[N], b[N], c[N];
ll psum[N];

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> c[i];
    }
    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);
    int j = 0;
    for (int i = 0; i < n; ++i) {
        while (j < n && b[i] > a[j])
            ++j;
        psum[i] = j;
    }
    for (int i = 1; i < n; ++i) {
        psum[i] += psum[i - 1];
    }
    j = 0;
    for (int i = 0; i < n; ++i) {
        while (j < n && c[i] > b[j])
            ++j;
        if (j > 0)
            ans += psum[j - 1];
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5616
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define all(a) a.begin(),a.end()
#define endl '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ull unsigned long long
#define int long long
#define iter set<int>::iterator
using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

template<class T>
using ordered_multiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rnd1(chrono::steady_clock::now().time_since_epoch().count());

//find_by_order
//order_of_key

const int N=2e5+7;
const int inf=1e18+5;
const int mod=1e9+7;

ld a[N];

main ()
{
    ios;
    int n;
    cin>>n;
    for (int i=1;i<=n;++i)cin>>a[i];
    sort(a+1,a+n+1);
    ld ans=a[1];
    for (int i=2;i<=n;++i){
        ans=(ans+a[i])/(ld)2;
    }
    cout<<fixed<<setprecision(12);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP2D(a, n, m) REP(i, n) REP(j, m) printf("%lld%c", a[i][j], j + 1 == m ? '\n' : ' '); puts("")
#define DUMP(a, n) REP(i, n) printf("%lld%c", a[i], i + 1 == n ? '\n' : ' ')

typedef long long ll;

const int N_MAX = 40;
const int S_MAX = 1 << 17;
const int MOD = 1e9 + 7;

int N, X, Y, Z;

int S;
ll dp[N_MAX + 1][S_MAX];

void solve() {
  S = 1 << (X + Y + Z);
  int mask = (S | 1 << (Y + Z) | 1 << Z) >> 1;
  dp[0][0] = 1;
  REP(i, N) {
    REP(s, S) {
      if ((s & mask) == mask) {
        dp[i + 1][s] = (dp[i + 1][s] + dp[i][s] * 10 % MOD) % MOD;
      } else {
        int s1 = s << 1 | 1;
        FOR(j, 1, 10) {
          int s2 = s1 << (j - 1) & (S - 1);
          dp[i + 1][s2] = (dp[i + 1][s2] + dp[i][s]) % MOD;
        }
      }
    }
  }
  ll ans = 0;
  REP(s, S) if ((s & mask) == mask) {
    ans = (ans + dp[N][s]) % MOD;
  }
  printf("%lld\n", ans);
}

void input() {
  scanf("%d%d%d%d", &N, &X, &Y, &Z);
}

int main() {
  input();
  solve();
  return 0;
}


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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int counter(int x){
    if(!x)return 0;
    return counter(x>>1)+(x&1);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    int d[N];
    REP(i,N){
        cin>>d[i];
    }
    ll ans;
    ans=0;
    REP(i,N){
        REP(j,N){
            if(i==j)continue;
            ans+=d[i]*d[j];
        }
    }
    ans/=2;
    print(ans);
    return 0;
}


Measured memory_bytes: 3584
#include<stdio.h>
#include<stdlib.h>
int main(void){
	int n, x, y;
	int r, c;
	int *results;
	int distance;
	scanf("%d", &n);
	scanf("%d", &x);
	scanf("%d", &y);
	results = (int *)malloc(sizeof(int) * n);
	for(int i=0; i<n; i++){
		results[i] = 0;
	}
	for(int j=0; j<n; j++){
		for(int k=j; k<n; k++){
			distance = abs(j-k);
			if(distance > abs(j-x+1)+abs(k-y+1)+1){
				distance = abs(j-x+1)+abs(k-y+1)+1;
			}
			if(distance > abs(j-y+1)+abs(k-x+1)+1){
				distance = abs(j-y+1)+abs(k-x+1)+1;
			}
			results[distance]++;
		}
	}
	for(int l=1; l<n; l++){
		printf("%d\n", results[l]);
	}
	return 0;
}

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



//“Remember, Hope is a good thing, maybe the best of things, and no good thing ever dies.”

//― Stephen King


#define ll long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define eb emplace_back
#define in insert
#define ff first
#define ss second
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define si set<int>
#define mpii map<int, int>
#define prq priority_queue
#define sz(s) (int) s.size()
#define pf(a) printf("%d ",a)
#define si1(a) scanf("%d",&a)
#define si2(a,b) scanf("%d%d",&a,&b)
#define si3(a,b,c) scanf("%d%d%d",&a,&b,&c)
//#define scan(v) for(int i = 0; i<n; i++){int x;cin>>x;v.pb(x);}
#define pi 2 * acos (0.0)
#define inf 1e9
#define co cout
#define en '\n'
#define re return
#define con continue
#define dbg cout<<"___________ok____________"<<endl;
#define yes() printf("YES\n")
#define no() puts("NO\n")
#define FOR(i, j, k) for(int i=(j); i<(k); i++)
#define REV(i, j, k) for(int i=(n-1); i>=k; i--)
#define all(v) v.begin(), v.end()
#define unq(a) sort(all(a)), a.erase(unique(all(a)),a.end())
#define rnd(a, b) ((((rand()<<15)^rand())%((b)-(a) + 1))+(a))
#define FAST_IO ios_base::sync_with_stdio(false),cin.tie(NULL)
#define mem(x, y) memset(x, y, sizeof(x))
#define prn(v) for(auto x: v)cout<<x<<" ";
const double EPS = 1e-9;
const int MXX = 2e5 + 5;

ll MOD = 1e9 + 7;
ll a[MXX],cum[MXX];


ll power( ll a, ll p ) {
    ll res = 1, x = a;
    while ( p ) {
        if ( p & 1 ) res = ( res * x );
        x = ( x * x ); p >>= 1;
    }
    return res;
}
ll M  = MOD;
ll F(ll N,ll P)
{
	if(P==0)
    {
        return 1;
    }
	if(P%2==0)
	{
		ll ret=F(N,P/2);
		return ((ret%M)*(ret%M))%M;
	}
	else return ((N%M)*(F(N,P-1)%M))%M;

}
int main ()
{
    FAST_IO;
    ll n;cin>>n;
    FOR(i, 0, n)cin>>a[i];
    cum[0] = a[0];
    FOR(i, 1, n)cum[i] = cum[i-1]+a[i], cum[i]%=MOD;
    ll ans = 0;
    FOR(i, 0, n)
    {
        ll val = (cum[n-1]-cum[i])*a[i];
        ans = (ans + val)%MOD;
    }
    ans+=MOD;
    co<<ans%MOD<<en;
    return 0;
}


Measured memory_bytes: 6692
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int n, x; cin >> n >> x;
    if(x == 1 || x == 2 * n - 1) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
        int k = 1, cnt = n - 2;
    while(cnt > 0) {
        if(k == x - 1 || k == x || k == x + 1) {
            ++k; continue;
        }
        cout << k << endl;
        ++k; --cnt;
    }
    cout << x - 1 << endl << x << endl << x + 1 << endl;
    cnt = n - 2;
    while(cnt > 0) {
        if(k == x - 1 || k == x || k == x + 1) {
            ++k; continue;
        }
        cout << k << endl;
        ++k; --cnt;
    }
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,c[30005],d[11],e[11],ans=0,f[11];
    cin>>n;
    cin>>s;
    for(int i=0;i<10;i++)
    {
        d[i]=e[i]=-1;
    }
    for(int i=0;i<n;i++)
    {
        c[i]=s[i]-'0';
    }
    for(int i=0;i<n;i++)
    {
        if(d[c[i]]==-1)
        {
            d[c[i]]=i;
        }
    }
    for(int i=n-1;i>=0;i--)
    {
        if(e[c[i]]==-1)
        {
            e[c[i]]=i;
        }
    }
    for(int i=0;i<10;i++)
    {
        for(int j=0;j<10;j++)
        {
            for(int jjj=0;jjj<10;jjj++)
            {
                f[jjj]=0;
            }
            if(d[i]!=-1)
            {
                for(int k=d[i]+1;k<e[j];k++)
            {
                if(f[c[k]]==0)
                {
                    f[c[k]]=1;
                }

            }
            for(int jjj=0;jjj<10;jjj++)
            {
                ans+=f[jjj];
            }
            }

        }
    }
    cout<<ans;

}




Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    string s;
    cin >> s;
    int n = s.size();
    rep(i,n)s[i] -= '0';
    int ans = 0;
    rep(i,n-1)if(s[i] == s[i+1]){
        ans++;
        s[i+1] = 1 - s[i+1];
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

  rep(_,q){
    long s,t;
    cin>>s>>t;

    if(n==1){
      cout << min(s,t) << endl;
      continue;
    }

    auto par = [&](long x){
      return (x+(n-2))/n;
    };

    while(s!=t){
      if(s>t) s = par(s);
      else t = par(t);
    }

    cout << s << endl;
  }

  return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
//#define redirect_in
//#define redirect_out
//#define debug

bool check(vector<long long> v){
    for(int i=0; i<3; ++i){
        if(v[i]%2){
            return false;
        }
    }
    return true;
}

int main(){
#ifdef redirect_in
    freopen("a.in", "r", stdin);
#endif
#ifdef redirect_out
    freopen("a.out", "w", stdout);
#endif
    vector<long long> v(3);
    while(cin>>v[0]>>v[1]>>v[2]){
        set<vector<long long> > st;
        long long cnt=0;
        bool flag=true;
        st.insert(v);
        while(check(v)){
            ++cnt;
            vector<long long> vv=v;
            v[0]=vv[1]/2+vv[2]/2;
            v[1]=vv[0]/2+vv[2]/2;
            v[2]=vv[0]/2+vv[1]/2;
            if(st.count(v)){
                flag=false;
                break;
            }
            st.insert(v);
        }
        if(flag==false){
            cout<<-1<<endl;
        }else{
            cout<<cnt<<endl;
        }
    }


    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>


#ifdef _DEBUG
#define typeof(X) std::identity<decltype(X)>::type //C++0x (for vs2010)
#else
#define typeof(X) __typeof__(X) // for gcc
#endif

#define sz(a)  int((a).size())
#define FOREACH(it, c) for (typeof((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define FOR(i,count) for (int i = 0; i < (count); i++)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

using namespace std;
static const double EPS = 1e-6;
typedef long long ll;
const int MODULO = 1000000007;
const int INF = 100000000; //1e8

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef complex<double> Cd;

int n;
Cd pt[300];

double sqr(double x) { return x * x; }

int C(Cd &o){
	int cnt = 0;
	for (int i = 0; i < n; i++){
		Cd c = pt[i] - o;
		if(sqr(c.real()) + sqr(c.imag()) <= 1.0 + EPS)
			cnt++;
	}
	return cnt;
}

int solve()
{
	for (int i = 0; i < n; i++){
		double x,y; cin>>x>>y;
		pt[i] = Cd(x,y);
	}

	int ans = 1;

	for (int i = 0; i < n; i++){
		for (int j = i+1; j < n; j++){
			Cd e = (pt[j] - pt[i]);
			double len = abs(e);
			if(len > 2.0 + EPS) continue;
			Cd md = pt[i] + e / 2.0;
			e /= len;
			e *= Cd(0,1);
			double o_dis = sqrt(1.0 - sqr(len / 2));
			e *= o_dis;
			static int dir[] = {1,-1};
			for (int k = 0; k < 2; k++){
				e *= -1;
				Cd o = md + e; // 中心を出す
				ans = max(ans,C(o));
			}
		}
	}

	return ans;

}


int main(){
	while(cin>>n,n){
		cout << solve() << endl;
	}
	return 0;
}

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

using ll  = long long;
using vl  = vector<ll>;
using vvl = vector<vl>;
#define rep(i,n) for(int i = 0; i < (n); ++i)

const int mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (t == 0) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
istream& operator>>(istream& i, mint& var) {
    ll tmp; i >> tmp;
    var.x = tmp;
    return i;
}
ostream& operator<<(ostream& o, const mint& var) {
    o << var.x;
    return o;
}

vector<mint> pow2;
int N;
vl size;
vvl edges;
mint sum(0);

void dfs(int v, int pre) {
    size[v] = 1;
    // vを根としたときに、全てが白でない場合の数
    mint count = pow2[N - 1] - 1;
    for (auto to : edges[v]) {
        if (to == pre) continue;
        dfs(to, v);
        size[v] += size[to];
        // １つの部分木のみが黒を含むパターンを取り除く
        count -= pow2[size[to]] - 1;
    }
    count -= pow2[N - size[v]] - 1;
    sum += count;
}

int main() {
    cin >> N;
    edges.resize(N);
    size.resize(N);
    pow2.assign(N+1, 1);
    rep(i,N-1) {
        int a, b; cin >> a >> b;
        a--; b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    rep(i,N) pow2[i+1] = pow2[i] * 2;
    dfs(0, -1);
    cout << sum / pow2[N] << endl;
    return 0;
}


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

/************* Using *************/
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using graph_t = vector<vector<ll>>;

/*********** Constants ***********/
const auto INF  = static_cast<int>(1e10);
const auto INFL = static_cast<ll>(1e18);
const auto MOD  = static_cast<ll>(1e9 + 7);
const auto NIL  = nullptr;

/*********** Variables ***********/
ll N;
vector<double> A;
double ANS;

/************* Utils *************/

/*********** Functions ***********/
bool init() {
    cin >> N;
    A.resize(N);
    for (auto &item : A) cin >> item;
    ANS = 0.0;
    return true;
}

void solve() {
    for (const auto& item : A) {
        ANS += 1.0 / item;
    }
    ANS = 1.0 / ANS;
}

void output() {
    cout << setprecision(10) <<ANS << endl;
}

int main() {
    init();
    solve();
    output();
    return 0;
}

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

struct katana
{
    int a,b;
};
bool cmp (katana a, katana b)
{
    if(a.a>b.a)
        return true;
    return false;
}
katana v[200010];
int main()
{
    long long n,h,i,j,s=0,cnt=1;
    cin>>n>>h;
    for(i=1; i<=2*n; i++)
    {
        cin>>v[i].a>>v[i+1].a;
        v[i+1].b=1;
        i++;
    }
    sort(v+1,v+2*n+1,cmp);
    n=n*2;
    i=1;
    while(v[i].b==1 && s<h)
    {
        s+=v[i].a;
        i++;
    }
    h-=s;
    if(h>0)
    {
        if(h%v[i].a==0)
            cout<<i-1+h/v[i].a;
        else
            cout<<i-1+h/v[i].a+1;
    }
    else
        cout<<i-1;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
/*
hash
*/
int main()
{
    int N,a[210000],hash[210000]={0},temp;
    cin >> N;
    for(int i = 0; i < N-1; i++){
        cin >> temp;
        hash[temp]++;
    }
    for (int i = 1; i < N+1; i++)
    {
        cout << hash[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4012
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

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

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
int main() {
	string S;
	cin >> S;
	if (S <= "2019/04/30")cout << "Heisei" << endl;
	else cout << "TBD" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n;
    cin >> n;
    cout << (n+1)/2 << endl;

    return 0;
}

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

double p[200005];

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
  int n,k;cin>>n>>k;
  double ans=0;
  double cur=0;
  for(int i=0;i<n;i++){
    cin>>p[i];
    p[i] = (p[i]+1)/2.0;
    cur += p[i];
    if(i-k>=0){
      cur -= p[i-k];
    }
    ans = max(ans, cur);
  }
  cout.precision(17);
  cout<<ans<<endl;

  
  return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(string[] args)
    {
        var l = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var n = l[0]; var m = l[1];
        var line = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var sum = line.Sum();
        line = line.Where(x => x * 4 * m >= sum).ToArray();
        if (m <= line.Length) Console.WriteLine("Yes");
        else Console.WriteLine("No");

    }
}


Measured memory_bytes: 28332
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> p;

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

    int N, K;
    cin >> N >> K;

    vector<int> p(N);

    for(int i = 0; i < N; i++) cin >> p[i];

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

    int sum = 0;

    for(int i = 0; i < K; i++) sum += p[i];

    cout << sum << endl;
}

Measured memory_bytes: 3636
object Main {
  case class Line(string: String) {
    def strings: Seq[String] = string.split(' ')
    def ints: Seq[Int] = strings.map(_.toInt)
    def longs: Seq[Long] = strings.map(_.toLong)
    def doubles: Seq[Double] = strings.map(_.toDouble)
    def i(n: Int): Int = ints(n)
    def d(n: Int): Double = doubles(n)
  }

  def readLine: Line = Line(io.StdIn.readLine())
  def readLines(n: Int): Seq[Line] = List.fill(n)(Line(io.StdIn.readLine()))

  def yesNo(b: Boolean): String = if (b) "Yes" else "No"

  def main(args: Array[String]): Unit = {
    val m: Int = readLine.i(0)
    val ns: Seq[Long] = readLine.longs

    println(List(ns.min, ns.max, ns.sum).mkString(" "))
  }
}

Measured memory_bytes: 48304
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h1 = sc.nextInt(), h2 = sc.nextInt();
        int k1 = sc.nextInt(), k2 = sc.nextInt();
        int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt();
        int p1 = h1 * a + h2 * b + h1 / 10 * c + h2 / 20 * d;
        int p2 = k1 * a + k2 * b + k1 / 10 * c + k2 / 20 * d;
        if(p1 == p2) {
            System.out.println("even");
        } else if(p1 > p2) {
            System.out.println("hiroshi");
        } else {
            System.out.println("kenjiro");
        }
    }
}



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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;




int main(){
	
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
     
    ll h,w;cin>>h>>w;
    char mz[h][w];
    REP(i,h) REP(j,w) cin>>mz[i][j];

    ll l[h][w], r[h][w], u[h][w], b[h][w];

    REP(i,h){
        REP(j,w){
            l[i][j]=0; r[i][j]=0; u[i][j]=0; b[i][j]=0;
        }
    }
    REP(i,h){
        REP(j,w){
            
            if(mz[i][j]=='.' && j-1>=0 && mz[i][j-1]=='.') l[i][j]=l[i][j-1]+1;
            if(mz[i][j]=='.' && i-1>=0 && mz[i-1][j]=='.') u[i][j]=u[i-1][j]+1;
        }
    }
    FORR(i,h-1,0){
        FORR(j,w-1,0){
            if(mz[i][j]=='.' && j+1<=w-1 && mz[i][j+1]=='.') r[i][j]=r[i][j+1]+1;
            if(mz[i][j]=='.' && i+1<=h-1 && mz[i+1][j]=='.') b[i][j]=b[i+1][j]+1;
        }
    }
    ll mx=0;
    REP(i,h){
        REP(j,w){
            if (mz[i][j]=='.') mx = max(mx,1+l[i][j]+r[i][j]+u[i][j]+b[i][j]);
            // if(i==1 && j==1) {cout<<r[i][j]<<endl; return 0;}
        }
    }
    cout<<mx<<endl;
    return 0;
}

Measured memory_bytes: 129152
using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.IO.Pipes;
using System.Linq;

class Program
{ 
	public static int Main()
	{
		Scanner cin = new Scanner();
		int[] a = new int[4];
		int[] b = new int[4];
		for (int i = 0; i < 4; i++)
		{
			a[i] = cin.nextInt();
		}
		for (int i = 0; i < 4; i++)
		{
			b[i] = cin.nextInt();
		}
		Console.WriteLine(Math.Max(a.Sum(x => x), b.Sum(x => x)));
		return 0;
	}

}

class Scanner {
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner() {
		s = new string[0];
		i = 0;
	}

	public string next() {
		if (i < s.Length) return s[i++];
		do {
			s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
		} while ((s.Length == 1 && s[0] == "") || s.Length == 0);
		i = 0;
		return s[i++];
	}

	public int nextInt() {
		return int.Parse(next());
	}

	public long nextLong() {
		return long.Parse(next());
	}

	public double nextDouble() {
		return double.Parse(next());
	}

}

Measured memory_bytes: 5828
#include<stdio.h>
#include<stdlib.h>
long long n;
long long k;
long long a[1000005];
int cmp(const void* a, const void* b)
{
    return *(long long*)a - *(long long*)b;
}
int getLeft(long long x)
{
    long long i;
    long long index = 0;
    long long left, right, mid;
    for (i = 1; i < n; i++)
    {
        left = i + 1;
        right = n;
        if (a[i] >= 0)
        {
            if (a[i] * a[left] < x)
            {
                while (left < right) {
                    mid = (left + right + 1) / 2;
                    if (a[i] * a[mid] < x) left = mid;
                    else right = mid - 1;
                }
                index += left - i;
            }
        }
        else
        {
            if (a[i] * a[right] < x)
            {
                if (a[i] * a[left] < x)
                {
                    index += right - left + 1;
                    continue;
                }
                while (left < right)
                {
                    mid = (left + right + 1) / 2;
                    if (a[i] * a[mid] >= x) left = mid;
                    else right = mid - 1;
                }
                index += n - left;
            }
        }
    }
    return index < k;
}
int main() 
{
    int i;
    long long left = -1000000000000000005;
    long long right = 1000000000000000005;
    long long mid;
    scanf("%lld %lld", &n, &k);
    for (i = 1; i <= n; i++)
    {
        scanf("%lld", &a[i]);
    }
    qsort(a + 1, n, sizeof(long long), cmp); 
    while (left < right)
    {
        mid = (left + right + 1) / 2;
        if (getLeft(mid))
        {
            left = mid;
        }
        else
        {
            right = mid - 1;
        }
    }
    printf("%lld", left);
    return 0;
}

Measured memory_bytes: 3324
A = []
b = []
for i in range(3):
    A.append(list(map(int, input().split())))
N = int(input())
for i in range(N):
    b.append(int(input()))

#print(A, N, b)

C = []

for i in range(3):
    _c = []
    for j in range(3):
        _c.append(A[i][j] in b)
    C.append(_c)

#print(C)

flag = False

for i in range(3):
    if all(C[i]):
        flag = True

for i in range(3):
    _c = []
    for j in range(3):
        _c.append(C[j][i])
    if all(_c):
        flag = True

if C[0][0] and C[1][1] and C[2][2]:
    flag = True

if C[0][2] and C[1][1] and C[2][0]:
    flag = True

if flag:
    print("Yes")
else:
    print("No")


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

int main()
{
    int n;
    cin >> n;
    int hash[n+1]={0}, res;
    for(int i=1; i*i<=n; i++)
    {
        for(int j=1; j*j<=n; j++)
        {
            for(int k=1; k*k<=n; k++)
            {
                res = i*i + j*j + k*k + i*j + j*k + k*i;
                if(res <= n)
                    hash[res]++;
            }
        }
    }

    for(int i=1; i<=n; i++)
    {
        cout << hash[i] << "\n";
    }
}

Measured memory_bytes: 3552
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ld = long double;
using qul = queue<ll>;
using pql = priority_queue<ll>;

// ========================================================================



ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a)
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a)
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll mch(ll n) {
	if (n == 1) return 1;
	else return n * mch(n - 1);
}
//1から整数nまでの階乗を出す(INFで割っていない)
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double m = sqrt(a);
	for (int i = 3; i <= m; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定
ll modpow(ll a, ll n, ll mod) {
	ll hi = 1;
	while (n > 0) {
		if (n & 1) hi = hi * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return hi;
}
//いろいろやります（ただの前座）
ll mg(ll a, ll mod) {
	return modpow(a, mod - 2, mod);
}
//割り算の10^9+7等対策で逆元を出します 

//#define int long long;


// ========================================================================


/*signed*/int main() {
	ll n; cin >> n;
	map<string, ll> mp;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	ll c = 0;
	for (auto x : mp) c = max(c, x.second);
	for (auto x : mp)
		if (x.second == c) cout << x.first << endl;

	return 0;
}

Measured memory_bytes: 19224
#include <stdio.h>

int main(void){
  int N;
  int i, j;
  scanf("%d", &N);
  int count = 0;

  for (i = 0; i < N; i++) {
    for (j = 0; j < N; j++) {
      if (4 * i + 7 * j == N) {
        count++;
      }
    }
  }

  if (count > 0) {
    puts("Yes");
  }else{
    puts("No");
  }
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	int a,s,d[1000],f[1000],g,h,j,i;
	scanf("%d %d",&a,&s);
	while(a!=0&&s!=0){
		g=1;
		h=0;
		for(i=1;i<=a;i++){
			scanf("%d",&d[i]);
		}
		for(i=1;i<=s;i++){
			scanf("%d",&f[i]);
		}
		for(i=1;i<=s;i++){
			g=f[i]+g;
			j=g;
			g=j+(d[j]);
			if(g<0){
				g=0;
			}
			h++;
			if(a<=g){
				break;
			}
			//printf("%d %d\n",g,h);
		}
		//printf("%d %d\n",g,h);
		printf("%d\n",h);
		scanf("%d %d",&a,&s);
	}
	return 0;
}

Measured memory_bytes: 1032
local mfl, mce, mmi = math.floor, math.ceil, math.min
local SegTree = {}
SegTree.updateAll = function(self)
  for i = self.stagenum - 1, 1, -1 do
    for j = 1, self.cnt[i] do
      self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])
      self.lazy[i][j] = false
    end
  end
end
SegTree.create = function(self, n, func, emptyvalue)
  self.func, self.emptyvalue = func, emptyvalue
  local stagenum, mul = 1, 1
  self.cnt, self.stage, self.size = {1}, {{}}, {}
  self.lazy = {{}}
  while mul < n do
    mul, stagenum = mul * 2, stagenum + 1
    self.cnt[stagenum], self.stage[stagenum] = mul, {}
    self.lazy[stagenum] = {}
  end
  for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end
  self.stagenum = stagenum
  for i = 1, mul do self.stage[stagenum][i] = emptyvalue end
  for i = 1, mul do self.lazy[stagenum][i] = false end
  self:updateAll()
end
SegTree.getValue = function(self, idx)
  return self.stage[self.stagenum][idx]
end
SegTree.setRange = function(self, left, right, value)
  if left == right then self.stage[self.stagenum][left] = mmi(self.stage[self.stagenum][left], value) return end
  local start_stage = 1
  while right - left + 1 < self.size[start_stage] do
    start_stage = start_stage + 1
  end
  local t1, t2, t3 = {start_stage}, {left}, {right}
  while 0 < #t1 do
    local stage, l, r = t1[#t1], t2[#t1], t3[#t1]
    table.remove(t1) table.remove(t2) table.remove(t3)
    local sz = self.size[stage]
    if (l - 1) % sz ~= 0 then
      local newr = mmi(r, mce((l - 1) / sz) * sz)
      table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)
      l = newr + 1
    end
    if sz <= r + 1 - l then
      if value < self.stage[stage][mce(l / sz)] then
        self.stage[stage][mce(l / sz)] = value
        self.lazy[stage][mce(l / sz)] = true
      end
      l = l + sz
    end
    if l <= r then
      table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)
    end
  end
end
SegTree.resolve = function(self, idx)
  for stage = 1, self.stagenum - 1 do
    local pos = mce(idx / (self.size[stage]))
    if self.lazy[stage][pos] then
      self.lazy[stage][pos] = false
      local v = self.stage[stage][pos]
      if v < self.stage[stage + 1][pos * 2 - 1] then
        self.stage[stage + 1][pos * 2 - 1] = v
        self.lazy[stage + 1][pos * 2 - 1] = true
      end
      if v < self.stage[stage + 1][pos * 2] then
        self.stage[stage + 1][pos * 2] = v
        self.lazy[stage + 1][pos * 2] = true
      end
    end
  end
end
SegTree.new = function(n, func, emptyvalue)
  local obj = {}
  setmetatable(obj, {__index = SegTree})
  obj:create(n, func, emptyvalue)
  return obj
end

local n, m = io.read("*n", "*n")
local t = {}
for i = 1, m do
  local a, b, c = io.read("*n", "*n", "*n")
  t[i] = {a, b, c}
end

table.sort(t, function(x, y) return x[1] < y[1] end)
local st = SegTree.new(n, mmi, 99999999999999)
st:setRange(1, 1, 0)
for i = 1, m do
  st:resolve(t[i][1])
  local lval = st:getValue(t[i][1])
  st:setRange(t[i][1] + 1, t[i][2], lval + t[i][3])
end
st:resolve(n)
print(99999999999999 <= st:getValue(n) and -1 or st:getValue(n))


Measured memory_bytes: 29928