akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
LL N;
LL K;
LL S[100001];
LL dp[100001];
LL nxt[100001];
LL MOD=1e9+7;
int main(){
	cin>>N>>K;
	vector<int>v;
	REP(i,sqrt(N)+10){
		if(i!=0){
			if(N/i!=0){
				v.push_back(N/i);
			}
			if(i<=N){
				v.push_back(i);
			}
		}
	}
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	vector<int>x;
	int c=v.size()-1;
	REP(i,v.size()){
		while(1){
			if(v[c]*v[i]<=N){
				break;
			}
			c--;
		}
		x.push_back(c+1);
	}

	vector<int>w;
	REP(i,v.size()){
		if(i==0){
			w.push_back(v[i]);
		}else{
			w.push_back(v[i]-v[i-1]);
		}
	}
	/*REP(i,v.size()){
		cout<<v[i]<<" "<<x[i]<<" "<<w[i]<<endl;
	}*/
	REP(i,w.size()){
		dp[i]=w[i];
	}
	REP(i,K-1){
		REP(j,100001){
			S[j]=0;
			nxt[j]=0;
		}
		REP(j,w.size()){
			S[0]+=dp[j];
			S[0]%=MOD;
			S[x[j]]-=dp[j];
			S[x[j]]+=MOD;
			S[x[j]]%=MOD;
		}
		REP(j,w.size()+1){
			if(j==0){
				continue;
			}
			S[j]+=S[j-1];
			S[j]%=MOD;
		}
		REP(j,w.size()){
			nxt[j]=S[j]*w[j];
			nxt[j]%=MOD;
		}
		
		REP(j,100001){
			dp[j]=nxt[j];
		}
	}
	
	LL ans=0;
	REP(i,w.size()){
		ans+=dp[i];
		ans%=MOD;
	}
	cout<<ans<<endl;
	
}

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

int main (){
  string s;cin>>s;
  ll n = s.size();
  if (s.at(n-1) == '3'){
    cout << "bon" << endl;
  }
  else if (s.at(n-1) == '0' || s.at(n-1) == '1' || s.at(n-1) == '6' || s.at(n-1) == '8'){
    cout << "pon" << endl;
  }
  else {
    cout << "hon" << endl;
  }
}


Measured memory_bytes: 3596
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

vector<pll> to[100005];

vector<ll> color;

void dfs(ll v,ll p=-1,ll d=0){
    if(d%2==0){
        color[v]=1;
    }
    for(auto x:to[v]){
        if(x.fi==p) continue;
        dfs(x.fi,v,d+x.se);
    }
    return ;
}

int main()
{
    ll n;
    cin >> n;
    color.resize(n,0);
    rep(i,n-1){
        ll u,v,w;
        cin >> u >> v >> w;
        u--; v--;
        to[u].push_back(make_pair(v,w));
        to[v].push_back(make_pair(u,w));
    }
    dfs(0LL);
    rep(i,n){
        cout << color[i] << endl;
    }
    return 0;
} 

Measured memory_bytes: 9600
#include<set>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    set<int> s;
    int q;
    cin>>q;
    while(q--)
    {
        int c,t;
        cin>>c>>t;
        if(c==0) 
        {
            s.insert(t);
            cout<<s.size()<<endl;
        }
        else if(c==1) 
        {
            cout<<s.count(t)<<endl;
        }
        else
        {
            s.erase(t);
        }
    }
}


