akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define SUM(x)              accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

class ATakahashikunTheStrider {
public:
  static void solve(istream &cin, ostream &cout) {
    int X;
    cin >> X;
    rep(i, 10000) {
      if (360 * (i + 1) % X == 0) {
        cout << 360 * (i + 1) / X << endl;
        return;
      }
    }
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  ATakahashikunTheStrider solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3664
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List
-- import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
-- import Control.Monad
-- import Control.Monad.ST
-- import Debug.Trace
-- trace _ = id

solve :: Int -> Int -> [Int] -> [Int] -> Int
solve bN bM as bs = princ (1, bN*bM, aRem0, bRem0, 0, 0, 0)
  where
  aRem0 = sortOn (* (-1)) as
  bRem0 = sortOn (* (-1)) bs

  princ (acc, x, aRem, bRem, aOcc, bOcc, emp)
    | x == 0 = acc
    | isHead x aRem && isHead x bRem =
      princ (acc, x-1, tail aRem, tail bRem, aOcc+1, bOcc+1, emp+aOcc+bOcc)
    | x == bN*bM = 0
    | isHead x aRem = 
      princ (acc `mMul` bOcc, x-1, tail aRem, bRem,
             aOcc+1, bOcc, emp+bOcc-1)
    | isHead x bRem = 
      princ (acc `mMul` aOcc, x-1, aRem, tail bRem,
             aOcc, bOcc+1, emp+aOcc-1)
    | emp == 0 = 0
    | otherwise = princ (acc `mMul` emp, x-1, aRem, bRem, aOcc, bOcc, emp-1)

isHead x [] = False
isHead x (y:_) = x == y

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Int
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_bN,bs_bM]:remLines1 = remLines0
      bN = readBInt bs_bN
      bM = readBInt bs_bM
      line2:remLines2 = remLines1
      as = map readBInt line2
      line3:remLines3 = remLines2
      bs = map readBInt line3
  in solve bN bM as bs

outAnswer :: Int -> IO ()
outAnswer = putStrLn . show

main :: IO ()
main = outAnswer . tmain =<< B.getContents

mPrime = 10^9 + 7

mAdd :: Int -> Int -> Int
mAdd x y = (x + y) `mod` mPrime

mSub :: Int -> Int -> Int
mSub x y = (x - y) `mod` mPrime    -- ok even if x < y

mMul :: Int -> Int -> Int
mMul x y = (x * y) `mod` mPrime

inp1 = "2 2\n4 3\n3 4\n"
inp2 = "3 3\n5 9 7\n3 6 9\n"
inp3 = "2 2\n4 4\n4 4\n"
inp4 = "14 13\n158 167 181 147 178 151 179 182 176 169 180 129 175 168\n181 150 178 179 167 180 176 169 182 177 175 159 173\n"
tv1 = tmain $ B.pack inp1
tv2 = tmain $ B.pack inp2
tv3 = tmain $ B.pack inp3
tv4 = tmain $ B.pack inp4
test1 = tv1 == 2
test2 = tv2 == 0
test3 = tv3 == 0
test4 = tv4 == 343772227
alltest = test1 && test2 && test3 && test4


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

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

    vector<int> v;
    int t = 0;
    char c = '9';
    bool st = true;
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            if (s[i] == '0') {
                st = false;
            }
        }
        if (s[i] == c || i == 0) {
            t++;
        } else {
            v.push_back(t);
            t = 1;
        }
        c = s[i];
    }

    v.push_back(t);

    if (st) {
        if (v.size() / 2 <= k) {
            cout << n << endl;
            return 0;
        }
    } else {
        if ((v.size() + 1) / 2 <= k) {
            cout << n << endl;
            return 0;
        }
    }

    int mx = 0;
    if (st) {
        for (int i = 0; i < v.size() - k * 2; i += 2) {
            int x = 0;
            for (int j = 0; j < 1 + k * 2; j++) {
                if (i + j >= v.size()) {
                    break;
                }
                x += v[i + j];
            }
            mx = max(mx, x);
        }
        if (v.size() % 2 == 0) {
            int xx = 0;
            for (int j = 0; j < k * 2; j++) {
                xx += v[j + (v.size() - k * 2)];
            }
            mx = max(mx, xx);
        }
    } else {
        for (int j = 0; j < k * 2; j++) {
            mx += v[j];
        }
        for (int i = 1; i <= v.size() - k * 2; i += 2) {
            int x = 0;
            for (int j = 0; j < 1 + k * 2; j++) {
                if (i + j >= v.size()) {
                    break;
                }
                x += v[i + j];
            }
            mx = max(mx, x);
        }
    }

    cout << mx << endl;
}


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

int main()
{
    int t,n,i,j,k;
    cin>>n>>k;
    int a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    int sum=0;
    for(i=0;i<k;i++)
        sum+=a[i];
    cout<<sum<<endl;
}


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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    int cnt1[26] = {}, cnt2[26] = {};
    cin >> s >> t;
    for (int i = 0; s[i]; i++) {
        cnt1[s[i] - 'a']++;
        cnt2[t[i] - 'a']++;
    }
    sort(cnt1, cnt1+26);
    sort(cnt2, cnt2+26);
    for (int i = 0; i < 26; i++) {
        if (cnt1[i] != cnt2[i]) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 916
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n,x,i,j;
    double cur;
    cin>>n;
    ll a[n];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    cur=a[0];
    for(i=1; i<n; i++)
    {
        cur=cur+a[i];
        cur/=(2*1.0);
    }
    cout.setf(ios::fixed);
    cout.precision(7);
    cout<<cur<<endl;
    return 0;
}





