akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace abc054_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            string[] a = new string[x[0]];
            for (int i = 0; i < x[0]; i++)
            {
                a[i] = Console.ReadLine();
            }
            string[] b = new string[x[1]];
            for (int i = 0; i < x[1]; i++)
            {
                b[i] = Console.ReadLine();
            }
            bool ret = true;
            for (int i = 0; i <= x[0] - x[1] && ret; i++)
            {
                for (int j = 0; j <= x[0] - x[1] && ret; j++)
                {
                    bool flag = true;
                    for (int k = 0; k < x[1] && flag; k++)
                    {
                        for (int l = 0; l < x[1] && flag; l++)
                        {
                            if (a[i + k][j + l] != b[k][l])
                            {
                                flag = false;
                            }
                        }
                    }
                    if (flag)
                    {
                        ret = false;
                    }
                }
            }
            Console.WriteLine(!ret ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 13396
#include <cstdio>
#include <iostream>

using namespace std;

int main() {

  string A, B, C;

  cin >> A >> B >> C;

  if(A[A.size()-1] == B[0] && B[B.size()-1] == C[0])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }
// ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }
//

int solve(int N,ll K,vi& a,vi& b) {
    vector<ii> ab(N);
    rep(i,N) ab[i] = ii(a[i], b[i]);
    sort(ALL(ab));
    vector<ll> ac(N+1);
    ac[0] = 0;
    rep(i,N) ac[i+1] = ac[i] + ab[i].second;
#ifdef DEBUG
    cerr << ab << endl;
    cerr << ac << endl;
#endif
    int ix = upper_bound(ALL(ac), K-1) - ac.begin() - 1;
    // cerr << "ix=" << ix << endl;
    return ab[ix].first;
}

int main() {
    int n; ll k; cin>>n>>k;
    vi a(n), b(n);
    rep(i,n) cin>>a[i]>>b[i];
    cout << solve(n,k,a,b) << endl;
    // cout << (solve(N,a) ? "Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
#define N 100
#define MAX 100

int main(){
  int i, j, n, flag, save, count=0;
  int A[MAX];

  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &A[i]);
  }

  flag = 1;
  while(flag){
    flag = 0;
    for(j=n-1;j>0;j--){
      if(A[j] < A[j-1]){
        save = A[j];
        A[j] = A[j-1];
        A[j-1] = save;
        flag = 1;
        count++;
      }
    }
  }

  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i != n-1) printf(" ");
  }
  printf("\n%d\n",count);


  return 0;
}




Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
void answer(int l);
int main(){
int n,k,q;
cin >>n>>k>>q;
vector<int>vec(n);
vector<int>ans(q);

for(int i=0;i<q;i++){
cin>>ans.at(i);}
  for(int i=0;i<q;i++){
    vec.at(ans.at(i)-1)++;}
for(int i=0;i<n;i++){
if(vec.at(i)+k-q>0)cout << "Yes" <<endl;
else cout << "No" <<endl;}
  }


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int n,k,ans=1;
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		if(ans>k) ans+=k;
		else ans+=ans;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 20
int solve(int , int );

int n,A[100*N];

int main()
{
  int i,q,m[10*N],sum,hantei;
  
  while(1)
    {
      scanf("%d",&n);
      if(n<=N) break;
    }

  i=0;
  while(i<n)
    {
      scanf("%d",&A[i]);
      if(A[i] >= 1 && A[i] <= 100*N) i++;
    }

  while(1)
    {
      scanf("%d",&q);
      if(q<=10*N) break;
    }

  i=0;
  while(i<q)
    {
      scanf("%d",&m[i]);
      if(m[i] >= 1 && m[i] <= 100*N) i++;
    }
  for(i=0;i<q;i++)
    {
      sum = m[i];
      hantei = solve(0,sum);
      if(hantei == 1) printf("yes\n");
      else printf("no\n");
    }
      
  return 0;
}


int solve(int i, int m)
{
  int res;
  if(m == 0) return 1;
  if (i >= n) return 0;
  if(solve(i+1,m) || solve(i+1,m-A[i])) res = 1;
  else res = 0;
  return res;
}
  



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

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

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

#[derive(PartialEq, PartialOrd)]
struct NonNan<T>(T);

impl<T: PartialEq> Eq for NonNan<T> {}

