akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))

def main():
    for number in m:
        if solve(0, number):
            print('yes')
        else :
            print('no')

def memolize(f):
    cache = {}

    def helper(x, y):
        if (x, y) not in cache:
            cache[(x, y)] = f(x, y)
        return cache[(x, y)]
    return helper

@memolize
def solve(i, m):
    if m == 0:
        return True

    if i >= n:
        return False

    res = solve(i + 1, m) or solve(i + 1, m - a[i])
    return res

if __name__ == '__main__':
    main()



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

int main() {
  int c,r;
  cin >> c >> r;

  int ary[c][r] = {0};
  rep(i, c)
    rep(j, r) cin >> ary[i][j];

  //out
  int sumc[r] = {0};
  int sumall = 0;
  rep(i, c){
    int sumr = 0;
    rep(j, r) {
      cout << ary[i][j] << " ";
      sumr += ary[i][j];
      sumc[j] += ary[i][j];
    }
    cout << sumr << endl;
    sumall += sumr;
  }

  rep(i, r) cout << sumc[i] << " ";

  cout << sumall << endl;
  
  return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <string>
#include <stack>
 
using namespace std;
 
#define f(i,a,b) for(int i=a;i<b;i++)
#define fll(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define vvi vector<vector<int>>
#define ss second
#define ff first
#define ll long long
#define lld long double
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pq priority_queue< int >
#define pqll priority_queue< ll >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define INF 1000000000
#define NINF -1000000000
 
ll maxll(ll a , ll b ){
    return a > b ? a : b;
}
 
ll minll(ll a , ll b){
    return a > b ? b : a;
}

// bool check(ll z){
//     ll temp = k;
//     // cout << z << endl;
//     f(i , 0 , n){
//         ll sub = (ll)z * a[i];
//         if (sub > b[i])
//         temp -= (sub -b[i]);
//         if (temp < 0){
//             return 0;
//         }
//     }
//         // cout << z << endl;
//     sol = z;
//         return 1;
// }


// To count Number of ones in a binary number
// int count_one(int x){
//     x = (x & (0x55555555)) + ((x >> 1) & (0x55555555));
//     x = (x & (0x33333333)) + ((x >> 2) & (0x33333333));
//     x = (x & (0x0f0f0f0f)) + ((x >> 4) & (0x0f0f0f0f));
//     x = (x & (0x00ff00ff)) + ((x >> 8) & (0x00ff00ff));
//     x = (x & (0x0000ffff)) + ((x >> 16) & (0x0000ffff));
//     // cout << x << endl;
//     return x;
// }

// int gcd (int a , int b){
//     return __gcd(a,b);
// }

// void print_vi(vi a){
//     for (int i: a){
//         cout << i << " " ;
//     }
//     cout << endl;
// }

// Best algo to find maximum sum subarray (contiguous)
// ll kadane (vl a){
//     ll curr = 0 , maxi = 0;
//     f(i , 0 , a.size()){
//         curr = max(a[i] , curr + a[i]);
//         maxi = max(maxi , curr);
//     }
//     return maxi;
// }

typedef struct books{
    int time;
    int a;
    int b;
}book;

book boo[200001];
bool compare(book a , book b){
    return a.time > b.time;
}

void solve(){
    
    ll x;
    cin >> x;
    vl a(x+1 , 0);
    f( i , 1 , x+1){
        for (int j = i ; j < x+1 ; j+= i){
            a[j]++;
        }
    }
    ll ans= 0;
    f( i , 1 , x+1){
        ans += i*(a[i]);
    }
    cout << ans << endl;
}

 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
 
 
    
    int t = 1;
    // cin >> t;
    
    while(t--){
        
        solve();
    }
}

