akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;
int main()
{

    int r,m,a,c,d;
    cin>>r>>m;

if(r>=-100 && m<=100){a=r*m;
    c=r-m;
    d=r+m;
    if(a>=c && a>=d){

        cout<<a;
    }
  else if(c>=a && c>=d){

        cout<<c;
    }

    else if(d>=a && d>=c){

        cout<<d;
    }



}else{cout<<"no";}
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl

typedef long long LL;
typedef long double LD;

int main(){
  int n,w,h;
  cin >> n >> w >> h;
  vector<int> ta(h+1,0),yo(w+1,0);
  int x,y,r;
  rep(i,n){
    cin >> x >> y >> r;
    ta[max(y-r,0)]++;
    ta[min(y+r,h)]--;
    yo[max(x-r,0)]++;
    yo[min(x+r,w)]--;
  }
  rep(i,h){
    ta[i+1]+=ta[i];
  }
  rep(i,w){
    yo[i+1]+=yo[i];
  }
  bool tok=true,yok=true;
  rep(i,h){
    if(ta[i]==0) tok=false;
  }
  rep(i,w){
    if(yo[i]==0) yok=false;
  }
  if(tok||yok) CYES;
  else CNO;
  return 0;
}



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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

int main() {
    fast_io;
    int n,m;
    cin>>n>>m;

    int total=0;
    while(m--) {
        int time;
        cin>>time;
        total+=time;
    }

    int ans=n-total;
    if(ans<0) {
        cout<<-1<<endl;
    }
    else {
        cout<<ans<<endl;
    }



}




Measured memory_bytes: 3560
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

require 'pp'

INT_MAX = 999999999999999999999999

M = 1000000007
def mul(a,b)
	a*b%M
end

N,d=gets.chomp.split(" ").map{|n| n.to_i}
A = gets.chomp.split("")
B = gets.chomp.split("")
arr = []
pa = "0"
pb = "0"
for i in 0..(N-1)
	a = A[i]
	b = B[i]
	if(a==b)
		arr << "v"
	elsif(pa==a&&pb==b)
		arr << "h"
	end
	pa = a
	pb = b
end

case arr[0]
when "v"
	cmb = 3
when "h"
	cmb = 6
end
pp = arr[0]
for i in 1..(arr.size-1)
	case [pp,arr[i]]
	when ["v","v"]
		cmb = mul(cmb,2)
	when ["v","h"]
		cmb = mul(cmb,2)
	when ["h","v"]
	when ["h","h"]
		cmb = mul(cmb,3)
	end
	pp = arr[i]
end
puts cmb


Measured memory_bytes: 4092
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,m,c,b[25]={};
    int cnt=0,d=0,ans=0;
    
    cin>>n>>m>>c;
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    
while(1){
    if(d>=n) break;
    ans=0;
    int a[25]={};

    for(int i=0;i<m;i++){
        cin>>a[i];
        ans+=a[i]*b[i];
        //cout<<a[i]<<" "<<b[i]<<endl;
    }
    ans+=c;
    if(ans>0) cnt++;
   // cout<<ans<<endl;
    d++;
    }
      cout<<cnt<<endl;
      return 0;
}

Measured memory_bytes: 256
pieces_num, markpoints_num = map(int, input().split())
markpoints = sorted(map(int, input().split()))

distances = []
for markpoints_i in range(1, markpoints_num):
    distances.append(markpoints[markpoints_i] - markpoints[markpoints_i - 1])
distances.sort()

print(sum(distances[:1 - pieces_num] if pieces_num != 1 else distances))


