akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#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 Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

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 mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination{
    vector<mint> fact,ifact;
    combination(int n):fact(n+1),ifact(n+1){
        assert(n < mod);
        fact[0] = 1;
        for(int i = 1;i <= n; ++i){
            fact[i] = fact[i-1]*i;
        }
        ifact[n] = fact[n].inv();
        for(int i = n; i >= 1; --i){
            ifact[i-1] = ifact[i]*i;
        }
    }
        mint operator()(int n, int k){
            if( k < 0 || k > n) return 0;
            return fact[n]*ifact[k]*ifact[n-k];
        }
    
};

ll modpow(ll p,ll q){
    if(q == 0)return 1;
    if(q%2 == 0){
        ll x = modpow(p,q/2);
        return x*x%mod;
    }else{
        return modpow(p,q-1)*p%mod;
    }
}

ll choose(ll n,ll k){
    ll x=1,y=1;
    rep(i,k){
        x = x*(n-i)%mod;
        y = y*(k-i)%mod;
    }
    y = modpow(y,mod-2);
    return x*y%mod;
}




int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s[0] == s[1] && s[1] == s[2])cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}


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

int main()
{
  int n, x; cin >> n >> x;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(),a.end());

  int sum = 0;
  int i = 0;
  for (; i<n; i++) {
    sum += a[i];
    if (sum >= x) break;
  }
  if (sum == x) i++;
  if (sum < x) i--;
  cout << i << endl;

  return 0;
}


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

using namespace std;

