akhauriyash/Code-Regression huggingface dataset:
from decimal import *

n,k = map(int,input().split())
a = list(map(int,input().split()))
MOD = 10**9 + 7

ze = []
pl,mi = [],[]
for i in range(n):
    if a[i] < 0:
        ze.append((-a[i],1))
        mi.append(a[i])
    else:
        ze.append((a[i],0))
        pl.append(a[i])
        
ze.sort(reverse = True)
pl.sort(reverse = True)
mi.sort()

one = 0
for i in range(k):
    one += ze[i][1]
    
ans = 1
zero = k-one

if one % 2 == 0:
    for i in range(k):
        ans = ans * ze[i][0] % MOD
    print(ans)
        
elif len(pl) == 0:
    for i in range(k):
        ans = ans * mi[n-1-i] % MOD
    print(ans)
        
else:
    if (zero == len(pl) and one == len(mi)) or len(pl) == 0 or len(mi) == 0:
        ak = [zero,one]
    elif (zero != len(pl) and one == len(mi)) or zero == 0:
        ak = [zero+1,one-1]
    elif zero == len(pl) and one != len(mi) or one == 0:
        ak = [zero-1,one+1]
    else:
        if Decimal(abs(mi[one]))/Decimal(pl[zero-1]) >= Decimal(pl[zero])/Decimal(abs(mi[one-1])):
            ak = [zero-1,one+1]
        else:
            ak = [zero+1,one-1]
            
    ans = 1
    for i in range(ak[0]):
        ans = ans * pl[i] % MOD
    for i in range(ak[1]):
        ans = ans * mi[i] % MOD
        
    print(ans)

Measured memory_bytes: 129080
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
def f(n):
    if n < 2:
        return 1
    else:
        return n * f(n - 2)

"""
2,5が大事
11 > 9 > 7 > 5 > 3 > 1

10 > 8 > 6 > 4 > 2 > 1
10の個数

というより5の倍数をどう数えるかが重要．
まず10でぜんたいを割って10による部分をansにたす．
その後，5の倍数を取り出す．
"""
if N % 2 == 1:
    print("0")
    sys.exit()

# base_ans = 0
# fn = str(f(N))
# while True:
#     if len(fn) < 1:
#         break
#     if fn[-1] == "0":
#         base_ans += 1
#         fn = fn[:-1]
#     else:
#         break
# print(base_ans)

ans = 0
if N >= 10:
    N //= 10
    ans += N

n = copy.deepcopy(N)
while n > 4:
    n //= 5
    ans += n

print(ans)

Measured memory_bytes: 10932
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int n = sc.nextInt();
		if(n == 0) {
			System.out.println(x);
			return;
		}

		int p [] = new int [n];

		for(int i = 0; i < n; i++) {
			p[i] = sc.nextInt();
		}


		int ans = x;
		for(int i = 0; i < 101; i++) {
			boolean t = true;
			for(int j = 0; j < n; j++) {
				if(p[j] == ans) {
					t = false;
				}
			}
			if(t) {
				System.out.println(ans);
				return;
			}

			if(i % 2 == 0) {
				ans -= (i + 1);

			}else {
				ans += (i + 1);
			}
		}
	}
}

Measured memory_bytes: 35748
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    int res = 1;
    while(b > 0){
        if(b&1) res = m(m(res)*m(a));
        a = m(m(a)*m(a));
        b >>= 1;
    }
    return res;
}
signed main(){
    fast();
    int n;
    cin >> n;
    vector<vector<int>> combs(10001, vector<int>(4, 0));
    for(int i=1; i<=100; i++){
        for(int j=i; j<=100; j++){
            for(int k=j; k<=100; k++){
                if(i*i+j*j+k*k+i*j+j*k+k*i <= 10000){
                    set<int> st;
                    st.ins(i); st.ins(j), st.ins(k);
                    combs[i*i+j*j+k*k+i*j+j*k+k*i][st.size()]++;
                }
            }
        }
    }
    vector<int> ans(n+1);
    for(int i=0; i<=n; i++){
        combs[i][2] *= 3;
        combs[i][3] *= 6;
        ans[i] = combs[i][1]+combs[i][2]+combs[i][3];
    }
    for(int i=1; i<=n; i++){
        cout << ans[i] << endl;
    }
    cerr << "\nTime elapsed : " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
}

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