Measured memory_bytes: 12456
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n;
	cin >> n;
	vi l(n * 2);
	rep(i, 0, n * 2) {
		cin >> l[i];
	}
	sort(all(l));
	int ans = 0;
	rep(i, 0, n * 2) {
		ans += min(l[i], l[i + 1]);
		i++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define MAX_N (100)
#define ABS(a) ((a) >= 0 ? (a) : -(a))

int main(int argc, char *argv[]) {
  int N, a[MAX_N], sum, avg, ret;
  scanf("%d", &N);
  for (int i = 0; i < N; i++)
    scanf("%d", &a[i]);
  sum = 0;
  for(int i = 0; i < N; i++)
    sum += a[i];
  if (ABS(sum - (sum / N) * N) <= ABS(sum - (sum / N + 1) * N))
    avg = sum / N;
  else
    avg = sum / N + 1;
  ret = 0;
  for (int i = 0; i < N; i++)
    ret += (a[i] - avg) * (a[i] - avg);
  printf("%d\n", ret);
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int N, K; cin >> N >> K;
  vi arr(N);
  rep(i,N) cin >> arr[i];

  vi ball(N+1);
  rep(i,N) ++ball[arr[i]];
  
  sort(all(ball));

  int ans = 0;
  rep(i,ball.size()-K) ans += ball[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e3 + 10;
int days[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int a, b;
	cin >> a >> b;
	if (days[a] == days[b]) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn._
object Main extends App{
  val sc = new java.util.Scanner(System.in)
  var n = sc.nextInt
  val a = sc.nextInt
  n=n-500*(n/500)
  if(n<=a){
    println("Yes")
  }
  else{
    println("No")
  }
}

Measured memory_bytes: 25420
#include <algorithm>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <cmath>

#define rep(i, x, n) for (int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

int main()
{
    string S;
    long long K;
    cin >> S >> K;
    string res = "1";
    int l = 0;
    rep(i, 0, S.size())
    {
        if (S[i] != '1')
        {
            res = S[i];
            break;
        }
        else
        {
            l++;
        }
    }
    if (l >= K)
    {
        cout << '1' << endl;
    }
    else
    {
        cout << res << endl;
    }
}

Measured memory_bytes: 256
# include <cctype>
# include <cstdio>

int main ( )  {
	
	int ans ( 0 ) ;

	for ( int i = 0 ; i < 3 ; ++ i )  {
		int c ;
		while ( isspace ( c = getchar ( ) ) ) ;
		ans += c == '1' ;
	}
	return ! printf ( "%d\n", ans ) ;
}


Measured memory_bytes: 128
import scala.io.StdIn.readInt

object Main {
  def scan(n:Int, cnt:Int, a:Array[Int]):Int = {
    if(n==1) cnt
    else if(a(n)!=0) a(n)
    else {
      val m = if(n%2==0)n/2 else n*3+1
      a(n) = scan(m,cnt+1,a)
      a(n)
    }
  }

  def main(args:Array[String]) = {
    var n = 0
    while( {n=readInt;n} != 0 ){
      println(scan(n,0,new Array[Int](1000001)))
    }
  }
}

Measured memory_bytes: 207736
N,M=map(int,input().split())

box_count=[1]*N
box_color=[1]
buf=[0]*(N-1)
box_color.extend(buf)

x,y=0,0
for _ in range(M):
    x,y=map(int,input().split())
    box_count[x-1]-=1
    box_count[y-1]+=1
    if box_color[x-1]==1:
        box_color[y-1]=1
    if box_count[x-1]==0 and box_color[x-1]==1:
        box_color[x-1]=0

ans=0
for cnt,color in zip(box_count,box_color):
    if cnt>0 and color==1:
        ans+=1

print(ans)

Measured memory_bytes: 5364
while True:
    s = input()
    if s == '0': break
    s = [s] + [input() for _ in range(2)]
    for i, m in enumerate(s):
        a=b=0
        for n in m[1:]:
            if n == 'A':
                a += 1
            else:
                b += 1
        if i != 2:
            ab = s[i+1][0]
            if ab == 'A':
                a += 1
            else:
                b += 1
            A, B = ('A', a), ('B', b)
            AB = sorted([A, B])
            A, B = AB[0][1], AB[1][1]
            print(A, B)
        else:
            A, B = ('A', a), ('B', b)
            AB = sorted([A, B], key=lambda x: x[1])
            if AB[1][0] == 'A':
                A, B = AB[1][1] + 1, AB[0][1]
            else:
                A, B = AB[0][1], AB[1][1] + 1
            print(A, B)

Measured memory_bytes: 7480
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<map>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const int INF = 2000000000;

ll N,M;
ll A,B,C;
std::string S,T;
bool F = true;
ll X[4][100010];
ll ans = 0;
ll LP(ll x,ll y){
	if(y < 0)return 0;
	if(y == 0)return 1;
	if(y % 2 == 0)return LP((x*x) % MOD,y / 2) % MOD;
	else return LP(x,y - 1)*x%MOD;
}
vector<int> G[5];
int main(){
	ios_base::sync_with_stdio(false);
	cin >> S;
	int cnd = 0;

	for(auto x : S){
		if(x == 'A'){ X[0][cnd]++; G[0].push_back(cnd); }
		if(x == 'B'){ X[1][cnd]++; G[1].push_back(cnd); }
		if(x == 'C'){ X[2][cnd]++; G[2].push_back(cnd); }
		if(x == '?'){ X[3][cnd]++; G[3].push_back(cnd); }
		cnd++;
	}
	REP(i,(signed)S.size()){
		X[0][i + 1] += X[0][i];
		X[1][i + 1] += X[1][i];
		X[2][i + 1] += X[2][i];
		X[3][i + 1] += X[3][i];
	}
	N = S.size();
	for(auto x : G[1]){
		ll p,q,a,c;
		a = (X[0][x - 1]) % MOD,c = (X[2][N - 1] - X[2][x]) % MOD,
			p = (X[3][x - 1]) % MOD,q = (X[3][N - 1] - X[3][x]) % MOD;
		ans +=
			(((a*c) % MOD*LP(3,p + q)) % MOD + ((a*q) % MOD*LP(3,p + q - 1)) % MOD +
			((p*c) % MOD*LP(3,p + q - 1)) % MOD + ((p*q) % MOD*LP(3,p + q - 2)) % MOD) % MOD;
		ans%=MOD;
	}
	for(auto x : G[3]){
		ll p,q,a,c;
		a = (X[0][x - 1]) % MOD,c = (X[2][N - 1] - X[2][x]) % MOD,
			p = (X[3][x - 1]) % MOD,q = (X[3][N - 1] - X[3][x]) % MOD;
		ans +=
			(((a*c) % MOD*LP(3,p + q)) % MOD + ((a*q) % MOD*LP(3,p + q - 1)) % MOD +
			((p*c) % MOD*LP(3,p + q - 1)) % MOD + ((p*q) % MOD*LP(3,p + q - 2)) % MOD) % MOD;
		ans %= MOD;
	}
	cout << ans%MOD << endl;
	return 0;
}

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

const int N = 1e+5 + 5;
int n, m;

vector<int> adj[N];
int dp[N], ans;
bool vis[N];
void dfs(int v)
{
    vis[v] = true;
    for (auto it : adj[v])
    {
        if (!vis[it])
            dfs(it);
        dp[v] = max(dp[v], 1 + dp[it]);
    }
    ans = max(ans, dp[v]);
    return;
}
int main()
{
    cin >> n >> m;
    for (int i = 1; i <= m; i++)
    {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
    }
    for (int i = 1; i <= n; i++)
        if (!vis[i])
            dfs(i);
    cout<<ans;
}

Measured memory_bytes: 8192
import sys
input = sys.stdin.readline

k = int(input())

a = []

for i in range(10):
    a.append(str(i))

for i in range(9):
    b = []
    for e in a:
        if e[0] == "0":
            b.append("0"+e)
            b.append("1"+e)
        elif e[0] == "9":
            b.append("8"+e)
            b.append("9"+e)
        else:
            b.append(str(int(e[0])-1)+e)
            b.append(e[0]+e)
            b.append(str(int(e[0])+1)+e)
    for e in b:
        a.append(e)

res = []
for e in a:
    if e[0] != "0":
        res.append(int(e))
res = list(set(res))
res.sort()

print(res[k-1])




Measured memory_bytes: 302724
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    int a, b; cin >> a >> b;
    if(a+b>=10){
        cout << "error" << endl;
    }
    else cout << a+b << endl;
    return 0;
}


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

signed main(void)
{
	string s;
	int a[4];

	a[0] = 0;
	a[1] = 4;
	a[2] = 6;
	a[3] = 8;
	cin >> s;
	rep(i, 4) 
	{
		if (s.size() >= a[i])
		{
			if (s[a[i]] == 'A')
				continue;
			else
				s.insert(s.begin() + a[i], 'A');
		}
	}
	if (s == "AKIHABARA")
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}


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

ans=''
ans+=''.join(['U']*(d-b))
ans+=''.join(['R']*(c-a))
ans+=''.join(['D']*(d-b))
ans+=''.join(['L']*(c-a+1))
ans+=''.join(['U']*(d-b+1))
ans+=''.join(['R']*(c-a+1))
ans+='DR'
ans+=''.join(['D']*(d-b+1))
ans+=''.join(['L']*(c-a+1))
ans+='U'
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a[100010];
long long ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	{
		ans+=a[i]/2;
		a[i]%=2;
		if(i<n&&a[i]&&a[i+1])
		{
			ans++;
			a[i]--;
			a[i+1]--;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 640
a,b,q = map(int,input().split())
inf = 10 ** 18
s = [-inf]
for _ in range(a):
  s.append(int(input()))
s.append(inf)
t = [-inf]
for _ in range(b):
  t.append(int(input()))
t.append(inf)
import bisect
st = [inf]
for i in range(1,a+1):
  here = bisect.bisect_left(t,s[i])
  st.append(min(abs(t[here-1]-s[i]),abs(t[here]-s[i])))
st.append(inf)
ts = [inf]
for j in range(1,b+1):
  here = bisect.bisect_left(s,t[j])
  ts.append(min(abs(s[here-1]-t[j]),abs(s[here]-t[j])))
ts.append(inf)
for _ in range(q):
  now = int(input())
  shere = bisect.bisect_left(s,now)
  there = bisect.bisect_left(t,now)
  z1 = abs(now-s[shere-1]) + st[shere-1]
  z2 = abs(now-s[shere  ]) + st[shere  ]
  z3 = abs(now-t[there-1]) + ts[there-1]
  z4 = abs(now-t[there  ]) + ts[there  ]
  print(min(z1,z2,z3,z4))

Measured memory_bytes: 20096
import qualified Data.Map as M

main = do
  [n,k] <- map read.words <$> getLine :: IO [Int]
  as    <- map read.words <$> getLine :: IO [Int]
  let shortages = M.fromList $ zip [1..] $ map ((k+1)-) as
  putStr $ solve n k shortages [] 0

solve n k shortages lasts step
  | step == k && win   = show (n+k*(n-1)) ++ "\n" ++ unwords ( map show $ ans n k lasts 0 )
  | step == k && not win = "-1"
  | otherwise = solve n k (M.insert l (s-1) shortages) (l:lasts) (step+1)
  where
  win = all (<=0) shortages
  (l,s) = M.foldlWithKey (\(mk,mv) k v -> if v > mv && k /= prev then (k,v) else (mk,mv)) (0,-100) shortages
  prev = if null lasts then 0 else head lasts
  ans n k (l:ls) 0 = filter (/=l) [1..n] ++ l : ans n k (l:ls) 1
  ans n k [e] _    = filter (/=e) [1..n]
  ans n k (e:l:ls) step = filter (\i -> i/=e && i/=l) [1..n] ++ l : ans n k (l:ls) (step+1)

-- ↓ 解法

-- 下記の操作で、財宝が見つからなかったとき、移動回数は1以上消費される。
-- 操作：財宝が存在する可能性のあるすべての箱を開ける。最後の箱は開けたままにする。
-- 操作をK+1回繰り返せば、必ず財宝が見つかる。(最初のK回で移動回数がすべて消費されるから。)
-- 1回目の操作で、財宝が存在する可能性がある箱はN個である。
-- 2回目以降の操作で、財宝が存在する可能性がある箱はN-1個(開いている箱を除く)である。
-- それぞれの箱が開けられる回数は、(K+1)-(最初のK回の操作のうち、最後に開けられた回数) である。
-- K回の操作で、どの箱を最後に開けるかを選べばよいが、下記の不足回数が最大の箱を選び、選ぶたびに1減らせばよい。
-- 不足回数：すべての操作で開けるには何回足りないか、すなわち最後に開けられる回数の必要最小限。(K+1-a_i)
-- ※ただし、連続して2度選ばれることはできない。(操作で開けない箱を最後に開けることはできないから。)
-- 最後に開ける箱をすべて選び終わった後、すべての箱の不足回数がゼロ以下であれば、勝てる。
-- 箱を開ける回数は、N + K(N-1) である。

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

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair <int, int>
#define pll pair <ll, ll>
#define gcd __gcd
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

const ll L = 1e5+5;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    string s;
  	cin >> s;

    if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3])
    {
        cout << "Bad" << endl;
    }

    else
    {
        cout << "Good" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, M, X[111111], l[111111];

  std::cin >> N >> M;

  if (N >= M) {
    std::cout << 0 << std::endl;

    return 0;
  }

  for (int i = 0; i < M; i ++)
    std::cin >> X[i];

  std::sort(X, X + M);

  for (int i = 0; i < M - 1; i ++)
    l[i] = X[i + 1] - X[i];

  std::sort(l, l + M - 1);

  std::cout << std::accumulate(l, l + M - N, 0LL) << std::endl;

  return 0;
}


Measured memory_bytes: 1024
from collections import deque

k = int(input())
a = deque(range(1, 10))

for i in range(k):
    x = a.popleft()
    mod = x % 10
    if mod != 0:
        a.append(x*10 + mod -1)
    a.append(x * 10 + mod)
    if mod != 9:
        a.append(x*10 + mod + 1)

print(x)

Measured memory_bytes: 11956
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        for(int i = 3; i < a +1; i++) {
            if(i % 10 == 3) {
                System.out.print(" " + i);
                continue;
            }
            if(i % 3 == 0) {
                System.out.print(" " + i);
                continue;
            }
            if(String.valueOf(i).contains("3")) {
                System.out.print(" " + i);
                continue;
            }
        }
        System.out.println();
    }
}


Measured memory_bytes: 29392
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;


// C++ implementation to find the length of
// longest increasing contiguous subarray
#include <bits/stdc++.h>

using namespace std;

// function to find the length of longest increasing
// contiguous subarray
int lenOfLongIncSubArr(long arr[], int n)
{
    // 'max' to store the length of longest
    // increasing subarray
    // 'len' to store the lengths of longest
    // increasing subarray at diiferent
    // instants of time
    int max = 1, len = 1;

    // traverse the array from the 2nd element
    for (int i=1; i<n; i++)
    {
        // if current element if greater than previous
        // element, then this element helps in building
        // up the previous increasing subarray encountered
        // so far
        if (arr[i] <= arr[i-1])
            len++;
        else
        {
            // check if 'max' length is less than the length
            // of the current increasing subarray. If true,
            // then update 'max'
            if (max < len)
                max = len;

            // reset 'len' to 1 as from this element
            // again the length of the new increasing
            // subarray is being calculated
            len = 1;
        }
    }

    // comparing the length of the last
    // increasing subarray with 'max'
    if (max < len)
        max = len;

    // required maximum length
    return max;
}

int main() {

    fast

    int n;
    cin>>n;

    long * arr=new long [n];
    for(int i=0;i<n;i++)cin>>arr[i];



    int ans=lenOfLongIncSubArr(arr,n);

        cout<<ans-1;




	return 0;
}


/*
ll  modularExponentiation(ll x,ll n,ll M)
{

    ll result=1;

    while(n>0)
    {

	if(n%2==1)

 result=(result*x)%M;

  x=(x*x)%M;

  n=n/2;

}

  return result;
}



*/


Measured memory_bytes: 1024
#include <iostream>
#include <stack>
#include <string>

using namespace std;

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

    stack<string> st;
    bool ok = true;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        if (s == "A") {
            st.push(s);
        }
        else {
            if (!st.empty()) {
                st.pop();
            }
            else {
                ok = false;
                break;
            }
        }
    }
    if (ok && !st.empty()) {
        ok = false;
    }
    if (ok) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3164