int main()
{
	int a, b, c;
	cin>>a>>b>>c;
	if (a == b && a != c || a == c && a != b || b == c && a != b) cout<<"Yes"<<endl; else cout<<"No"<<endl;
	return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define mp(a, b) make_pair((a), (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SZ(a) ((int)((a).size()))
#define watch(x) cerr << (#x) << " = " << (x) << endl;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

template<class T0, class T1>
inline ostream &operator<<(ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template<class T>
inline ostream &operator<<(ostream &out, vector<T> &a) {
    out << "[";
    for (int i = 0; i < a.size(); i++)
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

#ifdef RUS_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#else
    //    freopen("king.in", "r", stdin);
    //    freopen("king.out", "w", stdout);
#endif

    cout << setprecision(12) << fixed;
    smain();

#ifdef RUS_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float(clock() - start) / CLOCKS_PER_SEC << endl;
#endif

    return 0;
}

void smain() {

    int a, b;
    cin >> a >> b;
    if (a <= 0 && b >= 0)
        cout << "Zero";
    else {
        if (a > 0) {
            cout << "Positive";
        } else {
            if ((b - a + 1) % 2 == 1)
                cout << "Negative";
            else
                cout << "Positive";
        }
    }







}

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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

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

	int n;
	cin >> n;

	vector<int> a(n + 1), b(n + 1), c(n + 1);
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) cin >> b[i];
	for (int i = 1; i <= n - 1; i++) cin >> c[i];

	int ans = b[a[1]];
	for (int i = 2; i <= n; i++) {
		ans += b[a[i]];
		if (a[i - 1] + 1 == a[i]) {
			ans += c[a[i - 1]];
		}
	}

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


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
MAX = max(A)
dp = [True for _ in range(MAX+1)]

for a in set(A):
    for k in range(2*a,MAX+1,a):
        dp[k] = False
B = sorted(A)
for i in range(len(B)-1):
    if B[i] == B[i+1]:
        dp[B[i]] = False

print(sum(dp[a] for a in set(A)))

Measured memory_bytes: 41992
import math

N=int(input())
ans=0
L=[]
M=[]
if N==2:
	print(1)
	exit()
for i in range(2,int(math.sqrt(N))+1):
	if N%i==0:
		L.append(i)
		L.append(N//i)
for i in range(2,int(math.sqrt(N))+1):
	if (N-1)%i==0:
		L.append(i)
		L.append(N//i)

X=set(L)
Y=sorted(X)
for i in range(len(Y)):
	if N%Y[i]==1:
		ans+=1
	elif N%Y[i]==0:
		A=N//Y[i]
		while(1):
			if A%Y[i]==1:
				ans+=1
				break
			elif A%Y[i]==0:
				B=A//Y[i]
				if B==1:
					ans+=1
					break
				else:
					A=B
					continue
			else:
				break
print(ans+2)

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

int main(){
  long k, a, b;
  cin >> k >> a >> b;
  if (b <= a+2 || k <= a){
    cout << 1+k << endl;
  }
  else{
    long q = (k-a+1)/2;
    int r = (k-a+1)%2;
    cout << a+q*(b-a)+r << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N,K,X,Y,S;
  cin >>N>>K>>X>>Y;
  
  if(N>=K){
  S=K*X+(N-K)*Y;
  cout <<S<<endl;}
  else{
  S=N*X;
  cout <<S<<endl;
  }
   
return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int[] s = new int[13];
        int[] h = new int[13];
        int[] c = new int[13];
        int[] d = new int[13];

        for(int i = 0; i < 13; i++){
            s[i] = 0;
            h[i] = 0;
            c[i] = 0;
            d[i] = 0;
        }

        int num = sc.nextInt();

        for(int i = 0; i < num; i++){
            String mark = sc.next();
            int rank = sc.nextInt();

            if(mark.equals("S"))
                s[rank - 1] = 1;
            if(mark.equals("H"))
                h[rank - 1] = 1;
            if(mark.equals("C"))
                c[rank - 1] = 1;
            if(mark.equals("D"))
                d[rank - 1] = 1;
        }

        for(int i = 0; i< 13; i++){
            if(s[i] == 0)
                System.out.println("S " + (i + 1));
        }
        for(int i = 0; i< 13; i++){
            if(h[i] == 0)
                System.out.println("H " + (i + 1));
        }
        for(int i = 0; i< 13; i++){
            if(c[i] == 0)
                System.out.println("C " + (i + 1));
        }
        for(int i = 0; i< 13; i++){
            if(d[i] == 0)
                System.out.println("D " + (i + 1));
        }

        sc.close();
    }
}



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

int main(){
    ll a, b, c, d; scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
    ll x, y;
    printf("%lld\n", max(max(a*c, a*d), max(b*c, b*d)));
    return 0;
}


Measured memory_bytes: 3820
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<queue>
#include<stack>
#include<numeric>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define MEM(a,b) memset(a,b,sizeof(a))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int main() {
	IOS;
	int x;
	vector<int> v;
	REP(i, 3) {
		cin >> x;
		v.push_back(x);
	}
	int ans = 114514810,tmp;
	do {
		tmp = 0;
		tmp += abs(v[1] - v[0]);
		tmp += abs(v[2] - v[1]);
		if (tmp < ans)ans = tmp;
	} while (next_permutation(v.begin(), v.end()));
	cout << ans << endl;
}



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


using namespace std;

bool cmp(pair<int,int > x, pair<int,int > y) { 
	return x.second < y.second;
}


int main() {
	int n=0 ,tmp;
	scanf("%d",&n);
	pair<int,int > a[n];
	for(int i = 0; i < n; i++) {
		a[i].first=i+1;
		scanf(" %d", &a[i].second);		
	}
	sort(a,a+n,cmp);
	for(int i = 0; i < n; i++) 
		printf("%d ", a[i].first);

return 0;
} 

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

using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    int s[m],c[m];
    rep(i,m) cin >> s[i] >> c[i];  //s[i]桁目がc[i]
    rep(i,1000){
        string str = to_string(i);
        int cnt = 0;
        rep(j,m){
            if(str[s[j]-1] -'0' == c[j]) cnt++;
        }
        if(cnt == m && str.size() == n){
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

// 約数列挙
vector<long long> calc_divisor(long long n) {
    vector<long long> res;
    for (long long i = 1LL; i*i <= n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            long long j = n / i;
            if (j != i) res.push_back(j);
        }
    }
    sort(res.begin(), res.end());
    //sort(res.rbegin(), res.rend());
    return res;
}

int main(){
    ll n;
    cin >> n;
    auto v = calc_divisor(n);
    ll ans = INF;
    rep(i, v.size()){
        ll x = v[i];
        ll y = n/v[i];
        chmin(ans, x+y-2);
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
	int h, w, n;
	cin >> h >> w >> n;

	vector<vector<int>> field(h, vector<int>(w, 0));
	int x, y;
	x = y = 0;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		while (a--) {
			field[y][x] = i + 1;
			if (y % 2 == 0) {
				x++;
				if (x == w) {
					x = w - 1;
					y++;
				}
			}
			else {
				x--;
				if (x == -1) {
					x = 0;
					y++;
				}
			}
		}
	}
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			cout << field[i][j];
			if (j + 1 != w) cout << " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
 
int main(void)
{
int n,i,R[200000],max,min;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&R[i]);
}
min=R[0];
max=R[1]-R[0];
for(i=1;i<n;i++){
if(max<R[i]-min){
max=R[i]-min;
}
if(min>R[i]){
min=R[i];
}
}
printf("%d\n",max);
return 0;
}

Measured memory_bytes: 2544
#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 a, b; cin>>a>>b;
    if(a + b == 15) cout << "+" << endl;
    else if(a * b == 15) cout << "*" << endl;
    else cout << "x" << endl;

    return 0;
}

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

using namespace std;

int board[10][10];

char getE(string s)
{
  int now = s[0] - '0';
  for(int i = 1; i < s.size(); i++) {
    now = board[now][s[i] - '0'];
  }
  return (now + '0');
}

int main()
{

  for(int i = 0; i < 10; i++) {
    for(int j = 0; j < 10; j++) {
      cin >> board[i][j];
    }
  }

  int ret = 0;

  for(int i = 0; i < 10000; i++) {
    stringstream sss;
    sss << i;
    string s = "0" + sss.str();
    while(s.size() <= 4) s = "0" + s;
    s += getE(s);

    vector< string > kk;
    for(int j = 1; j < 6; j++) {
      for(char c = '0'; c <= '9'; ++c) {
        swap(c, s[j]);
        kk.push_back(s);
        swap(c, s[j]);
      }
      if(j > 1) {
        swap(s[j - 1], s[j]);
        kk.push_back(s);
        swap(s[j - 1], s[j]);
      }
    }
    sort(begin(kk), end(kk));
    kk.erase(unique(begin(kk), end(kk)), end(kk));
    bool f = false;
    for(string& t : kk) {
      if(t == s) continue;
      if(getE(t) == '0') f = true;
    }
    ret += f;
  }
  cout << ret << endl;
}

Measured memory_bytes: 3212
nums = [int(num) for num in input()]

target = 7

if sum(nums) == target:
    symbols = '+++'
elif nums[0] + nums[1] + nums[2] - nums[3] == target:
    symbols = '++-'
elif nums[0] + nums[1] - nums[2] + nums[3] == target:
    symbols = '+-+'
elif nums[0] + nums[1] - nums[2] - nums[3] == target:
    symbols = '+--'
elif nums[0] - nums[1] + nums[2] + nums[3] == target:
    symbols = '-++'
elif nums[0] - nums[1] + nums[2] - nums[3] == target:
    symbols = '-+-'
elif nums[0] - nums[1] - nums[2] + nums[3] == target:
    symbols = '--+'
elif nums[0] - nums[1] - nums[2] - nums[3] == target:
    symbols = '---'

result = ''
for i in range(len(symbols)):
    result += str(nums[i])
    result += symbols[i]
result += str(nums[-1])

print('{}=7'.format(result))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ans=0;
  cin >> n;
  int a[2][n];
  for(int i=0;i<2;i++){
    for(int j=0;j<n;j++){
      cin >> a[i][j];
    }
  }
  int sum1=0,sum2=0;
  for(int i=0;i<n;i++){
    sum1+=a[0][i];
    for(int j=i;j<n;j++){
      sum2+=a[1][j];
    }
    ans=max(sum1+sum2,ans);
    sum2=0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
S = str(input())

X = int(S[:2])
Y = int(S[2:])

if 0< X <= 12 and 0< Y <= 12:
    print('AMBIGUOUS')
elif 0< X <= 12:
    print('MMYY')
elif 0 < Y <= 12:
    print('YYMM')
else:
    print('NA')


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

int main() {
	int h;
	int t[3]={};
	for(int i=0;i<10;i++){
	cin >> h;
	for(int j=0;j<3;j++){
		if(h>t[j]){
			for(int k=1;k>=j;k--){
				t[k+1]=t[k];
			}
			t[j]=h;
			break;
		}
	}
	}
	for(int i=0;i<3;i++){
	cout << t[i] << endl;}
	return 0;
}

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

int main(){
    int n, p[101], c[101][101], k; 
    cin >> n;
    for (int i=1; i<=n; i++) {
        cin >> p[i-1] >> p[i];
    }
    for (int i=1; i<=n; i++) {
        c[i][i] = 0;
    }
    for (int i=2; i<=n; i++) {
        for (int j=1; j<=n-i+1; j++) {
            k = j + i -1;
            c[j][k] = 2147483647;
            for (int l=j; l <=k-1; l++) {
            c[j][k] = min(c[j][k], c[j][l] + c[l+1][k] + p[j-1]*p[l]*p[k]);
            }
        }
    }
    cout << c[1][n] << endl;
}


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

Int N;

Int souwa(vector<Int> V, Int P) {
    Int sum = 0;
    rep(i,N) {
        sum += (V[i] - P) * (V[i] - P);
    }
    return sum;
}

int main(){ 
  cin >> N;
  vector<Int> X(N);
  rep(i,N) cin >> X[i];

  Int Min = 100, Max = 0;
  rep(i,N) {
      Min = min(Min, X[i]);
      Max = max(Max, X[i]);
  }

    Int ans = 10000000;
  for(Int i = Min; i<=Max; i++) {
      ans = min(ans, souwa(X,i));
  }

  cout << ans << endl;
}


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

int main(){
    int n, q;
    cin >> n >> q;
    atcoder::dsu dsu(n);
    
    for (int i = 0; i < q; i++){
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0)
            dsu.merge(u, v);
        else
            printf("%d\n", dsu.same(u, v));
    }
}

Measured memory_bytes: 3912
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// debug & operator << (debug & dd, P p) { dd << "(" << p.x << ", " << p.y << ")"; return dd; }



int main() {
	string s;
	cin >> s;
	if(s.back() == 's') s += "es";
	else s += "s";
	cout << s << endl;
}


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

int main(){
  string s;
  cin >> s;
  vector<int> v(4,0);
  r(i,s.length()){
    if(s.at(i)=='N')v.at(0)++;
    if(s.at(i)=='S')v.at(1)++;
    if(s.at(i)=='W')v.at(2)++;
    if(s.at(i)=='E')v.at(3)++;
  }
  bool flag=true;
  if(v.at(0)==0&&v.at(1)!=0)flag=false;
  if(v.at(1)==0&&v.at(0)!=0)flag=false;
  if(v.at(2)==0&&v.at(3)!=0)flag=false;
  if(v.at(3)==0&&v.at(2)!=0)flag=false;
  
  if(flag)cout << "Yes"<<endl;
  else cout << "No"<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    private static Scanner sc;
    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {

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

            int max = Integer.MIN_VALUE;

            for (int i = 0; i <= k && i <= n; i++) {
                for (int j = 0; j <= k - i && j <= n - i; j++) {
                    int l = k - i - j;
                    int sum = 0;

                    List<Integer> tmp = new ArrayList<>();

                    for (int m = 0; m < i; m++) {
                        tmp.add(v[m]);
                        sum += v[m];
                    }

                    for (int m = 0; m < j; m++) {
                        tmp.add(v[n-1-m]);
                        sum += v[n-1-m];
                    }

                    tmp.sort(Comparator.naturalOrder());

                    for (int m = 0; m < l && m < tmp.size(); m++) {
                        if (tmp.get(m) < 0) {
                            sum -= tmp.get(m);
                        }
                    }
                    if (max < sum) max = sum;
                }
            }
            System.out.println(max);


        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 23892
import java.util.Scanner;

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

		int N = Integer.parseInt(sc.next());

		sc.close();

		if(N % 2 == 0) {
			System.out.println(0.5);
		}else {
			System.out.println((float)((N + 1) / 2) / N);
		}

	}
}

Measured memory_bytes: 21844
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    s = S()
    l = len(s)
    c = collections.Counter(s)
    r = l*(l-1) // 2 + 1
    for v in c.values():
        r -= v*(v-1) // 2

    return r

print(main())



Measured memory_bytes: 7752
n=gets.to_i
k=[1,6,36,216,1296,7776,46656,9,81,729,6561,59049]
s=Array.new(1200001,0)
for j in 1..n
  s[j]=j
end
for i in 1..11
  for j in 1..n
    s[i*n+j]=s[(i-1)*n+j]
  end
  s[i*n+k[i]]=1
  if k[i] < n then
    for j in (k[i]+1)..n
      s[i*n+j]=1+s[i*n+j-k[i]] if s[i*n+j] > 1+s[i*n+j-k[i]]
    end
  end
end
puts s[12*n]

Measured memory_bytes: 11132
program main;
var
    i, n, ac, wa, tle, re : integer;
    s : string;
begin
    readln(n);
    for i := 1 to n do begin
        readln(s);
        if s = 'AC'
            then ac := ac + 1;
        if s = 'WA'
            then wa := wa + 1;
        if s = 'TLE'
            then tle := tle + 1;
        if s = 'RE'
            then re := re + 1;
   end;
   writeln('AC x ', ac);
   writeln('WA x ', wa);   
   writeln('TLE x ', tle);  
   writeln('RE x ', re);
end.


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

int main() {
  int H, W, D, Q;
  cin >> H >> W >> D;
  vector<pair<int, int>> V(H * W + 1);
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      int ai;
      cin >> ai;
      V.at(ai) = pair<int, int>(i, j);
    }
  }
  vector<int> dp(H * W + 1, 0);
  for (int i = D + 1; i <= H * W; ++i) {
    int x = V.at(i).first,
    y = V.at(i).second,
    next_x = V.at(i - D).first,
    next_y = V.at(i - D).second;;
    dp.at(i) = dp.at(i - D) + abs(next_x - x) + abs(next_y - y);
  }
  cin >> Q;
  for (int i = 0; i < Q; ++i) {
    int li, ri;
    cin >> li >> ri;
    int mp = dp.at(ri) - dp.at(li);
    cout << mp << endl;
  }
}

Measured memory_bytes: 2176
def preParse(u):
    if u == NIL:
        return
    print(' {}'.format(u), end='')
    preParse(Left[u])
    preParse(Right[u])


def inParse(u):
    if u == NIL:
        return
    inParse(Left[u])
    print(' {}'.format(u), end='')
    inParse(Right[u])


def postParse(u):
    if u == NIL:
        return
    postParse(Left[u])
    postParse(Right[u])
    print(' {}'.format(u), end='')


NIL = -1
n = int(input())
data = [list(map(int, input().split()))for _ in range(n)]
Parent = [NIL]*n
Right = [None]*n
Left = [None]*n
for i in data:
    Right[i[0]] = i[2]
    Left[i[0]] = i[1]
    if i[2] != NIL:
        Parent[i[2]] = i[0]
    if i[1] != NIL:
        Parent[i[1]] = i[0]
for i in range(n):
    if Parent[i] == NIL:
        root = i
'''
print(root)
print(Parent)
print(Right)
print(Left)
'''
print('Preorder')
preParse(root)
print()
print('Inorder')
inParse(root)
print()
print('Postorder')
postParse(root)
print()


Measured memory_bytes: 5624
#include <ios>
#include <iostream>
using namespace std;
int main()
{
	int n, i, j, c = 0, a[100] = {};
	cin >> n;
	for(i = 0; i < n; ++i)
		cin >> a[i];

	for(i = 0; i < n; ++i){
		for(j = n-1; j > i; --j){
			if( a[j] < a[j-1] ){
				swap(a[j], a[j-1]);
				++c;				
			}
		}
	}

	for(i = 0; i < n; ++i){
		cout << a[i];
		if( i != n-1 )
			cout << " ";
	}
	cout << "\n" << c << "\n";

	return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    li n;
    cin >> n;
    repp(i, 1, n + 2) {
        if (i * i > n) {
            cout << (i - 1)*(i - 1) << endl;
            return 0;
        }
    }
    return 0;
}

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

using namespace std;

int main() {
    string sa, sb, sc;
    cin >> sa >> sb >> sc;
    int idxa = 0, idxb = 0, idxc = 0;
    char curr_player = 'a';
    while (true) {
        if (curr_player == 'a') {
            if (idxa == sa.length()) {
                cout << "A";
                return 0;
            }
            curr_player = sa[idxa];
            idxa++;
        } else if (curr_player == 'b') {
            if (idxb == sb.length()) {
                cout << "B";
                return 0;
            }
            curr_player = sb[idxb];
            idxb++;
        } else {
            if (idxc == sc.length()) {
                cout << "C";
                return 0;
            }
            curr_player = sc[idxc];
            idxc++;
        }
    }
}

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

#define SWAP(type, a, b) do { type t = a; a = b; b = t; } while(0)

int cnt = 0;

void bubbleSort(int *array, int n) {
    for(int i = 1; i < n; i++) {
        for(int j = 0; j < n - i; j++) {
            if(array[j] > array[j + 1]) {
                SWAP(int, array[j], array[j + 1]);
                cnt++;
            }
        }
    }
}

void printArray(int *array, int n) {
    for(int i = 0; i < n;) {
        printf("%d", array[i]);
        i++;
        if(i < n) {
            printf(" ");
        }
    }
    printf("\n");
}

int main(void) {
    int n;

    scanf("%d", &n);

    int *array = malloc(n * sizeof(int));
    if(array == NULL) {
        return 1;
    }

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

    bubbleSort(array, n);

    printArray(array, n);

    printf("%d\n", cnt);

    return 0;
}


Measured memory_bytes: 2112
N, M = gets.split.map(&:to_i)
A = (1..N).map{gets.chomp.split("")}
B = (1..M).map{gets.chomp.split("")}
result = false
for i in 1..(N-M+1)
    for j in 1..(N-M+1)
        result ||= A.map{|a| a[(i-1)..(i+M-2)]}[(j-1)..(j+M-2)] == B
    end
end
puts result ? "Yes" : "No"

Measured memory_bytes: 2172
/**
 *    author: apurba_debnath
**/
#include <bits/stdc++.h>


#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;


using namespace std;

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

    int k, a, b, flag = 0;
    cin >> k >> a >> b;
    for (int i = a; i <= b; ++i) {
        if (i % k == 0) {
            flag = 1;
            break;
        }
    }
    if (flag) cout << "OK";
    else cout << "NG";
    return 0;
}