Measured memory_bytes: 3772
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#define SE -1e10
#define EE 2e10
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int a,b,q;
  cin>>a>>b>>q;
  vector<long>s(a+2),t(b+2);
  for(int i=1;i<=a;i++)
  {
    cin>>s[i];
  }
  for(int i=1;i<=b;i++)
  {
    cin>>t[i];
  }
  s[0]=SE;t[0]=SE;
  s[a+1]=EE;t[b+1]=EE;
  long x;
  long res;
  for(int i=0;i<q;i++)
  {
    cin>>x;
    auto si=lower_bound(s.begin(), s.end(), x);
    auto ti=lower_bound(t.begin(), t.end(), x);
    long sr=*si,sl=*(si-1),tr=*ti,tl=*(ti-1);
    res=min(x-min(sl,tl),max(sr,tr)-x);
    res=min(res,tr-sl+min(tr-x,x-sl));
    res=min(res,sr-tl+min(sr-x,x-tl));

    cout<<res<<"\n";




  }

  return 0;

}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll x, y;
	cin >> x >> y;

	if (y > 0) {
		if (0 <= x && x <= y) cout << y - x << endl;
		else if (-y <= x && x < 0) cout << 1 + y + x << endl;
		else if (x < -y) cout << 1 - y - x << endl;
		else cout << 2 + x - y << endl;
	}
	else if (y == 0) {
		if (x <= y) cout << y - x << endl;
		else cout << 1 + x - y << endl;
	}
	else {
		if (x <= y) cout << y - x << endl;
		else if (y < x && x < 0) cout << 2 + (- y + x) << endl;
		else if (0 <= x && x <= -y) cout << 1 + (- y - x) << endl;
		else cout << 1 + y + x << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	map<ll,ll>a;
	for(ll i=0;i<n;i++){
		ll now;
		cin>>now;
		a[now]++;
	}
	ll ans=0;
	for(auto i=a.begin();i!=a.end();i++){
		auto j=i;
		j++;
		for( ;j!=a.end();j++ ){
			auto k=j;
			k++;
			for(;k!=a.end();k++){
				ll A=i->first;
				ll B=j->first;
				ll C=k->first;
				if(A<B+C&&B<A+C&&C<B+A){
					ans+=i->second*j->second*k->second;
				}
			}
		}
	}
	for(auto i=a.begin();i!=a.end();i++){
		for(auto j=a.begin() ;j!=a.end();j++ ){
				ll A=i->first;
				ll B=j->first;
				if(A==B){
					continue;
				}
				if(A<B+A&&B<A+A&&A<B+A){
					ans+=i->second*(i->second-1)/2*j->second;
				}			
		}
	}
	for(auto i=a.begin();i!=a.end();i++){
		ll A=i->second;
		ans+=A*(A-1)*(A-2)/6;
	}	
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 998244353;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
struct Combination{
private:
    ll N;
    vector<ll> fac, facinv;

public:
    Combination(ll n){
        N = n;
        fac.push_back(1); fac.push_back(1);
        rep(i,2,N+1) fac.push_back(fac[i-1] * i % MOD);
        rep(i,0,N+1) facinv.push_back(power(fac[i], MOD-2));
    }
    ll power(ll x, ll n){
        if(n == 0) return 1LL;
        ll res = power(x * x % MOD, n/2);
        if(n % 2 == 1) res = res * x % MOD;
        return res;
    }
    ll nck(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[k] % MOD * facinv[n-k] % MOD;
    }
    ll npk(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[n-k] % MOD;
    }
    ll get(ll x){return fac[x];};
    ll getinv(ll x){return facinv[x];};
};

void solve(){
    ll N,M,K;
    cin >> N >> M >> K;
    Combination cb(200010);
    ll ans = 0;
    rep(i,0,K+1){
        ll n = N - i;
        ll val = cb.nck(N-1, i);
        ll v = M;
        v *= cb.power(M-1, n-1);
        v %= MOD;
        ll res = v * val % MOD;
        ans += res;
        ans %= MOD;
    }
    print(ans);

    

}

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

Measured memory_bytes: 7960
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
//increase stack size
#pragma comment(linker, "/STACK:16777216")

ll mxm() {return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a, Args... args) { return max(a,mxm(args...)); }

ll mnm() {return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a, Args... args) { return min(a,mnm(args...)); }

template<class T> ostream& operator<<(ostream& os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<"]";
}
template<class L,class R> ostream& operator<<(ostream& os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template <typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
	const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vll vector<ll>
#define vii vector<ii>
#define vi vector<int>
#define vpll vector<pll>
#define vld vector<ld>
#define vvld vector<vld>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define I insert
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x)	x.begin(),x.end()

const int mod=1e9+7;
// 128 bit: __int128
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

struct compare{
	bool operator() (const int &a,const int &b) const{
		return a>b;
	}
};

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	string s;
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5])
		cout << "Yes" << endl;
	else cout << "No" << endl;		
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val input      = scala.io.StdIn.readInt
    val sqrt_input = Math.sqrt( input ).toInt

    var map: Map[ Int, Int ] = Map.empty

    ( 1 to input ).foreach{ i =>
      map += ( i -> 0 )
    }

    ( 1 to sqrt_input ).foreach{ x =>
      ( 1 to sqrt_input ).foreach{ y =>
        ( 1 to sqrt_input ).foreach{ z =>
          val calc_num = x*x + y*y + z*z + x*y + y*z + z*x
          if( calc_num <= input ) {
            map += ( calc_num -> ( map( calc_num ) + 1 ) )
          }
        }
      }
    }

    ( 1 to input ).foreach{ i =>
      println( map( i ) )
    }
  }
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  if(N%2==0){
    cout << N << endl;
  }else{
    cout << N*2 << endl;
  }
}