impl<T: PartialOrd> Ord for NonNan<T> {
    fn cmp(&self, other: &NonNan<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

fn main() {
    input! {
        n: usize,
        t: i64,
        a: i64,
        hs: [i64; n],
    }
    let v = hs
        .iter()
        .enumerate()
        .map(|(i, h)| {
            let diff = (a as f64 - (t as f64 - *h as f64 * 0.006)).abs();
            (NonNan(diff), i + 1)
        })
        .collect::<Vec<_>>();
    let &(ref _min, ans) = v.iter().min().unwrap();
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vb = vector<bool>;
using vs = vector<string>;
using vvi = vector<vi>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, n) for (int i = (a); i < (n); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _per(i, n) peri(i, 0, n)
#define peri(i, a, n) for (int i = (n) - 1; i >= (a); --i)
#define per(...) _overload3(__VA_ARGS__, peri, _per)(__VA_ARGS__)
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<typename T> inline void chmax(T& a, const T& b) {if (a < b) a = b;}
template<typename T> inline void chmin(T& a, const T& b) {if (a > b) a = b;}
template<typename T> inline void print(const T& x) {cout << x << "\n";}
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p) {is >> p.fi >> p.se; return is;}
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) {os << p.fi << " " << p.se; return os;}
template<typename T> istream& operator>>(istream& is, vector<T>& v) {each(in, v) is >> in; return is;}
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {rep(i, sz(v)) {os << v[i] << (i + 1 != sz(v) ? " " : "");} return os;}
struct Init {Init() {ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(10);}} init;

int main() {
    int k;
    string s;
    cin >> k >> s;
    if (sz(s) <= k) print(s);
    else print(s.substr(0, k) + "...");
}

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

constexpr long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

#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 REP(i,n) rep(i,0,n)
#define RREP(i,n) rrep(i,n,0)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

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

  long double ans = 0;
  for (int i = 1; i <= n; i++) {
    int tmp = i;
    long double ret = 1;
    ret /= n;
    while (tmp < k) {
      tmp *= 2;
      ret /= 2;
    }
    ans += ret;
  }

  cout << fixed << setprecision(20) << ans << endl;
  return 0;
}


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

using namespace std;

int main(){
  string s, t;

  cin>>s;

  t = s;

  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'b') t[i] = 'd';
    else if(s[i] == 'd') t[i] = 'b';

    else if(s[i] == 'p') t[i] = 'q';

    else if(s[i] == 'q') t[i] = 'p';
  }

  reverse(s.begin(), s.end());

  // cout<<t<<endl;

  cout<<(s == t ? "Yes":"No")<<endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,var=1000;
    cin>>n;
    if(var>=n)
    {
        cout<<var-n;
    }
    else
    {
        if(n%var==0)
        {
            cout<<var*(n/var)-n;
        }
        else
        {
            cout<<var*((n/var)+1)-n;
        }
        
    }
    return 0;
    

}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n, tmp;
    bool flag=true;
    cin >> n;
    
    for(int i=0; i<n; i++){
        cin >> tmp;
        if(tmp%2==0){
            if(tmp%3!=0 && tmp%5!=0){
                flag = false; cout << "DENIED"; break; 
            }
        }
    }    
    if(flag){cout << "APPROVED";}
    return 0;
}


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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);

int32_t main(){
	fast;
	int a,b;
	cin >> a >> b;
	
	if(b%a==0)
		cout << a+b;
	else
		cout << b-a;
}



Measured memory_bytes: 256
N,P=map(int,input().split())
ans=1
pf={}
if N==1:
    print(P)
else:
    M=P
    for p in range(2,round(M**0.5)+1):
        pf[p]=0
        while P%p==0:
            P//=p
            pf[p]+=1
        if P==1:
            break
    for p in pf:
        if pf[p]>=N:
            ans*=p**(pf[p]//N)
    print(ans)

Measured memory_bytes: 98996
# ほぼ最短路を求めるだけ

import heapq as hp
import numpy as np

H,W = map(int,input().split())
S = np.array([list(input()) for _ in range(H)])
S = np.pad(S,1,'constant')
visited = np.zeros_like(S,dtype=np.bool)

dist = np.inf

h = []
hp.heappush(h,(0,1,1))

while h:
  d,x,y = hp.heappop(h)
  if x == H and y == W:
    dist = d
    break
  for dx,dy in [[0,1],[1,0],[-1,0],[0,-1]]:
    nx = x+dx
    ny = y+dy
    if S[nx,ny] == '.' and not visited[nx,ny]:
      visited[nx,ny] = True
      hp.heappush(h,(d+1,nx,ny))
      
if dist == np.inf:
  print(-1)
else:
  print((S == '.').sum() - dist - 1)

Measured memory_bytes: 12472
n, a, b, c, d = list(map(int, input().split()))
s = input()
if d > c:
    for i in range(a, d-1):
        if s[i-1] == s[i] == "#":
            print("No")
            break
    else:
        print("Yes")
else:
    for i in range(a, c):
        if s[i-1] == s[i] == "#":
            print("No")
            break
    else:
        for j in range(b-1, d):
            if s[j-1] == s[j] == s[j+1] == ".":
                print("Yes")
                break
        else:
            print("No")

Measured memory_bytes: 3572
import java.util.*;

public class Main{
    public static void main (String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int com = 0;
        int ans = 0;
        int cunt = 1; /*何人目かを示す*/

        /*座標を入力する配列の確保*/
        int[] pointN = new int[N*2];
        int[] pointM = new int[M*2];

        /*座標の入力*/
        for(int i=0; i<N*2; i++){
            pointN[i] = sc.nextInt();
        }

        /*座標の入力*/
        for(int y=0; y<M*2; y++){
            pointM[y] = sc.nextInt();
        }

        for(int a=0; a<N*2; a++){
            for(int b=0; b<M*2; b++){
                com = Math.abs((pointN[a])-(pointM[b]))+Math.abs((pointN[a+1])-(pointM[b+1]));
                if(b==0){
                    ans = com;
                }
                if(com < ans){
                    ans = com;
                    cunt = b/2+1;
                }
                b++;
            }
            System.out.println(cunt);
            a++;
            cunt = 1;
        }
    }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};


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

  vector<int> a(N),b(N),c(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.rbegin(),a.rend());
  sort(b.rbegin(),b.rend());
  sort(c.rbegin(),c.rend());

  ll total=0;
  vector<ll> ab(N,0); //b[i]に対してaを何種類おけるか
  int i=0,j=0;
  while(j<N&&i<N){
    while(b[i]<=a[j]){
      j++;
      if(j==N) break;
    }
    ab[i]=N-j;
    total+=ab[i];
    i++;
  }
  ll ans=0;
  i=0,j=0;
  while(j<N&&i<N){
    while(c[i]<=b[j]){
      total-=ab[j];
      j++;
      if(j==N) break;
    }
    ans+=total;
    i++;
  }
  cout<<ans<<endl;
  return 0;
}