Measured memory_bytes: 81284
#include<stdio.h>
int main(void){
  int H,W,a,b,k=1;
  while(k != 0){
    scanf("%d %d",&H,&W);
    if(H==0 && W==0){
      break;
    }
    for(a=1;a<=H;a++){
      for(b=1;b<=W;b++){
        if((a+b) %  2 == 0){
          printf("#");
        }else{
          printf(".");
        }
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

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

int main(){
  ll A,B,M;cin>>A>>B>>M;
  vector<int> va(A);
  vector<int> vb(B);
  int ansa=1000000,ansb=1000000;
  int ans;
  int a,b,c;
  
  rep(i,A){
    cin>>va.at(i);
    ansa=min(ansa,va.at(i));
  }
  
  rep(i,B){
    cin>>vb.at(i);
    ansb=min(ansb,vb.at(i));
  }
  
  ans=ansa+ansb;
  
  rep(i,M){
    cin>>a>>b>>c;
    ans=min(ans,va.at(a-1)+vb.at(b-1)-c);
  }
  
  cout<<ans<<endl;
}
    
  

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();
		int zantei = x-a;
		int buyD = zantei/b;
		System.out.println(zantei-buyD*b);
	}

}


Measured memory_bytes: 23380
/**
 *   @author: pr4shan7 (प्रशांत)
 */
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // cout << fixed;
    // cout << setprecision (6);

    int n, k, q;
    cin >> n >> k >> q;
    int qu[q];
    // cout << "yes" << '\n';
    for (int i = 0; i < q; i++) {
        cin >> qu[i];
    }

    // cout << "yes" << '\n';
    int res[n];
    memset(res, 0, sizeof(res));

    for (int i = 0; i < q; i++) {
        int val = qu[i] - 1;
        if (val > 0) {
            res[0] -= 1;
            res[val] += 1;
        }
        if (val < n - 1) {
            res[val + 1] -= 1;
        }
    }

    for (int i = 1; i < n; i++) {
        res[i] += res[i - 1];
    }

    for (int i = 0; i < n; i++) {
        if (res[i] <= -k)
            cout << "No" << '\n';
        else {
            cout << "Yes" << '\n';
        }
    }

    // for (auto i : res)
    //     cout << i << ' ';
    // cout << '\n';

    return 0;
}


Measured memory_bytes: 1408
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}
struct unionfind{
  private:
  int maxN;
  vector<int> par,treesize;
  public:unionfind(int N) :maxN(N),par(N),treesize(N,1){
    for(int i=0;i<maxN;++i)par[i]=i;
  }
  int root(int x){
    while(par[x]!=x){
      x=par[x]=par[par[x]];
    }
    return x;
  }
  bool unite(int x,int y){
    int px=root(x);
    int py=root(y);
    if(px==py)return false;
    // if(treesize[px]>treesize[py])swap(px,py);
    par[px]=py;
    treesize[py]+=treesize[px];
    return true;
  }
  bool parcheck(int x,int y){
    return root(x)==root(y);
  }
  int size(int x){
    return treesize[root(x)];
  }
  void clear(){
    treesize.assign(maxN,1);
    for(int i=0;i<maxN;++i)par[i]=i;
  }
};

int main(){
  ll i,N,M,a,b,ans;
  cin>>N>>M;
  unionfind tree(N);
  pvec v(M);
  stack<ll> st;
  rep(i,M){
    cin>>a>>b;
    v[i]=datas(a-1,b-1);
  }
  ans=N*(N-1)/2;
  st.push(ans);
  while(M--){
    a=v[M].first;b=v[M].second;
    if(tree.root(a)==tree.root(b)){
      st.push(ans);
      continue;
    }
    ans-=tree.size(a)*tree.size(b);
    st.push(ans);
    tree.unite(a,b);
  }
  st.pop();
  while(!st.empty()){
    cout<<st.top()<<endl;
    st.pop();
  }
  return 0;
}

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

using namespace std;
typedef long long int ll;
int main() {
    
    ll n, m, k, i, a[200001], b[200001], ap, bp, dap=0, sum=0, hap, asum[200001]={}, bsum[200001]={}, big, end, mid;
    
    cin>>n>>m>>k;
    for(i=1;i<=n;i++)
    {
    scanf("%lld", &a[i]);
    asum[i]=a[i]+asum[i-1];
    }
    for(i=1;i<=m;i++)
    {
    scanf("%lld", &b[i]);
   bsum[i]=b[i]+bsum[i-1];
    }
    for(i=0;i<=n;i++)
    {
        ll x=k-asum[i];
        if(x<0)
        continue;
        else
        {
            big=0;
            end=m;
            while(big!=end)
            {
                mid=(big+end+1)/2;
                if(bsum[mid]>x)
                end=mid-1;
                else
                big=mid;
            }
            if((i+big)>dap)
            dap=i+big;
        }
    }
    
    cout<<dap;
    return 0;
}

Measured memory_bytes: 10000
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(a) (a).begin(), (a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x, 0, sizeof(x))
#define MINF(x) memset(x, 0x3f, sizeof(x))
#define MMINUS(a) memset(a, 0xff, sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double EPS = 1.0 / INF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

using namespace std;

//===================================== template =========================================================

int main() {
    cin.tie(nullptr); ios_base::sync_with_stdio(false);
    string S; cin >> S;
    int min = 0;
    for (int i = 0; i < S.size(); ++i) {
        if (i % 2 == 0) if (S[i] == '1') min++;
        if (i % 2 == 1) if (S[i] == '0') min++;
    }
    int cnt = 0;
    for (int i = 0; i < S.size(); ++i) {
        if (i % 2 == 0) if (S[i] == '0') cnt++;
        if (i % 2 == 1) if (S[i] == '1') cnt++;
    }
    chmin(min, cnt);
    cout << min << endl;
}


