akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;

typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef vector<pii> vii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OrderedSet;

const int MOD	= 1e9 + 7;
const double PI = acos(-1.0);

#define fastio			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto &i : c)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define fill(a)  memset(a, 0, sizeof (a))
#define error(x) cerr << #x << " = " << (x) << endl
#define errorp(p) cerr << #p << " = " << (p.first) << ", " << (p.second) << endl

template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }
int mul(int a, int b, int c){lli res=(lli)a*b;return (int)(res>=c?res%c:res);}
template<typename T>T power(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
template <class T>  inline void smax(T &x,T y){ x = max((x), (y));}
template <class T>  inline void smin(T &x,T y){ x = min((x), (y));}

int ans;
int N, M, X;

void recur(vector<vi> &arr, vi &c, int depth, vi &curr, int val){
    bool a = true;
    rep(i, M){
        if(curr[i] < X){
            a = false;
        }
    }
    if(a){
        smin(ans, val);
    }
    if(depth == N){
        return;
    }
    recur(arr, c, depth + 1, curr, val);
    //
    rep(i, M){
        curr[i] += arr[depth][i];
    }
    recur(arr, c, depth + 1, curr, val + c[depth]);
    rep(i, M){
        curr[i] -= arr[depth][i];
    }
}

int main(){
    #ifdef DEBUG
		freopen("test", "r", stdin);
	#endif
    fastio;
    
    cin >> N >> M >> X;
    vector<vi> arr(N, vi(M));
    vi c(N);
    rep(i, N){
        cin >> c[i];
        rep(j, M){
            cin >> arr[i][j];
            // cout << arr[i][j] << endl;
        }
    }
    ans = MOD;
    vi curr(M, 0);
    recur(arr, c, 0, curr, 0);

    if(ans != MOD)
        cout << ans << endl;
    else
        cout << -1 << endl;
    return 0;
}


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

int main() 
{
    int N;
    cin >> N;
    int D1, D2;
    int count = 0;
    for (int i = 0; i < N; ++i) {
        cin >> D1 >> D2;
        if (D1 == D2) {
            ++count;
        }
        else {
            count = 0;
        }
        if (count == 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

// O(log max{a, b})
long long gcd(long long a, long long b) {
    while (b) {
        long long c = a % b;
        a = b;
        b = c;
    }
    return a;
}

void _main() {
    int N;
    cin >> N;
    int g = 0;
    REP (i, N) {
        int A;
        cin >> A;
        g = gcd(g, A);
    }
    cout << g << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
As = list(map(int, input().split()))
#i = As.index(1)
#r = (i +(K-1)-1)//(K-1)+(N-i-1 +(K-1)-1)//(K-1)
r = (N-1 +(K-1)-1)//(K-1)
print(r)


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)
#define Float(x) OUTN(fixed, setprecision(x));

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) {
  for (auto &e : vec) cout << e << " \n"[&e==&vec.back()];
}

template <class T>
void OUTS(vector<vector<T>> &df) {
  for (auto &vec : df) OUTS(vec);
}

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) {
  for (auto &e : vec) cout << e << "\n";
}

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  vector<int> A(3);
  rep(i, 3) IN(A[i]);
  sort(all(A));
  i64 cost = 0;
  for (int i = 1; i < 3; ++i) {
    cost += abs(A[i] - A[i-1]);
  }
  OUTL(cost);
  return 0;
}


Measured memory_bytes: 256
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <climits>
#include <functional>
#include <string>
#include <sstream>
#include <bitset>  // std::bitset<N>

#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define rep(i,n) for (int i=0; i < int(n); i++)

long long f(long long a) {
     long long res[] = {a,1,a+1,0};
     return res[a%4];
}

long long getXor(long long a, long long b) {
     return f(b)^f(a-1);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll A, B;
    ll nums = B-A + 1;
    cin >> A >> B;
    ll ans;
    if(A == 0){
      if(B==0){
        ans = 0;
      }else{
        ans = 0LL^getXor(1, B);
      }
    }else{
       ans = getXor(A, B);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 03/14/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  string a,b,c; cin>>a>>b>>c;

  auto eq = [](char a, char b) {
    return a == '?' or b == '?' or a == b;
  };

  vector<bool> ab(8001, true), bc(8001, true), ac(8001, true);
  for (int i = 0; i < a.size(); i++) for (int j = 0; j < b.size(); j++) {
    ab[i-j+4000] = ab[i-j+4000] and eq(a[i], b[j]);
  }
  for (int i = 0; i < a.size(); i++) for (int j = 0; j < c.size(); j++) {
      ac[i-j+4000] = ac[i-j+4000] and eq(a[i], c[j]);
    }
  for (int i = 0; i < b.size(); i++) for (int j = 0; j < c.size(); j++) {
      bc[i-j+4000] = bc[i-j+4000] and eq(b[i], c[j]);
    }

  int A=a.size(),B=b.size(),C=c.size();
  int ans = a.size()+b.size()+c.size();
  for (int i = -B-C; i <= A+C; i++) for (int j = max(-B-C, -B-C+i); j <= min(A+B, A+B+i); j++) {
    if (not (ab[i+4000] and ac[j+4000] and bc[j-i+4000]))
      continue;
    int l = min(min(i,j), 0);
    int r = max(max(A, i+B), j+C);
    ans = min(ans, int(r-l));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll N, A, B;
    cin >> N >> A >> B;

    ll ans = 0;
    if (A > B) ans = 0;
    else if (N == 1) {
        if (A != B) ans = 0;
        else ans = 1;
    }
    else {
        if (N == 2) ans = 1;
        else {
            if (A == B) ans = 1;
            else {
                N -= 2;
                A *= N;
                B *= N;
                ans = B - A + 1;
            }
        }
    }

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

Measured memory_bytes: 256
#include<iostream>
#include<queue>
using namespace std;
int n,a[2][100001],d[2][20][100001],e[2][20][100001];
int query(int parity,int l,int r)
{
	int k=0;l>>=1;r-=parity;r>>=1;
	while((1<<(k+1))<=r-l+1)k++;
	//fprintf(stderr,"Querying d(%d,%d,%d) = %d && d(%d,%d,%d) = %d\n",parity,k,l,d[parity][k][l],parity,k,r-(1<<k)+1,d[parity][k][r-(1<<k)+1]);
	return min(d[parity][k][l],d[parity][k][r-(1<<k)+1]);
}
int pos(int parity,int l,int r)
{
	int k=0;l>>=1;r-=parity;r>>=1;
	while((1<<(k+1))<=r-l+1)k++;
	//fprintf(stderr,"Posing e(%d,%d,%d) (d = %d) && e(%d,%d,%d) (d = %d)\n",parity,k,l,d[parity][k][l],parity,k,r-(1<<k)+1,d[parity][k][r-(1<<k)+1]);
	return d[parity][k][l]>d[parity][k][r-(1<<k)+1]?e[parity][k][r-(1<<k)+1]:e[parity][k][l];
}
struct range
{
	int l,r;
	range(int left,int right):l(left),r(right){}
	bool operator<(const range &b)const{return query(l&1,l,r)>query(b.l&1,b.l,b.r);}
};
int main()
{
	scanf("%d",&n);
	for(int i=0,j=0;i<n;i+=2,j++)scanf("%d%d",a[0]+j,a[1]+j);
	for(int i=0,j=0;i<n;i+=2,j++)
	{
		d[0][0][j]=a[0][j];
		d[1][0][j]=a[1][j];
		e[0][0][j]=i;
		e[1][0][j]=i+1;
	}
	for(int i=1;(1<<i)<=n/2;i++)
		for(int j=0;j+(1<<i)<=n/2;j++)
			for(int k=0;k<2;k++)
				if(d[k][i-1][j]<d[k][i-1][j+(1<<(i-1))])
				{
					d[k][i][j]=d[k][i-1][j];
					e[k][i][j]=e[k][i-1][j];
				}
				else
				{
					d[k][i][j]=d[k][i-1][j+(1<<(i-1))];
					e[k][i][j]=e[k][i-1][j+(1<<(i-1))];
				}
#if 0
	for(int i=0;(1<<i)<=n/2;i++)
		for(int j=0;j+(1<<i)<=n/2;j++)
			for(int k=0;k<2;k++)fprintf(stderr,"d(%d,%d,%d)=%d\ne(%d,%d,%d)=%d\n\n",k,i,j,d[k][i][j],k,i,j,e[k][i][j]);
	fputs("Sparse Table Ended here.\n\n\n",stderr);
#endif
	priority_queue<range> q;
	q.push({0,n-1});
	while(!q.empty())
	{
		range u=q.top();q.pop();
		int p=pos(u.l&1,u.l,u.r-1),r=pos(u.r&1,p+1,u.r);
#if 0
		fprintf(stderr,"Fuck %d %d\n",u.l,u.r);
		if(r==-1)fprintf(stderr,"Error with %d %d %d -> %d\n\t%d %d %d => -1\n",u.l&1,u.l,u.r,p,u.r&1,p+1,u.r);
		fprintf(stderr,"Get %d => %d;\t%d => %d\n",p,query(u.l&1,u.l,u.r-1),r,query(u.r&1,p+1,u.r));
#endif
		printf("%d %d ",query(u.l&1,u.l,u.r-1),query(u.r&1,p+1,u.r));
		if(u.l<=p-1)q.push({u.l,p-1});
		if(p+1<=r-1)q.push({p+1,r-1});
		if(r+1<=u.r)q.push({r+1,u.r});
	}
	putchar('\n');
	return 0;
}


Measured memory_bytes: 32636
/*  Success may not come to me immediately,
 *  but it will come definitely....
 */
#include<bits/stdc++.h>
//=====================================================================
using namespace std;
//=====================================================================
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//=====================================================================
#define li  	int64_t
#define ld  	double_t
#define ulli    uint64_t
//=====================================================================
#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define repi(i,v)   for(i=v.begin();i!=v.end();i++)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))
#define nl      	cout<<'\n'
//=====================================================================
typedef vector<li>       vli;
typedef vector<string>   vstr;
typedef pair<li,li>      pli;
typedef pair<li,pli >    ppli;
typedef pair<li,ppli >   pppli;
typedef vector<pli >     vpl;
typedef vector<ppli >    vppli;
typedef vector<pppli >   vpppli;
//=====================================================================
#define pb  push_back
#define pob pop_back
#define pf  push_front
#define pof pop_front
#define all(v)  v.begin(),v.end()
#define itr iterator
#define sz  size()
#define lb  lower_bound
#define ub  upper_bound
#define bs  binary_search
#define mp  make_pair
#define F   first
#define S   second
//=====================================================================
#define mod (li)(1e9+7)
#define inf (li)(1e18)
#define MX1 (li)(1e5+5)
#define MX2 (li)(1e6+5)
#define pi  acos(-1)
//=====================================================================
li power(li a,li b){li ans=1;while(b){if(b&1){ans=(ans*a)%mod;}
a=(a*a)%mod;b>>=1;}return ans;}
//=====================================================================
li mmi(li n){return power(n,mod-2);}
//=====================================================================
li two(li n){return (1LL<<n);}
//=====================================================================
void onbit(li &n,li x){n|=two(x);}
//=====================================================================
void offbit(li &n,li x){n&=~two(x);}
//=====================================================================
li cntbit(li n){li res=0;while(n and ++res)n-=n&-n;return res;}
//=====================================================================
li dx[]={-1,0,1,0},dy[]={0,-1,0,1};
//=====================================================================
/*------------------------MAIN CODE BEGINS NOW!------------------------*/

li a[105];

void solve(){
  li i,n;cin>>n;
  rep(i,0,n) cin>>a[i];
  li g=a[0],l=a[0];
  rep(i,1,n){
    g=__gcd(l,a[i]);
    if(l%g==0) l=l/g*a[i];
    else l=a[i]/g*l;
  }
  cout<<l;
}

int main(){
  opt
  #ifndef ONLINE_JUDGE
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
  #endif
  li t=1;
  //cin>>t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 256
def run(x):
    n = 10**5 + 1000
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+1):
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    for i in range(x, n):
        if is_prime[i]:
            ans = i
            break
    return ans


def main():
    x = int(input())
    print(run(x))


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;

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

#define inf5 100002
#define inf9 1000000002

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

	--a;--b;
	cout << (b + (a - 1)) / a << endl;

	return 0;
}


Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
S = input()[:-1]
while len(S):
    if S[:len(S)//2] == S[len(S)//2:]:
        print(len(S))
        exit()
    S = S[:-1]


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
struct INF { template<class T> operator T() { return numeric_limits<T>::max() / 2; } } INF;


int main(){

    int x;
    cin >> x;
    cout << (x == 1 ? 0 : 1) << endl;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXSIZE=10000020;
int bufpos;
char buf[MAXSIZE];
#define NEG 0
void init(){
	#ifdef LOCAL
		freopen("E.txt","r",stdin);
	#endif
	buf[fread(buf,1,MAXSIZE,stdin)]='\0';
	bufpos=0;
}
#if NEG
int readint(){
	bool isneg;
	int val=0;
	for(;!isdigit(buf[bufpos]) && buf[bufpos]!='-';bufpos++);
	bufpos+=(isneg=buf[bufpos]=='-');
	for(;isdigit(buf[bufpos]);bufpos++)
		val=val*10+buf[bufpos]-'0';
	return isneg?-val:val;
}
#else
int readint(){
	int val=0;
	for(;!isdigit(buf[bufpos]);bufpos++);
	for(;isdigit(buf[bufpos]);bufpos++)
		val=val*10+buf[bufpos]-'0';
	return val;
}
#endif
char readchar(){
	for(;isspace(buf[bufpos]);bufpos++);
	return buf[bufpos++];
}
int readstr(char* s){
	int cur=0;
	for(;isspace(buf[bufpos]);bufpos++);
	for(;!isspace(buf[bufpos]);bufpos++)
		s[cur++]=buf[bufpos];
	s[cur]='\0';
	return cur;
}
const int maxn=100002;
int fa[maxn];
ll sum[maxn];
int sz[maxn];
int getf(int x){
	return fa[x]==x?x:fa[x]=getf(fa[x]);
}
struct edge{
	int u,v,w;
	bool operator <(const edge& rhs)const{
		return w<rhs.w;
	}
}e[maxn];
int main(){
	init();
	int n=readint(),m=readint();
	for(int i=1;i<=n;i++)
		fa[i]=i,sum[i]=readint();
	for(int i=1;i<=m;i++)
		e[i].u=readint(),e[i].v=readint(),e[i].w=readint();
	sort(e+1,e+m+1);
	int ans=0;
	for(int i=1;i<=m;i++){
		int u=e[i].u,v=e[i].v,w=e[i].w;
		u=getf(u),v=getf(v);
		if (u!=v)
			fa[u]=v,sz[v]+=sz[u],sum[v]+=sum[u];
		sz[v]++;
		if (w<=sum[v])
			ans+=sz[v],sz[v]=0;
	}
	printf("%d",m-ans);
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n;cin >> n;
    ll a,b;cin >> a >> b;
    vector<ll> x(n);
    rep(i,n)
    {
        cin >> x[i];
    }
    sort(x.begin(), x.end());
    ll h = 0;
    for (int i = 0; i < n-1; i++)
    {
        ll temp = 0;
        if((temp = a*(x[i+1]-x[i])) <b)
        {
            h+= temp;
        }else
        {
            h+=b;
        }
    }
    cout << h << endl;
    
}

Measured memory_bytes: 4044
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class B
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var (X, Y) = Scanner.Scan<int, int>();
            var answer = false;
            for (var i = 0; i <= X; i++)
            {
                if (i * 2 + (X - i) * 4 == Y) answer = true;
            }
            Console.WriteLine(answer ? "Yes" : "No");
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 28008
#include<iostream>
#include<vector>
#include<limits.h>
using namespace std;

int main() {
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	vector<int> x(N);
	vector<int> y(M);
	int max_num = INT_MIN, min_num = INT_MAX;
	for (int i = 0; i < N; i++) {
		cin >> x[i];
		max_num = max_num < x[i] ? x[i] : max_num;
	}
		
	for (int i = 0; i < M; i++) {
		cin >> y[i];
		min_num = min_num > y[i] ? y[i] : min_num;
	}
	
	if (max_num >= min_num || max_num >= Y || min_num <= X)
		cout << "War";
	else
		cout << "No War";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <tuple>
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(){
    string s;
    cin >> s;

    if(s <= "2019/04/30")cout << "Heisei" <<endl;
    else cout << "TBD" <<endl;
}


Measured memory_bytes: 256
from collections import defaultdict
from heapq import heappop, heappush


class Graph(object):
    """
    隣接リストによる有向グラフ
    """

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst, weight=1):
        self.graph[src].append((dst, weight))

    def get_nodes(self):
        return self.graph.keys()


class Dijkstra(object):
    """
    ダイクストラ法（二分ヒープ）による最短経路探索
    計算量: O((E+V)logV)
    """

    def __init__(self, graph, start):
        self.g = graph.graph

        # startノードからの最短距離
        # startノードは0, それ以外は無限大で初期化
        self.dist = defaultdict(lambda: float('inf'))
        self.dist[start] = 0

        # 最短経路での1つ前のノード
        self.prev = defaultdict(lambda: None)

        # startノードをキューに入れる
        self.Q = []
        heappush(self.Q, (self.dist[start], start))

        while self.Q:
            # 優先度（距離）が最小であるキューを取り出す
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, weight in self.g[u]:
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q, (alt, v))

    def shortest_distance(self, goal):
        """
        startノードからgoalノードまでの最短距離
        """
        return self.dist[goal]

    def shortest_path(self, goal):
        """
        startノードからgoalノードまでの最短経路
        """
        path = []
        node = goal
        while node is not None:
            path.append(node)
            node = self.prev[node]
        return path[::-1]


g = Graph()
N, M = [int(i) for i in input().split()]


for i in range(M):
    u, v = [int(i) for i in input().split()]
    g.add_edge(u-1, v-1, 1)
    g.add_edge(u-1+N, v-1, 1)
    g.add_edge(u-1, v-1+N, 1)

d = Dijkstra(g, 0)

ans_n = 10 ** 6
ans_index = -1
for i in range(N):
    d = Dijkstra(g, i)
    ans_n_ = d.dist[i+N]

    if ans_n_ < ans_n:
        ans_index = i
        ans_n = ans_n_

if ans_n == 10 ** 6:
    print(-1)
else:
    d = Dijkstra(g, ans_index)
    ans = d.shortest_path(ans_index + N)
    ans.sort()
    print(ans_n)
    for j in range(ans_n):
        print(ans[j]+1)




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

int main()
{
    int ar[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int t;
    cin>>t;
    cout<<ar[t-1]<<endl;
















    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int r,D,x,amount;

void Algae(int a,int b,int c){
  amount = a*c-b;
  printf("%d\n",amount);
}

int main(void){
  scanf("%d%d%d",&r,&D,&x);
  for(int i=1;i<=10;i++){
    Algae(r,D,x);
    x = r*x-D;
  }
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<ll> l(n+1);
    rep(i,n+1){
        if(i==0) l[i] = 2;
        else if (i == 1) l[i] = 1;
        else l[i] = l[i-1] + l[i-2];
    }
    cout << l[n] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    string s;
    cin >> s;
    for(int i = 0; i < 19; i++){
        if(i == 5 || i == 13){
            cout << " ";
            continue;
        }
        cout << s[i];
    } 
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int war(int X,int Y,int *x,int *y,int N,int M){
  int i,Z=-100,W=100;
  if(X>=Y) return 1;

  for(i=0;i<N;i++)
  if(x[i]>Z) Z=x[i];

  for(i=0;i<M;i++){
  if(y[i]<=Z) return 1;
  if(y[i]<W) W=y[i];
}
  for(i=Z+1;i<=W;i++){
  if(X<i && Y>=i)
  return 0;
}
return 1;
}
int main(void){
  int i,X,Y,N,M,x[100],y[100];
  scanf("%d%d%d%d",&N,&M,&X,&Y );
  for(i=0;i<N;i++)
  scanf("%d",&x[i] );
  for(i=0;i<M;i++)
  scanf("%d",&y[i] );
  if(war(X,Y,x,y,N,M)==1)
  printf("War\n");
  else printf("No War");
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<map>


using namespace std;

int main(void){
 char s[50];
 char t[50];

 cin>>s;
 cin>>t;
 
 if(strlen(s)+1!=strlen(t)){
   cout<<"No"<<endl;
   return 0;
 }
 else;
 
 for(int i=0; i<strlen(s); i++){
  if(s[i]==t[i]);
  else {
   cout<<"No"<<endl;
   return 0;
  }
 }
 cout<<"Yes"<<endl;

 return 0;
}


Measured memory_bytes: 3676
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.Queue

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def ryuka(a: Long, b: Long, n: Long): Long = {
    if (n == 0) (a) else (ryuka(b, a + b, n - 1))
  }

  def solve(sc: => Scanner): Unit = {
    println(ryuka(2, 1, sc.nextInt))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 25412
#include<iostream>
using namespace std;
int main()
{
    int a;
    cin >> a;
    bool result = false;

    for (int i = 1; i < 10 ; ++i) {
        if (a % i == 0 && (a / i) < 10){
            result = true;
            break;
        }
    }

    if(result){
        cout << "Yes"<< endl;
    }else{
        cout<< "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { cout << '\n'; }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << ' ' << val;
            return *this;
        }
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy operator<<(T&& val)
    {
        cout << val;
        return {};
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
                first = false;
            }
            cout << x;
        }
    }
};

int main()
{
    input in;
    output out;

    auto N = in.read<int>();
    std::string S, T;
    in >> S, T;
    for (auto i : boost::irange(0, N)) {
        std::cout << S[i] << T[i];
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long


int main()
{
	string s, an;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0') an.push_back('0');
		else if (s[i] == '1') an.push_back('1');
		else if (s[i] == 'B' && an.size() != 0) an.pop_back();
	}
	cout << an << endl;
}


Measured memory_bytes: 256
n = int(input())
c = input()

r_cnt = 0
for i in range(n):
    if c[i] == 'R':
        r_cnt += 1


r_cnt_2 = 0
for i in range(r_cnt):
    if c[i] == 'R':
        r_cnt_2 += 1

if r_cnt == n:
    print(0)
else:
    print(r_cnt - r_cnt_2)


Measured memory_bytes: 9368
#include <iostream>

using namespace std;

int main()
{
    char a[6];
    for(int x=0;x<6;x++)
        cin >> a[x];
    if(a[0]!=a[5])
    {
        cout << "NO"<<endl;
        exit(0);
    }
    if(a[2]!=a[3])
    {
        cout << "NO"<<endl;
        exit(0);
    }
    if (a[1] != a[4])
    {
        cout << "NO" << endl;
        exit(0);
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 888
///*****************************************************///
///*.......................Faiyaj Bin Amin............................*///
///*...................................................................*///
///*.........................KUET CSE 2K17......................*///
///*...................................................*///
///*****************************************************///

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define fastio      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define ret return
#define rep(q, i, n) for(int q=i; q<n; q++)
#define forn(i, n) for(int i=0; i<n; i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define ll long long
#define pb push_back
#define em emplace_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define ff first
#define ss second
#define pii pair<int,int>
#define pdd pair<double, double>

#define see(x)        cerr<< __LINE__ << ": " << (#x) << " is "<< (x) <<'\n';
#define seecontent(v) for(auto x : v) { cout << x << " ";} cout << "\n\n";

#define PI 2*acos(0.0)
#define lcm(a, b)  ((a / __gcd(a, b) ) * b)

#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)

#define mx 100005
#define INF 1e18
#define MOD 1000000007
#define MIN 0

//template <typename T>  using orderedSet =
//    tree<T, null_type, less_equal<T>,
//    rb_tree_tag, tree_order_statistics_node_update>; //find_by_order, order_of_key


/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0}; // Directional
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

/**------------------------------------BITMASK------------------------------------------**/
//int Change(int N, int pos){return N= N^(1<<pos);}
//bool Check(int N, int pos){return (bool)(N &(1<<pos));}  /// check bit 0 or 1
/**-----------------------------------------------------------------------------------------------**/

//using namespace __gnu_pbds;
using namespace std;

int main()
{
    fastio;

    ll n;
    cin>>n;

    ll a[n], b[n], c[n-1];

    forn(i, n)
    {
        cin >> a[i];
    }
    forn(i, n)
    {
        cin >> b[i];
    }
    forn(i, n-1)
    {
        cin >> c[i];
    }

    ll cnt=0;
    forn(i, n)
    {
        cnt += b[a[i]-1];

//        see(cnt);
        if(i>0)
        {
            if(a[i]-1==a[i-1]-1+1)
                {
////                    cout << "yes\n";
////                    see(a[i]-1);
////                    see(c[a[i]-1]);
                    cnt+=c[a[i-1]-1];
                }

        }
    }
    cout<< cnt << "\n";

    return 0;
}

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

#define LL long long

LL sqrt(LL n) {
    if(9223372030926249001 < n) {
        return 3037000500;
    }
    LL l = 1;
    LL r = min<LL>(3037000500, n);
    for(;1 < r - l;) {
        LL mid = (l + r)/2;
        if(n < mid*mid) {
            r = mid;
        }else if(mid*mid < n){
            l = mid;
        }else{
            return mid;
        }
    }
    return r;
}

LL digit(LL n) {
    if(n == 0)
        return 1;
    LL i;
    for(i = 0;0 < n;i++) {
        n /= 10;
    }
    return i;
}

int main() {
    LL N;
    cin >> N;
    LL sq = sqrt(N);
    LL res = 334;
    for(LL i = 1;i <= sq;i++) {
        if(N%i == 0) {
            res = min(digit(N/i), res);
        }
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;

int main(){

    long long int s;
    cin>>s;
    long long int l=1000000000;
    if(s==l*l){
        cout<<0<<' '<<0<<' '<<0<<' '<<l<<' '<<l<<' '<<0<<endl;
        return 0;
    }
    cout<<0<<' '<<0<<' '<<l<<' '<<1<<' '<<l-(s%l)<<' '<<(s+l-s%l)/l<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

map<s64, s64> pfac;
void prime_factorization(s64 x)
{
    for (s64 i = 2; i * i <= x; ++i)
    {
        while (x % i == 0)
        {
            ++pfac[i];
            x /= i;
        }
    }
    if (x > 1) ++pfac[x];
}

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

    s64 n;
    cin >> n;

    prime_factorization(n);

    s64 ans = 0;
    for (auto& item : pfac)
    {
        if (item.first == 1) continue;
        s64 p = 1;
        while (p * (p + 1) / 2 <= item.second) ++p;
        ans += p - 1;
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3644
[a,b, m] = input().split()
a = int(a)
b = int(b)
m = int(m)

lisa = [0] * a
lisb = [0] * b
lism = [[0, 0, 0]] * m 
lisab = input().split()
lisbc = input().split()
lisa = [int(i) for i in lisab]
lisb = [int(i) for i in lisbc]


minval = min(lisa) + min(lisb)

for i in range(m):
    [aa, bb, cc] = input().split()
    if (lisa[int(aa)-1] + lisb[int(bb)-1] - int(cc) < minval):
        minval = lisa[int(aa)-1 ] + lisb[int(bb)-1] - int(cc)
print(minval)
# print(a, b, m)


Measured memory_bytes: 72268
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

class UnionFind():
    def __init__(self, n):
        self.n = n
        # parents[i]: 要素iの親要素の番号
        # 要素iが根の場合、parents[i] = -(そのグループの要素数)
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    # 要素xが属するグループの要素数を返す
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    # 要素xが属するグループに属する要素をリストで返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    # 全ての根の要素をリストで返す
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    # グループの数を返す
    def group_count(self):
        return len(self.roots())
    # 辞書{根の要素: [そのグループに含まれる要素のリスト], ...}を返す
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    # print()での表示用
    # all_group_members()をprintする
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M = MAP()
L = [LIST() for i in range(M)]
A = [0] * N
# graph = defaultdict(list)
L = sorted(L, key=lambda x: x[1])
tmp = L[0][1]
ans = 1
for a, b in L:
    if a < tmp <= b:
        continue
    else:
        ans += 1
        tmp = b
print(ans)

        


Measured memory_bytes: 32756
<?php
    list($n,$b) = explode(" ", trim(fgets(STDIN)));
    $arr = explode(" ", trim(fgets(STDIN)));
    sort($arr);
    $ans = 0;
    for($i = 0; $i < $b; $i++){
        $ans += $arr[$i];
    }
    echo $ans . "\n";
?>


Measured memory_bytes: 16296
from collections import deque

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
g = [[] for _ in range(N+1)]

for a, b in AB:
  g[a].append(b)
  g[b].append(a)

d = deque([1])
l = [0]*(N+1)
while d:
  r = d.popleft()
  for s in g[r]:
    if l[s] == 0:
      d.append(s)
      l[s] = r

print("Yes", *l[2:], sep="\n")

Measured memory_bytes: 60024
#include<stdio.h>
typedef long long LL;
int N,i,j,x,y=0,A[200000],town[200000];LL K;
inline LL IN(void)
{
  LL x=0;int f=1;char c=getchar();
  while((c<'0'||c>'9')&&c!='-')c=getchar();
  if(c=='-')f=-f,c=getchar();
  while(c>='0'&&c<='9')x=x*10+c-48,c=getchar();
  return f*x;
}
int main(void)
{
  N=IN(),K=IN();
  for(i=0;i<N;i++)A[i]=IN(),town[i]=-1;
  for(i=0,j=0;;i=A[i]-1,j++)if(town[i]<0)town[i]=j;else{x=town[i];break;}
  while(K>0){if(i==y){K%=x-j;if(!K)return printf("%d",i+1),0;}y=A[y]-1,K--;}
  return printf("%d\n",y+1),0;
}

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

vector<int> lose[5001];
bool use[5001];
bool use2[5001];
vector<int> res;
vector<int> res2;

void search(int x)
{
	if (use[x]) return;
	for (int i = 0; i < lose[x].size(); i++){
		search(lose[x][i]);
	}
	use[x] = true;
	res.push_back(x);
}

void search2(int x)
{
	if (use2[x]) return;
	for (int i = lose[x].size() - 1; i >= 0; i--){
		search2(lose[x][i]);
	}
	use2[x] = true;
	res2.push_back(x);
}

int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	
	for (int i = 0; i < m; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		lose[b].push_back(a);
	}
	
	for (int i = 1; i <= n; i++){
		if (!use[i]) search(i);
	}
	for (int i = n; i >= 1; i--){
		if (!use2[i]) search2(i);
	}
	for (int i = 0; i < n; i++){
		printf("%d\n", res[i]);
	}
	printf("%d\n", res != res2);
	
	return 0;
}

Measured memory_bytes: 2220
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] s = new int[n + 1];
        for (int i = 0; i < n; i++) {
            s[i] = scanner.nextInt();
        }
        int q = scanner.nextInt();
        int[] t = new int[q];
        for (int i = 0; i < q; i++) {
            t[i] = scanner.nextInt();
        }
        int count = 0;
        for (int i = 0; i < q; i++) {
            if (LinearSearch(s, t[i])) {
                count++;
            }
        }
        System.out.println(count);
    }

    static boolean LinearSearch(int[] a, int key) {
        int i = 0;
        a[a.length - 1] = key;
        while (a[i] != key) {
            i++;
        }
        if (i == a.length - 1) {
            return false;
        }
        return true;
    }
}


Measured memory_bytes: 69708
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  string S;
  cin >> N >> S;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    set<char> s1;
    for (int j = 0; j < i; j++) {
      s1.insert(S[j]);
    }
    int cnt = 0;
    set<char> s2;
    for (int j = i; j < N; j++) {
      if (s1.find(S[j]) != s1.end() && s2.find(S[j]) == s2.end()) {
        cnt++;
      }
      s2.insert(S[j]);
    }
    ans = max(cnt, ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

int main() {
    ll d, t, s;
    cin >> d >> t >> s;

    if(s*t < d) {
        out("No");
    }
    else {
        out("Yes");
    }
    
    re0;
}

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

using namespace std;

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

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

int main(){
	
	ll a,b;cin >> a >> b;
	ll t1 = b,t2 = a,t3 = a;
	
	if(a == b){
		cout << 1 << endl;
		return 0;
	}
	
	bool flag = false;
	for(ll i = 60;i >= 0;i--){
		bool A = (a & (1LL << i)) > 0;
		bool B = (b & (1LL << i)) > 0;
		if(!flag && A != B){
			//cout << "same " << i << endl;
			t2 = a | (1LL << i);
			t3 = t2;
			for(int j = i;j >= 0;j--)t3 |= (1LL << j);
			flag = true;
			continue;
		}
		if(flag && B){
			//cout << "solo " << i << endl;
			t1 = b;
			for(int j = i;j >= 0;j--)t1 |= (1LL << j);
			break;
		}
	}
	
	ll ans = (t1 - a + 1) + (t3 - t2 + 1);
	if(t1 >= t2)ans -= (t1 - t2 + 1);
	/*
	cout << toBit(a) << endl;
	cout << toBit(b) << endl;
	cout << toBit(t1) << endl;
	cout << toBit(t2) << endl;
	cout << toBit(t3) << endl;
	*/
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <cstring>
#include <queue>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(1){
		int n,l,r; cin >> n >> l >> r;
		if(n==0&&l==0&&r==0)break;
		vector<int> a(n);
		for(int i=0;i<n;i++){
			cin >> a[i];
		}
		auto uruu=[&](int x){
			for(int i=0;i<n;i++){
				if(x%a[i]==0)return (i+1)%2;
			}
			return (n+1)%2;
		};
		int res=0;
		for(int i=l;i<=r;i++){
			res+=uruu(i);
		}
		cout << res << endl;
	}
}




Measured memory_bytes: 3100