Measured memory_bytes: 2176
#include <iostream>
#include <stdio.h>
#include <math.h> 
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>
#include <numeric>
#include <bitset>
#include <queue>
#include <map>
#include <typeinfo>

using namespace std;

int main()
{
	vector<vector<int>> data(5);
	int min_num = 0;
	int min_val = 10;

	for (int i = 0; i < 5; ++i) {
		int tmp = 0;
		cin >> tmp;
		data[i].push_back(tmp); //[0]
		data[i].push_back(tmp % 10); //[1]
		if (tmp % 10 < min_val && tmp % 10 != 0) {
			min_num = i;
			min_val = tmp % 10;
		}
		data[i].push_back(10 -(tmp % 10)); //[2]
		if (data[i][1] == 0) {
			data[i].push_back(tmp); //[3]
		}
		else {
			data[i].push_back(tmp + data[i][2]); //[3]
		}
	}

	int ans = 0;
	for (int i = 0; i < 5; ++i) {
		if (i == min_num) {
			ans = ans + data[i][0];
		}
		else{
			ans = ans + data[i][3];
		}

	}

	cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define int long long
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
const int N = 2e5 + 1000,mod = 1e9 + 7;
int n,m,k,isfirst = 1,len;
char s[N];
int A[N],B[N],ans;
signed main()
{
	k = 0x3f3f3f3f; n = read(); m = read(); scanf("%s",s + 1);
	for(int i = 1;i <= m;i ++)
	{
		if(s[i] != s[1]) {if(isfirst || len & 1) k = min(k,len / 2 + 1); isfirst = len = 0;}
		else len ++;
	}
	if(isfirst)
	{
		int x1 = 1,x2 = 0;
		for(int i = 1;i <= n;i ++)
		{
			x2 = (x1 + x2) % mod;
			x1 = (x2 - x1 + mod) % mod;
		}
		cout << (2ll * x1 + x2 ) % mod << "\n"; return 0;
	}
	if(n & 1) {puts("0"); return 0;}
	n /= 2; k = min(k,n);
	A[0] = B[0] = 1;
	for(int i = 1;i <= n;i ++)
	{
		A[i] = B[i - 1];
		if(i > k) A[i] = (A[i] - B[i - k - 1] + mod) % mod;
		B[i] = (B[i - 1] + A[i]) % mod; 
	}
	for(int i = 1;i <= k;i ++) ans = (ans + 2ll * i * A[n - i]) % mod;
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#define ll long long
using namespace std;

const int N=105;
const ll inf=1000000000000000000ll;

struct E{
	int x,y;
}e[N<<1];
int n,x,y,mxd,mx;
ll ans;
int dep[N],dp[N];
ll cnt[N];
vector<int> lev[N];

void dfs1(int k,int pre){
	int j,u;
	dp[k]=1;
	for (j=0;j<lev[k].size();j++){
		u=lev[k][j];
		if (u==pre) continue;
		dfs1(u,k);
		mx=max(mx,dp[k]+dp[u]);
		dp[k]=max(dp[k],dp[u]+1);
	}
}

void dfs2(int k,int pre){
	int j,u,d=0;
	for (j=0;j<lev[k].size();j++){
		u=lev[k][j];
		if (u==pre) continue;
		dep[u]=dep[k]+1; d++;
		dfs2(u,k);
	}
	cnt[dep[k]]=max(cnt[dep[k]],1ll*d);
}

int main(){
	int i,j;
	scanf("%d",&n); ans=inf;
	for (i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		e[i].x=x; e[i].y=y;
		lev[x].push_back(y);
		lev[y].push_back(x);
	}
	dfs1(1,0);
	printf("%d ",(mx+1)/2);
	cnt[n+1]=1;
	for (i=1;i<=n;i++){
		memset(cnt,0,sizeof(cnt));
		dep[i]=1; mxd=0;
		dfs2(i,0);
		for (j=1;j<=n;j++) mxd=max(mxd,dep[j]);
		if (mxd>(mx+1)/2) continue;
		for (j=n;j>=1;j--){
			if (!cnt[j]) cnt[j]=1;
			else cnt[j]=cnt[j]*cnt[j+1];
		}
		ans=min(ans,cnt[1]);
	}
	for (i=1;i<n;i++){
		memset(cnt,0,sizeof(cnt));
		x=e[i].x; y=e[i].y; mxd=0;
		dep[x]=1;
		dfs2(x,y);
		dep[y]=1;
		dfs2(y,x);
		for (j=1;j<=n;j++) mxd=max(mxd,dep[j]);
		if (mxd>(mx+1)/2) continue;
		for (j=n;j>=1;j--){
			if (!cnt[j]) cnt[j]=1;
			else cnt[j]=cnt[j]*cnt[j+1];
		}
		ans=min(ans,cnt[1]*2);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sp <<" "<<
bool isprime(ll n){
    if (n <= 1)return false;ll g=sqrt(n);
    for (ll i = 2; i <= g; i++)if (n % i == 0)return false;
    return true;
}
ll MOD=LLONG_MAX;
ll power(ll base, ll exp)
{
    if(exp==1)return base;
    else{if(exp%2==0){ll base1=(pow(power(base, exp/2),2));return base1%MOD;}
        else{ll ans=(base*pow(power(base,(exp-1)/2),2));return ans%MOD;}}
}
ll temp,temp1,temp2;
int main()
{
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++) cin>>a[i];
    ll res=0;
    for(ll i=1;i<n;i++)
    {
        if(a[i]<a[i-1])
        {
            res+=a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }
    cout<<res;
    
    return 0;
}


Measured memory_bytes: 5244
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n; cin >> n;
  vii tasks(n);
  rep(i,n) {
    int a, b; cin >>a >>b;
    tasks[i] = ii(a,b);
  }
  sort(tasks.begin(), tasks.end(), [] (ii a, ii b) {return a.second < b.second;});
  int timeConsumed = 0;
  rep(i,n) {
    if (tasks[i].second - tasks[i].first < timeConsumed) {
      cout << "No" << endl;
      return 0;
    }
    timeConsumed+=tasks[i].first;
  }
  cout << "Yes" << endl;
  return 0;
}

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

int N, M;
ll K;
vector<ll> A;
vector<ll> B;

bool is_ok(int cnt_a, int mid){
  return A[cnt_a] + B[mid] <= K;
}

int binary_search(int cnt_a) {
    int left = 0; // 配列の左端
    int right = B.size(); // 配列の右端
    // 両端の差が1になるまで続ける
    while (right - left > 1){
        int mid = left + (right - left) / 2; // 区間の真ん中
        if (is_ok(cnt_a, mid)) left = mid;  // もし調べている対象が「is_okの条件」に当てはまればleftをmidまで移動
        else right = mid;  // 当てはまらなければrightをmidまで移動
    }
    return left;
}

int main(){
  cin >> N >> M >> K;
  // 0インデックスには何も読まない0という初期値をそのまま入れておく
  A.push_back(0);
  B.push_back(0);

  rep(i, N){
    ll a;
    cin >> a;
    A.push_back(a);
  }
  rep(i, M){
    ll b;
    cin >> b;
    B.push_back(b);
  }

  rep(i, N) A[i+1] += A[i];
  rep(i, M) B[i+1] += B[i];

  int ans = 0;
  int cnt_b;
  rep(cnt_a, N+1){
    if (A[cnt_a] > K) continue;
    cnt_b = binary_search(cnt_a);
    ans = max(ans, cnt_a + cnt_b);
  }
  cout << ans << endl;
}

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

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0)
            ans += a[i];
        else
            ans -= a[i];
    }

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


Measured memory_bytes: 256
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math

MOD = 10 ** 9 + 7
# MOD = 998244353

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


n = int(input())
prime = Counter(prime_factorize(n))
# print(prime)

ans = 0
for p, v in prime.items():
    c = 1
    while v >= c:
        ans += 1
        v -= c
        c += 1

print(ans)


Measured memory_bytes: 69056
using System;
using System.Collections.Generic;

class ABC_131_D
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());

        long allTask = 0;
        List<Pair> task = new List<Pair>();
        for (int i = 0; i < N; i++)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            allTask += A;
            task.Add(new Pair(A, B));
        }

        task.Sort((a, b) => b.B - a.B);

        long last = allTask;

        for (int i = 0; i < N; i++)
        {
            if (last > task[i].B)
            {
                Console.WriteLine("No");
                return;
            }

            last -= task[i].A;
        }

        Console.WriteLine("Yes");
    }

    class Pair
    {
        public Pair(int a, int b)
        {
            A = a;
            B = b;
        }
        public int A;
        public int B;
    }

}