int n;
int ans;
void solve () {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans = 1e9;
    for (int i = 0, j = k - 1; j < n; i++, j++) {
        ans = min (ans, a[j] - a[i]);
    }
    cout << ans;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }

using ll = long long;
const ll mod = LLONG_MAX;

int main(){
 string s;
 cin>>s;
 for(int i=0;i<s.size()-1;i++){
   if(s[i]=='A'&&s[i+1]=='C'){
     cout<<"Yes"<<endl;
     return 0;
   }
 }
 cout<<"No"<<endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <math.h>

using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define PRIME 1000000007
#define ADD(a, b) (((a) % PRIME + (b) % PRIME) % PRIME)
#define MUL(a, b) ((((a) % PRIME) * ((b) % PRIME)) % PRIME)
#define SUB(a, b) (((a) % PRIME - (b) % PRIME + PRIME) % PRIME)

long long gcd(long long a, long long b) {
	a = abs(a); b = abs(b);
	if (a < b) { long long t = a; a = b; b = t; }
	if (a == b || b == 0)return a;
	else return gcd(b, a % b);
}

void solve() {
	int n; cin >> n;
	map<pair<long long, long long>, pair<long long, long long>> cnt;
	REP(i, n) { 
		long long a, b; 
		cin >> a >> b;

		if (a < 0) {
			a *= -1; b *= -1;
		}

		if (b == 0 && a != 0) {
			cnt[make_pair(1, 0)].first++;
		}
		else if (a == 0 && b != 0) {
			cnt[make_pair(1, 0)].second++;
		}
		else if (a == 0 && b == 0) {
			cnt[make_pair(0, 0)].first++;
		}
		else if (b > 0) {
			long long g = max(gcd(a, b), 1LL);
			cnt[make_pair(a / g, b / g)].first++;
		}
		else {
			long long g = max(gcd(a, b), 1LL);
			cnt[make_pair(-b / g, a / g)].second++;
		}
	}

	long long ans = 1; 
	long long zero = cnt[make_pair(0, 0)].first;
	for (auto c : cnt) {
		long long val = 1;
		if (c.first.first == 0 && c.first.second == 0) {
			continue;
		}
		else if (c.second.first == 0) {
			REP(i, c.second.second) val = MUL(val, 2);
		}
		else if (c.second.second == 0) {
			REP(i, c.second.first) val = MUL(val, 2);
		}
		else {
			long long val1 = 1, val2 = 1;
			REP(i, c.second.first) val1 = MUL(val1, 2);
			REP(i, c.second.second) val2 = MUL(val2, 2);
			val = ADD(val1, val2);
			val = SUB(val, 1);
		}
		ans = MUL(ans, val);
	}
	cout << (ans + zero - 1 + PRIME) % PRIME << endl;


}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 19104
#include<stdio.h>

int main(void){
   int a,b,c,d,i;
   int cnt1=0;
   int cnt2=0;
   scanf("%d %d %d %d", &a,&b,&c,&d);
   for(i=0;i*b<c;i++){
      cnt1++;
   }
   for(i=0;i*d<a;i++){
      cnt2++;
   }
   if(cnt1 <= cnt2){
      printf("Yes\n");
   } else {
      printf("No\n");
   }
}


Measured memory_bytes: 1660
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};



signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N,M,K; cin >> N >> M >> K;
    VI deg(N);
    VI de(N);
    UnionFind uf(N);
    REP(i,M){
        int a,b; cin >> a >> b;
        a--; b--;
        deg[a]++;
        deg[b]++;
        uf.unite(a,b);
    }
    REP(j,K){
        int a,b; cin >> a >> b;
        a--; b--;
        int ta = uf.find(a);
        int tb = uf.find(b);
        if(ta == tb){
            de[a]++;
            de[b]++;
        }
    }
    REP(i,N){
        int ans = uf.size(i) - deg[i] - de[i];
        cout << ans-1 << endl;
    }

}


Measured memory_bytes: 2048
S = input()
X, Y = map(int, input().split())

def run_length(s) -> list:
    res = [[s[0], 1]]
    for i in range(1, len(s)):
        if res[-1][0] == s[i]:
            res[-1][1] += 1
        else:
            res.append([s[i], 1])
    return res

RL = run_length(S)
if RL[0][0] == 'T':
    RL = [['F', 0]] + RL

SIZE = len(S)
nx = 1 << SIZE
ny = 1 << SIZE