Measured memory_bytes: 3556
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a<=b && b<=c){
		cout<<a<<" "<<b<<" "<<c<<endl;
	}
	else if(a<=c && c<=b){
		cout<<a<<" "<<c<<" "<<b<<endl;
	}
	else if(c<=a && a<=b){
		cout<<c<<" "<<a<<" "<<b<<endl;
	}
	else if(c<=b && b<=a){
		cout<<c<<" "<<b<<" "<<a<<endl;
	} 
	else if(b<=c && c<=a){
		cout<<b<<" "<<c<<" "<<a<<endl;
	} 
	else if(b<=a && a<=c){
		cout<<b<<" "<<a<<" "<<c<<endl;
	}
return 0;
}


Measured memory_bytes: 3096
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
count=0
for i in range(N):
    count+=min(A[i],B[i])
    if A[i]<B[i]:
        if A[i+1]<B[i]-A[i]:
            count+=A[i+1]
            A[i+1]=0
        else:
            count+=B[i]-A[i]
            A[i+1]-=B[i]-A[i]
print(count)

Measured memory_bytes: 18624
N = int(input())

f0 = []
f1 = []
for _ in range(N):
    x, y = list(map(int, input().split()))
    f0.append(x-y)
    f1.append(x+y)
max_0 = max(f0)
max_1 = max(f1)
min_0 = min(f0)
min_1 = min(f1)
print(max(max_0-min_0, max_1-min_1))

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