Measured memory_bytes: 13968
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
#define dout(n) cout<<# n<<" = "<<n<<endl;
    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin>>a>>b;
    cout<<(a*(a-1)/2)+(b*(b-1)/2)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    string s;
    cin >> s;
    vector<string> v{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    for (int i = 0; i < 7; i++) {
        if (v[i] == s)cout << 7 - i;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 20000000
#define VMAX 1000000

int countingsort(int A[], int B[], int n, int C[]){
    int i;
    for (i = 0; i < n; i++){
        C[A[i]] += 1;
    }


    for(i  = 1; i <  VMAX; i++){
        C[i] = C[i-1] + C[i];
    }

    for(i = n-1; i >= 0; i--){
        B[C[A[i]]--] = A[i];
    }
    

    return 0;
}


int main(){
    int i, n;
    int C[VMAX];
    scanf("%d", &n);

    int A[n], B[n];

    for(i = 0; i < VMAX; i++){
        C[i] = 0;
    }

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

    countingsort(A, B, n, C);

    for(i = 1; i <= n; i++){
        if(i != n){
            printf("%d", B[i]);
            printf(" ");
        } else{
            printf("%d\n", B[i]); 
        }
    }

    return 0;
}


Measured memory_bytes: 21384
import heapq

def main():
    N, K = map(int, input().split())
    *D, = map(int, input().split())

    m = min(N, K)

    ans = 0
    # take i items
    for i in range(m+1):
        # take a items from left
        for a in range(i+1):
            items = D[:a] + D[N-(i-a):]
            ans = max(ans, sum(items))
            heapq.heapify(items)
            # push items
            for _ in range(min(i, K-i)):
                head = heapq.heappop(items)
                if head > 0:
                    break
                ans = max(ans, sum(items))
    print(ans)

main()

Measured memory_bytes: 3064
N, M, C = (int(i) for i in input().split())
tage_lists = [int(i) for i in input().split()] 

result = 0
for _ in range(N):
  code_list = [int(i) for i in input().split()]
  
  total = 0
  for count, num in enumerate(code_list):
    total += num * tage_lists[count]
  
  if(total + C > 0):
    result += 1

print(result)

Measured memory_bytes: 3060
from itertools import product
n, m = list(map(int, input().split()))
A = [list(input()) for _ in range(n)]
B = [list(input()) for _ in range(m)]
for i, j in product(range(n - m + 1), range(n - m + 1)):
    if all([A[i + k][j:j + m] == B[k] for k in range(m)]):
        print('Yes')
        exit()
print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds ;
#define ll long long
#define ld long double
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define sz(a) int((a).size())
#define hell (ll)1000000007
#define f first
#define s second
#define sll(x) scanf("%lld",&x)
#define si(x) scanf("%d",&x)
typedef tree< ll , null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update > ordered_set ;
ll t = 1 ;
void solve()
{
	ll n , q ;
    cin >> n >> q ;
    vector<ll> s(n) , d(q) , tt(n) , x(n) ;
    vector<vector<ll> > v ;
    map<ll,ll> mapa ;
    rep( i , 0 , n ){
        cin >> s[i] >> tt[i] >> x[i] ;
        v.pb({x[i],s[i],tt[i]}); 
    }
    rep( i , 0 , q ){
		cin >> d[i] ;
	}
    sort(all(v));
    
	ordered_set seta ;
	rep( i , 0 , q ){
		seta.insert(d[i]);
	}
	for(auto i : v ) {
		ll le =  i[1]-i[0] , ri = i[2]-i[0]-1 ;
		//cout << "le : " << le << " ri : " << ri << " " ;
		ll u = seta.order_of_key(le) , vvv = seta.order_of_key(ri) ;
		//cout << u << ' ' << vvv << "\n" ;
		vector<ll> va ;
        for(ll j = u ; j <= min((ll)sz(seta)-1,vvv) ; j++ ){
			ll temp = *seta.find_by_order(j) ;
            if( temp >= le and temp <= ri )
                va.pb(temp);
		}
        for( auto ii : va )
        {
            mapa[ii] = i[0] ;
            seta.erase(ii);
        }
	}
	rep( i , 0 , q ){
		if(mapa.find(d[i])!=mapa.end())
		cout << mapa[d[i]] << "\n" ;
		else
			cout << "-1\n" ;
		}
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //cin>>t;
    while(t--)
        solve() ;
    return 0 ;
}


Measured memory_bytes: 34220
#include <stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    int a[30];
    int b[30];
    int c[30];
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    for(int i=0;i<n;i++) scanf("%d",&b[i]);
    for(int i=0;i<n-1;i++) scanf("%d",&c[i]);

    int  ans=0;
    ans+=b[a[0]-1];
    for(int i=1;i<n;i++)
    {
        ans+=b[a[i]-1];
        if(a[i]==a[i-1]+1)
        {
            ans+=c[a[i-1]-1];
        }
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()
const ll mod = 1e9+7;
 
ll modpow(ll a,ll b){
  ll ans=1%mod;
  while(b){	
    if(b&1) ans=(ans*a)%mod;
    a=(a*a)%mod;
    b=b>>1; 
  }
  return ans;
  }
 
ll modinv(ll a, ll m) {
  ll b=m,u=1,v=0;
  while(b){
    ll t = a/b;
    a -= t*b;
    swap(a,b);
    u -= t*v;
    swap(u,v);
  }
  u %= m;
  if(u<0) u += m;
  return u;
}
 
ll fact(ll k){
  ll tmp=k;
  if(k == 0) tmp=1;
  while(k>1){
    k--;
    tmp = tmp * k % mod;
  }
  return tmp;
}
 
int main(){
  ll X,Y;cin>>X>>Y;
  ll ans = 0;
  ll n=2*X-Y,m=2*Y-X;
  if(n>=0 && m>=0 && n%3==0 && m%3==0){
    n /= 3;
    m /= 3;
    ans += fact(n+m)*modinv(fact(n),mod)%mod*modinv(fact(m),mod)%mod;
    ans %= mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3584
#include <stdio.h>
int gcd(int x,int y)
{
if(y==0)
return x;
else
return gcd(y,x%y);
}
int main()
{
int x,y;
while(scanf("%d %d",&x,&y) != EOF)
printf("%d %d\n",gcd(x,y),x/gcd(x,y)*y);
return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    string S;
    cin >> S;
    bool check = 0;
    vector<bool> A(4,0);

    for(int i = 0; i < S.size(); i++) {
        if(S.at(i) == 'N') {
            A.at(0) = 1;
        } else if(S.at(i) == 'W') {
            A.at(1) = 1;
        } else if(S.at(i) == 'S') {
            A.at(2) = 1;
        } else if(S.at(i) == 'E') {
            A.at(3) = 1;
        }
    }
    if(!(A.at(0)^A.at(2)) && !(A.at(1)^A.at(3))) {
        check = 1;
    }
    
    if(check) {
    cout << "Yes" << endl;
    } else {
    cout << "No" << endl;
    }


    return 0;
}

Measured memory_bytes: 3576
/* AOJ (Aizu Online Judge) My Practice
 * Author: Leonardone @ NEETSDKASU
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int stack[20001];
int sp = 0;

int main(void) {
    char temp[20010];
    int i, j, len, c, t;
    scanf("%s", temp);
    len = strlen(temp);
    for (i = 0; i < len; i++) {
        switch (temp[i]) {
        case '\\':
            stack[sp] = -i;
            sp++;
            break;
        case '/':
            c = 0;
            for (j = sp - 1; j >= 0; j--) {
                if (stack[j] > 0) {
                    c += stack[j];
                } else {
                    c += i + stack[j];
                    break;
                }
            }
            if (j >= 0) {
                stack[j] = c;
                sp = j + 1;
            }
            break;
        }
    }
    c = 0;
    t = 0;
    for (i = 0; i < sp; i++) {
        if (stack[i] > 0) {
            t += stack[i];
            c++;
        }
    }
    printf("%d\n%d", t, c);
    for (i = 0; i < sp; i++) {
        if (stack[i] > 0) {
            printf(" %d", stack[i]);
        }
    }
    puts("");
    return 0;
}

Measured memory_bytes: 644
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		int[] H = new int[N];
		int max_h = 0;
		for(int i=0;i<N;i++) {
			H[i] = sc.nextInt();

			if(H[i] > max_h) {
				max_h = H[i];
			}

			if(max_h - H[i] > 1) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 52968
A,B = map(int,input().split())

Aodd = -1
Beven = -1
if A % 2 == 1:
    Aodd = A
    A += 1
if B % 2 == 0:
    Beven = B
    B -= 1

ans = ((B-A) // 2 + 1) % 2
if Aodd != -1:
    ans = ans ^ Aodd
if Beven != -1:
    ans = ans ^ Beven

print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  bool contains_odd = false;
  bool contains_even = false;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.rbegin(), A.rend());
  ll g = gcd(A[0], A[1]);
  for (int i = 2; i < N; i++) {
    g = gcd(g, A[i]);
  }
  if (K % g == 0 && K <= A[0]) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}

Measured memory_bytes: 3948
n, d = map(int, input().split())
x, y = [], []

for i in range(n):
    xx, yy = map(int, input().split())
    x.append(xx)
    y.append(yy)

count = 0
d2 = d * d

for i in range(n):
    if x[i] ** 2 + y[i] ** 2 <= d2:
        count += 1

print(count)



Measured memory_bytes: 96692
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

ll dp[55][2];

int main(){
	ll n, p;
	cin >> n >> p;
	vl a(n);
	rep(i, n) cin >> a[i], a[i] %= 2;
	dp[0][0] = 1;
	rep(i, n) {
		rep(j, 2) dp[i+1][j] += dp[i][j];
		rep(j, 2) dp[i+1][(j+a[i])%2] += dp[i][j];
	}
	cout << dp[n][p] << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
using namespace std;

using LL = long long;

LL cost(LL x, LL y)
{
	if (x % 3 == 0)
		return 0;
	LL res = y;
	LL lef = x / 2;
	LL rht = x - lef;
	for (int hum = 0; hum <= y; ++hum)
	{
		LL mx = hum * x, mn = hum * x;
		mx = max(mx, lef * (y - hum));
		mn = min(mn, lef * (y - hum));
		mx = max(mx, rht * (y - hum));
		res = min(res, mx - mn);
	}
	return res;
}

LL h, w;
int main(void)
{
	cin >> h >> w;
	LL ans1 = cost(h, w);
	LL ans2 = cost(w, h);
	cout << min(ans1, ans2) << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    ll res = 700;
    REP(i, s.length())
    {
        if (s[i] == 'o')
            res += 100;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
def inpl(): return list(map(int, input().split()))
N = int(input())
A = inpl()
B = inpl()
ans = 0

if sum(A) <= sum(B):
    print(-1)
else:
    NG = 0
    OK = []
    for i in range(N):
        if A[i] - B[i] > 0:
            OK.append(A[i] - B[i])
        elif A[i] - B[i] < 0:
            NG += A[i] - B[i]
            ans += 1
    OK = sorted(OK)
    while NG < 0:
        ans += 1
        NG += OK.pop()
    print(ans)

Measured memory_bytes: 81968
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if((a<=0&&b>=0)||(a==0||b==0))
		cout<<"Zero"<<endl;
	else if(a>0)
		cout<<"Positive"<<endl;
	else {
		if((a-b)%2==0)
			cout<<"Negative"<<endl;
		else
			cout<<"Positive"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("-O3","unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<cmath>
#include<cstdio>
#include<algorithm>
#include<bitset>
#include<complex>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<typeinfo>
#include<typeindex>
#include<type_traits>
#include<utility>
#include<valarray>
#include<vector>
#include<array>
#include<forward_list>
#include<random>
#include<ratio>
#include<tuple>
#include<unordered_map>
#include<unordered_set>
#include<cstring>

using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
const Int Inf = 1e17;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rep1(i,n) for(int(i)=0; i<n; i++)
#define rep(i,n) for(unsigned int(i)=0; i!=n; ++i)
#define rer(i,l,r) for(int i=l; i<=r; i++)
#define gnr(i,l,r) for(int i=r; i>=l; i--)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(pri2i,n-1)cout<<a[pri2i]<<' '; cout<<a[n-1]<<'\n';}
#define prip(p) cout<<p.fi<<' '<<p.se<<'\n'
#define var(type) valarray<type>
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q;
string s,sb;
bool ok;
char cf,cb;

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

  cin>>n>>m; if(n>9||m>9){pri1(-1); return 0;}
  pri1(n*m);
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

struct UF {

  vector<int> parent_, rank_;

  UF(int n) : parent_(n + 5), rank_(n + 5, 1) {
    for (int i = 0; i < n + 5; ++i) {
      parent_[i] = i;
    }
  }

  int find_set(int x) {
    if (x != parent_[x]) {
      parent_[x] = find_set(parent_[x]);
    }
    return parent_[x];
  }

  bool is_connected(int x, int y) {
    return find_set(x) == find_set(y);
  }

  void unite(int x, int y) {
    int s1 = find_set(x), s2 = find_set(y);
    if (s1 == s2) { return; }
    if (rank_[s1] > rank_[s2]) {
      parent_[s2] = s1;
    }
    else {
      parent_[s1] = s2;
      if (rank_[s1] == rank_[s2]) { ++rank_[s2]; }
    }
  }
};

int main()
{
  int N; scanf("%d", &N);
  vector<pair<ll, int> > X(N), Y(N);
  ll x, y;
  for (int i = 0; i < N; ++i) {
    scanf("%lld %lld", &x, &y);
    X[i] = make_pair(x, i);
    Y[i] = make_pair(y, i);
  }
  sort(X.begin(), X.end());
  sort(Y.begin(), Y.end());
  vector<pair<ll, pair<int, int>>> edges;
  for (int i = 1; i < N; ++i) {
    edges.push_back(make_pair(abs(X[i].first - X[i - 1].first),
                              make_pair(X[i].second, X[i - 1].second)));
    edges.push_back(make_pair(abs(Y[i].first - Y[i - 1].first),
                              make_pair(Y[i].second, Y[i - 1].second)));
  }
  sort(edges.begin(), edges.end());
  UF uf(N);
  ll ans = 0;
  for (int i = 0; i < (int)edges.size(); ++i) {
    ll w = edges[i].first;
    int u = edges[i].second.first, v = edges[i].second.second;
    if (not uf.is_connected(u, v)) {
      uf.unite(u, v);
      ans += w;
    }
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 9584
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

vector<ll> dijkstra(vector<vector<pair<ll, ll>>> g, int start) {
	vector<ll> dist(g.size(), INF64);
	dist[start] = 0;

	priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;
	pq.emplace(start, 0LL);

	while (!pq.empty()) {
		pair<ll, ll> p = pq.top(); pq.pop();
		if (dist[p.first] < p.second) {
			continue;
		}

		for (auto e : g[p.first]) {
			if (dist[e.first] > dist[p.first] + e.second) {
				dist[e.first] = dist[p.first] + e.second;
				pq.emplace(e.first, dist[e.first]);
			}
		}
	}

	return dist;
}

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

	int n, m, s, t;
	cin >> n >> m >> s >> t;
	s--; t--;

	vector<vector<pair<ll, ll>>> yenGraph(n), sunukeGraph(n);
	for (int i = 0; i < m; i++) {
		int u, v, a, b;
		cin >> u >> v >> a >> b;
		u--; v--;
		yenGraph[u].emplace_back(v, a);
		yenGraph[v].emplace_back(u, a);

		sunukeGraph[u].emplace_back(v, b);
		sunukeGraph[v].emplace_back(u, b);
	}

	// s -> 換金所 (円)
	vector<ll> distYen = dijkstra(yenGraph, s);
	// 換金所 -> t(スヌーク)
	vector<ll> distSunuke = dijkstra(sunukeGraph, t);

	vector<ll> ans(n);
	// 初期金額 - (s -> 換金所[i]) - (換金所[i] -> t)
	for (int i = 0; i < n; i++) {
		ans[i] = 1000000000000000LL - distYen[i] - distSunuke[i];
	}
	for (int i = 0; i < n - 1; i++) {
		ans[n - i - 2] = max(ans[n - i - 2], ans[n - i - 1]);
	}

	for (auto v : ans) {
		cout << v << endl;
	}

	return 0;
}


Measured memory_bytes: 28928
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL T, A, B, C, D;

LL gcd(LL a, LL b)
{
	if (a < b) std::swap(a, b);
	LL r = a % b;
	while (r != 0)
	{
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

int main()
{
	in >> T;
	rep(loop, T)
	{
		in >> A >> B >> C >> D;
		if (A < B || B > D) out << "No" << std::endl;
		else if (C >= B) out << "Yes" << std::endl;
		else if (D%B == 0) out << (A%B <= C ? "Yes" : "No") << std::endl;
		else
		{
			LL max = (B - A % B) - gcd(B, D) + A % B;
			out << (max <= C ? "Yes" : "No") << std::endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : template.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <bits/stdc++.h>
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages (for VC++ users)
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with it!
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define forn(i,n) \
for (int i =0; i<(n); i++)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
// If you need to recall how to use memset:
#define MEMSET_INF 127 // about 2B
#define MEMSET_HALF_INF 63 // about 1B
//memset(dist, MEMSET_INF, sizeof dist); // useful to initialize shortest path distances
//memset(dp_memo, -1, sizeof dp_memo); // useful to initialize DP memoization table
//memset(arr, 0, sizeof arr); // useful to clear array of integers

int main() {
	ios::sync_with_stdio(false);
 cin.tie(0);
 string s; cin >> s;
 int rs = 0;
 int mx = 0;
 forn(i, s.length()) {
 	if(s[i] == 'R') {
 		rs++;
 		mx = max(rs, mx);
 	} else {
 		mx = max(rs, mx);
 		rs = 0;
 	}
 }
 cout  << mx << "\n";
return 0;
}



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


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


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

ll A, B, C, D, E, F;

int main(){
  cin >> A >> B >> C >> D >> E >> F;
  pll rat = {0, 1};
  ll tot = 0, sugar = 0;

  rep(n1, 31){
    rep(n2, 31){      
      rep(n3, 101){
	rep(n4, 101){
	  ll t = 100*(n1*A + n2*B) + (n3*C + n4*D);
	  ll s = n3*C + n4*D;

	  if((t <= F) && (100*s <= (t-s)*E) && (s*rat.second > t*rat.first)){
	    rat.first = s;
	    rat.second = t;
	    tot = t;
	    sugar = s;
	  }
	}
      }
    }
  }

  if((tot == 0) && (sugar == 0))
    cout << 100*A << ' ' << 0 << endl;
  else
    cout << tot << ' ' << sugar << endl;

  return 0;
}


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

char b[30],o[200],*x,*y;
int n,i,j,k,d,r;
int main()
{
	scanf("%d\n",&n);
	gets(b);
	for(i=r=0;i<n;i++)
	{
		memset(o,0,sizeof(o));
		gets(o);
		for(x=strchr(o,b[0]);x;x=strchr(o+(x-o+1),b[0]))
			for(y=strchr(o+(x-o),b[1]);y;y=strchr(o+(y-o+1),b[1]))
			{
				for(d=y-x,j=0,k=x-o;b[j]&&o[k]&&b[j]==o[k];j++,k+=d);
				if(j==strlen(b))
				{
					r++;
					goto e;
				}
			}
			e:;
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
typedef long long ll;
using namespace std;

int main() {
	ll n,m,x,y,xma=-1000,ymi=1000;
	cin>>n>>m>>x>>y;
	ll a,b;
	for(int i=0;i<n;i++){
		cin>>a;
		xma=max(xma,a);
	}
	xma++;
	for(int i=0;i<m;i++){
		cin>>b;
		ymi=min(ymi,b);
	}
	if(xma<=ymi && x<ymi && y>=xma && x<y){
		cout << "No War"<<endl;
	}
	else{
		cout<< "War"<<endl;
	}
	return 0;
}




Measured memory_bytes: 256
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main(): #startline-------------------------------------------
    a,b = map(int,input().split())
    if a+b == 15:
        print("+")
    elif a*b == 15:
        print("*")
    else:
        print("x")
if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 13644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private static final long MOD = (long)Math.pow(10, 9) + 7;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int[] groups = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
		
		int x = sc.nextInt();
		int y = sc.nextInt();
		if (groups[x] == groups[y]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


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

int main() {
  int a, b;
  int c[5] = {};

  for (int i = 0; i < 3; i++) {
    cin >> a >> b;
    c[a]++;
    c[b]++;
 }

  cout << (c[1] < 3 && c[2] < 3 && c[3] < 3 && c[4] < 3 ? "YES" : "NO");
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int i, n;
        n = sc.nextInt();
        int L = 0, R = 0;
        for( i = 0; i < n; i++) {
            String a = sc.next();
            String b = sc.next();

            if(a.compareTo(b) == 0) {
                L++;
                R++;
            }
            else if(a.compareTo(b) < 0) {
                L += 3;
            }
            else {
                R += 3;
            }
        }
        System.out.println(R + " " + L);
        sc.close();
    }
}



Measured memory_bytes: 29508
cnt=0
n=int(input())
S=[0 for i in range(n)]
S=input().split()
q=int(input())
T=[0 for i in range(q)]
T=input().split()
for i in range(q):
    p=0
    for j in range(n):
        if T[i]==S[j]:
            if p==0:
                cnt+=1
                p+=1
print(cnt)


Measured memory_bytes: 6200
// 2004à\ID Circle and Points

#include <iostream>
#include <queue>
#include <cmath>

using namespace std;

const double sqrt2 = sqrt(2.0); 
const double eps = 1e-6;
char dx[] = {-1,1,-1,1};
char dy[] = {1,1,-1,-1};

class Square{
public:
	int bound; double x, y, size;
	Square(int bound, double x, double y, double size) : bound(bound), x(x), y(y), size(size) {}
	bool operator < (const Square &s) const { return bound < s.bound; }
};

inline double sqr(double x) { return x*x; }

int main(){
	int N;
	double x[300], y[300];
	while(cin >> N){
		if(!N) break;
		for(int i=0;i<N;i++) cin >> x[i] >> y[i];
		int ans = 1;
		priority_queue<Square> qu;
		qu.push(Square(N, 5.0, 5.0, 10.0));
		while(!qu.empty()){
			Square s = qu.top(); qu.pop();
			if(s.bound <= ans) break;
			for(int i=0;i<4;i++){
				double nx = s.x + dx[i]*s.size/2.0;
				double ny = s.y + dy[i]*s.size/2.0;
				int c = 0, upper = 0;
				for(int j=0;j<N;j++){
					double dist = sqr(x[j]-nx)+sqr(y[j]-ny);
					if(dist < 1.0+eps) c++;
					if(dist < sqr(1.0+sqrt2*s.size/2.0)+eps) upper++;
				}
				ans = max(ans, c);
				if(upper > ans) qu.push(Square(upper, nx, ny, s.size/2.0));
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 980
from __future__ import print_function
while(1):
    x = raw_input()
    if(x == "0 0"):
        break
    x = x.split(" ")
    h = int(x[0])
    w = int(x[1])
    for i in range(0,h):
        for j in range(0,w):
            print("#", end="")
        print("\n",end="")
    print("\n",end="")


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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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



int main(void)
{
  string s;
  cin >> s;
  ll lc = 0, gc = 0;
  ll i = 0;
  ll su = 0;
  while(i < s.size()) {
    lc = 0;
    gc = 0;
    while(s[i] == '<') {
      i++;
      su += lc;
      lc++;
      
    }
    while(s[i] == '>') {
      i++;
      su += gc;
      gc++;
    }
    su += max(lc, gc);
  }
  cout << su  << endl;
}


Measured memory_bytes: 900
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main() {
    char mark;
    int n;
    int rank;
    int tramp[4][13];

    cin>>n;

    for (int i = 0; i < 4; ++i) {
        for (int j = 0; j< 13; ++j) {
            tramp[i][j]=0;
        }
    }


    for (int i = 0; i < n; ++i) {
        cin>>mark>>rank;
        if(mark=='S')tramp[0][rank-1]=1;
        if(mark=='H')tramp[1][rank-1]=1;
        if(mark=='C')tramp[2][rank-1]=1;
        if(mark=='D')tramp[3][rank-1]=1;
    }

    for (int i = 0; i < 4;i++) {
        for (int j = 0; j < 13; ++j) {
            if (tramp[i][j] == 0) {
                if (i == 0)printf("%c %d\n", 'S', j + 1);
                if (i == 1)printf("%c %d\n", 'H', j + 1);
                if (i == 2)printf("%c %d\n", 'C', j + 1);
                if (i == 3)printf("%c %d\n", 'D', j + 1);
            }
        }
    }


    return 0;

}


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

int main () {

    string s;
    cin >> s;

    int K;
    cin >> K;

    vector<string> strs;
    for (int i = 0; i < s.size(); i++) {
        for (int j = 1; j <= K; j++) {

            if (i + j > s.size()) continue;
            strs.push_back(s.substr(i, j));
        }
    }

    sort(strs.begin(), strs.end());
    strs.erase(unique(strs.begin(), strs.end()), strs.end());

    cout << strs[K - 1] << endl;

    return 0;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int ht[n+1]={(int)1e9};
	for(int i=1;i<=n;i++)
		cin>>ht[i];
	int dp[n+2]={0};
	dp[1]=0;
	for(int i=2;i<=n;i++)
	{
		dp[i]=min(abs(ht[i]-ht[i-1])+dp[i-1],abs(ht[i]-ht[i-2])+dp[i-2]);
	}
	cout<<dp[n];
}


Measured memory_bytes: 4392
#include <iostream>
#include <algorithm>
#include <cmath>


const int MAXN = 1e5;
const int INFTY = 2e9;

int height[MAXN];
int dp[MAXN];


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

    int rocks, maxJump;
    std::cin >> rocks >> maxJump;
    
    for (int iRock = 0; iRock < rocks; iRock++)
        std::cin >> height[iRock];

    for (int iRock = rocks - 2; iRock > -1; iRock--)
    {
        dp[iRock] = INFTY;
        int furthestRock = std::min(rocks, iRock + maxJump + 1);

        for (int jRock = iRock + 1; jRock < furthestRock; jRock++)
            dp[iRock] = std::min(dp[iRock], std::abs(height[iRock] - height[jRock]) + dp[jRock]);
    }

    std::cout << dp[0] << '\n';

    return 0;
}


Measured memory_bytes: 1024
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	std::vector<P> keys(m);
	REP(i, 0, m){
		ll cost, cnt, key = 0;
		scanf("%ld %ld", &cost, &cnt);
		REP(j, 0, cnt){
			int num;
			scanf("%d", &num);
			key |= (1<<(num-1));
		}
		keys[i] = P(cost, key);
	}

	ll dp[1+m][1<<n];
	REP(i, 0, 1+m) REP(j, 0, 1<<n) dp[i][j] = INF;
	dp[0][0] = 0;
	REP(i, 0, m){
		REP(j, 0, 1<<n){
			dp[i+1][j] = std::min(dp[i+1][j], dp[i][j]);
			dp[i+1][j|keys[i].se] = std::min(dp[i+1][j|keys[i].se], dp[i][j]+keys[i].fi);
		}
	}
	if(dp[m][(1<<n)-1]==INF) puts("-1");
	else printf("%ld\n", dp[m][(1<<n)-1]);
	return 0;
}



Measured memory_bytes: 35812
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n = I()
    for i in range(1, 11):
        ans = i*1000 - n
        if ans >= 0:
            print(ans)
            break

if __name__ == '__main__':
    main()

Measured memory_bytes: 9120
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){ 
    string s;cin>>s;
    if (s=="Sunny") cout << "Cloudy" << endl;
    else if (s=="Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int s[100010];

int main(){
	int n,k,q;
	cin>>n>>k>>q;
	int a;

	for (int i = 0; i < q; ++i){
		cin>>a;
		s[a-1]++;
	}

	for (int i = 0; i < n; ++i){
		if(k-q+s[i]<=0){
			cout<<"No"<<endl;
		}else{
			cout<<"Yes"<<endl;
		}
	}



	return 0;
}


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

#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<cstring>
#include<climits>
#include<queue>
#include<algorithm>
#include<iomanip>
#define ll long long int
#define endl '\n'

using namespace std;

vector<int> ar[100001];
const int maxN = 17;
int parent[100001],vis[100001]={0};
int cnt=1;

void dfs(int node,int par)
{

	parent[node] = par;
    vis[node]=1;

	for(int i:ar[node]){
        if(vis[i]==0){
            dfs(i,node);
        }
	}



}

void bfs(int node,int par){

    parent[node] = par;
    vis[node]=1;
    queue<int> q;
    q.push(node);
    while(!q.empty()){
        int cur=q.front();
        q.pop();
        //cout<<cur<<" ";
        for(int i=0;i<ar[cur].size();i++){
            if(vis[ar[cur][i]]==0){
                vis[ar[cur][i]]=1;
                q.push(ar[cur][i]);
                parent[ar[cur][i]]=cur;
                cnt++;

            }
        }
    }

}


int main()
{
	int n,a,b,q,x,y;

	cin>>n>>q;




	for(int i=0;i<=n;i++){
		vis[i]=0;
		ar[i].clear();
	}
	for(int i=1;i<=q;i++){
		cin>>x>>y;
		ar[x].push_back(y);
		ar[y].push_back(x);
	}
    bfs(1,-1);
   //cout<<"cnt "<<cnt<<endl;

    if(cnt!=n){
        cout<<"No"<<endl;
    }
    else{
            cout<<"Yes"<<endl;
        for(int i=2;i<=n;i++){
            cout<<parent[i]<<endl;
        }
    }

}


Measured memory_bytes: 10924
def eratosthenes(n):
    prime_table = [False,False,True]+[False if i%2!=0 else True for i in range(n-2)]
    i=3
    pn=[2]
    while i*i<=n:
        if prime_table[i]:
            j=i*i
            pn.append(i)
            while j<=n:
                prime_table[j]=False
                j+=i
        i+=2
    for j in range(i,n+1):
        if prime_table[j]:
            pn.append(j)
    return pn

prime_numbers=eratosthenes(200000)
while 1:
    n,p=map(int,input().split())
    if n==-1:
        break
    i=0
    while prime_numbers[i]<=n:
        i+=1
    d=[]
    for j in range(i,i+30):
        for k in range(j,i+30):
            d.append(prime_numbers[j]+prime_numbers[k])
    d.sort()
    print(d[p-1])




Measured memory_bytes: 8624
#include<bits/stdc++.h>
#define inf 1000000000000
#define int long long int
#define hell (int)(1e9+7)

using namespace std;

void solve(){
    string s,t;
    cin>>s>>t;
    if(s.length()+1==t.length()&&t.substr(0,s.length())==s)
        cout<<"Yes";
    else
        cout<<"No";
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3660
A, B, C, X, Y = map(int, input().split())
x, y = min(X,Y), max(X,Y)-min(X,Y)
D = [A,B][X<=Y]
if A+B <= C+C:
    ans = (A+B)*x+D*y
else:
    ans = (C+C)*x+min(D,C+C)*y
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void) {
	char eibun[1010];
	char* kensaku;
	char* pos;
	int kazu,nowkazu;
	scanf("%d",&kazu);
	while(getchar()!='\n');
	for(nowkazu=0;nowkazu<kazu;nowkazu++) {
		fgets(eibun,sizeof(eibun),stdin);
		kensaku=eibun;
		while(pos=strstr(kensaku,"Hoshino")) {
			*(pos+6)='a';
			kensaku=pos+1;
		}
		printf("%s",eibun);
	}
	return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3
# atcoder 
# Türkler var mı?
# Herkese memnün oldum
import sys

readline = sys.stdin.buffer.readline
iimr = lambda: map(int, sys.stdin.buffer.readline().rstrip().split())
#sys.setrecursionlimit(10 ** 8)

def debug(*x):
    print(*x, file=sys.stderr)


class atcoder():
    def __init__(self):
        pass

    def çözmek(self):
        N = input()

        res = []    
        res.append(self.関数(N))
        if res[0] % 9:
            print("No")
        else: 
            print("Yes")
    
    def 関数(self, n):
        gr = len(n)
        wa = 0
        for i in range(gr):
            wa += int(n[i])
        #debug(wa)
        return wa

if __name__ == "__main__":
    ima = atcoder()
    ima.çözmek()



Measured memory_bytes: 9328
n, kk = map(int, input().split())
p = [list(map(int, input().split())) for i in range(n)]
x_set = set(i[1] for i in p)
y_set = set(i[0] for i in p)
d_x = {}
d_y = {}
for i, x in enumerate(sorted(list(x_set))):
    d_x[x] = i
for i, y in enumerate(sorted(list(y_set))):
    d_y[y] = i
g_x = {}
g_y = {}
w = len(d_x)
h = len(d_y)
board = [[0]*(w+1) for i in range(h+1)]
tmp = [[0]*h for i in range(w)]
for y, x in p:
    ys = d_y[y]
    xs = d_x[x]
    g_x[xs] = x
    g_y[ys] = y
    tmp[ys][xs] += 1
for i in range(h):
    for j in range(w):
        board[i+1][j+1] = board[i+1][j] + board[i][j+1] - board[i][j] + tmp[i][j]
#for i in board:
#    print(i)
ans = float("inf")
for i in range(h-1):
    for j in range(i+1, h):
        for k in range(w-1):
            for l in range(k+1, w):
                s = board[j+1][l+1] - board[i][l+1] - board[j+1][k] + board[i][k]
                if s >= kk:
                    #print(g_y[j], g_y[i], g_x[l] , g_x[k])
                    area = (g_y[j] - g_y[i]) * (g_x[l] - g_x[k])
                    ans = min(ans, area)
print(ans)

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> dp(3);
  int a,b,c;
  cin >> a >> b >> c;
  dp[0] = a;
  dp[1] = b;
  dp[2] = c;
  n--;
  while(n--){
    vector<long long> dp2(3);
    cin >> a >> b >> c;
    dp2[0] = a+max(dp[1],dp[2]);
    dp2[1] = b+max(dp[0],dp[2]);
    dp2[2] = c+max(dp[0],dp[1]);
    dp = dp2;
  }
  cout << max({dp[0],dp[1],dp[2]});
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long int lli;
lli MOD = 1000000007;
struct P {
    complex<double> p;
    double r;
    P(double a, double b, double c)
    {
        p = complex<double>(a, b);
        r = c;
    }
};

int main()
{
    double a, b, c, cc;
    cin >> a >> b >> c >> cc;
    complex<double> s = complex<double>(a, b), t = complex<double>(c, cc);
    int n;
    cin >> n;
    vector<P> d;
    rep(i, n)
    {
        cin >> a >> b >> c;
        d.push_back(P(a, b, c));
    }
    d.push_back(P(s.real(), s.imag(), 0));
    d.push_back(P(t.real(), t.imag(), 0));
    double e[1005][1005] = {};
    rep(i, n + 2) rep(j, n + 2)
    {
        double dis = max(0.0, sqrt(norm(d[i].p - d[j].p)) - d[i].r - d[j].r);
        //cout << dis << endl;
        e[i][j] = dis;
        //cout << dis << endl;
    }
    double di[1005];
    rep(i, n + 2) di[i] = 1e20;
    priority_queue<pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>>> que;
    que.push(make_pair(0.0, n));
    while (!que.empty()) {
        pair<double, int> now = que.top();
        que.pop();
        int cur = now.second;
        //cout << cur << endl;
        double ds = now.first;
        //cout << "現在" << cur << ' ' << ds << endl;
        if (di[cur] < ds)
            continue;
        di[cur] = ds;
        rep(i, n + 2)
        {
            if (i == cur)
                continue;
            if (di[i] > di[cur] + e[cur][i]) {
                //cout << di[i] << endl;
                di[i] = di[cur] + e[cur][i];
                //cout << di[i] << endl;
                que.push(make_pair(di[cur] + e[cur][i], i));
            }
        }
    }
    printf("%.10f\n", di[n + 1]);
}


Measured memory_bytes: 12420
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str.
   builtin functions :
   __builtin_popcount(n) : no. of set bits in n.
   __builtin_parity(n) : parity of no. of set bits
   __builtin_clz(n) : no. of leading zeros before 1
   __builtin_ctz(n) : no of zeros from last to first occurrence of 1
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll binlen(ll a)
{
	ll v = 0;
	for(ll i=0;i<61;++i)
	{
		v += (1ll<<i);
		if(a<=v) return i;
	}
}

ll ar[M];
vector<ll> adj[30];

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

	ll n,i,mn,j,ans = 0;

	cin >> n;
	for(i=1;i<=n;++i)
	{
		cin >> ar[i];
		for(j=0;j<20;++j)
		{
			if((ar[i]>>j)&1ll)
				adj[j].pb(i);
		}
	}

	for(i=1;i<=n;++i)
	{
		mn = n;
		for(j=0;j<20;++j)
		{
			auto it = lower_bound(all(adj[j]),i);
			if(it == adj[j].end())
			{
				mn = min(mn,n);
				continue; 
			}
			it++;
			if(it == adj[j].end())
			{
				mn = min(mn,n);
				continue; 
			}
			mn = min(mn,(*it)-1);
		}
		ans += mn-i+1;
	}

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

Measured memory_bytes: 21060