Measured memory_bytes: 256
require "pp"

class UnionFind
  attr_reader :par

  def initialize list
    @par = {}
    list.each{|x| @par[x] = x}
  end

  def root x
    return x if par[x] == x
    return par[x] = root(par[x])
  end

  def unite(x, y)
    rx = root x
    ry = root y
    return if rx == ry
    par[rx] = ry
  end
end

class Main
  def run()
    # Read
    n, m = gets.split(" ").map(&:to_i)
    x_y_z_list = []
    m.times do |i|
      x_y_z_list << gets.split(" ").map(&:to_i)
    end

    # Build Union Find
    union_find = UnionFind.new((1..n).to_a)
    x_y_z_list.each do |x_y_z|
      x, y, z = x_y_z
      union_find.unite(x, y)
    end

    puts union_find.par.map{|i, x| i == x}.delete_if{|x| !x}.count
  end
end

main = Main.new()
main.run()


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

bool dp[50][51];
int main() {
    int r, c, count=0;
    cin>>r>>c;
    memset(dp, 0, sizeof(dp));
    for (int i=0; i<r; ++i)
        for (int j=0; j<c; ++j) {
            char ch;
            cin>>ch;
            if (ch=='#') {
                dp[i][j]=1;
                ++count;
            }    
        }
    bool ans=1;
    for (int i=0; i<r; ++i)
        for (int j=0; j<c; ++j) {
            if (dp[i][j]) {
                if (i-1>=0 && dp[i-1][j]) continue;
                if (i+1<r && dp[i+1][j]) continue;
                if (j-1>=0 && dp[i][j-1]) continue;
                if (j+1<c && dp[i][j+1]) continue;
                ans=0;
                break;
            }
        }
    if (count==1) cout<<"No"<<endl;
    else if (ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
     return 0;
}

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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

ll readLL(){
	ll i;
	scanf("%lld",&i);
	return i;
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

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

template<class T>
T Sq(const T& t){
	return t*t;
}

const int mod=1000000007;
template<class T,class U>
void add(T& a,U b){
	a=((ll)a+b)%mod;
}

template<>
void add(int& a,int b){
	a+=b;
	if(a>=mod)a-=mod;
}

template<class T,class U>
void sub(T& a,U b){
	a=((ll)a-b%mod+mod)%mod;
}

template<>
void sub(int& a,int b){
	a-=b;
	if(a<0)a+=mod;
}

template<class T,class U>
void mult(T& a,U b){
	a=((ll)a*b)%mod;
}

const int S=3341919;
using int128=__int128;
struct Line{
	int128 a,b;
	int128 calc(int128 x){
		return a*x+b;
	}
};
struct ConvexHull{
	Line buf[S];
	int b,e;
	void Init(){
		b=e=0;
	}
	void Push(Line l){
		while(e-b>=2){
			Line p=buf[e-2],q=buf[e-1];
			if(l.a*(p.b-q.b)+l.b*(q.a-p.a)>=q.a*p.b-p.a*q.b)
				e--;
			else
				break;
		}
		buf[e++]=l;
	}
	int128 Get(int128 x){
		while(e-b>=2){
			if(buf[b].calc(x)<=buf[b+1].calc(x))
				b++;
			else
				break;
		}
		return buf[b].calc(x);
	}
} ch;

int main(){
	ll n=readLL(),a=readLL();
	ch.Init();
	ch.Push(Line{int128(1),int128(0)});
	ll ans=n;
	FOR(i,2,S){
		int128 v=ch.Get(i);
		if(v>=n){
			chmin(ans,i);
			break;
		}
		ch.Push(Line{v,-v*(a+i)});
		chmin(ans,a+i+(n-1)/v+1);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 104576
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> adj(N,vector<int>());
  //cout << "size of adj : " << adj.size() << endl;
  for (int i=0; i<M; i++) {
    int A,B;
    cin >> A >> B;
    //cout << A-1 << B-1 << endl;
    adj.at(A-1).push_back(B-1);
    adj.at(B-1).push_back(A-1);
  }
  //cout << "Initialization ends." << endl;

  queue<int> bfs;
  vector<bool> ch(N,false);
  vector<int> ans(N,0);
  ch.at(0) = true;
  bfs.push(0);
  while(!bfs.empty()){
    int search = bfs.front();
    bfs.pop();
    for(auto x:adj.at(search)){
      if(!ch.at(x)) {
        ch.at(x) = true;
        ans.at(x) = search;
        bfs.push(x);
      }
    }
  }

  for(auto &x:ans) x++;
  cout << "Yes" << endl;
  for (int i=1; i<N; i++) cout << ans.at(i) << endl;
}

Measured memory_bytes: 9980
#include<bits/stdc++.h>
using namespace std;
int main(){
  int K,X;
  cin >> K >> X;
  K--;
  int MIN = max(X-K,-1000000);
  int MAX = min(X+K, 1000000);
  
  for(int i = MIN; i <= MAX;i++){
    cout << i <<" " ;
  }
  
  return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import sys
from heapq import heapify, heappop, heappush

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# Nの制約が1000,円の中心を飛び石→dijkstra
sx, sy, gx, gy = lr()
N = ir()
XYR = [[sx, sy, 0]] + [lr() for _ in range(N)] + [[gx, gy, 0]]
graph = [[] for _ in range(N+2)]  # 0がstart,N+1がgoal
for i in range(N+2):
    for j in range(i+1, N+2):
        sp = XYR[i]; ep = XYR[j]
        length = max(0, ((sp[0]-ep[0]) ** 2 + (sp[1]-ep[1]) ** 2) ** .5 - sp[2] - ep[2])
        graph[i].append((j, length))
        graph[j].append((i, length))

def dijkstra(start):
    INF = 10 ** 15
    dist = [INF] * (N+2)
    dist[start] = 0
    que = [(0, start)]
    while que:
        d, prev = heappop(que)
        if dist[prev] < d:
            continue
        for next, l in graph[prev]:
            d1 = d + l
            if dist[next] > d1:
                dist[next] = d1
                heappush(que, (d1, next))
    return dist

dist = dijkstra(0)
answer = dist[N+1]
print(answer)
# 46


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

int main()
{
	int a = 0, b = 0;

	cin >> a >> b;
	if (a > b)
		cout << "a > b" << endl;
	else if (a < b)
		cout << "a < b" << endl;
	else 
		cout << "a == b" << endl;


	return 0;
}

Measured memory_bytes: 3008
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // Write Your Code Below
    ll a, b, c;
    double sum, s;
    string ans;
    cin >> a >> b >> c;
    sum = a+b+c;
    s = sum/2;
    if(s==a || s==b || s==c){
        ans = "Yes";
    }else{
        ans = "No";
    }
    cout << ans << endl;
}


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

using namespace std;

using ll = long long;


int main(){
    ll n, k;
    cin >> n >> k;
    ll arr[n];
    for(ll i = 0; i < n; ++i){
        cin >> arr[i];
    }
    sort(arr, arr + n);
    cout << accumulate(arr, arr + k, 0);

    return 0;

}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,q;
const int maxn=5e5+5;
int lt[maxn];
set<int> a[26];

bool check(int k,int l,int r){
	int b;
	if (a[k].lower_bound(l)==a[k].end()) return false;
	b = *a[k].lower_bound(l);
//	cout << "csy" << ' ' << k << ' ' << b << endl;
	if (b<=r) return true;
	else return false;
}

int calc(int l,int r){
	int ans=0;
	for (int i=0;i<26;i++){
		if (check(i,l,r)) ans++;
	}
	return ans;
}

int main(){
	cin >> n;
	char p;
	for (int i=1;i<=n;i++){
		p = getchar();
		if (p=='\n'){i--;continue;}
		a[(int)p-97].insert(i);
		lt[i]=(int)p-97;
	}
	cin >> q;
	for (int i=1,t,nx,ny;i<=q;i++){
		cin >> t;
		if (t==1){
			cin >> nx >> p;
			ny = (int)p-97;
			if (lt[nx]==ny) continue;
			else{
				a[lt[nx]].erase(a[lt[nx]].find(nx));
				a[ny].insert(nx);	
				lt[nx]=ny;
			}
		}
		else{
			cin >> nx >> ny;
			cout << calc(nx,ny) << endl;	
		}
	}
	return 0;
}

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

#define MAXD 1001
#define INF 1000000000
#define x second
#define y first
using pii = pair<int,int>;
int h,w,ch,cw,dh,dw,DX[]{1,0,-1,0},DY[]{0,1,0,-1};
char grid[MAXD][MAXD];

bool is_path(pii p){
    return p.x>0 && p.y>0 && p.x<=w && p.y<=h && grid[p.y][p.x]=='.';
}

queue<pii> q[MAXD * MAXD];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>h>>w>>ch>>cw>>dh>>dw;
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            cin>>grid[i][j];
        }
    }
    vector<vector<int>> dist(h+1, vector<int>(w+1, INF));
    int m = 0;
    q[0].emplace(ch,cw);
    dist[ch][cw] = 0;
    for (int m = 0; q[m].size(); ++m) {
        while(q[m].size()) {
            pii u = q[m].front();
            q[m].pop();
            if (u == make_pair(dh,dw)) {
                cout << m;
                exit(0);
            }
            if (dist[u.y][u.x] < m) continue;
            for (int d = 0; d < 4; ++d){
                int dx = DX[d], dy = DY[d];
                pii v = {u.y + dy, u.x + dx};
                if (is_path(v) && m < dist[v.y][v.x]) {
                    dist[v.y][v.x] = m;
                    q[m].push(v); 
                }
            }
            for (int dy = -2; dy <= 2; ++dy) {
                for (int dx = -2; dx <= 2; ++dx) {
                    pii v = {u.y + dy, u.x + dx};
                    if (is_path(v) && m+1 < dist[v.y][v.x]) {
                        dist[v.y][v.x] = m+1;
                        q[m+1].push(v); 
                    }
                }
            }
        }
    }
    cout << -1;
}