s=list(map(int,list(input())))[::-1]
n=len(s)
chk=[0]*2019
chk[0]=1
t,m,ans=1,0,0
for i in s:
    m=(m+t*i)%2019
    ans+=chk[m]
    chk[m]+=1
    t=t*10%2019
print(ans)

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

char X, Y;

int main() {
    cin >> X >> Y;

    if (X > Y) {
        cout << ">" << endl;
    } else if (X < Y) {
        cout << "<" << endl;
    } else {
        cout << "=" << endl;
    }
}

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
      cin >> vec.at(i);
  }
  vector<int> backet(N);
  for(int i =0 ; i < N; i++){
  	backet.at(vec.at(i) - 1)++;
  }
  int total = 0;
  for(int i = 0; i < N; i++){
    if(backet.at(i)) total++;
  }
  if(total <= K){
  	cout << 0 << endl;
  }
  else{
  	sort(backet.begin(), backet.end());
    int res = 0;
    bool f = false;
    int j = 0;
    for(int i = 0; i < N; i++){
		if(!backet.at(i)) continue;
      	if(!f){ 
          j = i;
          f = true;
        }
      	res += backet.at(i);
        if(i - j + 1>= total - K) break;
    }
    cout << res << endl;
  }
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

ll int gcd(int a,int b){
	if(b==0)
	return a;
	return gcd(b,a%b);	
}

