akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld pi=3.141592653589793238;



signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll K;
    cin >> K;
    deque<P> vec;
    for(ll i=0;i<N;++i){
        ll a;
        cin >> a;
        ll b;
        cin >> b;
        vec.emplace_back(P(a,b));
    }
    sort(vec.begin(), vec.end());
    ll num=0;ll ans=0;
    while(num<K){
        num+=vec[0].second;
        ans=vec[0].first;
        vec.pop_front();
    }
    prt(ans)fl


    return 0;
}


Measured memory_bytes: 1920
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll int MOD=1e9+7;
#define INF 2*1e9
#define N 310000 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

struct tree{
    int num,rank,max,min,sta,par;
};
tree t[110000];
vector<int> v[110000];
vector<int> s[110000];
int m;
void dfs(int a,int b,int r){
    t[a].rank=r;
    t[a].par=b;
    s[r].pb(a);
    if(m<r) m=r;
    rep(i,v[a].size()){
        if(v[a][i]!=b) dfs(v[a][i],a,r+1);
    }
}
int main(){
    int n;
    cin>>n;
    rep2(i,1,n-1){
        int a,b;
        cin>>a>>b;
        v[a].pb(b);v[b].pb(a);
    }
    int p;
    cin>>p;
    int aaa,bbb;
    cin>>aaa>>bbb;
    t[aaa].sta=1;
    t[aaa].num=bbb;
    dfs(aaa,0,0);
    rep2(i,1,p-1){
        int a,b;
        cin>>a>>b;
        t[a].num=b;t[a].sta=1;
        if((abs(b-bbb)^t[a].rank)%2==1){
            cout<<"No"; return 0;
        }
    }
    rep2(i,1,n){
        if(t[i].sta){
          t[i].max=t[i].min=t[i].num;
        }
        else{
        t[i].max=INF;
        t[i].min=-INF;
        }
    }
    for(int i=m;i>=0;i--){
        rep(j,s[i].size()){
            int temp=s[i][j];
            rep(k,v[temp].size()){
                int now=v[temp][k];
                if(t[temp].rank>t[now].rank) continue;
                t[temp].min=max(t[temp].min,t[now].min-1);
                t[temp].max=min(t[temp].max,t[now].max+1);
            }
        }
    }
    rep(i,m+1){
        rep(j,s[i].size()){
            int temp=s[i][j];
            if(t[temp].sta){
                if(t[temp].min>t[temp].num||t[temp].max<t[temp].num){
                    cout<<"No";return 0;
                }
            }
            else{
                if(t[temp].min>t[temp].max){
                    cout<<"No";return 0;
                }
                int pnum=t[t[temp].par].num;
                if(pnum+1<=t[temp].max){
                    t[temp].num=pnum+1;
                }
                else if(pnum-1>=t[temp].min){
                    t[temp].num=pnum-1;
                }
                else{
                    cout<<"No";return 0;
                }
            }
        }
    }
    cout<<"Yes"<<endl;
    rep2(i,1,n){
        cout<<t[i].num<<endl;
    }
    return 0;
}



Measured memory_bytes: 19328
N = int(input())
S = []
for i in range(N):
    S.append(int(input()))
    
S = sorted(S)
# print(S)

sum_S = sum(S)

if sum_S % 10 != 0:
    print(sum_S)
else:
    for i in range(N):
        if S[i] % 10 != 0:
            sum_S -= S[i]
            break
    if sum_S % 10 != 0:
        print(sum_S)
    else:
        print(0)

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

#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define FILL0(x) memset(x,0,sizeof(x))
#define FILL1(x) memset(x,-1,sizeof(x))

using namespace std;

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 

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

    int n, k;
    cin >> n >> k;

    ll a[n];
    rep(i, n)
    {
        cin >> a[i];
    }
/*
    ll score[n];
    score[k-1]=1;
    rep(i, k)
    {
        score[k-1]*=a[i];
    }
    
    for(int i=k; i<n; i++)
    {
        score[i]=score[i-1]/a[i-k]*a[i];
    }
*/
    for(int i=k; i<n; i++)
    {
        if(a[i-k]<a[i])
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
        
    }





    return 0;

}



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

#define pq priority_queue
#define mp make_pair
#define cauto const auto &

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar, val) memset(ar, val, sizeof(ar))

typedef long long int64;
typedef long long lint;
typedef long long lli;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;

typedef pair<int, int> pint;
typedef pair<long, long> plong;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T = int> T in() {
    T x;
    cin >> x;
    return (x);
}
template <class T> void print(T &x) {
    cout << x << '\n';
    return;
}

template <class T> ll sized_subset(T &comb) {
    T x = comb & -comb, y = x + comb;
    return ((comb & ~y) / x) >> 1 | y;
}

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