x_flag = 1
for i in range(0, len(RL), 2):
    s, l = RL[i]
    if i == 0:
        nx = nx << l
    else:
        x_flag = (x_flag + RL[i - 1][1]) % 2
        if x_flag:
            nx = (nx << l) | (nx >> l)
        else:
            ny = (ny << l) | (ny >> l)

if ((nx >> (SIZE + X)) & 1) & ((ny >> (SIZE + Y)) & 1):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 40304
#include<iostream>
#include <algorithm>
#include <string>
using namespace std;
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
typedef long long ll;
const int INF = numeric_limits<int>::max();
const int MOD = (1e9 + 7);

int main(){
  int N, M;
  cin >> N >> M;
  ll sum = 0;
  int a[N], b[N];
  rep(i, N){
    a[i] = i+M;
    sum += a[i];
    if(a[i]<0) b[i] = -a[i];
    else b[i] = a[i];
  }
  
  int minb = b[0]; int mini = 0;
  rep(i, N-1){
    if(b[i+1]<b[i]){
      minb=b[i+1];
      mini = i+1;
  }
  }
  sum -= a[mini];
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define int long long
#ifdef DEBUG
std::ostream& dout = cout;
#else
stringstream dout;
#endif
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
	in >> p.first >> p.second;
	return in;
}
signed main(signed argc, char* argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	const int MOD = 1e9 + 7;
	string s,t;
	cin>>s>>t;
	int a,b;
	cin>>a>>b;
	string u;
	cin>>u;
	if(s==u)a--;
	if(t==u)b--;
	cout<< a<<' '<<b<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int N,count=0;
    double prob;
    cin>>N;
    for(int i=1;i<=N;i++)
        if(i%2==1) count++;
    prob=(double)count/N;
    printf("%.10lf\n",prob);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;
string i;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin >>a>>b>>c;
  if(b-a==c-b) cout <<"YES\n";
  else cout <<"NO\n";
  return 0;
}


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

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>

#define INF 100000000000
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

struct UnionFind{
    vector<long long int> par; //par[i] : iの親の番号
    vector<long long int> rnk; //root[i] : iの木のランク

    //コンストラクタ
    UnionFind(long long int n): par(n), rnk(n){
        //木の初期化
        for(long long int i = 0; i < n; i++){
            par[i] = i;
            rnk[i] = 1;
        }
    }

    //データxが属する木の根を再帰で取得
    long long int root(long long int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = root(par[x]);
        }
    }

    //xとyが同じ木に属しているかを判定
    bool same(long long int x, long long int y){
        return root(x) == root(y);
    }

    //xとyの木を併合
    void unite(long long int x, long long int y){
        long long int rx = root(x); //xの根
        long long int ry = root(y); //yの根
        if(rx == ry) return; //根が同じならそのまま

        if(rnk[rx] < rnk[ry]){
            par[rx] = ry;
        }else{
            par[ry] =rx;
            if(rnk[rx] == rnk[ry]) rnk[rx]++;
        }
    }
};

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

    UnionFind road(n), rail(n);
    int i;
    int p, q;
    for(i = 0; i < k; i++){
        cin >> p >> q;
        road.unite(p-1, q-1);
    }
    for(i = 0; i < l; i++){
        cin >> p >> q;
        rail.unite(p-1, q-1);
    }

    map<pair<int, int>, int> m;
    for(i = 0; i < n; i++){
        m[make_pair(road.root(i), rail.root(i))]++;
    }

    for(i = 0; i < n; i++){
        cout << m[make_pair(road.root(i), rail.root(i))] << endl;
    }
}

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

using namespace std;

long long n, a, b;
vector<long long> h;