int main(){
	ll int a,b;
	cin>>a>>b;
	
	ll int x=gcd(a,b);
	ll int y=a*b;
	//cout<<x<<"\n";
	ll int ans=y/x;
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 256
// copied from https://atcoder.jp/contests/abc177/submissions/16358885

#include <iostream>
#include <vector>
#define ll long long
using namespace std;

int main(void) {
	int N;
	cin >> N;
	int A[N];
	ll B[N+1];
	int mod = 1000000007;

	for (int i = 0; i < N; i++) {
		cin >> A[i];
		B[i + 1] = B[i] + A[i];
	}

	long ans = 0;

	//i について全探索する
	for (int i = 0; i < N; i++) {
		//累積和を使ってA[i+1] + ... + A[N] を求める
		long long sum = (B[N] - B[i + 1]) % mod;

		ans += A[i] * sum;
		ans %= mod;
	}

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



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

namespace abc167c
{
    class Program
    {
        static int output = -1;
        static List<int> priceHolder = new List<int>();
        static List<List<int>> scoreHolder = new List<List<int>>();
        static List<int> answerHolder = new List<int>();
        static int globalN;
        static int m;
        static int x;
        static void Main(string[] args)
        {
            //==========================================================================================================================
            //1) input
            List<int> input = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            globalN = input[0];
            m = input[1];
            x = input[2];

            for (int index = 0; index < globalN; index++)
            {
                List<int> input1 = Console.ReadLine().Split(' ').Select(int.Parse).ToList();

                priceHolder.Add(input1[0]);
                input1.RemoveAt(0);
                scoreHolder.Add(input1);
            }
            //==========================================================================================================================
            //2) output


            Execute(globalN, new int[globalN]);

            if (answerHolder.Count ==0)
            {
                output = -1;
            }
            else
            {
                output = answerHolder.Min();
            }

            

            Console.WriteLine(output);

        }


        /// <summary>
        /// n桁の数において、各桁の数値「0,1,2」を用いた組み合わせの総当たり
        /// </summary>
        /// <param name="n">桁数</param>
        public static void Execute(int n, int[] a)
        {
            if (n < 1)
            {
                var total = 0;
                var holder = new int[m];
                for (int index = 0; index < globalN; index++)
                {
                    if (a[index] == 1)
                    {
                        total += priceHolder[index];

                        for (int indexM = 0; indexM < m; indexM++)
                        {
                            holder[indexM] += scoreHolder[index][indexM];
                        }
                    }
                }

                if (!holder.Any(v => v < x))
                {
                    answerHolder.Add(total);
                }

            }
            else
            {
                a[n - 1] = 0;
                Execute(n - 1, a);
                a[n - 1] = 1;
                Execute(n - 1, a);
            }


        }
    }
}


Measured memory_bytes: 28796
// 2014/02/06 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

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

	int A[100002];
	A[0] = 0;
	for(int i=1; i<=N; i++){
		cin >> A[i];
	}
	A[N+1] = 0;

	int T[100002] = {0};
	int T_max = 0;

	int n = N;
	while(true){
		for(int i=1; i<=N; i++){
			if(A[i-1]<A[i] && A[i]>A[i+1]){
				T[i] = max(T[i-1], T[i+1])+(L-A[i]);
				T_max = max(T_max, T[i]);
				A[i] = 0;
				n--;

				i++;
			}
		}

		if(n==0)
			break;
	}

	cout << T_max << endl;

	return 0;
}

Measured memory_bytes: 1948
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int N = sc.nextInt();
      int K = sc.nextInt();
      int count = 0;

      for(int i =0;i<N;i++){
        int h = sc.nextInt();
        if(h>=K){
          count++;
        }
      }
      System.out.println(count);
                   }
      }