ll tp[100001];

void maketp()
{
    tp[0] = 1;
    for (int i = 1; i < 100001; i++)
    {
        tp[i] = (tp[i - 1] * i) % MOD;
    }
}

ll comb(ll n, ll r)
{
    if (n < r)
        return 0;
    else
        return (tp[n] / (tp[n - r] * tp[r]) % MOD) % MOD;
}

signed main()
{
    int n, m;
    cin >> n >> m;
    maketp();

    if (abs(n - m) > 1)
    {
        cout << 0 << endl;
        return 0;
    }
    // n > mを保証
    if (m > n)
    {
        int tmp = n;
        n = m;
        m = tmp;
    }
    if (n != m)
        cout << (tp[n] * tp[m]) % MOD << endl;
    else
        cout << (tp[n] * tp[m] * 2) % MOD << endl;
}


Measured memory_bytes: 1024
using System;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] In1 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int n = In1[0];
            int m = In1[1];
            int c = In1[2];
            int[] B = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int cnt =0;
            for(int i = 0; i < n; i++)
            {
                int sum = c;
                int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                for(int j = 0; j < m; j++)
                {
                    sum += (A[j]*B[j]);
                }
                if (sum > 0) cnt++;
            }
            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 28220
from collections import*
input=open(0).readline
n=int(input())
e=[[]for _ in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    e[a-1].append(b-1)
    e[b-1].append(a-1)
f=[0]*n
v=[1]+[0]*~-n
q=deque([(0,0)])
while q:
    t,c=q.pop()
    v[t]=1
    f[t]=c
    for i in e[t]:
        if not v[i]:
            q.append((i,c+1))
s=[0]*n
v=[0]*~-n+[1]
q=deque([(n-1,0)])
while q:
    t,c=q.pop()
    v[t]=1
    s[t]=c
    for i in e[t]:
        if not v[i]:
            q.append((i,c+1))
a=b=0
for i,j in zip(f,s):
    if i<=j:
        a+=1
    else:
        b+=1
if a>b:
    print('Fennec')
else:
    print('Snuke')

Measured memory_bytes: 59080
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <cmath>
#include <queue>
#include <ctime>
#include <utility> // std::pair
#include <functional> // std::greater <int> ()
#define int long long
#define inf 1000000000000000001
#define BASE 29 // hashings mod, can be rand'd
#define mod 998244353 // can be 1000000007
#define pi 3.1415926535897
#define pii pair <int, int>
#define fii first
#define see second

typedef long long ll;
typedef long double ld;
using namespace std;

int n;
int h[100005];

// functions
void input(){
	cin >> n;
	for(int i=1; i<=n; i++){
		cin >> h[i];
	}
	return;
}

void solve(){
	bool ok=0;
	for(int i=2; i<=n; i++){
		int t=h[i]-h[i-1];
		if(t<=-2 || t==-1 && ok){
			cout << "No";
			return;
		}
		if(t==-1){
			ok=1;
		}
		if(t>0){
			ok=0;
		}
	}
	cout << "Yes";
	return;
}

void output(){
	return;
}

signed main(){
/*
//  REMEMBER TO TURN OFF IFDEF IN PROBLEMS WITH FILE I/O
*/
//#ifdef sheeep
//	freopen("forces.inp", "r", stdin);
//	freopen("forces.out", "w", stdout);
//#endif
	ios_base::sync_with_stdio(false);
//	int t;
//	cin >> t;
//	for(int i=1; i<=t; i++){
		input();
		solve();
		output();
//	}
	return 0;
}
// Author: NamSPro



Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#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;
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-1;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 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 pb push_back
#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)
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);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  if(n<r)return 0;
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  // startupcpp();
  // ll test;cin>>test;while(test--){
  ll i,x,N,D;
  cin>>N;
  vec ch(N,0);
  rep(i,N+1){
    cin>>x;
    --x;
    if(ch[x]){
      D=i+1-ch[x];
    }
    ch[x]=i+1;
  }
  rep(i,N+1){
    print((mod+modncr(N+1,i+1)-modncr(N-D,i))%mod);
  }
  return 0;
}

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