Measured memory_bytes: 681840
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N,M; cin>>N>>M;
  vii A(N);
  rep(i,0,M){
    int X,Y,Z; cin>>X>>Y>>Z;
    A[X-1].push_back(Y-1);
    A[Y-1].push_back(X-1);
  }
  vector<bool> F(N,1);
  int ans=0;
  rep(i,0,N){
    if(F[i]){
      F[i]=0;
      ans++;
      queue<int> Q;
      Q.push(i);
      while(Q.size()>0){
        int K=Q.front();
        Q.pop();
        rep(j,0,A[K].size()){
          if(F[A[K][j]]){
            F[A[K][j]]=0;
            Q.push(A[K][j]);
          }
        }
      }
    }
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 7284
#include <algorithm>
#include <functional>
#include <iostream>
#include <cfenv>
#include <cmath>
using namespace std;

int main(){
    int N,H;
    cin >> N >> H;
    int a[N],b[N];
    int cnt=0;
    for(int i=0;i<N;i++){
        scanf("%d", &a[i]);
        scanf("%d", &b[i]);
    }
    int a_max=0;
    for(int i=0;i<N;i++){
        if(a_max<a[i]){
            a_max=a[i];
        }
    }
    sort(b,b+N,greater<>());
    for(int i=0;i<N;i++){
        if(a_max<b[i]){
            H-=b[i];
            cnt++;
            if(H<=0){
                cout << cnt << endl;
                return 0;
            }
        }
    }
    cout << (int)ceil((double)H/a_max)+cnt << endl;
}

Measured memory_bytes: 1024
N, T = map(int, input().split())
route = {}

for i in range(N):
    c, t = map(int, input().split())
    route[c] = t


val = float("inf")
for c, t in route.items():
    if t <= T:
        if c <= val:
            val = c

if val < float("inf"):
    print(val)
else:
    print("TLE")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long
using namespace std;
int a, b, c, d, e, f;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a;
	int i = 0;
	int n = 100;
	for (i = 0; n < a; i++)
	{
		n = n * 1.01;
	}
	cout << i;
}