Measured memory_bytes: 46764
#include <bits/stdc++.h>
using namespace std;
vector <int> v;
vector <char> vc;
vector <string> vs;
map <string,int> sm;
map <int,int> mp;
map <char,int>cm;
//int string_to_int(string s){stringstream x(s);double a=0; x>>a; return a;}
//long long int gcd(long long int a, long long int b){if(a%b==0)return b;return gcd(b, a%b);}
//long long int lcm(long long int a, long long int b){return (a*b)/gcd(a, b);}
//int string_sum(string s){int b = 0;auto k =s.size();for(int j=0; j<k; j++){b +=(s[j]-48);}return b;}
//long long int factorial(long long int n){if (n == 0)return 1;return n * factorial(n - 1);}
#include <bits/stdc++.h>
using namespace std;

int main() {
    int a,b,c=0,n;
    string s,p;
    cin >> n;
    int j=0;
    
    for(int i=0; i<n; i++)
        {
      		cin >> a;
            v.push_back(a);     
        } 
    sort(v.begin(),v.end());    
    for (int i = 0; i < n - 2; ++i)
        {
            int k = i + 2;
            for (int j = i + 1; j < n; ++j)
            {         
                while (k < n && v[i] + v[j] > v[k])
                ++k;           
                if(k > j)
                c += k - j - 1;
            }
        }       
    cout << c << endl;
       
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}


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

    for (;;) {
        int t, n; cin >> t >> n;
        if (t == 0) break;
        const int MAX = 61;
        int used[MAX * 2 + 1][MAX * 2 + 1];
        memset(used, 0, sizeof(used));
        REP(i, n) {
            int x, y; cin >> x >> y;
            used[y + MAX][x + MAX] = -1;
        }
        int sx, sy; cin >> sx >> sy;

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

        queue<tuple<int,int,int>> que;
        que.emplace(sy, sx, 0);
        used[sy + MAX][sx + MAX] = 1;
        while (!que.empty()) {
            int y, x, d; tie(y, x, d) = que.front();
            que.pop();
            if (d == t) continue;
            REP(k, 6) {
                int ny = y + dy[k], nx = x + dx[k];
                if (used[ny + MAX][nx + MAX] == 0) {
                    used[ny + MAX][nx + MAX] = 1;
                    que.emplace(ny, nx, d + 1);
                }
            }
        }

        int ans = 0;
        REP(i, MAX * 2 + 1) {
            REP(j, MAX * 2 + 1) {
                if (used[i][j] == 1) ++ans;
            }
        }
        cout << ans << endl;
   }

    return 0;
}