int main() {
    int n = in();
    double x,ans=0;
    string u;
    REP(i, n) {
        cin>>x>>u;
        if(u=="JPY"){ans+=x;}
        else{ans+=x*380000.0;}
    }
    printf("%lf\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int N, M;
    cin >> N >> M;
    ll y, P[M], tmp;
    map<ll, int> pref;
    map<ll , int> mp;
    for(int i=0;i<M;i++){
        cin >> P[i] >> y;
        pref[P[i]] = 0;
        mp[y] = i;
    }
    
    for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
        tmp = P[itr->second];
        P[itr->second] =tmp * 1000000 + pref[tmp] + 1;
        pref[tmp]++;
    }
    for(int i=0;i<M;i++){
        cout << setw(12) << setfill('0') << P[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 14720
#include <bits/stdc++.h>
#define cmax(a,b) (a<(b)?a=(b):a)
#define cmin(a,b) (a>(b)?a=(b):a)
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
using namespace std; 

#define Pr(f,...) //printf(f,##__VA_ARGS__),fflush(stdout)

typedef long long ll;

const int K=60;

int main(){
#ifdef CURIOUSCAT 
	//freopen("dat.in","r",stdin);
#endif	
	ll A,B,T=0,Q,ans;
	cin>>A>>B;
	if(A==B){ return puts("1"),0; }
	dec(k,K-1,0)if((A>>k&1)^(B>>k&1)){
		T=1ll<<k;
		A&=T-1;
		B&=T+T-1;
		break;
	}
	ans=T-A;
	for(Q=T>>1;Q;Q>>=1)if(B&Q)break;
	ll l1=T,r1=Q?T+Q+Q-1:T;
	ll l2=T+A,r2=T+T-1;
	if(r1<l2)ans+=r1-l1+1+r2-l2+1;
	else ans+=r2-l1+1;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
/*
                 ,,ggddY888Ybbgg,,
          ,agd8""'   .d8888888888bga,
       ,gdP""'     .d88888888888888888g,
     ,dP"        ,d888888888888888888888b,
   ,dP"         ,8888888888888888888888888b,
  ,8"          ,8888888P"""88888888888888888,
 ,8'           I888888I    )88888888888888888,
,8'            `8888888booo8888888888888888888,
d'              `88888888888888888888888888888b
8                `"8888888888888888888888888888
8                  `"88888888888888888888888888
8                      `"8888888888888888888888
Y,                        `8888888888888888888P
`8,                         `88888888888888888'
 `8,              .oo.       `888888888888888'
  `8a             8888        88888888888888'
   `Yba           `""'       ,888888888888P'
     "Yba                   ,88888888888'
       `"Yba,             ,8888888888P"'
          `"Y8baa,      ,d88888888P"'
               ``""YYba8888P888"'
*/
using namespace std;
#define int long long
#define KOD ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;
#define sz size()
#define S second
#define X(a,b) a = ((b) > (a)) ? (b) : (a);
#define N(a,b) a = ((b) > (a)) ? (a) : (b);
#define F first
#define SORT(x) sort(x.begin(),x.end())
#define Rev(a) reverse(a.begin() , a.end());
#define pb push_back
#define pre(x) cout.precision(0);
#define bit(x) __builtin_popcount(x)
#define is(a) insert(a);
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef unordered_map<int,int> wi;
typedef unordered_set<int> si;
const int M = 1e5+2;
const int inf = 1e18;
main(){
	int a , b , c , d;
	cin >> a >> b >>c >> d;
	int h = 0; 
	while(a > 0 && c > 0){
		c -= b;
		if(c <= 0) {
			return cout << "Yes" , 0 ;
		}
		a -= d;
		if(a <= 0 ){
			return cout << "No" , 0 ;
		}
	}
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << endl
#define RETURN(x)    \
  cout << x << endl; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << endl
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll N;
  cin >> N;
  vll A(N);
  vll B(N);
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> B[i];

  ll ans = 0;
  rep(i, N) {
    ll count = 0;
    rep(j, i + 1) {
      count += A[j];
    }
    rep2(k, i, N) {
      count += B[k];
    }
    ans = max(ans, count);
  }
  ANS;

  return 0;
}

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

using namespace std;
const int maxn=5e3+5;
int n,m;
int dp[maxn];
int c[maxn];
int ans;
int main(){
	scanf("%d%d",&n,&m);
	for (int i = 1 ; i <= n/2; i++)
		c[i] = i - 1 + 1;
	for (int i = n-1 ; i > n/2; i--)
		c[i] = n - i + 1;
	dp[0]=1;
	for (int i=1;i<=n-1;i++){
		for (int j=c[i];j<n;j++){
			dp[j]+=dp[j-c[i]];
			if (dp[j] >= m)
				dp[j] -= m;
		}
	}
	for (int i=0;i<n;i++){
		ans +=1ll * dp[i] * (n - i) % m;
		if (ans >= m)
			ans -= m;
	}
	cout << ans << '\n';
	
	
	
}

Measured memory_bytes: 256
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = new Date();
  Main();
  var end = new Date() - start;
  
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	if(N % 2 == 1){
		N *= 2;
	}
	myout(N);
}


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

int main() {
    /*変数定義，入力*/
    int N;
    cin >> N;
    int count = 1;
    //int A, B;cin >> A >> B;
    vector<char> s(N);  rep(i, N) cin >> s[i];
    
    /*演算*/
    for(int i = 0; i < N - 1; i++){
        if(s.at(i) != s.at(i+1)) count++;
    }

    /*出力*/
    cout << count << endl;

    /*終了*/
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

I mass[1000000];
int main(){
    CIN(N);CIN(M);
    REP(a,M){
        CIN(b);CIN(c);
        mass[b-1].pb(a);
        mass[c-1].pb(a);
    }
    set<int> se;
    LL ans = 0;
    REP(a,N){
        REP(b,mass[a].size()){
            if(se.find(mass[a].at(b)) != se.end()){
               ans++;
               se.clear();
            }
        }
        REP(b,mass[a].size()){
            se.insert(mass[a].at(b));
        }
    }
    COUT(ans);
    return 0;
}


Measured memory_bytes: 29564
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input().rstrip())
    W = []
    for i in range(N):
        W.append(input().rstrip())
        
    for i in range(1,N):
        if W[i][0] != W[i-1][-1]:
            print('No')
            return
        if W[i] in W[0:i-1]:            
            print('No')
            return            
    print('Yes')
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
string s;
bool yes = true;
int main() {

	cin >> s;
	for(int i = 0; i < s.size(); i++) {
		if (i % 2 == 0 && s[i] != 'R' && s[i] != 'U' && s[i] != 'D') {
			yes = false;
			break;
		}
		if (i % 2 == 1 && s[i] != 'L' && s[i] != 'U' && s[i] != 'D') {
			yes = false;
			break;
		}
	}
	if (yes)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	fclose(stdin);
	fclose(stdout);
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N,M = list(map(int, input().rstrip().split()))
a_list = [int(input().strip()) for _ in range(M)]
#-----

step = [1,1] + ["x"]*(N-1)

for i in a_list:
    step[i] = 0

for i in range(2,N+1):
    if step[i] == "x":
        step[i] = ( step[i-1] + step[i-2] ) % (10**9 + 7)

print(step[N])


Measured memory_bytes: 8592
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int>P;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n,m;
const int Maxn=2e5+5;
vector<int>G[Maxn];
int pre[Maxn];
void bfs(){
	memset(pre,-1,sizeof(pre));
	queue<int>q;
	q.push(1);
	while(!q.empty()){
		int u=q.front();q.pop();
		rep(i,SZ(G[u])){
			int to=G[u][i];
			if(pre[to]==-1){
				pre[to]=u;
				q.push(to);
			}
		}
	}
}
int main(){
	cin>>n>>m;
	rep(i,m){
		int u,v;
		cin>>u>>v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	bfs();
	bool ok=true;
	for(int i=2;i<=n;i++){
		if(pre[i]==-1){
			ok=false;
			break;
		}
	}
	if(!ok){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	for(int i=2;i<=n;i++){
		cout<<pre[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 13252
#include<cstdio>
const int N=100010;
int a[N],n;
long long l=2,r=2;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=n;i>=1;i--){
		l=1ll*a[i]*((l+a[i]-1)/a[i]);
		r=1ll*a[i]*((r+a[i])/a[i])-1;
		//printf("%lld %lld\n",l,r);
		if(r<l){puts("-1");return 0;}
	}
	printf("%lld %lld\n",l,r);
	return 0;
}

Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		Graph g = new Graph(n);
		for(int i=0;i<m;i++) {
			String[] s = sc.next().split(",");
			int a = Integer.valueOf(s[0]) - 1;
			int b = Integer.valueOf(s[1]) - 1;
			int c = Integer.valueOf(s[2]);
			int d = Integer.valueOf(s[3]);
			g.addEdge(a, b, c);
			g.addEdge(b, a, d);
		}
		String[] s = sc.next().split(",");
		int x1 = Integer.valueOf(s[0]) - 1;
		int x2 = Integer.valueOf(s[1]) - 1;
		int y1 = Integer.valueOf(s[2]);
		int y2  = Integer.valueOf(s[3]);
		System.out.println(y1-y2-g.minDistDijkstra(x1)[x2]-g.minDistDijkstra(x2)[x1]);
	}

}
class Graph {
	public static final int INF = 1<<29;
	int n;
	ArrayList<Edge>[] graph;

	@SuppressWarnings("unchecked")
	public Graph(int n) {
		this.n = n;
		this.graph = new ArrayList[n];
		for(int i=0;i<n;i++) {
			graph[i] = new ArrayList<Edge>();
		}
	}

	public void addBidirectionalEdge(int from,int to,int cost) {
		addEdge(from,to,cost);
		addEdge(to,from,cost);
	}
	public void addEdge(int from,int to,int cost) {
		graph[from].add(new Edge(to, cost));
	}

	//dijkstra O(ElogV)
	public int[] minDistDijkstra(int s) {
		int[] dist = new int[n];
		Arrays.fill(dist, INF);
		dist[s] = 0;
		PriorityQueue<Node> q = new PriorityQueue<Node>();
		q.offer(new Node(0, s));
		while(!q.isEmpty()) {
			Node node = q.poll();
			int v = node.id;
			if (dist[v] < node.dist) {
				continue;
			}
			for(Edge e:graph[v]) {
				if (dist[e.to] > dist[v] + e.cost) {
					dist[e.to] = dist[v] + e.cost;
					q.add(new Node(dist[e.to], e.to));
				}
			}
		}
		return dist;
	}

	class Edge {
		int to;
		int cost;
		public Edge(int to,int cost) {
			this.to = to;
			this.cost = cost;
		}
	}
	class Node implements Comparable<Node>{
		int dist;
		int id;
		public Node(int dist,int i) {
			this.dist = dist;
			this.id = i;
		}
		public int compareTo(Node o) {
			return (this.dist < o.dist) ? -1 : ((this.dist == o.dist) ? 0 : 1);
		}
	}
}

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

int main() {
  string s;
  string ans = "Yes";
  
  cin >> s;
  for(int i=0; i<s.length(); i++){
    if(i%2==0 && s[i]=='L'){
      ans="No";
    }
    if(i%2==1 && s[i]=='R'){
      ans="No";
    }
  }
  cout << ans <<endl;
  return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
ab=list(list(map(int,input().split())) for _ in range(M))
graph=list([0]*N for _ in range(N))
ans=0
for a,b in ab:
    graph[a - 1][b - 1] = 1
    graph[b - 1][a - 1] = 1

def dfs(s):
    visited[s]=1
    for i in range(N):
        if graph[s][i] == 0 or visited[i] == 1:
            continue
        dfs(i)

for a,b in ab:
    graph[a - 1][b - 1] = 0
    graph[b - 1][a - 1] = 0
    visited=[0]*N
    dfs(0)
    graph[a - 1][b - 1] = 1
    graph[b - 1][a - 1] = 1
    if sum(visited)<N:
        ans+=1


print(ans)

Measured memory_bytes: 41308
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

class SegmentTree:
  __slots__ = ['ide','n','seg','segfunc']

  def __init__(self,size,func,element):
    self.segfunc = func
    self.ide = element
    # self.size = sizeを超える最小の2冪の数
    self.n = 2 ** (n-1).bit_length()
    # 全てのnodeの数は(2*n-1)個
    # 上にn-1個,最下段にn個
    self.seg = [self.ide] * (2*self.n-1)

  def apply(self,array):
    arraysize = len(array)
    # 配列埋め込み
    for i in range(arraysize):
      self.seg[self.n-1+i] = array[i]
    # 上にあげる
    for i in range(self.n-2,-1,-1):
      self.seg[i] = self.segfunc(self.seg[2*i+1],self.seg[2*i+2])

  def update(self,k,x):
    k += self.n -1
    self.seg[k] = x
    while k:
      k = (k-1)//2
      self.seg[k] = self.segfunc(self.seg[2*k+1],self.seg[2*k+2])

  def notrec(self,l,r):
    # 半開区間[l,r)
    l += self.n-1; r += self.n-1
    vl = vr = self.ide
    while l < r:
      if l & 1 == 0:
        vl = self.segfunc(vl,self.seg[l])
        l += 1
      if r & 1 == 0:
        vr = self.segfunc(vr,self.seg[r-1])
      l = (l-1)//2; r = (r-1)//2
    return self.segfunc(vl,vr)

def makebin(s):
  k = ord(s)-ord("a")
  # print(1<<k,k)
  return 1 << k

def segfunc(a,b):
  return a | b

def out(n):
  count = 0
  while n:
    if n & 1 == 1:
      print(chr(ord("a")+count))
    n//=2
    count += 1

n = int(input())
st = SegmentTree(n,segfunc,0)
S = input()
for i,si in enumerate(S):
  st.update(i,makebin(si))
Q = int(input())
# print(st.seg)
# exit()
for _ in range(Q):
  typo,a,b = input().split()
  if typo == "1":
    st.update(int(a)-1,makebin(b))
  else:
    print(bin(st.notrec(int(a)-1,int(b)))[1:].count("1"))


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

int main(){
    int n, t;
    scanf("%d", &n);
    vector <int> a;
    for(int i = 0; i < n; i++){
        scanf("%d", &t);
        a.push_back(t);
    }
    sort(a.begin(), a.end());
    float start = a[0];
    for(int i = 1; i < n; i++){
        start = (start + a[i]) / 2.;
    }
    printf("%.5f", start);

    return 0;
}


Measured memory_bytes: 3812
n = int(input())
s = [input() for i in range(n)]
alpha = [chr(i) for i in range(97,123)]
moji = []
ans = ''

for i in alpha:
  c = 10**10
  for j in s:
    c = min(c,j.count(i))
  moji.append(c)


for k in range(len(alpha)):
  ans += alpha[k]*moji[k]
  
print(ans)

Measured memory_bytes: 3064
let a, b, k = Scanf.scanf " %d %d %d" @@ fun a b c -> a, b, c
let ns = [|a; b|]
let _ =
  for i = 0 to k - 1 do
    let r = i mod 2 in
    if ns.(r) mod 2 = 1 then ns.(r) <- ns.(r) - 1; ns.(1 - r) <- ns.(1 - r) + ns.(r) / 2; ns.(r) <- ns.(r) / 2 done;
  Printf.printf "%d %d\n" ns.(0) ns.(1)

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

int n,m,q;
vector<int> a,b,c,d;
int ans;

void dfs(vector<int> A){
    if(A.size() == n+1){
        int now = 0;
        rep(i,q){
            if(A[b[i]] - A[a[i]] == c[i]) now += d[i];
        }
        ans = max(ans,now);
        return;
    }
    A.push_back(A.back());
    while(A.back() <= m){
        dfs(A);
        A.back()++;
    }
}

int main(){
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    rep(i,q) cin >> a[i] >> b[i] >> c[i] >> d[i];
    dfs(vector<int>(1,1));
    cout << ans << endl;
}

Measured memory_bytes: 3572
#include <iostream>
  #include <complex>
  #include <vector>
  #include <string>
  #include <algorithm>
  #include <cstdio>
  #include <numeric>
  #include <cstring>
  #include <ctime>
  #include <cstdlib>
  #include <set>
  #include <map>
  #include <unordered_map>
  #include <unordered_set>
  #include <list>
  #include <cmath>
  #include <bitset>
  #include <cassert>
  #include <queue>
  #include <stack>
  #include <deque>
 #include <iomanip>

  using namespace std;
   

//abcdefghijklmnopqrstuvwxyz
//ABCDEFGHIJKLMNOPQRSTUVWXYZ
  typedef long long ll;
  typedef long double lld;
  typedef string str;
  typedef unsigned long long ull;
  ll INF = INT_MAX;
  ll mod = 998244353;
  lld PI = 3.141592653;

// const int N = 2e5 + 5;

// int a[N];
// int n,k;



// void solve(){

// string s;
// cin>>s;


// }

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

  int n;
  cin>>n;
  map<string, int> a;
  // a["AC"] = 0;
  // a["WA"] = 1;
  // a["TLE"] = 2;
  // a["RE"] =3;
  string s;
  while(n--){
    cin>>s;
    a[s]++;
  }
  cout<<"AC x "<<a["AC"]<<"\n";
  cout<<"WA x "<<a["WA"]<<"\n";
  cout<<"TLE x "<<a["TLE"]<<"\n";
   cout<<"RE x "<<a["RE"]<<"\n";
}



Measured memory_bytes: 3192
def BFS(s = 0):
    Q.pop(0)
    color[s] = 2
    for j in range(len(color)):
        if A[s][j] == 1 and color[j] == 0:
            Q.append(j)
            color[j] = 1
            d[j] = d[s] + 1
    if len(Q) != 0:
        BFS(Q[0])

n = int(raw_input())
A = [0] * n
for i in range(n):
    A[i] = [0] * n

for i in range(n):
    value = map(int, raw_input().split())
    u = value[0] - 1
    k = value[1]
    nodes = value[2:]
    for j in range(k):
        v = nodes[j] - 1
        A[u][v] = 1

color = [0] * n
Q = [0]
d = [-1] * n
d[0] = 0

BFS(0)

for i in range(n):
    print(str(i + 1) + " " + str(d[i]))

Measured memory_bytes: 6476
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

const ll MAX = 1e7;
const ll MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

int main(){
    ll x, y;
    cin >> x>> y;
    if( (2*x - y)%3 != 0 || (-x + 2*y)%3 !=0 || -x+2*y < 0 || -y+2*x < 0){
        cout << 0 << "\n"; return 0;
    }
    ll n = (2*x - y)/3, m = (-x + 2*y)/3;
    COMinit();
    cout << fac[n+m]*(finv[n]*finv[m] % MOD) % MOD<<"\n";
  return 0;
}

//151840682



Measured memory_bytes: 234624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e7+5;
int main() {
    ll a,b;
    cin>>a>>b;
    if(a==1||b==1)
        cout<<1<<endl,exit(0);
    ll p= a%2?a/2+1:a/2,q=a/2;
    if(b%2==0)
        cout<<(p+q)*(b/2)<<endl;
    else
        cout<<(p+q)*(b/2)+p<<endl;
}


Measured memory_bytes: 256
fun main (args:Array<String>){
    val num = readLine()!!.toInt()
    var strAlpha = readLine()!!
    val alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    for(i in 0..strAlpha.length-1){
        var strAlphaIndex = alpha.indexOf(strAlpha[i]) + num
        if(strAlphaIndex > 25){
            print(alpha[strAlphaIndex - 26])
            continue
        }
        print(alpha[strAlphaIndex])
    }
}

Measured memory_bytes: 38648
#include <bits/stdc++.h>
#define int long long
#define double long double
#define sqr(x) (x) * (x)
using namespace std;
const int Nmax = 2e5 + 5;

int dp[Nmax];
int a[Nmax];
int id[Nmax];
int n,m,k;

double x[Nmax];

double inter(int i, int j)
{
    return 1.0L * (dp[i] + sqr(a[i]) - dp[j] - sqr(a[j])) / (a[i] - a[j]);
}

bool ok(int i, int j, int k)
{
    return inter(i, k) < inter(j, k);
}

void add(int i)
{
    while (m > 1 && !ok(id[m - 1], id[m], i)) m--;
    id[++m] = i;
    if (m > 1) x[m - 1] = inter(id[m - 1], id[m]);
    x[m] = 1e18;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("file.inp","r",stdin);
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    for (int i = 2, j = 1; i <= n; i++)
    {
        add(i - 1);
        j = min(j, m);
        while (2 * a[i] > x[j]) j++;
        int pre = id[j];
        dp[i] = dp[pre] + sqr(a[i] - a[pre]) + k;
    }
    cout << dp[n];
    return 0;
}


Measured memory_bytes: 11396
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int par[100000];

void init(int n){
    REP(i,n){
        par[i] = i;
    }
}

int find(int x){
    if (par[x] == x){
        return x;
    }else{
        return par[x] = find(par[x]);
    }
}

bool same(int x, int y){
    return find(x) == find(y);
}

void merge(int x, int y){
    x = find(x);
    y = find(y);
    if (x==y) return;
    par[x] = y;
}

struct edge{ int u, v; int cost; };

vector<edge> es;

bool comp(const edge &e1, const edge &e2){
    return e1.cost < e2.cost;
}

int kruskal(int n){
    sort(es.begin(), es.end(), comp);
    init(n);
    int res = 0;
    REP(i,es.size()){
        edge e = es[i];
        if (!same(e.u, e.v)){
            merge(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}

int main() {
	int n;
	cin >> n;
	vector<P> x(n), y(n);
	REP(i,n){
		scanf("%d %d", &x[i].first, &y[i].first);
		x[i].second = y[i].second = i;
	}

	sort(ALL(x));
	sort(ALL(y));

	REP(i,n-1){
		edge e;
		e.u = x[i].second;
		e.v = x[i+1].second;
		e.cost = x[i+1].first - x[i].first;
		es.push_back(e);
		e.u = y[i].second;
		e.v = y[i+1].second;
		e.cost = y[i+1].first - y[i].first;
		es.push_back(e);
	}

	cout << kruskal(n) << endl;

    return 0;
}

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

using namespace std;

int main() {

    vector<pair<string,int>> input;
    map<pair<string,int >,int> index;
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        string s;
        int sc;
        cin >> s >> sc;
        input.push_back({s,sc});
        index[{s,sc}]=i+1;
    }

    sort(input.begin(),input.end(),[&](pair<string,int> a, pair<string,int > b) -> bool {
        if (a.first != b.first) return a.first < b.first;
        return a.second > b.second;
    });

    for(auto i : input){
        //cout << i .first << ' ' << i.second << endl;
        cout << index[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
// 2020-09-17 23:17:20
// clang-format off
#include <bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

// clang-format on
void answer() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  ll ans = 0;
  vector<vector<int> > m(h, vector<int>(w, 0));
  int dx[] = {0, 1, 0, -1};
  int dy[] = {1, 0, -1, 0};
  rep(si, h) rep(sj, w) if (m[si][sj] == 0) {
    queue<P> que;
    que.emplace(si, sj);
    m[si][sj] = 1;
    ll white = 0;
    ll black = 0;
    while (!que.empty()) {
      auto [ci, cj] = que.front();
      que.pop();
      white += (s[ci][cj] == '.');
      black += (s[ci][cj] == '#');
      rep(di, 4) {
        int ni = ci + dx[di];
        int nj = cj + dy[di];
        if (ni < 0 || h <= ni || nj < 0 || w <= nj) continue;
        if (m[ni][nj] == 1) continue;
        if (s[ci][cj] == s[ni][nj]) continue;
        m[ni][nj] = 1;
        que.emplace(ni, nj);
      }
    }
    ans += white * black;
  }
  cout << ans << '\n';
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 4416
require 'set'
 
class Arrow
  attr_reader :source, :sink, :label

  def initialize(source, sink, label)
    @source = source
    @sink = sink
    @label = label
  end
end

def push(queue, key)
  size = queue.size
  index = queue.index{|target, _| target >= key} || size

  return queue[index][1] if index < size && queue[index][0] == key
  return nil if index > 0 && !key.start_with?(queue[index - 1][0])
  queue.slice!(index..-1) if index < size && !queue[index][0].start_with?(key)

  value = {}
  queue.insert(index, [key, value])
  value
end

def calc(n, arrows, start, goal)
  ins = Array.new(n){[]}
  arrows.each do |arrow|
    ins[arrow.sink] << arrow.source
  end

  reachable_from = {}
  stack = [goal]
  until stack.empty?
    node = stack.pop
    reachable_from[node] = true
    ins[node].each do |source|
      stack << source unless reachable_from[source]
    end
  end

  return nil unless reachable_from[start]
  arrows.select!{|arrow| reachable_from[arrow.sink]}

  outs = Array.new(n){[]}
  arrows.each do |arrow|
    outs[arrow.source] << arrow
  end

  max = n * arrows.map{|arrow| arrow.label.size}.max

  queue = [['', {start => true}]]
  until queue.empty?
    spell, map = queue.shift
    return spell if map[goal]

    return nil if spell.size > max

    map.each do |node, _|
      outs[node].each do |arrow|
        t = push(queue, spell + arrow.label)
        t[arrow.sink] = true if t
      end
    end
  end
  nil
end

loop do
  n, a, s, g = gets.split.map(&:to_i)
  break if n == 0

  arrows = (0...a).map do |i|
    x, y, lab = gets.split
    Arrow.new(x.to_i, y.to_i, lab)
  end

  puts calc(n, arrows, s, g) || 'NO'
end

Measured memory_bytes: 10476
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long Int;
typedef pair<Int,Int> P;
typedef pair<Int,P> P2;
const int inf=2147483647;
struct LazySegTree{
private:
  int n;
  vector<Int> node,lazy;
  vector<bool> lazyflag;
public:
  LazySegTree(vector<Int> v){
    int sz=(int)v.size();
    n=1;
    while(n<sz) n*=2;
    node.resize(2*n-1);
    lazy.resize(2*n-1,inf);
    lazyflag.resize(2*n-1,false);

    for(int i=0;i<sz;i++) node[i+n-1]=v[i];
    for(int i=n-2;i>=0;i--) node[i]=min(node[2*i+1],node[2*i+2]);
  }
  void eval(int k,int l,int r){
    if(lazyflag[k]){
      node[k]=lazy[k];
      if(r-l>1){
        lazy[2*k+1]=lazy[k];
        lazy[2*k+2]=lazy[k];
        lazyflag[2*k+1]=true;
        lazyflag[2*k+2]=true;
      }
      lazyflag[k]=false;
    }
  }
  void update(int a,int b,Int x,int k=0,int l=0,int r=-1){
    if(r<0) r=n;
    eval(k,l,r);
    if(b<=l||r<=a) return;
    if(a<=l&&r<=b){
      lazy[k]=x;
      lazyflag[k]=true;
      eval(k,l,r);
    }
    else{
      update(a,b,x,2*k+1,l,(l+r)/2);
      update(a,b,x,2*k+2,(l+r)/2,r);
      node[k]=min(node[2*k+1],node[2*k+2]);
    }
  }
  Int getmin(int a,int b,int k=0,int l=0,int r=-1){
    if(r<0) r=n;
    eval(k,l,r);
    if(r<=a||b<=l) return inf;
    if(a<=l&&r<=b) return node[k];
    return min(getmin(a,b,2*k+1,l,(l+r)/2),getmin(a,b,2*k+2,(l+r)/2,r));
  }
  void debug(){
    for(int i=0;i<node.size();i++) cout<<node[i]<<" ";
    cout<<endl;
    for(int i=0;i<lazy.size();i++) cout<<lazy[i]<<" ";
    cout<<endl;
  }
};
int main(){
  int n,q;
  cin>>n>>q;
  vector<P2> vec;
  vector<Int> comp;
  for(int i=0;i<n;i++){
    Int s,t,x;
    cin>>s>>t>>x;
    comp.push_back(max(s-x,(Int)-1));
    comp.push_back(max(t-x,(Int)0));
    vec.push_back(P2(x,P(s,t)));
  }
  comp.push_back(0);
  comp.push_back(-1);
  comp.push_back(inf);
  sort(vec.begin(),vec.end());
  sort(comp.begin(),comp.end());

  comp.erase(unique(comp.begin(),comp.end()),comp.end());
  //for(int i=0;i<comp.size();i++) cout<<comp[i]<<" ";
  //cout<<endl;
  vector<Int> kv(2*n+50,-1);
  LazySegTree seg=LazySegTree(kv);
  for(int i=vec.size()-1;i>=0;i--){
    Int s=max(vec[i].second.first-vec[i].first,(Int)-1);
    Int t=max(vec[i].second.second-vec[i].first,(Int)0);
    int spos=lower_bound(comp.begin(),comp.end(),s)-comp.begin();
    int tpos=lower_bound(comp.begin(),comp.end(),t)-comp.begin();
    seg.update(spos,tpos,vec[i].first);
  //  cout<<spos<<" "<<tpos<<endl;
  }
  for(int i=0;i<q;i++){
    int d;
    cin>>d;
    int pos=upper_bound(comp.begin(),comp.end(),d)-comp.begin();
    pos--;
    Int ans=seg.getmin(pos,pos+1);
    //cout<<pos<<" ";
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 31100
S = input()
n = len(S)

#print(S[:int((n-1)/2)], S[:int((n-1)/2)][::-1])
#print(S[:int((n-1)/2)] , S[:int((n-1)/2)][::-1])
#print(S[int((n+1)/2):], S[int((n+1)/2):][::-1])                  
if S[:int((n-1)/2)] == S[:int((n-1)/2)][::-1] and S[int((n+1)/2):]== S[int((n+1)/2):][::-1] and S[:int((n-1)/2)] == S[int((n+1)/2):][::-1]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
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;
  }
}

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

#define MAXN 100000
int N;
int A[MAXN+5];

int main(){
    scanf("%d",&N);
    long long Sum=0;
    for(int i=1;i<=N;i++){
        scanf("%d",&A[i]);
        Sum+=A[i];
    }
    long long All=1ll*N*(N+1)/2;
    if(Sum%All)
        return !puts("NO");
    int k=Sum/All;
    for(int i=1;i<=N;i++){
        int d=A[i]-A[i-1==0?N:i-1];
        if(d-k>0||(k-d)%N!=0)
            return !puts("NO");
    }
    puts("YES");
}


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

int main(void) {
    char str[100], *s[3];
    char *sep = "/";
    fgets(str, 100, stdin);
    int i, month;
    for(i = 0; i < 3; ++i){
        s[i] = (i == 0)? strtok(str, sep): strtok(NULL, sep);
    }
    month = atoi(s[1]);
    if( month <= 4) { printf("Heisei\n"); } else { printf("TBD\n"); }
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int a = sc.nextInt();
		int b = sc.nextInt();
		String u = sc.next();
		if(u.equals(s)) {
			a--;
		}else {
			b--;
		}

		System.out.println(a + " " + b);
	}
}

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

int main(void){
  int H,W,i,j;
  while(H != 0 || W != 0){
    cin >> H >> W;
    for (i=0 ; i<H;i++){
      for(j=0; j<W;j++){
        if (H != 0 || W != 0){
          if((i==0 || i ==H-1)|| (j==0 || j==W-1)){
            cout << "#";
          }else cout << ".";
        }
      }
      cout << endl;
    }
    if (H != 0 || W != 0) cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3092
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
	 int n = sc.nextInt(),count,out,hit;
	 String x;
		
	 	for(int i = 0; i < n; i++){
	 		count = out = hit = 0;
	 		for(;;){
	 			x = sc.next();
	 			if(x.equals("OUT")){
	 				out++;
	 				if(out == 3)break;
	 			}
	 			else if(x.equals("HIT")){
	 				if(hit == 3)count++;
	 				else hit++;
	 			}else if(x.equals("HOMERUN")){
	 				count += hit + 1;
	 				hit = 0;
	 			}
	 		}
	 		System.out.println(count);
	 	}
		sc.close();
	}
}

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

/* type defnition */
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using Graph = vector<vi>;


//macros
#define __all(v) v.begin(),v.end()


/*  Util Function defnition                  */

inline int ctoi(char c){
    return c - '0';
}

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

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

/*  End Util Function defnition              */



/*  Global Variable defnition                 */

/*  End Global Variable defnition              */



/**/


/**/

void calclation(){
    int N,M;
    cin >> N >> M;
    vector<long long> height(N);
    for(int i = 0;i < N;i++)
    {
         cin >> height[i];
    }
    Graph g(N);
    for(int i = 0;i < M;i++)
    {
        int a,b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int res = 0;
    for(int i = 0;i < N;i++)
    {
        bool flag = true;
        for(auto j : g[i])
        {
            if(height[i] <= height[j]) flag = false;
        }
        if(flag) res++;
    }
    cout << res << '\n';
}

//main function
int main(int, char**) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    calclation();
    return 0;
}


Measured memory_bytes: 9184
let () = Scanf.scanf "%d" @@ fun n ->
  let ans =
    if n <= 9 then n
    else if n <= 99 then 9
    else if n <= 999 then 9 + n - 99
    else if n <= 9999 then 909
    else if n <= 99999 then 909 + n - 9999
    else 90909
  in
  Printf.printf "%d" ans 

Measured memory_bytes: 3800
import fractions
A, B = map(int, input().split())

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

g=fractions.gcd(A, B)
#print(g)
lst=factorize(g)
#print(lst)
print(1+len(set(lst)))

Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
typedef long long int i64;
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string>) {}
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << a << endl; err(++it, args...); }
template<typename T1,typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& buf) {
  return os << "(" << buf.first << ": " << buf.second << ")"; }
#define DefOut(Con) template<typename T>ostream&operator<<(ostream&os,Con<T>&A){ bool f = false; os << "{"; \
  for (auto &e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
#define DefOut2(Con) template<typename K,typename V>ostream&operator<<(ostream&os,Con<K,V>&A) \
{ bool f = false; os << "{"; for (auto &e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
template<typename T>ostream &operator << (ostream &os,vector<vector<T>>& A) {
  for (auto &B: A) os << '\n' << B; return os; }
DefOut(vector) DefOut(set) DefOut(multiset) DefOut2(map) 
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1000000007;
long long const INF = 1e18;
#define PI 3.14159265358979323846
/***********************************************************************/
struct item {
  int x, s, t;
};
int32_t main() {

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, q;
  cin >> n >> q;
  vector<item> a(n);
  for (int i = 0; i < n; ++i) {
    int x, s, t;
    cin >> s >> t >> x;
    a.push_back({x, s, t});
  }
  vector<int> b(q);
  for (int i = 0; i < q; ++i) cin >> b[i];
  sort(ALL(a), [] (auto x, auto y) {
    return x.x > y.x;
  });
  vector<int> tree(q << 1, MOD);
  
  for (int i = 0; i < n; ++i) {
    int x = a[i].x, s = a[i].s, t = a[i].t;
    s -= x; t -= x;
    int l = (int) (lower_bound(ALL(b), s) - b.begin());
    int r = (int) (lower_bound(ALL(b), t) - b.begin());
    if (r > l) {
      for (l += q, r += q; l < r; l /= 2, r /= 2) {
        if (l & 1) tree[l++] = x;
        if (r & 1) tree[--r] = x;
      }
    }
  }
  for (int i = 0; i < q; ++i) {
    int ans = MOD;
    int p = i + q;
    for (; p > 0; p /= 2) {
      uin(ans, tree[p]);
    }
    if (ans == MOD) ans = -1;
    cout << ans << '\n';
  }
  
  return 0;
}


Measured memory_bytes: 8920
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String[] card = scan.nextLine().split("\\s");
        int alicesCard = Integer.valueOf(card[0]);
        int bobsCard = Integer.valueOf(card[1]);
        if(alicesCard == 1 || bobsCard == 1){
            if(alicesCard == 1){
                alicesCard = 14;
            }
            if(bobsCard == 1){
                bobsCard = 14;
            }
        }
        if(alicesCard == bobsCard){
            System.out.println("Draw");
        }else if(alicesCard > bobsCard){
            System.out.println("Alice");
        }else{
            System.out.println("Bob");
        }
    }
}

Measured memory_bytes: 22736