Measured memory_bytes: 3648
#!/usr/bin/perl

my ($n) = map { $_ - 0 } split(/\s+/,<STDIN>);
my @x = map { $_ - 0 } split(/\s+/,<STDIN>);

my $tot = 0;
for(my $i = 0; $i < $n ; $i ++){
  $tot += $x[$i];
}
$avg = $tot / $n;

my $mn = -1;
my $i_avg = int($avg+0.5);

for(my $j = -2 ; $j <= 2; $j++){
  my $xx = 0;
  for(my $i=0;$i<$n;$i++){
    $xx += ( $i_avg + $j - $x[$i] ) ** 2;
  }
  $mn = $xx if( $mn == -1 or $xx < $mn );
}
print "$mn\n";



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

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n; cin >> n;
  set<string> st;
  rep(i, n) {
    string s; cin >> s;
    st.insert(s);
  }
  cout << st.size() << endl;
}


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


#define MOD (long long) (1e9 + 7);

int main(){
    long long n;
    int avail = 0;

    cin >> n;

    long long res = 1;

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

        while((avail - 1) * 2 >= x){
            res = res * avail % MOD;
            avail--;
        }
    }

    while(avail > 0){
        res = res * avail % MOD;
        avail--;
    }

    cout << res << endl;
    return 0;
}


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

int main(){
    int thp,tat,ahp,aat;
    cin >> thp >> tat >> ahp >> aat;

    int count = 0;
    while(thp>0 && ahp>0){
        if(count%2 == 0){
            ahp -= tat;
            count ++;
        }
        else{
            thp -= aat;
            count ++;
        }
    }
    if (thp > 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

int main(){
  int N;cin>>N;
  int W[100];
  int sum=0;
  int sum_a=0;
  int ans=10000000;
  rep(i,N){
    cin>>W[i];
    sum+=W[i];
  }
  
  rep(T,N){
    rep(i,T+1){
      sum_a+=W[i];
    }
    ans=min(ans,abs(sum-2*sum_a));
    sum_a=0;
  }
  cout<<ans<<endl;
}
      

Measured memory_bytes: 3596
program ABC068B
    implicit none
    integer(8)::N,count_break,i,j
    integer(8)::result=1
    integer(8)::break_max=0
    read(5,*)N

    do i=1,N
        count_break=0
        j=i
        do
            if(mod(j,2)==0)then
                count_break=count_break+1
                j=j/2
            else
                exit
            end if
        end do

        if(count_break>break_max)then
            break_max=count_break
            result=i
        end if
    end do

    print'(i0)',result
end program ABC068B

Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		boolean is = true;
		
		while(sc.hasNextInt()){
			int[] buy = new int[10];
			int n = sc.nextInt();
			if(n == 0)break;
			
			for(int i = 0; i < n; i++){
				buy[sc.nextInt()] += 1;
			}
			
			for(int i = 0; i < 10; i++){
				is = true;
				for(int u = 0; u < buy[i]; u++){
					is = false;
					System.out.print("*");
				}
				if(is)System.out.print("-");
				System.out.println();
			}
		}
		sc.close();
	}
}