Measured memory_bytes: 888
N,M = map(int,(input().split()))
MOD = 10**9+7

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i ==0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr

kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]
 
gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]
 
def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

if M == 1:
    print(1)
else:
    fac = factorization(M)
    ans = 1
    for i in fac:
        ans = (ans * nCr(i[1]+N-1,i[1]))%MOD
    print(ans)

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

int main() {
 int N;
  cin>>N;
  int X=N/1.08+0.9999;
  int Y=X*1.08;
  if(Y==N){cout<<X<<endl;}
      else{cout<<":("<<endl;}
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>


#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}

const ll INF = 1e10;
int main(){
    string s;
    cin >> s;
    map<char, int>mp;
    for(char c : s){
        mp[c]++;
    }

    cout << (max({mp['a'] , mp['b'] , mp['c']}) - min({mp['a'] , mp['b'] , mp['c']}) <= 1 ? "YES" : "NO" ) << endl;
}

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

    int main()
    {
        long long num;

        scanf("%lld",&num);

        int koita=0;
        for (long h=1;h<=3500;h++)
        {
            for (long n=1;n<=3500;n++)
            {
                long x=4*h*n-num*n-num*h,y=num*h*n;
                if (x>0&&y>=x&&y%x==0)
                {
                koita=1;
                printf("%d %d %d",h,n,y/x);
                break;
                }
            }
            if (koita)
            break;
        }

    return 0;
    }




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

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

int main()
{
    int N, X;
    cin >> N >> X;
    vector<int> L(N);
    for (int i = 0; i < N; i++) cin >> L[i];

    int sum = 0;
    for (int i = 0; i < N; i++)
    {
        sum += L[i];
        if (sum > X) {cout << i + 1 << endl; return 0;}
    }
    cout << N + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long 
using namespace std;
LL gcd(LL a,LL b)
{
	if(b==0) return a;
	else return gcd(b,a%b);
}
LL a[102],n;
int main()
{
	cin>>n;
	for(int i=1;i<=n;++i) cin>>a[i];
	LL last=a[1];
	for(int i=2;i<=n;++i)
	 {
	 	LL gg=gcd(last,a[i]);
	 	last=last/gg*a[i];
	 }
	printf("%lld\n",last);
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

const ll mod = 1e9+7;
const ll INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

int main(){
  ll a,b;
  int i=0;
  string s;
  stack<ll> t;

while(cin>>s){
    if(s=="+"){
      a=t.top();
      t.pop();
      b=t.top();
      t.pop();
      t.push(a+b);
    }else if(s=="-"){
      a=t.top();
      t.pop();
      b=t.top();
      t.pop();
      t.push(b-a);
    }else if(s=="*"){
      a=t.top();
      t.pop();
      b=t.top();
      t.pop();
      t.push(a*b);
    }else{
      t.push(atoll(s.c_str()));
    }
    if(getchar()=='\n'){
      cout<<t.top()<<endl;
    }
  }
}



Measured memory_bytes: 3180
#include "bits/stdc++.h"
using namespace std;
 
int main() {
        int n;
        scanf("%d", &n);
        string s, t;
        cin >> s >> t;
        if (s == t) return !puts("0");
        if (s[0] != t[0]) return !puts("-1");
        vector<int> a, b;
        b.push_back(0);
        for (int i = 1; i < n; i ++) if (t[i] != t[i - 1]) b.push_back(i);
        int p = n - 1;
        int bp = b.size() - 1;
        while (p > 0) {
                while (t[b[bp]] != s[p]) p --;
                if (p == 0) break;
                a.push_back(p);
                bp --;
                p = min(p, b[bp]);
        }
        a.push_back(0);
        if (a.size() != b.size()) return !puts("-1");
        reverse(a.begin(), a.end());
        int lb = -1, ub = a.size();
        while (ub - lb > 1) {
                int s = (lb + ub) / 2;
                bool ok = true;
                for (int i = 0; i < b.size(); i ++) {
                        if (i + s < a.size()) ok &= a[i + s] - s >= b[i];
                }
                if (ok) ub = s;
                else lb = s;
        }
        printf("%d\n", ub + 1);
        return 0;
}


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

int main() {
	// your code goes here
	int n,l,ma=0;
	cin>>n;
	int a[10010]={0};
	for(int i=0;i<n;i++){
		cin>>l;
		a[l]++;
		if(l>ma) ma=l;
	}

	
	for(int i=0;i<10010;i++){
		if(a[i]==0) continue;
		if(i!=ma){
			for(int j=0;j<a[i];j++) cout<<i<<" ";
		}
		else{
			for(int j=0;j<a[i]-1;j++) cout<<i<<" ";
			cout<<i<<endl;
		}
		
	}
	return 0;
}

Measured memory_bytes: 1208
//   PIGMEISTER™   //

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define sidha(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define ulta(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define sab(a) a.begin(),a.end()
#define bas(a) a.rbegin(),a.rend()
#define test ll _;cin>>_;while(_--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD (ll)1000000007
//#define MOD (ll)998244353
#define PI (ld)3.141592653589793238
#define MAX 100005

ll ans[MAX];

ll bfs(vector<ll> adj[], ll n, ll root = 1) {
    queue<ll> q;
    bool vis[n+5] = {0};
    ll count = 1;
    q.push(root);
    vis[root] = 1;
    while (!q.empty()) {
        ll u = q.front();
        q.pop();
        for (auto v : adj[u]) {
            if (!vis[v]) {
                q.push(v);
                vis[v] = 1;
                ans[v] = u;
                ++count;
            }
        }
    }
    return count;
}

int main()
{
    jaldi;
    
    ll n, m;
    cin >> n >> m;
    vector<ll> adj[n+1];
    ll a, b;
    sidha (i, 0, m) {
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    ll f = bfs(adj, n);
    if (f < n) return cout << "No", 0;
    cout << "Yes\n";
    sidha (i, 2, n+1) cout << ans[i] << '\n';
    
    return 0;
}


Measured memory_bytes: 13160
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  ll A, B, C, X;
  cin >> A >> B >> C >> X;
  ll ans = 0;
  rep(i, A+1) {
    rep(j, B+1) {
      rep(k, C+1) {
        if (i * 500 + j * 100 + k * 50 == X) {
          ans++;
        }
      }
    }
  }
  cout << ans;
  return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
  //配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P= pair<ll, ll>;
// const ll mod = 1e9+7;
const ll mod= 998244353;
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for(ll(i)= 0; (i) < (n); (i)++)
#define REPS(i, n) for(ll(i)= 1; (i) <= (n); (i)++)
#define RREP(i, n) for(ll(i)= (n - 1); (i) >= 0; (i)--)
#define RREPS(i, n) for(ll(i)= (n); (i) > 0; (i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());

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

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

/* modとる */
inline ll modu(ll a) { return (a % mod + mod) % mod; }

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    vector<ll> H(C - A);
    ll base= 0;
    vector<vector<ll>> pows(3010, vector<ll>(3010, 1));
    REPS(i, 3005) {
        REP(l, 3005) { pows[i][l + 1]= modu(pows[i][l] * i); }
    }
    REP(l, C - A) { H[l]= pows[B][l + 1]; }
    if(C == A) {
        cout << pows[A][D - B] << "\n";
    } else {
        REP(i, D - B) {
            if(i == 0) {
                base= 1;
                RREP(l, C - A) {
                    H[l]= modu(H[l] * (l + 1));
                    RREP(k, l) {
                        H[l]= H[l] + modu(modu(H[k] * (k + 1)) *
                                          pows[B + i + 1][l - k - 1]);
                    }
                }
            } else {
                ll nmemory= 0;
                ll omemory= 0;
                REP(l, C - A) {
                    H[l]   = modu(H[l] * (l + 1 + A));
                    nmemory= H[l];
                    swap(nmemory, omemory);
                    if(l > 0)
                        H[l]= modu(H[l] + (B + i + 1) * H[l - 1] -
                                   nmemory * (B + i));
                }
                RREP(l, C - A) {
                    H[l]= modu(H[l] +
                               base * modu((B + i) *
                                           modu(-pows[B + i][l + 1] +
                                                (B + i) * pows[B + i + 1][l] +
                                                pows[B + i + 1][l])));
                }
            }
            base= modu(base * A);
        }
        ll sum= modu(base * pows[D][C - A]);
        sum   = modu(sum + *H.rbegin());
        cout << sum << "\n";
    }
}

Measured memory_bytes: 74196
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(N: int, A: "List[int]"):
    def _to_bits(v):
        xb = []
        h = {}
        i = 0
        while v > 0:
            xb.append((2 ** i, v % 2))
            h[2 ** i] = v % 2
            v //= 2
            i += 1
        return xb, h
    xor = 0
    for i in range(2, N):
        xor ^= A[i]
    s = A[0] + A[1]
    #print(xor, s)
    rest = s - xor
    if rest < 0 or rest % 2 or (rest // 2) > A[0]:
        ret = -1
    else:
        ret = 0
        rest //= 2
        xb, xx = _to_bits(xor)
        rb, rr = _to_bits(rest)
        for k, v in rr.items():
            if v == 1 and k in xx and xx[k] == 1:
                ret = -1
                print(ret)
                return
        #print(xb)
        #print(rb)
        #print(rest)
        xb.reverse()
        tmp = rest
        for base, v in xb:
            #if v:
            #    print(base, v, tmp)
            if v and tmp + base < A[0]:
                tmp += base
        if tmp > 0:
            ret = A[0] - tmp
        else:
            ret = -1
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


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

N,K=map(int,input().split())
ANS=[]

if N%2==1:

    for i in range(N//2+1):
        ANS.append((K+i,K+2*N-1-2*i,K+3*N-1-i-N//2))

    for i in range(N//2):
        ANS.append((K+N//2+1+i,K+2*N-2-2*i,K+3*N-1-i))

    for x,y,z in ANS:
        if x+y>z:
            print(-1)
            sys.exit()

    for x,y,z in ANS:
        print(x,y,z)


else:

    for i in range(N//2):
        ANS.append((K+i,K+2*N-1-2*i,K+3*N-1-i-N//2))

    for i in range(N//2):
        ANS.append((K+N//2+i,K+2*N-2-2*i,K+3*N-1-i))


    for x,y,z in ANS:
        if x+y>z:
            print(-1)
            sys.exit()

    for x,y,z in ANS:
        print(x,y,z)

    
        
    


Measured memory_bytes: 22744
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <map>
#include <functional>

using lint = long long;

void solve() {
    int n;
    std::cin >> n;

    std::vector<lint> ds(n);
    std::map<lint, int> drev;
    for (int v = 0; v < n; ++v) {
        std::cin >> ds[v];
        drev[ds[v]] = v;
    }

    std::vector<int> vs(n);
    std::iota(vs.begin(), vs.end(), 0);
    std::sort(vs.begin(), vs.end(),
              [&](int u, int v) { return ds[u] > ds[v]; });

    std::vector<int> szs(n, 1);
    std::vector<std::vector<int>> to(n);

    for (auto v : vs) {
        if (v == vs.back()) continue;

        lint nxt = ds[v] - (n - szs[v] * 2);
        if (!drev.count(nxt)) {
            std::cout << -1 << std::endl;
            return;
        }

        int u = drev[nxt];
        to[u].push_back(v);
        szs[u] += szs[v];
    }

    int r = vs.back();

    lint dsum = 0;
    std::function<void(int, int)> dfs =
        [&](int v, int d) -> void {
        dsum += d;
        for (auto u : to[v]) dfs(u, d + 1);
    };
    dfs(r, 0);

    if (dsum != ds[r]) {
        std::cout << -1 << std::endl;
        return;
    }

    for (int v = 0; v < n; ++v) {
        for (auto u : to[v]) {
            std::cout << v + 1 << " " << u + 1 << std::endl;
        }
    }
    return;
}

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

    solve();

    return 0;
}


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

// insert x: 連結リストの先頭にキー x を持つ要素を継ぎ足す。
// delete x: キー x を持つ最初の要素を連結リストから削除する。そのような要素が存在しない場合は何もしない。
// deleteFirst: リストの先頭の要素を削除する。
// deleteLast: リストの末尾の要素を削除する。

struct Node {
    int key;
    Node *prev, *next;
};

Node *nil;

void init() {
    nil = (Node *)malloc(sizeof(struct Node));
    nil->next = nil;
    nil->prev = nil;
}

void insert(int key) {
    Node *x;
    x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    x->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

Node *listSearch(int key) {
    Node *cur = nil->next;
    while(cur != nil && cur->key != key) {
        cur = cur->next;
    }
    return cur;
}

void deleteNode(Node *t) {
    if(t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst() {
    deleteNode(nil->next);
}

void deleteLast() {
    deleteNode(nil->prev);
}

void deleteKey(int key) {
    deleteNode(listSearch(key));
}

void printList() {
    Node *cur = nil->next;
    int isf = 0;
    while(true) {
        if(cur == nil) break;
        if(isf++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

int main() {
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for(i = 0; i < n; i++) {
        scanf("%s%d", com, &key);
        if(com[0] == 'i') {
            insert(key);
            np++;
            size++;
        } else if(com[0] == 'd') {
            if(strlen(com) > 6) {
                if(com[6] == 'F')
                    deleteFirst();
                else if(com[6] == 'L')
                    deleteLast();
            } else {
                deleteKey(key);
                nd++;
            }
            size--;
        }
    }

    printList();
    return 0;
}


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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

/*
while(!frag && cin >> a >>b, a|b)
*/

int main(void){
    int n; cin >> n;
    ll a[n]; 
    rep(i,0,n) cin >> a[i];
    
    ll sum = 0;
    map<int,int> mp;
    rep(i,0,n) mp[a[i]]++;
    rep(i,0,n) sum += a[i];

    vector<ll> ans = {};
    int q; cin >> q;
    rep(i,0,q){
        int b,c; 
        cin >> b >> c;
        sum = sum + mp[b]*(c-b);
        ans.push_back( sum );

        mp[c] += mp[b];
        mp[b] = 0;
    }

    rep(i,0,ans.size()){
        cout << ans[i] << "\n";
    }
}

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

typedef long long int ll;
typedef long double ld;

#define Pb push_back
#define Mp make_pair

#define ff first
#define ss second

#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))

#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN

#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define db1(x) cout<<#x<<" : "<<x<<endl;
#define db2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define db3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;

const int N = 1e5+5;
int h[N];
int n;
int dp[N];

int solution(int idx)
{
  if(idx == n)
  {
    return 0;
  }
  if(idx>n)
  {
    return 10000000;
  }
  if(dp[idx] != -1)
  {
    return dp[idx];
  }
  int &ans = dp[idx];
  int dp1=INT_MAX;
  int dp2=INT_MAX;
  if(idx+1 <= n) dp1 = solution(idx+1)+abs(h[idx]-h[idx+1]);
  if(idx+2 <= n) dp2 = solution(idx+2)+abs(h[idx]-h[idx+2]);
  ans = min(dp1,dp2);
  return ans;
}

void solve()
{
    cin >> n;
    for(int i=1;i<=n;i++) cin >> h[i];
    memset(dp,-1,sizeof(dp));
    int ans = solution(1);
    cout << ans;
}

signed main()
{
  IOS;
  //freopen("input.txt", "rt", stdin);
  //freopen("output.txt", "wt", stdout);
  int t=1;
  //cin >> t;
  while(t--)
  {
    solve();
  }
  return 0;
}
/*==============================================================================================================================================================*/


Measured memory_bytes: 8944
n, m, c = map(int, input().split())
bb = list(map(int, input().split()))
ans = 0

for i in range(n):
  aa = list(map(int, input().split()))
  val = c
  for a, b in zip(aa, bb):
    val += a * b
  if val > 0:
    ans += 1

print(ans)


Measured memory_bytes: 3060
import sys, io, os, re
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from pprint import pprint
from math import sin, cos, pi, radians, sqrt, floor, ceil
from copy import copy, deepcopy
from collections import deque
from fractions import gcd
from functools import reduce
from itertools import groupby
from heapq import heapify, heappush, heappop

# sys.setrecursionlimit(5000)

n1 = lambda: int(sys.stdin.readline().strip())
nn = lambda: list(map(int, sys.stdin.readline().strip().split()))
f1 = lambda: float(sys.stdin.readline().strip())
fn = lambda: list(map(float, sys.stdin.readline().strip().split()))
s1 = lambda: sys.stdin.readline().strip()
sn = lambda: list(sys.stdin.readline().strip().split())
nl = lambda n: [n1() for _ in range(n)]
fl = lambda n: [f1() for _ in range(n)]
sl = lambda n: [s1() for _ in range(n)]
nm = lambda n: [nn() for _ in range(n)]
fm = lambda n: [fn() for _ in range(n)]
sm = lambda n: [sn() for _ in range(n)]

def array1(n, d=0): return [d] * n
def array2(n, m, d=0): return [[d] * m for x in range(n)]
def array3(n, m, l, d=0): return [[[d] * l for y in xrange(m)] for x in xrange(n)]
def linc(A, d=1): return map(lambda x: x + d, A)
def ldec(A, d=1): return map(lambda x: x - d, A)

N = n1()
rootN = int(ceil(sqrt(N)))

tbl = array1(10**4+1)

for i in range(1, rootN):
    for j in range(1, rootN):
        
        for k in range(1, rootN):
            n = i**2 + j**2 + k**2 + i*j + i*k + j*k
            if n <= 10000:
                tbl[n] += 1
            else:
                break

for i in range(1, N+1):
    print(tbl[i])

Measured memory_bytes: 74004
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>

using namespace std;

int main() {
   
        int n;
        cin >> n;
        int *a = new int [n];  int l;
        for (int i = 0; i < n; i++) 
            cin >> a[i];
           
        int ans = 0;
        for (int i = 0; i < n; i++) {
            cin >> l;
            ans += l;
        }
        int *b= new int [n-1];
        for (int i = 0; i < n - 1; i++) 
            cin >> b[i];
      
        for (int i = 0; i < n - 1; i++) {
            if (a[i] == a[i + 1] - 1)ans += b[a[i] - 1];
        }
        cout << ans << endl;

    }
     
    

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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 

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

int N = S.size();
int tmp = 0;
vector<int>ans(N, 0);
REP(j, 2){
REP(i, N){
	if(S.at(i) == 'R') tmp++;
	else {
		ans.at(i) += tmp / 2;
		ans.at(i - 1) += (tmp + 1) / 2;
		tmp = 0;
	}
}

reverse(all(ans));
reverse(all(S));

REP(k, N){
	if(S.at(k) == 'R') S.at(k) = 'L';
	else S.at(k) = 'R';
}
}

REP(i, N){
	cout << ans.at(i) << endl;
}
}

Measured memory_bytes: 1024
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)   (x).begin(),(x).end()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define mp       make_pair
#define eb       emplace_back
typedef pair<LL, double> P;
typedef pair<P, P> PP;

int N, W, v[1010], w[1010], dp[1010][10100];

int calc(int i, int j) {
	int res;
	if (dp[i][j] != -1)return dp[i][j];
	if (i == N)res = 0;
	else if (j < w[i]) {
		res = calc(i + 1, j);
	}
	else {
		res = max(calc(i + 1, j - w[i])+v[i],calc(i+1,j));
	}
	return dp[i][j] = res;
}

int main() {
	cin >> N >> W;
	for (int i = 0; i < 1010; i++)for (int j = 0; j < 10100; j++)dp[i][j] = -1;
	for (int i = 0; i < N; i++) {
		cin >> v[i] >> w[i];
	}
	cout << calc(0, W) << endl;
}

Measured memory_bytes: 42952
#include <cstdio>

class Problem {
  int M, K;
 public:
  Problem() {
    scanf("%d %d", &M, &K);
  }
  void solve() {
    int bound = 1 << M;
    if (K >= bound || (K == 1 && M == 1)) printf("-1");
    else if (K == 0 && M == 1) printf("0 0 1 1");
    else {
      printf("%d ", K);
      for(int i = 0; i < bound; i++) {
        if(i == K) continue;
        printf("%d ", i);
      }
      printf("%d ", K);
      for(int i = bound-1; i >= 0; i--) {
        if(i == K) continue;
        printf("%d ", i);
      }
    }
  }
};

int main() {
  Problem().solve();
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int n, m; cin >> n >> m;
	vector<int> s(n + 2);
	for (int i = 0; i < m; i++) {
		int l, r; cin >> l >> r;
		s[l]++;
		s[r + 1]--;
	}
	for (int i = 0; i < n; i++) s[i + 1] += s[i];
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += s[i] >= m;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B;
    cin >> A >> B;
    int ans=0;
     if(A>B){
        ans+=A;
        A--;
    }
    else{
        ans+=B;
        B--;
    }   
    if(A>B){
        ans+=A;
        A--;
    }
    else{
        ans+=B;
        B--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func exec(stdin *Stdin, stdout *Stdout) {
	h := stdin.ReadInt()
	w := stdin.ReadInt()
	a := []string{}
	for i := 0; i < h; i++ {
		a = append(a, stdin.Read())
	}

	b := [][]bool{}
	q := NewDeque()
	for i := 0; i < h; i++ {
		b = append(b, []bool{})
		for j := 0; j < w; j++ {
			b[i] = append(b[i], false)
		}
	}

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if a[i][j] == '#' {
				q.AppendLast(Tuple{x: i, y: j, count: 0})
				b[i][j] = true
			}
		}
	}

	ans := 0
	diffs := []Tuple{
		Tuple{x: 0, y: 1},
		Tuple{x: 0, y: -1},
		Tuple{x: 1, y: 0},
		Tuple{x: -1, y: 0},
	}
	for !q.IsEmpty() {
		cur, _ := q.PopFirst().(Tuple)
		ans = Max(ans, cur.count)
		for _, diff := range diffs {
			nx := cur.x + diff.x
			ny := cur.y + diff.y
			if 0 <= nx && nx < h && 0 <= ny && ny < w && !b[nx][ny] {
				b[nx][ny] = true
				q.AppendLast(Tuple{x: nx, y: ny, count: cur.count + 1})
			}
		}
	}

	stdout.Println(ans)
}

type Tuple struct {
	x     int
	y     int
	count int
}

func main() {
	stdout := NewStdout()
	exec(NewStdin(bufio.ScanWords), stdout)
	stdout.Flush()
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), int(math.MaxInt32))
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}

type Deque struct {
	deque []interface{}
}

func NewDeque() *Deque {
	return &Deque{deque: []interface{}{}}
}

func (d *Deque) AppendFirst(v interface{}) {
	e := make([]interface{}, len(d.deque)+1)
	copy(e[1:], d.deque)
	d.deque = e
}

func (d *Deque) AppendLast(v interface{}) {
	d.deque = append(d.deque, v)
}

func (d *Deque) PopLast() interface{} {
	n := len(d.deque)
	v := d.deque[n-1]
	d.deque = d.deque[0 : n-1]
	return v
}

func (d *Deque) PopFirst() interface{} {
	v := d.deque[0]
	d.deque = d.deque[1:]
	return v
}

func (d *Deque) IsEmpty() bool {
	return len(d.deque) == 0
}

func Max(a ...int) int {
	v := a[0]
	for i := 1; i < len(a); i++ {
		if v < a[i] {
			v = a[i]
		}
	}
	return v
}


Measured memory_bytes: 83200
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

void main_()
{
    ll N;
    vector<ll> Xs;
    cin >> N;
    Xs.reserve(N);
    copy_n(istream_iterator<ll>(cin), N, back_inserter(Xs));

    vector<ll> v(N / 2 + 1);
    partial_sort_copy(begin(Xs), end(Xs), begin(v), end(v));
    auto a1 = v[N / 2 - 1];
    auto a2 = v[N / 2];

    for (auto x : Xs) {
        cout << ((x <= a1) ? a2 : a1) << endl;
    }
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 4608
#![allow(unused_imports)]


use itertools::Itertools as _;
use proconio::input;

fn main() {
    input! {
        n: usize
    }

    match (n % 10, n / 10 % 10, n / 100 % 10) {
        (7, _, _) | (_, 7, _) | (_, _, 7) => println!("Yes"),
        _ => println!("No"),
    }
}


Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int N, L;
    cin >> N >> L;
    vector<string> S(N);
    for (int i = 0;i < N;i++) {
        cin >> S.at(i);
    }
    sort(S.begin(), S.end());
    for (int i = 0; i < N; i++) {
        cout << S.at(i);
    }
    cout << endl;
}

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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 100005;

int n, ans;

struct Node {
	int l, r;

	bool operator < (const Node &rhs) const {
		return r < rhs.r;
	}
} a[N];

void solve() {
	read(n);
	for (int i = 1; i <= n; ++i) {
		int x, l;
		read(x), read(l);
		a[i].l = x - l, a[i].r = x + l;
	}
	std::sort(a + 1, a + 1 + n);
	int now = -0x3f3f3f3f;
	for (int i = 1; i <= n; ++i) {
		if (a[i].l >= now) {
			++ans;
			now = a[i].r;
		}
	}
	print(ans);
}

int main() {
	int T = 1;
	// read(T);
	while (T--) {
		solve();
	}
}


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

int main(){
  string s;
  cin>>s;
  string k="AAA";
  string p="BBB";
  if(s==k || s==p){
     cout<<"No"<<endl;
  }
  else{
     cout<<"Yes"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	int n;
	while(cin >> n)
	{
		for(int i = n - 1; ; i--)
		{
			bool flag = true;
			for(int j = 2; j * j <= i; j++)
			{
				if(i % j == 0)
				{
					flag = false;
					break;
				}
			}
			if(flag)
			{
				cout << i << " ";
				break;
			}
		}

		for(int i = n + 1; ; i++)
		{
			bool flag = true;
			for(int j = 2; j * j <= i; j++)
			{
				if(i % j == 0)
				{
					flag = false;
					break;
				}
			}
			if(flag)
			{
				cout << i << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 0
#!/usr/bin/ruby
while (n=gets.to_i)!=0
	a=n.times.map{gets.split.map &:to_i}
	m=gets.to_i
	b=m.times.map{gets.split.map &:to_i}
	a=(a+b).sort
	d=[]
	(n+m).times{|i|
		d[i]=1
		i.times{|j|
			if a[j][0]<a[i][0]&&a[j][1]<a[i][1]
				d[i]=[d[j]+1,d[i]].max
			end
		}
	}
	p d.max
end

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

int main(){
  while(1){
    int n,m;
    cin >> n >> m;
    if(n==0) return 0;
    vector<int> c(m),x(n);
    for(int i=0;i<m;i++) cin >> c[i];
    for(int i=0;i<n;i++) cin >> x[i];
    vector<vector<int>> dp(n+1,vector<int>(256,INF));
    dp[0][128]=0;
    for(int i=0;i<n;i++){
      for(int j=0;j<256;j++){
        for(int k=0;k<m;k++){
          dp[i+1][min(max(j+c[k],0),255)]=min(dp[i+1][min(max(j+c[k],0),255)],dp[i][j]+(x[i]-min(max(j+c[k],0),255))*(x[i]-min(max(j+c[k],0),255)));
        }
      }
    }
    int ans=INF;
    for(int i=0;i<256;i++) ans=min(ans,dp[n][i]);
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 23664