Measured memory_bytes: 3244
#include<stdio.h>

int search(int A[], int n, int key){
	int i = 0; A[n] = key;
	while(A[i] != key) i++;
	return i != n;
}

int main(void){
	int i, n, A[10000 + 1], q, key, sum = 0;
	scanf("%d", &n);
	for(i = 0; i < n; i++) scanf("%d", &A[i]);
	scanf("%d", &q);
	for(i = 0; i < q; i++){
		scanf("%d", &key);
		if(search(A, n, key)) sum++;
	}
	printf("%d\n", sum);
	return 0;
}


Measured memory_bytes: 2108
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#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 rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>()>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    ll n=lin();
    ll m=(ll)sqrt(n);
    while(n%m!=0||m*(m+1)>=n){
        m--;
        if(m==0)break;
    }
    ll ans=0;
    rep2(k,1,m){
        if(n%k==0)ans+=n/k-1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/operators.hpp>
#include <boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	std::string str;
	std::cin >> str;
	std::cout << (str[2] == str[3] && str[4] == str[5] ? "Yes" : "No") << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, k ;
    vector<int> d;
    vector<vector<int>> A ;
    cin >> n >> k ;
    d.resize(k);
    A.resize(k, vector<int>() );
    for(int i = 0; i < k ; i++)
    {
        cin >> d[i];
        A[i].resize(d[i]);
        for(int j = 0 ; j < d[i] ; j++)
        {
            cin >> A[i][j] ;
        }
    }

    int ans = 0 ;
    for(int i = 1 ; i <= n ; i++)
    {
        bool flag = false;
        for(auto x : A){
            for (auto y : x )
            {
                if ( y == i) flag = true ;
            }
        }

        if(!flag) ans++; 
    }
     cout << ans << endl ;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
#include<cmath>
#include<string>
#include<iomanip>
#include <numeric>
#include <limits>
using namespace std;

int main()
{
string a,b; cin>>a>>b;
int ab= stoi(a+b);
int s= (int) sqrt(ab);
if(s*s==ab) cout<<"Yes";
else cout<<"No";
return 0;
}


Measured memory_bytes: 3620
def prime_factorize(n):
    ans = []
    for i in range(2, int(n ** (1 / 2)) + 1):
        while True:
            if not n % i == 0:
                break
            ans.append(i)
            n /= i
        if n == 1:
            break
    if n != 1:
        ans.append(int(n))
    return ans

a, b = map(int, input().split())
s = set(prime_factorize(a))
t = prime_factorize(b)
ans = 1
for i in s:
    if i in t:
        ans += 1
print(ans)

Measured memory_bytes: 3064
from collections import defaultdict

N = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)

for i in a:
    d[i] += 1
cnt = 0
ans = 0
for k, v in d.items():
    if v != 1:
        cnt += v - 1
    ans += 1

if cnt == 0:
    print(ans)
elif cnt == 1:
    print(ans - 1)
elif cnt % 2 == 0:
    print(ans)
else:
    print(ans - 1)

Measured memory_bytes: 18656
#include <stdio.h>

void insert(int len, int a[len]);