Measured memory_bytes: 53936
#0001.rb

#???????????\????????????????????????????????????
height_num = []
input_roop = 10
output_roop = 2

for input in 1..input_roop do
  #get????????¨???????????????????????§int?????????
  height = gets.to_i
  #?????????????????°?????????????????\??????
  height_num.push(height)
end

#??§????????????3????¬????????????§???????????????
heighest3 = height_num.sort.reverse

for output in 0..output_roop do
  puts heighest3[output]
end

Measured memory_bytes: 6092
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
ll sieve[1000001]={0},i,j;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p);
p=(p*p);
k>>=1;
}
return a;
}
using namespace std;
  ll countDivisors(ll n) 
{ 
    ll cnt = 0; 
    for (ll i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            if (n / i == i) 
                cnt++; 
  
            else 
                cnt = cnt + 2; 
        } 
    } 
    return cnt; 
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 int tc=1;
//cin>>tc;
ll cas=1;
 while(tc--)
 {
	ll n,W;
	cin>>n>>W;
	ll w[n],v[n];
	ll dp[W+1]={0};
	for(i=0;i<n;i++)
	cin>>w[i]>>v[i];
	for(i=0;i<n;i++)
	for(j=W;j>=w[i];j--)
	dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
	cout<<dp[W];
	cout<<"\n"; 
 } 
}


Measured memory_bytes: 1024
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();
		sc.close();

		int fromN = N * (N - 1) / 2;
		int fromM = M * (M - 1) / 2;
		System.out.println(fromN + fromM);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
void solve(){
  #ifndef ONLINE_JUDGE    
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}
struct ans{
 ll cost; 
 vector<ll> price; 
};
signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    //*comment for all except cc/cf   
    ll n,m,x;
    cin>>n>>m>>x; 
    struct ans p[n];
    for(ll i=0;i<n;i++){
      ll cst,a; 
      cin>>cst;
      p[i].cost=cst;
      for(ll j=0;j<m;j++){
        cin>>a; 
        p[i].price.pb(a);
      }
    }
    ll ans=INT_MAX;
    for(ll k=0;k<(1<<n);k++){
      ll u[m];
      fill(u,0);
      ll c=0;
      for(ll i=0;i<n;i++){
        if((k>>i)&1){
          c+=p[i].cost; 
          for(ll h=0;h<m;h++){
            u[h]+=p[i].price[h]; 
          }
        } 
      }
      bool ok=1;
      for(ll h=0;h<m;h++){
        if(u[h]<x) { ok=0; break;}
      }
      if(ok==1) ans=min(ans,c); //cout<<ans<<" @$$@ "<<c<<endl; 
    }
      if(ans==INT_MAX) cout<<-1<<endl; 
      else cout<<ans<<endl; 
    //printclock;
    return 0;
}
    

Measured memory_bytes: 3664
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

double DP[305][305][305], N;
bool visited[305][305][305];

double Calc(int i, int j, int k){
  if (i < 0 || j < 0 || k < 0) return 0;
  if (visited[i][j][k]) return DP[i][j][k];

  if (i == 0 && j == 0 && k == 0) return 0;

  visited[i][j][k] = true;
  double ans = 0;
  double I = i, J = j, K = k;

  ans += Calc(i - 1, j, k) * I / (I + J + K);
  ans += Calc(i + 1, j - 1, k) * J / (I + J + K);
  ans += Calc(i, j + 1, k - 1) * K / (I + J + K);
  ans += N / (I + J + K);

  return DP[i][j][k] = ans;
}

int main(){
  cin >> N;
  int A = 0, B = 0, C = 0;
  for (int i = 0; i < N; i++){
    int a; scanf("%d", &a);
    if (a == 1) A++;
    else if (a == 2) B++;
    else if (a == 3) C++;
  }
  printf("%.8lf\n", Calc(A, B, C));

  return 0;
}


Measured memory_bytes: 246016
#include<iostream>
using namespace std;
int main()
{
   int H,W,sum=0,j;
   char a[60][60];
   while(cin>>H>>W)
    {
    int i,j;
      for(i=1;i<=H;i++)
      for(j=1;j<=W;j++)
      cin>>a[i][j];
      for(i=1;i<=H;i++)
      for(j=1;j<=W;j++)
      {
         if(a[i][j]=='#')
         cout<<a[i][j];
         else
         {
            if(a[i-1][j-1]=='#') sum++;
            if(a[i-1][j]=='#')  sum++;
            if(a[i-1][j+1]=='#') sum++;
            if(a[i+1][j]=='#') sum++;
            if(a[i+1][j-1]=='#') sum++;
            if(a[i+1][j+1]=='#') sum++;
            if(a[i][j-1]=='#') sum++;
            if(a[i][j+1]=='#') sum++;
            cout<<sum;
         }
         sum=0;
       if(j == W)
        cout<<endl;
      }
    }
   return 0;
}


Measured memory_bytes: 256
N = int(input())
la = list(map(int, input().split()))

lv = list()
l9 = list()