bool solve(long long total) {
  long long cnt_a = total;
  long long cnt_b = 0;
  for (int i = 0; i < n; i++) {
    long long rest = h[i] - a * cnt_a - b * cnt_b;
    if (rest > 0) {
      return false;
    }
    long long cnt = - rest / (a - b);
    cnt_a = cnt;
    cnt_b = total - cnt_a;
  }
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> a >> b;
  h = vector<long long>(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  sort(h.begin(), h.end(), greater<long long>());
  long long ok = (h[0] + b - 1) / b;
  long long ng = (h[0] + a - 1) / a - 1;
  while (ok - ng > 1) {
    long long mid = (ok + ng) / 2;
    if (solve(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  cout << ok << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <vector>
#include <cstdlib> //abs(int)
using namespace std;
int main(void){
  string A;
  cin >> A;
  sort(A.begin(),A.end());
  if(A == "abc"){
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 5

int main(void)
{
        int a[5]={0, 0, 0, 0, 0};
        scanf("%d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &a[4]);
        int i = 0, j = 0,m = 0;

        for(i = 0; i < MAX; i++)
        {
                for(j = i + 1; j < MAX ; j++)
                {
                        if(a[i]<a[j])
                        {
                                   m = a[i];
                                a[i] = a[j];
                                a[j] = m;
                        }
                }

        }
        printf("%d %d %d %d %d\n",a[0],a[1],a[2],a[3],a[4]);

        return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;


signed main() {
    string a, b;
    cin >> a >> b;
    ll r = (ll)b.size();
    ll tmp = 0;
    
     
    rep(i, (ll)a.size()-(ll)b.size()+1) {
        tmp = 0;
        rep(j, (ll)b.size()) {
            if(a[i+j] != b[j]) {
                tmp ++;
            }
        }
        r = min(r, tmp);
        
    }
    mes(r);
    
    
    
        
    
    
    
    
    
    
    
    
}

Measured memory_bytes: 3632
use std::env;
use std::io::*;
use std::str::*;
use std::mem;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}
fn read_char() -> char {
    let c = read::<String>();
    let c = c.chars().collect::<Vec<char>>();
    c[0]
}
fn read_String_Vec() -> Vec<char> {
    let S = read::<String>();
    S.chars().collect::<Vec<char>>()
}

fn vecchar_to_String(Vs: Vec<char>) -> String {
    let mut S = String::new();
    for i in 0..Vs.len() {
        S.push(Vs[i]);
    }
    S
}

/*
A : 65
Z : 90
a : 97
z : 122
*/

/*
let N = read::<i32>();
let S = read::<String>();
let S = read_String_Vec();
let C = read_char();
*/

/*
 .to_string() : * -> String
 &*S          : String -> &str
*/

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let N = read::<i32>();
    let mut T = Vec::new();
    for t in 0..N {
        let tmp = read::<i32>();
        T.push(tmp);
    }

    let M = read::<i32>();
    let mut P = Vec::new();
    let mut X = Vec::new();

    for m in 0..M {
        let tmp1 = read::<i32>();
        let tmp2 = read::<i32>();
        P.push(tmp1);
        X.push(tmp2);
    }
    let sum_time = {
        let mut sum = 0;
        for t in &T {
            sum += *t;
        }
        sum
    };

    for m in 0..(M as usize) {
        println!("{}", sum_time - T[(P[m]-1) as usize] + X[m]);
    }


}


Measured memory_bytes: 4352
N = int(input())
S = input()

pos = [[] for i in range(10)]

for i, s in enumerate(S):
    pos[int(s)].append(i)

res = set()


def calc(i, pin):
    if len(pin) == 3:
        res.add(pin)
        return

    for num in range(10):
        tmp = list(filter(lambda x: x > i, pos[num]))
        if len(tmp) == 0:
            continue
        calc(tmp[0], pin + str(num))


calc(-1, '')
print(len(res))


Measured memory_bytes: 5008
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define dbgi(x) cout << #x << " = " << (x) << "\n";
#define dbgvi(x) cout << #x << " = "; for(int i = 0; i < (x.size()); ++i) cout << x[i] << " ";
#define mrk() cout << "HERE\n"
#define vi vector < int >
#define vs vector < string >
#define int long long
#define vii vector < vi >
#define viii vector < vii >
#define viiii vector < viii >
#define pii pair < int, int >
#define foru(i, a, b) for(int i = a; i < b; ++i)
#define ford(i, b, a) for(int i = b; i > a; --i)
using namespace std;


bool isprime(int n){
    if(n == 1)return false;
    for(int i = 2; i * i <= n; ++i){
        if(n % i == 0){
            return false;
        }
    }
    return true;
}

const int maxn = (int)1e5 + 1;
vi pref(maxn, 0);

void prepare(){
    foru(i, 1, maxn){
        int add = (isprime(i) && isprime((i + 1) / 2));
        pref[i] = pref[i - 1] + add;
    }
}



signed main(){
    prepare();
    int q;
    cin >> q;
    foru(i, 0, q){
        int l, r;
        cin >> l >> r;
        cout << pref[r] - pref[l - 1] << "\n";
    }


}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % 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; }

const ll M = 1e9+7;

vector<ll> fac(2010); //n!(mod M)
vector<ll> ifac(2010); //k!^{M-2} (mod M)

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

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

    ll N, K;
    cin >> N >> K;

    ll Nr = N - K;

    vector<ll> ans(K+1);

    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<2000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }

    ll comb_1, comb_2;
    for(ll i = 1; i <= K; i++){
        comb_1 = comb(Nr+1, i);
        comb_2 = comb(K-1, i-1);
        ans[i] = (comb_1 * comb_2)%M;
    }

    for(ll i = 1; i <= K; i++){
        cout << ans[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

#define MIN(a,b) ((a)<(b)?(a):(b))

int main(void){
    long long n,a,b;
    scanf("%lld %lld %lld",&n,&a,&b);
    if(!((b-a)%2))printf("%lld",(b-a)/2ll);
    else {
        printf("%lld",MIN(a-1,n-b)+1+(b-a)/2);
    }
    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin>>a[i];

    int ng = 0, ok = n;
    while(ok - ng > 1){
        int mid = (ng + ok) / 2;

        bool valid = true;
        vector<P> v;
        for(int i=0; i+1<n; i++){
            if(a[i] >= a[i+1]){
                while(v.size() && !(v.back().first <= a[i+1])) v.pop_back();
                if(v.size() && v.back().first == a[i+1]) v.back().second++;
                else v.emplace_back(a[i+1], 1);

                while(v.back().second == mid){
                    int digit = v.back().first;
                    if(digit == 1){
                        valid = false;
                        goto END;
                    }
                    v.pop_back();
                    if(v.size() && v.back().first == digit - 1) v.back().second++;
                    else v.emplace_back(digit-1, 1);
                }
            }
        }

        END:;
        if(valid) ok = mid;
        else ng = mid;
    }

    cout << ok << endl;

    return 0;
}

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

using namespace std;
using ll = long long;

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

int main() {
  int n;
  cin >> n;
  int h[n];
  rep(i, n) cin >> h[i];
  vector<int> a(n + 1);
  rep(i, n) a[i + 1] = max(a[i], h[i]);

  int ans = 0;
  rep(i, n) if (h[i] >= a[i])++ ans;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3540
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        System.out.println(reader.nextInt()/3);
    }

    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



Measured memory_bytes: 21076
import sys

n = int(input())
aaa = list(map(int, input().split()))

ans = [0]
tmp = 0
for a in aaa[:-1]:
    tmp = a - tmp
    ans.append(tmp * 2)
adj = aaa[-1] - tmp
ans2 = []
for a in ans:
    ans2.append(a + adj)
    adj *= -1
print(*ans2)


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

int main() {
    int n;
    cin >> n;
    int a[n], b[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    for (int i = 1; i < n; i++) {
        a[i] += a[i-1];
    }
    for (int i = n-2; i >= 0; i--) {
        b[i] += b[i+1];
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans = max(ans, a[i] + b[i]);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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




LL big_mod(LL val,LL pow,LL mod)
{
    LL res = 1;
    val = val % mod;
    while(pow > 0)
    {
        if(pow & 1)
        {
            res = (res*val) % mod;
        }
        pow = pow >> 1;
        val = (val*val) % mod;
    }
    return res;
}

int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    MII mp;
    string s;
    int i,l,x=0,ans=0,mod=2019;
    mp[0]=1;
    cin >> s;
    l=s.SZ;
    reverse(s.B,s.E);
    for(i=0;i<l;i++)
    {
        x+=(s[i]-'0')*big_mod(10,i,mod);
        x%=mod;
        ans+=mp[x];
        ++mp[x];
    }
    cout << ans;
    return 0;
}


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

namespace MyProgram{
    class AtCoder{
        static void Main(){
            int N = int.Parse(Console.ReadLine());
            long[] A = new long[N];
            for(var i=0;i<N;i++){
                A[i] = long.Parse(Console.ReadLine());
            }
            var dic = new Dictionary<long,long>(N);
            for(var i=0;i<N;i++){
                if(!dic.ContainsKey(A[i]))dic[A[i]]=1;
                else dic[A[i]]++;
            }
            long sum=0;
            foreach(var key in dic.Keys){
                sum += dic[key] % 2;
            }
            Console.WriteLine(sum);
        }
    } 
}

Measured memory_bytes: 18780
#include<bits/stdc++.h>
using namespace std;
#define ll long long
namespace io{
	const int l=1<<20;
	char buf[l],*s,*t;
	inline char gc(){
		if(s==t){
			t=(s=buf)+fread(buf,1,l,stdin);
			return s==t?EOF:*s++;
		}
		return *s++;
	}
	char c;
	template<class IT>inline void gi(IT &x){
		x=0;c=gc();while(c<'0'||c>'9')c=gc();
		while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^'0');c=gc();}
	}
};
using io::gi;
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
const ll p=998244353ll,inf=1000000000000000000ll;
const int N=200005;

int main(){
	int n;string s;
	cin>>n>>s;
	if(n>=3200)cout<<s;else cout<<"red";
	return 0;
}

Measured memory_bytes: 764
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    if a <= 8 and b <= 8:
        print("Yay!")
    else:
        print(":(")
    return

#B
def B():
    d, n = LI()
    print(str(n * (n != 100) or n + 1) + "00" * d)
    return

#C
def C():
    II()
    ans = 0
    a = LI()
    for ai in a:
        while not ai % 2:
            ans += 1
            ai = ai // 2
    print(ans)
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()


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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);

  int N;
  cin >> N;
  vector<int> a, b;
  map<int, int> mp;
  for (int i = 0; i < N; i++) {
    int ia;
    cin >> ia;
    mp[ia]++;
  }
  for (auto& m : mp) {
    a.push_back(m.first);
    b.push_back(m.second);
  }
  dump(a, b);
  if (mp.size() == 1) {
    if (a[0] == 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else if (mp.size() == 2) {
    if (b[0] == b[1] * 2) {
      if ((a[0] ^ a[1]) == a[0]) {
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    } else if (b[1] == b[0] * 2) {
      if ((a[1] ^ a[0]) == a[1]) {
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    } else {
      cout << "No" << endl;
    }
  } else if (mp.size() == 3) {
    if (b[0] == b[1] && b[1] == b[2]) {
      if ((a[0] ^ a[1]) == a[2]) {
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    } else {
      cout << "No" << endl;
    }
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 4860
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
signed main(){
  int a,b;
  cin>>a>>b;
  if(a%b==0)
    cout<<0;
  else
    cout<<1;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        for (int i = 1; i <= n; i++) {
            if (i * (i + 1) / 2 == n) {
                System.out.println("Yes");
                System.out.println(i + 1);
                int[][] array = new int[i + 1][i];
                for (int j = 0, a = 1; j <= i; j++) {
                    for (int k = j; k < i; k++, a++) {
                        array[j][k] = array[k + 1][j] = a;
                    }
                    
                }
                for (int j = 0; j <= i; j++) {
                    System.out.print(i + " ");
                    for (int k = 0; k < i; k++) {
                        System.out.print(array[j][k] + " ");
                    }
                    System.out.println();
                }
                return;
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 46676
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define MP make_pair
#define llu unsigned long long
#define U unsigned int
#define ff first
#define ss second
#define SIZE 100005
#define pie 3.14159265358979323
#define minuss 1e-6
#define pair pair<ll,ll>
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define BIG 1000000000
#define INF 1000000000000005
#define N 10000
map<string,ll> mps;
map<ll,string> mpss;
set<ll>s1;
set<string>s2;
map<string,ll>::iterator str;
set<ll>::iterator itr;
/*
std::cout << std::fixed;
std::cout << std::setprecision(1);
std::cout << VALUE NAME<<endl;
*/
ll tra[100006],tra1[100006];


int main()
{
    fast_cin;
    ll t;

    map<ll,ll>mp;
    map<ll,ll>::iterator it;
    string s,ss,add;

    ll n,m;
    cin>>n>>m;
  ll sum=1;
  ll co=0;
    while (sum < m)
    {
        sum += n - 1;
        co++;
    }
    cout<<co<<endl;

}


Measured memory_bytes: 3600
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		String T = sc.next();
		int A = sc.nextInt();
		int B = sc.nextInt();
		String U = sc.next();

		if (U.equals(S)) {
			System.out.print(A - 1);
			System.out.print(" " + B);
		} else if (U.equals(T)) {

			System.out.print (A + " ");
			System.out.print(B - 1);
		}
	}

}

Measured memory_bytes: 22996
// AUTHOR:: MOHAMMAD FAISAL
#include<bits/stdc++.h>
using namespace std;

int main(){
 	
  int n;
  cin >> n;
  string s;
  cin >> s;
  int len = (int)s.size();
  
  if(len<=n)
    cout<<s;
  else{
  	for(int i=0;i<n;i++)
      cout<<s[i];
    cout<<"...";
  }
 return 0; 
}

Measured memory_bytes: 3624
n, c, k = map(int, input().split())
T = sorted([int(input()) for _ in range(n)])

out = T.pop(0) + k
peo = 1
bus = 1

for t in T:
    if t <= out and peo < c:
        peo += 1

    else:
        out = t + k
        peo = 1
        bus += 1

print(bus)

Measured memory_bytes: 8280
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
using namespace std;

int InsertionSort(vector<int>& Array, int N, int g)
{
  	int count = 0;
  	for(int i = g; i< N;i++)
    {
    	int tmp = Array[i];
	  	int j = i -g;
      	while(j>=0 && Array[j] > tmp)
        {
          	Array[j+g] = Array[j];
          	j = j-g;
          	count++;
        }
    	Array[j+g] = tmp;
    }
  	return count;
}

void ShellSort(vector<int> Array, int N)
{
  	int count=0;
  	vector<int> G;
  	G.push_back(1);
  	int g=G[0];
  	while(N > g*3+1)
    {
      g=g*3+1;
      G.push_back(g);
    }
  	int m = G.size();
  	for(int i=m-1;i>=0;i--)
    {
      count+=InsertionSort(Array, N, G[i]);
    }
  	cout << m << endl;
  	for(int i=m-1;i>0;i--) cout << G[i] << " ";
  	cout << G[0] << endl;
  	cout << count << endl;
  	for(int i=0;i<N;i++) cout << Array[i] << endl;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	long N;
	cin >> N;
	vector<int> A(N);
  	int idx = 0;
  	while(cin >> A[idx]) idx++;
  	
  	ShellSort(A, N);    
  	return 0;
}



Measured memory_bytes: 10664
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <ctime>
#include <cmath>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;

#define sz(x) (int)(x.size())

typedef long long ll;
typedef tuple<int, int, int> tri;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef __gnu_pbds::tree<
    int,
    __gnu_pbds::null_type,
    less<int>,
    __gnu_pbds::rb_tree_tag,
    __gnu_pbds::tree_order_statistics_node_update>
    ordered_set;

const ll MODULO = 1000000007;

void ftime()
{
#ifndef ONLINE_JUDGE
    cout << "\nTime: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
#endif
}

static int speed_increase = []() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    return 0;
}();

void solve()
{
    ll x, k, d;
    cin>>x>>k>>d;
    x = abs(x);
    ll best = x%d, bcount = x/d;
    ll sbest = abs(best-d), sbcount = bcount+1;
    if(sbest < best) {
        swap(sbest, best);
        swap(sbcount, bcount);
    }
    if(bcount > k) {
        cout<<abs(x-k*d);
    } else {
        k -= bcount;
        cout<<(k%2==0 ? best : sbest);
    }
}

int main()
{
    solve();
    // ftime();
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
using pqueg = priority_queue<int, vector<int>, greater<int>>;
using pquel = priority_queue<int, vector<int>, less<int>>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
int lcm(int a, int b){
  return a / __gcd(a, b) * b;
}
int r_int(int a, int b){
  return rand() % b + a;
}
const lint mod=1e9+7;


int main()
{
  lint n, m;
  cin >> n >> m;
  vector<vector<lint>> cnct(n);
  REP(i,m){
    lint a, b;
    cin >> a >> b;
    a--;
    b--;
    cnct[a].push_back(b);
    cnct[b].push_back(a);
  }

  vector<lint> dist(n, n);
  vector<lint> sign(n, -1);
  dist[0] = 0;
  sign[0] = 0;
  queue<lint> que;
  que.push(0);
  while(que.size()){
    lint node = que.front();
    que.pop();
    for(lint x : cnct[node]){
      if(dist[x] == n){
        que.push(x);
      }
      if(dist[node]+1 < dist[x]){
        dist[x] = dist[node]+1;
        sign[x] = node;
      }
    }
  }

  string ans = "Yes";
  auto itr = find(ALL(sign), -1);
  if(itr != sign.end()){
    cout << "No\n";
  }else{
    cout << "Yes\n";
    FOR(i,1,sign.size()){
      cout << sign[i]+1 << "\n";
    }
  }

  return 0;
}


Measured memory_bytes: 13828
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
using namespace std;
typedef long long ll;


int main(int argc, char *args[]) {
	int N;
	cin >> N;
	if (N <= 999) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ABD" << endl;
	}
}


Measured memory_bytes: 256
N, M = map(int, input().split())
X = sorted(list(map(int, input().split())))
distances = []

if N >= M:
    print(0)
else:
    for i in range(M-1):
        distance = X[i+1] - X[i]
        distances.append(distance)

    distances = sorted(distances, reverse=True)
    ans = sum(distances)

    for i in range(N-1):
        ans -= distances[i]

    print(ans)


Measured memory_bytes: 13960
#include<iostream>
#include<cstdio>
#include<cmath>
#define size 20000000
using namespace std;
int find_prime(int n)
{
    int count =0;
    bool *numberList=new bool[size+1];
    for(unsigned long i=3;i<=sqrt(n);i+=2)
    {
        for(unsigned long j=i;i*j<=n;j+=2)
            numberList[i*j]=true;
    }
    for (unsigned long i=3;i<=n;i+=2)
    {
        if(!numberList[i])
            count++;
    }

    return count;

}
int main ()
{
    int n;
    while((scanf("%d",&n))!=EOF)
    {
        if(n==1||n==0)
            printf("0\n");
        else if(n==2)
            printf("1\n");

        else
        {
        int v=0;
        v=find_prime(n);
        printf("%d\n",v+1);
        }
    }
    return 0;
}

Measured memory_bytes: 26184
#include<bits/stdc++.h>
using namespace std;
int main(){
	long n; cin>>n;
	vector<long> a(n);
	for(int i=0;i<n;i++)
		cin>>a[i];
	long x=a[0],s=a[0];
	long f=0,b=0,r=1;
	for(int i=1;i<n;i++){
		x^=a[i],s+=a[i];
		if(x==s)
			r+=i-b;
		else{
			do{
				x^=a[b],s-=a[b];
				b++;
			}while(x!=s);
			r+=i-b;
		}
		r++;
	}
	cout<<r;
}

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

int main(){
	unsigned long int A,B;
	
	cin >> A >> B;
	int ans;
	for(int i=1;i<=10000;i++){
		ans=i*0.08;
		if(ans==A){
			ans=i*0.1;
			if(ans==B){
				cout << i << endl;
				return 0;
			}
		}
	}
	cout << -1 << endl;	
}

Measured memory_bytes: 256
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
//	fastio;
	double pi=3.1415926535897932384626433832795;
	double n;
	cin>>n;
	printf("%.10f\n",n*2.0*pi);
	return 0;
}


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

int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////
    int K;

    cin>>K;

    if(K%2==0){
        cout<<(K/2)*(K/2)<<endl;
    }
    else{
        cout<<(K/2+1)*(K/2)<<endl;
    }

    return 0;
}


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

int main(){

	double a, b, c, h, L, S, C;

	scanf("%lf %lf %lf", &a, &b, &C);

	C = C / 180 * 3.1415926535;

	S = a * b * sin(C) / 2;

	c = sqrt(a * a + b * b - 2 * a * b * cos(C));

	L = a + b + c;

	h = b * sin(C);

	printf("%f\n", S);
	printf("%f\n", L);
	printf("%f\n", h);




	return 0;
}

Measured memory_bytes: 672
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD 1000000007
using namespace std;

int main(void){
    long long n,k,choice=0,count=0;
    long long ans=0,sum=0;
    cin >> n >> k;
    vector<int> used(n+1,0),place;
    pair<int,int> a[n];
    //fist ->t second ->d
    for(int i=0; i<n; i++){
        cin >> a[i].second >> a[i].first;
    }
    sort(a,a+n);
    reverse(a,a+n);
    for(int i=0; i<n; i++){
        if(choice<k){
            sum+=a[i].first;
            choice++;
            if(used[a[i].second]==0){
                used[a[i].second]++;
                count++;
            }else {
                place.push_back(i);
            }
            ans=max(ans,sum+count*count);
        }else if(used[a[i].second]==0){
            if(place.size()==0)break;
            sum-=a[place.back()].first;
            place.pop_back();
            sum+=a[i].first;
            used[a[i].second]++;
            count++;
            ans=max(ans,sum+count*count);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792