int main()
{
  int n;
  scanf("%d",&n);
  int a[n];
  int b[n];
  int c[n-1];
  insert(n, a);
  insert(n, b);
  insert(n-1, c);
  int i;
  i = 0;
  int satisfaction;
  satisfaction = 0;
  while (i < n)
  {
    satisfaction += b[a[i] - 1];
    if (i != n-1 && a[i] + 1 == a[i + 1])
    {
      satisfaction += c[a[i] - 1];
    }
    i++;
  }
  printf("%d",satisfaction);
}

void insert(int len, int a[len])
{
  int i;
  i = 0;
  while (i < len)
  {
    scanf("%d",&a[i]);
    i++;
  }
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>


using namespace std;
typedef long long ll;

ll N, M = 0;

int main(){

    cin >> N >> M;

    vector<pair<ll, ll> > T;
    //入力
    ll A, B = 0;
    for(int i = 0; i < N; i++){
        cin >> A >> B;
        T.push_back(make_pair(A, B));
    }

    ll yen = 0;

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

    ll num = 0;
    ll i = 0;
    for(;;){
        if(num == M){
            break;
        }

        if(T[i].second == 0){
            i++;
        }else{
            yen += T[i].first;
            T[i].second --;
            num++;
        }
    }

    cout << yen << endl;
    
}

Measured memory_bytes: 2420
n = int(input())
a = list(map(int, input().split()))
x = [0]*100001
for i in range(n):
    x[a[i]] += 1
q = int(input())
ans = sum(a)
for i in range(q):
    b, c = map(int, input().split())
    ans += x[b]*(c-b)
    x[c] += x[b]
    x[b] = 0
    print(ans)

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll; 
typedef std::pair<ll, ll> PLL;

signed main() {
    vector<ll> v(4);
    rep(i,0,3){
        ll a,b;
        cin>>a>>b;
        v[a-1]++;
        v[b-1]++;
    }
    sort(begin(v),end(v));
    if(v == vector<ll>{1,1,2,2}){                                                                        
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }   
    return 0;
} 

Measured memory_bytes: 256
params = [int(x) for x in input().split(" ")]

X = params[0]
Y = params[1]
Z = params[2]

K = params[3]

A = [int(x) for x in input().split(" ")]

B = [int(x) for x in input().split(" ")]

C = [int(x) for x in input().split(" ")]

A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)

history = []
ansList = []

queue = []

queue.append([A[0]+B[0]+C[0], 0,0,0])
history.append(queue[0])



while True:
	queue.sort(reverse=True)
	ansList.append(queue[0])

	if len(ansList) >= K:
		break

	Aindex = queue[0][1]
	Bindex = queue[0][2]
	Cindex = queue[0][3]

	queue = queue[1:]

	try:
		nextA = [A[Aindex+1]+B[Bindex]+C[Cindex], Aindex+1, Bindex, Cindex]
		if not nextA in history:
			queue.append(nextA)
			history.append(nextA)
	except:
		pass

	try:
		nextB = [A[Aindex]+B[Bindex+1]+C[Cindex], Aindex, Bindex+1, Cindex]
		if not nextB in history:
			queue.append(nextB)
			history.append(nextB)
	except:
		pass

	try:
		nextC = [A[Aindex]+B[Bindex]+C[Cindex+1], Aindex, Bindex, Cindex+1]
		if not nextC in history:
			queue.append(nextC)
			history.append(nextC)
	except:
		pass
		
for ans in ansList:
	print(ans[0])

Measured memory_bytes: 4596
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const [a, b, c, x, y] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

const res = _ => {
  const totals = []

  for (let n = 0; n <= Math.max(x, y) * 2; n += 2) {
    const aCount = x - Math.abs(n / 2) >= 0 ? x - Math.abs(n / 2) : 0
    const bCount = y - Math.abs(n / 2) >= 0 ? y - Math.abs(n / 2) : 0
    const total = aCount * a + bCount * b + n * c

    totals.push(total)
  }

  return Math.min(...totals)
}

console.log(res())


Measured memory_bytes: 10572
#include <bits/stdc++.h>
#define repz(i, z, n) for(decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for(decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(all(v)))
#define MIN(v) (*min_element(all(v)))
#define INF 1000000000000 //1E+12
#define MOD 1000000007    //合同式の法

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<

using namespace std;
typedef long long ll;
typedef unsigned long long ul;
// 1s間で可能なループ回数2E+8回
// intの最大値2147483647~2E+9
// long longの最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<> push_back
// 連想配列map<key,value> insert,
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 setprecision()
// to_string<->stoi
// stoll(longlong)
// stod(double)
// 大文字65-90(-32)
// 小文字97-122(+32)
// 1E+9 +7
typedef pair<int,int> P;
const ll mod = 1000000000+7;
struct edge{ll to, cost;};