for i in range(N):
    if 1 <= la[i] <= 399:
        if 1 not in lv:
            lv.append(1)
    if 400 <= la[i] <= 799:
        if 2 not in lv:
            lv.append(2)
    if 800 <= la[i] <= 1199:
        if 3 not in lv:
            lv.append(3)
    if 1200 <= la[i] <= 1599:
        if 4 not in lv:
            lv.append(4)
    if 1600 <= la[i] <= 1999:
        if 5 not in lv:
            lv.append(5)
    if 2000 <= la[i] <= 2399:
        if 6 not in lv:
            lv.append(6)
    if 2400 <= la[i] <= 2799:
        if 7 not in lv:
            lv.append(7)
    if 2800 <= la[i] <= 3199:
        if 8 not in lv:
            lv.append(8)
    if la[i] >= 3200:
        l9.append(9)

print(max(len(lv), 1), len(lv)+len(l9))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n,a;
    bool f=true;
    in>>n;
    fr(i,n){
        in>>a;
        if(a%2==0&&a%3&&a%5) f=false;
    }
    puts(f?"APPROVED":"DENIED");
}

Measured memory_bytes: 256
<?php

$args = [];
$input = explode(' ', trim(fgets(STDIN)));

$expend = (int)$input[0];
$count = (int)$input[1];

while(true){
	$input = explode(' ', trim(fgets(STDIN)));
	foreach ($input as $value) {
		if ($value !== '') {
			$args[] = $value;
		}
		if (count($args) >= $count) {
			break;
		}
	}
	if (count($args) >= $count) {
		break;
	}
}
sort($args);
$c = count($args);

while (true) {
	$str = (string)$expend;
	$flg = true;
	for ($i=0; $i < $c; $i++) { 
		if (strpos($str, $args[$i]) === false) {
			continue;
		}else{
			$flg = false;
			$expend = $expend + 1;
			break;
		}
	}
	if ($flg) {
		break;
	}
}
echo $expend;


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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<string> s(n);
  for (auto&& e : s) {
    cin >> e;
  }
  vector<int> li, mi, ri;
  vector<int> h(n);
  for (int i = 0; i < n; ++i) {
    int t = 0, mn = 0;
    for (char c : s[i]) {
      if (c == '(') {
        ++t;
      } else {
        --t;
      }
      mn = min(mn, t);
    }
    if (t > 0) {
      li.push_back(i);
      h[i] = -mn;
    } else if (t < 0) {
      ri.push_back(i);
      h[i] = t - mn;
    } else {
      mi.push_back(i);
    }
  }
  sort(begin(li), end(li), [&](int i, int j) {
    return h[i] < h[j];
  });
  sort(begin(ri), end(ri), [&](int i, int j) {
    return h[i] > h[j];
  });
  string all;
  for (int i : li) {
    all += s[i];
  }
  for (int i : mi) {
    all += s[i];
  }
  for (int i : ri) {
    all += s[i];
  }
  int t = 0;
  for (char c : all) {
    if (c == '(') {
      ++t;
    } else {
      --t;
    }
    if (t < 0) {
      cout << "No\n";
      exit(0);
    }
  }
  cout << (t ? "No\n" : "Yes\n");
}


Measured memory_bytes: 45544
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;
const int mod = 1e9 + 7;

lint fact[5005], invf[5005];
lint dp[2505][5005];

lint ipow(lint x, lint p){
	lint ret = 1, piv = x % mod;
	while(p){
		if(p&1) ret *= piv;
		piv *= piv;
		ret %= mod;
		piv %= mod;
		p >>= 1;
	}
	return ret % mod;
}

lint bino(int x, int y){
	if(x < y) return 0;
	return fact[x] * (invf[y] * invf[x-y] % mod) % mod;
}

int n, a, b, c;

int main(){
	cin >> n >> a >> b >> c;
	if(b % 2 == 1){
		cout << 0 << endl;
		return 0;
	}
	b /= 2;
	fact[0] = invf[0] = 1;
	for(int i=1; i<=n; i++){
		fact[i] = fact[i-1] * i % mod;
		invf[i] = ipow(fact[i], mod - 2);
	}
	lint ret = 0;
	dp[0][0] = 1;
	for(int i=1; i<=b; i++){
		lint sum = 0;
		for(int j=0; j<=c; j++){
			sum += dp[i-1][j];
			sum %= mod;
			dp[i][j] = sum;
		}
	}
	for(int j=0; j<=c; j++){
		for(int k=0; k<=a; k++){
			if((c - j - k) >= 0 && (c - j - k) % 3 == 0){
				int cnt = (c - j - k) / 3;
				ret += dp[b][j] * ((bino(a, k) * bino(a + cnt + b, a + cnt) % mod) * bino(a + cnt, a) % mod);
				ret %= mod;
			}
		}
	}
	cout << ret << endl;
}