using namespace std;

long long a,b;

long long lo(long long x)
{
	int res=0;
	while (x)
	{
		x/=2;
		++res;
	}
	return res;
}

int main()
{
	std::ios_base::sync_with_stdio(false);
	cin>>a>>b;
	cout<<lo(b/a)<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
typedef struct E{
	int to;
	struct E *next;
}edge;
int N, M, d[1<<17], que[1<<17], l=0, r=0;
edge G[1<<17], *nil;
void push(int i, int j){
	edge *X = (edge*)malloc(sizeof(edge));
	(*X).to = j;
	(*X).next = G[i].next;
	G[i].next = X;
	return;
}
int main(){
	scanf("%d%d", &N, &M);
	for(int i=0; i<=N; i++){
		d[i] = -1;
		G[i].next = nil;
	}
	for(int i=0; i<M; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		push(a, b);
		push(b, a);
	}
	d[1] = 0;
	que[r++] = 1;
	while(l != r){
		int i = que[l++];
		edge *x = G[i].next;
		while(x != nil){
			int j = (*x).to;
			if(d[j] == -1){
				d[j] = i;
				que[r++] = j;
			}
			x = (*x).next;
		}
	}
	puts("Yes");
	for(int i=2; i<=N; i++){
		printf("%d\n", d[i]);
	}
	return 0;
}

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


int main(){
    int n,A[110],v,cnt;
    cin>>n;
    for(int i=0;i<n;i++)cin>>A[i];
    bool ok=1;
    for(int I=0;ok;I++){
        ok=0;
    for(int i=n-1;i>I;i--){
        v=A[i];
        if(A[i]<A[i-1]){
            A[i]=A[i-1];
            A[i-1]=v;
            cnt++;
            ok=1;
        }
    }
    }
    for(int i=0;i<n;i++){
        cout<<A[i];
        if(i!=n-1)cout<<" ";
    }
    cout<<endl<<cnt<<endl;

    return 0;
}






Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <string>
using namespace std;
float ans,r;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("test.inp","r",stdin);
    //freopen("test.out","w",stdout);
    cin>>r;
    ans=2*r*3.14159;
    cout<<ans;
}