// s:start, d:distance, g: hen, prev asi
void shortest_path(int s,vector<ll> &d, vector<vector<edge>> &G,vector<ll> &prev){
  priority_queue<P, vector<P>,greater<P>> que;

  d=vector<ll>(SIZE(d),INF);
  prev = vector<ll>(SIZE(d), INF);
  d[s]=0;
  que.push(P(0,s));

  while(!que.empty()) {
    P p = que.top(); que.pop();
    // cout << p.F << p.S << endl;
    int v = p.second;
    if(d[v]<p.first) continue;
    for(edge e:G[v]){
      // cout << e.to << "<-"<< v << endl;
      // cout << d[e.to] << d[v] << e.cost << endl;
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v]+e.cost;
        que.push(P(d[e.to],e.to));
        prev[e.to] = v;
      }
    }
    // cout << d[0] << d[1] << d[2] << d[3] << endl;
  }
}
int main(){
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n, m; cin >> n >> m;
  vector<ll> d(n);
  vector<vector<edge>> G(n, vector<edge>(0));
  vector<ll> prev;

  rep(i,m){
    int a,b;  cin >> a >> b;
    edge e, j;
    e.cost = 1;
    e.to = b-1;
    j.cost = 1;
    j.to = a-1;
    G[a-1].push_back(e);
    G[b-1].push_back(j);
  }
  // rep(i,n){
  //   for(edge e:G[i]){
  //     cout << i << " " << e.to << endl;
  //   }
  // }
  shortest_path(0, d, G, prev);
  repz(i,1,n){
    if(d[i]==INF){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  repz(i,1,n) cout << prev[i]+1 << endl;
  return 0;
}


Measured memory_bytes: 18104
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;
ll ma[200006];
signed main()
{
    fast;
   
    ll n,i,j,sum=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
    	ll x;
    	cin>>x;
    	ma[x]++;
    	sum += x;
    }
    ll q;
    cin>>q;
    while(q--)
    {
    	ll b,c;
    	cin>>b>>c;
    	ma[c] += ma[b];
    	sum -= ma[b]*b;
    	sum += ma[b]*c;
    	ma[b] = 0;
    	cout<<sum<<"\n";
    }

}

Measured memory_bytes: 4392
import heapq
import sys
from itertools import product
X, Y, Z, K = [int(i) for i in sys.stdin.readline().split()]
A_ls = [int(i) for i in sys.stdin.readline().split()]
B_ls = [int(i) for i in sys.stdin.readline().split()]
C_ls = [int(i) for i in sys.stdin.readline().split()]
A_ls.sort(reverse=True)
B_ls.sort(reverse=True)
C_ls.sort(reverse=True)
_sum_ls = [(-(A_ls[0] + B_ls[0] + C_ls[0]), 0, 0, 0)]
heapq.heapify(_sum_ls)
for i in range(K):
    score, a, b, c = heapq.heappop(_sum_ls)
    print(- score)
    if len(A_ls) > a+1:
        cand = (- (A_ls[a+1] + B_ls[b] + C_ls[c]), a+1, b, c)
        if not cand in _sum_ls:
            heapq.heappush(_sum_ls, cand)
    if len(B_ls) > b+1:
        cand = (- (A_ls[a] + B_ls[b+ 1] + C_ls[c]), a, b+1, c)
        if not cand in _sum_ls:
            heapq.heappush(_sum_ls, cand)
    if len(C_ls) > c+1:
        cand = (- (A_ls[a] + B_ls[b] + C_ls[c+1]), a, b, c+1)
        if not cand in _sum_ls:
            heapq.heappush(_sum_ls, cand)

Measured memory_bytes: 3828
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        for (int i = a; i <= b; i++) {
            if (i % k == 0) {
                System.out.println("OK");
                return;
            }
        }
        System.out.println("NG");
    }
}


Measured memory_bytes: 35812
#include <stdio.h>
#define MAX_N (100000)

int main(void) {
  int N;
  scanf("%d", &N);

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

  int B = 0;
  for(int i = 0; i < N; i++) {
    B ^= A[i];
  }
  if(B == 0) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a, b, c, n;
    int ans = 0;
    cin >> a >> b;
    ans = a-b*2;
    if(ans < 0) ans= 0;
    cout << ans << endl;
    return 0;
}

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

void output(int *A, int N)
{
	for (int i = 0; i < N; i++) {
		cout << A[i];
		(i + 1 == N) ? cout << endl : cout << " ";
	}
}

//挿入ソート
int main()
{
	int N, A[100];

	//入力
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	output(A, N);

	//挿入ソート
	int j;
	for (int i = 1; i < N; i++) {
		j = i;
		while ((j > 0) && (A[j - 1] > A[j])) {
			//交換
			swap(A[j - 1], A[j]);
			j--;
		}
		output(A, N);
	}

	return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define w(t) int t;cin>>t;while(t--)
#define pb push_back
#define mk make_pair
#define ascSort(v) sort(v.begin(), v.end())
#define descSort(v) sort(v.begin(), v.end(), greater<int>())
#define ff first
#define ss second
#define pi pair<int,int>
#define vi vector<int>
#define umapi unordered_map<int,int>
#define INF 1000000007
const int mod=998244353;
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>PBDS;

void FIO(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
}

int32_t main(){
	
	FIO();
	
		string s,t;cin>>s>>t;
		if(s.length()+1==t.length()&&t.substr(0,s.length())==s)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	
	
	return 0;
	
		
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define vec vector<int>
using namespace std;
main()
{
  int t=1;
  //cin>>t;
  while(t--)
  {
    int n,i;
    cin>>n;
    /*vector<int> a(n);
    for(i=0;i<n;i++)
        cin>>a[i];
    */
    int ans=ceil(double(n)/1000)*1000-n;
    cout<<ans<<"\n";
  }
}


Measured memory_bytes: 3616