Measured memory_bytes: 17792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[1000000];
vector<char> va;
vector<char> vb;
int main(void)
{
	scanf(" %s",s);
	ll q;
	scanf("%lld",&q);
	ll ti,fi;
	char ch;
	ll rev1=1,rev2=1,rev3=1;
	for(ll i=0;i<q;i++)
	{
		scanf("%lld",&ti);
//		printf("--%lld--\n",rev1);
		if(ti==1)
		{
			rev1*=-1;
		}
		else
		{
			scanf("%lld",&fi);
			scanf(" %c",&ch);
			if(fi==1)
			{
				if(rev1==1)
				{
					va.push_back(ch);
				}
				else
				{
					vb.push_back(ch);
				}
			}
			else
			{
				if(rev1==1)
				{
					vb.push_back(ch);
				}
				else
				{
					va.push_back(ch);
				}
			}
		}
	}
	if(rev1==1)
	{	
		for(ll i=va.size()-1;i>=0;i--)
		{
			printf("%c",va[i]);
		}
		printf("%s",s);
		for(ll i=0;i<vb.size();i++)
		{
			printf("%c",vb[i]);
		}
	}
	else
	{
		for(ll i=vb.size()-1;i>=0;i--)
		{
			printf("%c",vb[i]);
		}
		for(ll i=strlen(s)-1;i>=0;i--)
		{
			printf("%c",s[i]);
		}		
		for(ll i=0;i<va.size();i++)
		{
			printf("%c",va[i]);
		}
	}
}

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

#define int long long

main()
{
  int a, b;
  
  cin >> a >> b;

  if(abs(a - b) <= 1) {
    cout << "Brown" << endl;
  } else {
    cout << "Alice" << endl;
  }

  return (0);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    long a[3]={0};
    long i;
    for(i=0; i<n; i++) {
        long x;
        scanf("%ld", &x);
        if(x%4==0) a[0]++;
        else if(x%2!=0) a[1]++;
        else a[2]++;
    }
    if(a[1] > a[0]+1) {
        printf("No\n"); return 0;
    }
    else if (a[1] == a[0]+1) {
        if(a[2]>0) {
            printf("No\n"); return 0;
        }
    }

    printf("Yes\n");

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
using namespace std;

int main(){
  string S;
  cin >> S;
  string x,y;
  x += S.at(0);
  x += S.at(1);
  y += S.at(2);
  y += S.at(3);
  int xx = stoi(x);
  int yy = stoi(y);
  if((1 <= xx && xx <= 12) && (1 <= yy && yy <= 12)){
    cout << "AMBIGUOUS" << endl;
  }else if(1 <= xx && xx <= 12){
    cout << "MMYY" << endl;
  }else if(1 <= yy && yy <= 12){
    cout << "YYMM" << endl;
  }else{
    cout <<"NA" << endl;
  }
}


Measured memory_bytes: 3616
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<cassert>
#include<sstream>
#include<numeric>
#include<iostream>
#include<algorithm>
#include<functional>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> Vi;
typedef pair<int,int> pii;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=200000+19;
const int oo=(1<<30)-1;
const int p=1e9+7;

struct node{
	int x,v;
	bool operator < (const node &B) const{
		return v<B.v;
	}
} A[N];

struct seg{
	int L,R;
	bool operator < (const seg &B) const{
		return R<B.R||R==B.R&&L<B.L;
	}
} S[N];

int dp[N],sum[N];
int stk[N];
int n,top,m;

int main(){
	n=IN();
	For(i,1,n+1) A[i]=(node){IN(),IN()};
	sort(A+1,A+n+1);
	for (int i=n;i;i--){
		if (!top||A[i].x<=A[stk[top]].x) stk[++top]=i;
		int l=1,r=top;
		while (l<=r){
			int mid=(l+r)/2;
			if (A[stk[mid]].x<=A[i].x) S[i].R=stk[mid],r=mid-1;else l=mid+1;
		}
	}
	top=0;
	for (int i=1;i<=n;i++){
		if (!top||A[i].x>=A[stk[top]].x) stk[++top]=i;
		int l=1,r=top;
		while (l<=r){
			int mid=(l+r)/2;
			if (A[stk[mid]].x>=A[i].x) S[i].L=stk[mid],r=mid-1;else l=mid+1;
		}
	}
	m=n;
	S[++m]=(seg){n+1,n+1};
	S[++m]=(seg){0,0};
	sort(S+1,S+m+1);
	dp[1]=1;
	sum[1]=1;
	For(i,2,m+1){
		int l=1,r=i-1,res=i;
		while (l<=r){
			int mid=(l+r)/2;
			if (S[mid].R+1>=S[i].L) res=mid,r=mid-1;else l=mid+1;
		}
		dp[i]=(sum[i-1]-sum[res-1]+p)%p;
		sum[i]=(sum[i-1]+dp[i])%p;
	}
	printf("%d\n",dp[m]);
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int x, a, b;
  cin >> x >> a >> b;
  int aa, bb;
  aa = x - a;
  if(aa < 0) aa *= -1;
  bb = x - b;
  if(bb < 0) bb *= -1;
  if(aa < bb)
  {
    cout << "A" << endl;
  }
  else
  {
    cout << "B" << endl;
  }
}

Measured memory_bytes: 256
a, b, c, d = map(int, input().split())
n = int(input())

A = [4*a, 2*b, c]
t = 0
if min(A) * 2 > d:
    t = n//2 * d
    n = n - (n//2)*2

t += n * min(A)

print(t)

Measured memory_bytes: 38256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int x, y;
    cin >> x >> y;
    int kane = max(0, 100000 * (4-x)) + max(0, (100000*(4-y)));
    if(x == 1 && y == 1)
        kane += 400000;
    cout << kane << endl;

    return 0;
}

Measured memory_bytes: 256