Measured memory_bytes: 3808
#include<iostream>
using namespace std;
int main(){
	int a,b,c,i,ans=0,yaku=0;
	cin>>a>>b>>c;
	for(i=a;i<=b;i++){
		yaku=c%i;
		if(yaku==0){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3100
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    if( a < b ){
        cout<<"a < b"<<endl;
    }else if( a > b ){
        cout<<"a > b"<<endl;
    }else if( a = b ){
        cout<<"a == b"<<endl;
    }
}



Measured memory_bytes: 3116
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
//#define int long long
#define EPS 1e-10
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
typedef long long llong;
signed main() {
	int a, b;
	char op;
	cin >> a >> op >> b;
	if (op == '+')cout << a + b << endl;
	else cout << a - b << endl;
	return 0;
}

Measured memory_bytes: 764
#include<cstdio>
#include<algorithm>
using namespace std;
int x[100010];
int main(void){
  int d, n, m, dn, k;
  int l, r, mid;
  long long ans;
  x[0] = 0;
  for( ; ; ){
    scanf("%d", &d);
    if(!d) break;
    scanf("%d %d", &n, &m);
    for(int i = 1; i <= n - 1; i++){
      scanf("%d", &dn);
      x[i] = dn;
    }
    x[n] = d;
    sort(x, x + n + 1);
    ans = 0;
    for(int i = 0;i < m; i++){
      scanf("%d", &k);
      l = 0; r = n;
      while(l <= r){
	mid = (l + r) / 2;
	if(x[mid] < k){
	  if(l == mid) break;
	  l = mid;
	}
	if(x[mid] > k){
	  if(r == mid) break;
	  r = mid;
	}
	if(x[mid] == k) break;
      }
      if(x[mid] != k) ans += min(k - x[l], x[r] - k);
    }
    printf("%d\n", ans);
  }
}


Measured memory_bytes: 1432
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}}; ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}
int main() {
    const i64 INF = 1e16;
    i64 ans = 0;
    i64 N;
    cin >> N;
    N++;
    vector<i64> X(N, 0);
    X[N - 1] = 1;
    i64 s = 1; // sum of X
    i64 p = N - 1;
    for(i64 h = N - 1; h >= 0; h--) {
        if(p < 0) {
            cout << -1 << endl;
            return 0;
        }
        if(h < N - 1) {
            X[h] += s;
            s *= 2ll;
        }
        if(s > INF) {
            s = INF; // これ以上多いものは必要ない
        }
        i64 a;
        cin >> a;
        while(p >= 0 && a > 0) {
            if(X[p] >= a) {
                X[p] -= a;
                s -= a;
                ans += a * (p - h + 1ll);
                a = 0;
            } else {
                a -= X[p];
                s -= X[p];
                ans += X[p] * (p - h + 1ll);
                X[p] = 0;
                p--;
            }
        }
        if(a > 0) {
            cout << -1 << endl;
            return 0;
        }
        while(p >= 0 && X[p] == 0) p--;
    }
    if(ans <= 0) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4048
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

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

long lcm( long m, long n ){
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	return ((m / gcd(m, n)) * n); 
}

ll A, B, C, D;

int main(){
	cin >> A >> B >> C >> D;

	ll CD = lcm(C, D);
	ll ans = B - A + 1;

	ans -= (B/C) - ((A-1)/C);
	ans -= (B/D) - ((A-1)/D);
	ans += (B/CD) - ((A-1)/CD);
	cout << ans << endl;


}

Measured memory_bytes: 3612
///supercalifragilisticexpialidocious.
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <cstdlib>
#include <cctype>
#include <ctime>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <utility>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <list>
#include <bitset>
#include <complex>
using namespace std;
#define f first
#define s second
#define PB pop_back
#define pb push_back
#define mp make_pair
#define int long long
#define sz(s) (int)s.size()
#define seper(n) setprecision(n)
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a,b,sizeof a)
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
typedef long long ll;
typedef map<int , int> mii;
typedef pair<int , int> pii;
typedef map<string , int> msi;
typedef pair<int , string> pis;
typedef pair<int , pair<int , int> > piii;
const int MAXN = 1e5 + 10;
int n , m , u , v , p , c , d , prnt_u , prnt_v , cm[MAXN] , par[MAXN] , szz[MAXN];
bool bo[MAXN] , boo[MAXN];
vector<int> adj[MAXN];
int Find(int u)
{
	if(cm[u] == u)
		return u;
	return cm[u] = Find(cm[u]);
}
bool dfs(int u , int p)
{
	if(bo[u] and par[u] != (par[p] ^ 1))
		return false;
	if(bo[u])
		return true;
	par[u] = par[p] ^ 1 , bo[u] = true;
	for(auto v : adj[u])
		if(v != p)
			if(!dfs(v , u))
				return false;
	return true;
}
void input()
{
	cin >> n >> m;
	for(int i = 0 ; i < n ; i ++)
		cm[i] = i;
	for(int i = 0 ; i < m ; i ++)
	{
		cin >> u >> v , u -- , v -- , adj[u].pb(v) , adj[v].pb(u);
		if((prnt_u = Find(u)) != (prnt_v = Find(v)))
			cm[prnt_u] = prnt_v;
	}
	return;
}
int32_t main()
{
	input();
	for(int i = 0 ; i < n ; i ++)
		if(Find(i) == i)
			boo[i] = dfs(i , 0);
	for(int i = 0 ; i < n ; i ++)
		szz[Find(i)] ++;
	for(int i = 0 ; i < n ; i ++)
		if(Find(i) == i)
		{
			if(szz[i] == 1)
				p ++;
			else if(boo[i])
				c ++;
			else
				d ++;
		}	
	return cout << 1LL * p * n + 1LL * (n - p) * p + 1LL * c * c * 2 + 1LL * d * (d + c * 2) << endl , 0;
}


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

using namespace std;

int main() {
  char s[11];
  cin >> s;
  int len = strlen(s);
  int minimumAbs = 1001;
  for (int i = 0; i < len - 2; i++) {
    int x = s[i] - '0';
    int y = s[i + 1] - '0';
    int z = s[i + 2] - '0';
    int whole = x * 100 + y * 10 + z;
    if (abs(whole - 753) < minimumAbs) {
      minimumAbs = abs(whole - 753);
    }
  }
  cout << minimumAbs << '\n';
  return 0;
}


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

static int N = 1000;

int main(){
  int i,k,j,l,n,min=0;
  int p[N+1],m[N+1][N+1];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d %d",&p[i-1],&p[i]);
  }

  for(i=1;i<=n;i++)m[i][i]=0;
  for(l=2;l<=n;l++){
    for(i=1;i<=n-1;i++){
      j = i + l - 1;
      m[i][j] = (1 << 21);
      for(k=i;k<=j-1;k++){
	if(m[i][j] <= m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]){
	m[i][j] = m[i][j];
	}else{
	  m[i][j] = m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	}
      }
    }
  }

  printf("%d\n",m[1][n]);

  return 0;
}
  



Measured memory_bytes: 2196