Measured memory_bytes: 27556
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>

using namespace std;

int main(){
    long long l,r;
    cin >> l >> r;
    if(r/2019 - l/2019 !=0){
        cout << 0 << endl;
    }
    else{
        long long mn = 2019 * 2019;
        for(int i=l%2019;i<=r%2019-1;i++){
            for(int j=i+1;j<=r%2019;j++){
                long long R = (i*j)%2019;
                mn =min(mn, R);
            }
        }
        cout << mn << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  auto f = [&](ll N){
    return N - (N / C + N / D - N / lcm(C, D));
  };
  cout << f(B) - f(A - 1) << endl;
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int tintin(int n){
  int ans=0;
  while(n!=0){
    ans+=n%10;
    n=n/10;
  }
  return ans;
}
  int main(){
    int n;
    cin >> n;
    if(n % tintin(n)==0){
      cout << "Yes" << endl;
    }
    else{
cout << "No" << endl;
    }
  return 0;
}
    
 

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

using namespace std;

#define ll long long

const int INF = 1e9+9999;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, sum = 0;
    cin >> n;
    vector <int> a(n, INF);

    for (int i=0; i<n-1; ++i) {
        int x;
        cin >> x;
        a[i] = min(a[i], x);
        a[i+1] = min(a[i+1], x);
    }

    for (int i=0; i<n; ++i)
        sum += a[i];

    cout << sum;

}

Measured memory_bytes: 256
const main = lines => {
  console.log(solve(lines));
};

const solve = (lines: string[]): string => {
  const { s } = parseLines(lines);

  const t: { [s: string]: number } = {};
  let ans = 0;

  s.forEach(str => {
    const a = str
      .split('')
      .sort()
      .join('');
    if (!t[a]) t[a] = 1;
    else {
      ans += t[a];
      ++t[a];
    }
  });

  return ans.toString();
};

const parseLines = (lines: string[]) => {
  const obj = { N: +lines[0], s: lines.slice(1) };
  debug(obj);
  return obj;
};

const debug = (message?: any, ...optionalParams: any[]) => {
  if (!!process.env.LOCAL_DEBUG) console.log(message, ...optionalParams);
};

if (!process.env.LOCAL_DEBUG) {
  const { stdin: input, stdout: output } = process;
  input.resume();
  input.setEncoding('utf8');
  const lines = [];
  require('readline')
    .createInterface({ input, output })
    .on('line', line => lines.push(line))
    .on('close', () => main(lines));
}

export default solve;


Measured memory_bytes: 43468
#include <iostream>
#include <vector>
#include <string>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=a,i##_len=(b);i<i##_len;++i)

using namespace std;
using ll = long long;
typedef long long ll;

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

int main() {
    string s;
    cin >> s;
    int len = s.size();
    string t = string(s);
    reverse(t.begin(), t.end());
    string u = s.substr(0, len / 4);
    string v = s.substr(len / 4 + int(len % 4 == 3), len / 4);
    reverse(v.begin(), v.end());
    if (s == t && u == v) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
using namespace std;

signed main() {
    int a, b;
    cin >> a >> b;
    cout << (a - 1) * (b - 1) << endl;
    return 0;
}


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

int w, h;
char M[60][30];

class Point {
public:
  int x;
  int y;
  Point() {}
  Point(int x, int y) : x(x), y(y) {}
  bool operator <(const Point &p) const {
    if(x != p.x) return x < p.x;
    return y < p.y;
  }
};

class State {
public:
  int time;
  Point left;
  Point right;
  State() {
    time = 0;
  }
  bool operator <(const State &s) const {
    if(time != s.time) return time > s.time;
    if(left < s.left || s.left < left) return left < s.left;
    return right < s.right;
  }
};

class VisSta {
public:
  Point left;
  Point right;
  VisSta(State &s) {
    left = s.left;
    right = s.right;
  }

  bool operator <(const VisSta &vs) const {
    if(left < vs.left || vs.left < left) return left < vs.left;
    return right < vs.right;
  }
};

int solve() {
  State s;
  priority_queue<State> que;
  set<VisSta> vis;
  const int rr[9][2] = {{1,-2},{1,-1},{1,0},{1,1},{1,2},
			{2,-1},{2,0},{2,1},{3,0}};
  const int rl[9][2] = {{-1,-2},{-1,-1},{-1,0},{-1,1},{-1,2},
			{-2,-1},{-2,0},{-2,1},{-3,0}};

  for(int i = 0; i < h; ++i) {
    for(int j = 0; j < w; ++j) {
      if(M[i][j] == 'S') {
	s.left = Point(j, i);
	s.right = Point(j, i);
	que.push(s);
      }
    }
  }

  while(!que.empty()) {
    s = que.top();
    que.pop();

    if(M[s.left.y][s.left.x] == 'T' || M[s.right.y][s.right.x] == 'T') {
      //cout << s.left.x << ", " << s.left.y << " | " << s.right.x << ", " << s.right.y << endl;
      return s.time;
    }
    
    for(int k = 0; k < 9; ++k) {
      State newS = s;
      int nx = s.left.x + rr[k][0];
      int ny = s.left.y + rr[k][1];
      if(nx < 0 || nx >= w) continue;
      if(ny < 0 || ny >= h) continue;
      if(nx == s.right.x && ny == s.right.y) continue;
      if(M[ny][nx] == 'X') continue;
      newS.right = Point(nx, ny);
      if(isdigit(M[ny][nx])) newS.time += M[ny][nx] - '0';
      VisSta vs(newS);
      if(vis.find(vs) == vis.end()) {
        vis.insert(vs);
        que.push(newS);
      }
    }

    for(int k = 0; k < 9; ++k) {
      State newS = s;
      int nx = s.right.x + rl[k][0];
      int ny = s.right.y + rl[k][1];
      if(nx < 0 || nx >= w) continue;
      if(ny < 0 || ny >= h) continue;
      if(nx == s.left.x && ny == s.left.y) continue;
      if(M[ny][nx] == 'X') continue;
      newS.left = Point(nx, ny);
      if(isdigit(M[ny][nx])) newS.time += M[ny][nx] - '0';
      VisSta vs(newS);
      if(vis.find(vs) == vis.end()) {
        vis.insert(vs);
        que.push(newS);
      }
    }
  }
  return -1;
}

main() {
  while((cin >> w >> h) && (w || h)) {
    for(int i = 0; i < h; ++i) {
      for(int j = 0; j < w; ++j) {
	cin >> M[i][j];
      }
    }
    cout << solve() << endl;
  }
}

Measured memory_bytes: 1456
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

ll power(ll a, ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans*=a;
        a*=a;
        n>>=1;
    }
    return ans;
}

int main()
{
    IOS;
    ll n;
    cin>>n;
    vector<pair<ll,ll>> v;
    repf(i,0,n) 
    {
        ll x;
        cin>>x;
        v.pb({x,i+1});
    }
    sort(all(v));
    repf(i,0,n)
    {
        cout<<v[i].se<<" ";
    }
    cout<<endl;
    return 0;  
}

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

ll dp[300010];

int main()
{
  int n;
  cin >> n;
  list<int> a;
  if (n % 2 == 0)
  {
    for (int i = 0; i < n; ++i)
    {
      int t;
      cin >> t;
      if (i % 2 == 0)
      {
        a.push_back(t);
      }
      else
      {
        a.push_front(t);
      }
    }
  }
  else
  {
    for (int i = 0; i < n; ++i)
    {
      int t;
      cin >> t;
      if (i % 2 == 0)
      {
        a.push_front(t);
      }
      else
      {
        a.push_back(t);
      }
    }
  }
  cout << a.front();
  for (auto itr = a.begin(); itr != a.end(); ++itr)
  {
    if (itr == a.begin())
      continue;
    cout << ' ' << *itr;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 8448
#include <cstring>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
int N, K;
ll A[101];
ll DP[102][100002]; //i人目, 使ったあめの個数はj

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

  cin >> N >> K;
  for(int i = 1; i <= N; i++) cin >> A[i];

  DP[0][0] = 1LL;
    for (int i = 1; i <= N; i++) {
        DP[i][0] = 1LL;
        for (int j = 1; j <= K; j++) {
            DP[i][j] += DP[i][j - 1] + DP[i - 1][j];
            if (j > A[i]) DP[i][j] -= DP[i - 1][j - A[i] - 1];
            DP[i][j] = (DP[i][j] + MOD) % MOD;
        }
    }

  cout << DP[N][K] << endl;
  return 0;
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    cout << ((n + 1000 - 1) / 1000) * 1000 - n;
    return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String sa = sc.nextLine();
        sa +=sa;
        int i = sa.length();
        String sb = sc.nextLine();
        int k = sb.length();
        sc.close();
        boolean isExist = false;
        for(int l=0; l < i;l++){
        	if(i - (l+k) >=0) {
        		if(sa.substring(l,l+k).equals(sb)){
        			isExist = true;
        		}
        	}
       	}
        if(isExist){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26316
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
	vector<int> exist(4,-1);
	string str;
	cin >> str;
	for (char& el : str){
		switch (el){
		case'N':	exist[0] = 1;	break;
		case'W':	exist[1] = 1;	break;
		case'S':	exist[2] = 1;	break;
		case'E':	exist[3] = 1;	break;
		}
	}
	if ((exist[0] * exist[2] == 1) && (exist[1] * exist[3] == 1)){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;

}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000"]

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <stack>
#include <random>

#define fr first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define hm unordered_map
#define pii pair<int, int>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define cinv(v) for (auto& x: v) cin >> x
//#define fr(i, n) for (int i = 0; i < n; ++i)
#define fl(i, l, n) for (int i = l; i < n; ++i)

using namespace std;

#ifdef __LOCAL
    #define dbg(x) cerr << #x << " : " << x << '\n'
    const int maxn = 110 + 10;
#else
    #define dbg(x)
    const int maxn = 110;
#endif

//tg: @galebickosikasa

const ll inf = (ll) 1e9 + 10;
const ld pi = 3.14159265358979323846264;
const ld eps = 1e-8;
const ll mod = (ll) 1e9 + 7;
const ll ns = 97;
const int MAXLOG = 20;
const int N = 45;

#define int ll

random_device rd;
mt19937 SuperRandom(rd());



signed main(){
    ios_base::sync_with_stdio(false);
    cout.tie(nullptr);
    cin.tie(nullptr);
    int n;
    cin >> n;
    cout <<  (n + 1) / 2;






}

Measured memory_bytes: 256
import java.io.*; 
import java.math.*;
import java.util.*;
 
public class Main {
	static final long MOD = 998244353;
	//static final long MOD = 1000000007;
	static int pow;
	static boolean[] visited;
    public static void main(String[] args) throws IOException {
        FastScanner sc = new FastScanner();
        int N = sc.nextInt();
        pow = (int)Math.pow(2, N);
        int[] nums = new int[pow];
        for (int i = 0; i < pow; i++)
        	nums[i] = sc.nextInt();
        nums = sort(nums);
        boolean ans = true;
        boolean[] hit = new boolean[pow];
        hit[pow-1] = true;
        loop:
        for (int i = 0; i < N; i++) {
        	boolean[] mark = new boolean[pow];
        	int index = pow-1;
        	for (int j = pow-1; j >= 0; j--) {
        		if (hit[j]) {
        			continue;
        		} else if (nums[j] < nums[index]) {
        			mark[j] = true;
        			while (index > 0) {
        				index--;
        				if (hit[index]) {
        					break;
        				}
        			}
        		}
        	}
        	int marked = 0;
        	for (int j = 0; j < pow; j++) {
        		hit[j] = (hit[j]||mark[j]);
        		if (hit[j]) {
        			marked++;
        		}
        	}
        	if (marked < Math.pow(2, i+1)) {
        		ans = false;
        		break loop;
        	}
        }
        if (ans) {
        	System.out.println("Yes");
        } else {
        	System.out.println("No");
        }
    }
    
    public static int[] sort(int[] array) {
    	//Sort an array (immune to quicksort TLE)
		Random rgen = new Random();
		for (int i = 0; i< array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    int temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		Arrays.sort(array);

		return array;
	}
    
    static class FastScanner { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try { 
                str = br.readLine(); 
            } catch (IOException e) {
                e.printStackTrace(); 
            } 
            return str; 
        }
    }
}

Measured memory_bytes: 62260
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <utility>
using namespace std;

struct Edge {
    int src, dst, cost;
    Edge(int s, int d, int c = 1) : src(s), dst(d), cost(c) {}
    bool operator<(const Edge &e) const { return cost < e.cost;}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

struct UnionFind {
    vector<int> par, rnk, weight;
    UnionFind(int n) :par(n), rnk(n), weight(n) { for(int i=0; i < n; ++i) par[i] = i; }
    void unite(int x, int y, int w = 0) {
        x = root(x); y = root(y);
        if (x == y) return;
        if (rnk[x] < rnk[y]) swap(x, y), w = -w;
        par[y] = x;
        if(rnk[x] == rnk[y]) ++rnk[x];
        return;
    }
    bool same(int x, int y) { return root(x) == root(y); }
    int root(int x) {
        if(par[x]==x) return x;
        return root(par[x]);
    }
    int sizeOf(int x) { return rnk[root(x)]; }
};

// O(|E|log|E|)
int kruskal(Edges &es, int n) {
    UnionFind uf(n);
    sort(es.begin(), es.end());
    int min_cost = 0;

    for (Edge e : es){
        if (!uf.same(e.src, e.dst)) {
            uf.unite(e.src, e.dst);
            min_cost += e.cost;
        }
    }
    return min_cost;
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N;cin>>N;
    vector<pair<int,int> > p,q;
    Edges es;

    for(int i=0;i<N;++i) {
        int x,y;cin>>x>>y;
        --x;--y;
        p.emplace_back(x,i);
        q.emplace_back(y,i);
    }
    sort(p.begin(),p.end());
    sort(q.begin(),q.end());

    for(int i=0;i<N-1;++i){
        int cost = abs(p[i].first - p[i+1].first);
        es.emplace_back(p[i].second, p[i+1].second, cost);
        es.emplace_back(p[i+1].second, p[i].second, cost);
    }

    for(int i=0;i<N-1;++i){
        int cost = abs(q[i].first - q[i+1].first);
        es.emplace_back(q[i].second, q[i+1].second, cost);
        es.emplace_back(q[i+1].second, q[i].second, cost);
    }

    cout << kruskal(es,N) << '\n';
    return 0;
}

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

int main () {
  vector<int> p(3);
  cin >> p[0] >> p[1] >> p[2];

  sort(p.begin(), p.end());
  cout << p[0] + p[1] << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> pair_t;
using Graph = vector<vector<ll>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = 1 << 29;
/****** define constant end ********/
/****** define variable start ******/
ll n, a, b;
vl x;
/******* define variable end *******/
int solve() {
	cin >> n >> a >> b;
	x.resize(n);
	REP(i, n){
		cin >> x[i];
	}
	ll ans = 0;
	REP(i, n-1){
		ll walk = (x[i+1] - x[i]) * a;
		ll tele = b;
		if(walk < tele){
			ans += walk;
		}else{
			ans += tele;
		}
	}
	cout << ans << endl;
	return 0;
}

int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define PRE 0
#define NEXT 1

/*
n????????????????????????			10 <= n <= 200000
m????????????????????????????????????	5 <= m < n
q????????¨?????°????????????			1 <= q <= 1000

a?????????????????????				1 <= a <= 100
b????????¨???????????????(q???)		

???????????????????????§??????????????????????±?????????¨?¨??????????n * n?????????????????????
??£??????????????§??????n * a = 200000 * 100 2000???????????§???????????????


????????????
?????????????????£???????????????????£??????????
???n?????????????????????????????§??????
???m??????????????????????????????.
??????????????????????????????????????£?????????????????????	O(n)
????????¨?????????????????????						O(q)

*/


typedef struct _LinkedList{
	int number;
	struct _LinkedList *pre;
	struct _LinkedList *next;
}LinkedList;

LinkedList top = {0,NULL,NULL}, *bottom = &top;


LinkedList *con_list(LinkedList *arg,int value){
	LinkedList *newll = (LinkedList *)malloc(sizeof(LinkedList));
	newll->number = value;
	newll->next = NULL;
	newll->pre = NULL;
	if(arg->next != NULL){
		newll->next = arg->next;
		arg->next->pre = newll;
	}else{
		bottom = newll;
	}
	arg->next = newll;
	newll->pre = arg;
	return newll;
}


void del_list(LinkedList *arg){
	if(arg->next == NULL){
		arg->pre->next = NULL;
		bottom = arg->pre;
		free(arg);
	}else{
		arg->pre->next = arg->next;
		arg->next->pre = arg->pre;
		free(arg);
	}
}

LinkedList *search_list(LinkedList *arg,int rep_num,int direction){
	LinkedList *now = arg;
	if(direction == PRE){
		while(rep_num--){
			if(now->pre == &top){
				now = bottom;
			}else{
				now = now->pre;
			}
		}
	}else{
		while(rep_num--){
			if(now->next == NULL){
				now = top.next;
			}else{
				now = now->next;
			}
		}
	}
	return now;
}



int main(void){
	int n, m ,q, a, b, i, j;
	int query[200000];
	
	LinkedList *s = &top;
	scanf("%d%d%d",&n,&m,&q);
	for(i = 0;i < n;i++){
		s = con_list(s,i);
	}
	s = top.next;
	for(i = 0;i < m;i++){
		scanf("%d",&a);
		if(a % 2 == 0){
			s = search_list(s,a,NEXT);
		}else{
			s = search_list(s,a,PRE);
		}
		if(s->next == NULL){
			s = top.next;
			del_list(bottom);
		}else{
			s = s->next;
			del_list(s->pre);
		}
	}
	memset(query,0,sizeof(query));
	for(;top.next != NULL;){
		query[top.next->number] = 1;	//???????????????
		del_list(top.next);
	}
	for(i = 0;i < q;i++){
		scanf("%d",&b);
		printf("%d\n",query[b]);
	}
	/*
	for(s = top.next;s != NULL;s=s->next){
		printf("%d\n",s->number);
	}
	del_list(bottom);
	del_list(bottom);
	for(s = top.next;s != NULL;s=s->next){
		printf("%d\n",s->number);
	}*/

	return 0;
}

Measured memory_bytes: 8064