akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n)cin >> a[i];
    a[0]--;
    loop(i,1,n){
        if(a[i-1] > a[i]){
            cout << "No" << endl;
            return 0;
        }
        if(a[i-1] != a[i])a[i]--;
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stdio.h>
#include <iomanip>
using namespace std;

int main()
{
    double n, k, b, ans = 0;
    cin >> n >> k;
    vector<int> a(n), cnt(n);

    for(double i = 0;i < n;i++){
        a[i] = i + 1;
        while(a[i] < k){
            a[i] *= 2;
            cnt[i]++;
        }
    }

    for(double i = 0;i < n;i++){
        b = 1;
        for(int j = 0;j < cnt[i];j++){
            b = b * 0.5;
        }
        ans += b * 1 / n;
    }

    cout <<setprecision(12)<< ans;
    return 0;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPD(i,n) for(int i=(n)-1;i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=(b);--i)
#define TLE() cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms.\n";
const ll MOD = 1E9+7;
const ll IINF = 1E18;
const int INF = 1e9;
const double EPS = 1E-9;
const double PI = atan(1.0) * 4.0;
template<class T> T getbit(T s, int i) {return s>>i&1;}
template<class T> void flipbit(T& s, int i) {s^=(1LL<<i);}
constexpr int cntbit(ll x) {return __builtin_popcountll(x);}
constexpr int lg2(ll x) {return __lg(x);} // return int(log2(x))
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 
ll fpow(ll a,ll p){ll res=1LL;while(p){if(p&1LL) res=res*a%MOD;a=a*a%MOD;p>>=1LL;} return res;}

const int MX=2e5+5;
int n,m,k;
ll f[MX];
ll res;

ll nCk(int n,int k){
	ll res=f[n];
	res=res*fpow(f[n-k],MOD-2)%MOD;
	res=res*fpow(f[k],MOD-2)%MOD;
	return res;
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	// consider x-axis and y-axis separately
	// consider each row in x-asix separately...
	f[0]=1;
	FOR(i,1,MX-1)
		f[i]=f[i-1]*i%MOD;
	cin>>n>>m>>k;
	FOR(i,1,n){
		ll t=(i-1)*m%MOD;
		ll g=(n-i)*m%MOD;
		res+=(t-g+MOD)%MOD*i%MOD*m%MOD;
		res%=MOD;
	}		
	FOR(i,1,m){
		ll t=(i-1)*n%MOD;
		ll g=(m-i)*n%MOD;
		res+=(t-g+MOD)%MOD*i%MOD*n%MOD;
		res%=MOD;
	}
	res=res*nCk(n*m-2,k-2)%MOD;
	cout<<res<<'\n';
}



Measured memory_bytes: 5228
#include<stdio.h>

int main()
{
	int a[3000],b[3000],i,j,x;
	
	for(i=0;i<3000;i++){
	scanf("%d %d",&a[i],&b[i]);
	if(a[i]==0&&b[i]==0){
		break;}
	else if(a[i]>b[i]){
		x=a[i];
		a[i]=b[i];
		b[i]=x;
	}}
	
	for(j=0;j<i;j++){
	printf("%d %d\n",a[j],b[j]);
	}

	return 0;
}

Measured memory_bytes: 624
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long ll;

const int N=2e5+1e3+7;

int n,a[N];

ll ans;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	if(a[1]!=0)
	{
		puts("-1");
		return 0;
	}
	for(int i=2;i<=n;i++)
	{
		if(a[i]>a[i-1]+1)
		{
			puts("-1");
			return 0;
		}
		else if(a[i]==a[i-1]+1)
			continue;
		else
			ans+=a[i-1];
	}
	ans+=a[n];
	printf("%lld",ans);
} 

Measured memory_bytes: 1024
#include <cstdio>
#include <string>

using namespace std;

int main() {
    char buf[131072];
    int K;
    scanf("%s %d", buf, &K);
    string s(buf);

    for (size_t i=0; i<s.length()&&K; ++i) {
        if (s[i] == 'a') continue;
        if (K >= 'z'-s[i]+1) {
            K -= 'z'-s[i]+1;
            s[i] = 'a';
        }
    }

    fprintf(stderr, "%d\n", K);

    if (K) {
        K %= 26;
        if (s[s.length()-1]+K > 'z') {
            fprintf(stderr, "1\n");
            s[s.length()-1] += K-'z';
        } else {
            s[s.length()-1] += K;
        }

        while (s[s.length()-1] > 'z')
            s[s.length()-1] -= 26;
    }

    printf("%s\n", s.c_str());
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
ll a[502][502];
vector<ll> p;
bool used[100000];
void init() {
	fill(used, used + 100000, false);
	for (int i = 2; i < 100000; i++) {
		if (used[i])continue;
		p.push_back(i);
		for (int j = i * 2; j < 100000; j+=i) {
			used[j] = true;
		}
	}
	rep(i, 502) {
		rep(j, 502) {
			a[i][j] = 1;
		}
	}
}
void makemap() {
	int now = 0;
	for (int i = 1; i <= 1007; i += 2) {
		for (int j = 0; j < 502; j++) {
			int t = i - j;
			if (0<=t&&t<502) {
				a[j][t] *= p[now];
				if (0 <= t - 1 && t - 1 < 502)a[j][t - 1] *= p[now];
				if (0 <= t + 1 && t + 1 < 502)a[j][t + 1] *= p[now];
			}
		}
		now++;
	}
	for (int i = 501; i >= -503; i -= 2) {
		for (int j = 0; j < 502; j++) {
			int t = j - i;
			if (0 <= t && t < 502) {
				a[j][t] *= p[now];
				if (0 <= t - 1 && t - 1 < 502)a[j][t - 1] *= p[now];
				if (0 <= t + 1 && t + 1 < 502)a[j][t + 1] *= p[now];
			}
		}
		now++;
	}
	rep(i, 502) {
		rep(j, 502) {
			if ((i + j) % 2 == 0)a[i][j]++;
		}
	}
}
int main() {
	init(); makemap();
	int n; cin >> n;
	rep1(i, n) {
		rep1(j, n) {
			if (j > 1)cout << " ";
			cout << a[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 5376
import java.util.Scanner;

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

        if (0 <= second && second < 86400) {
            /*
             * 34524 / 3600 = 9.59
             * (34524 - (3600 * 9)) / 60 = 35.4
             * (34524 - (3600 * 9)) - (35 * 60) = 24
             */
            int h = second / 3600;
            int m = (second - (h * 3600)) / 60;
            int s = (second - (h * 3600)) - (m * 60);

            System.out.println(h + ":" + m + ":" + s);
        }
    }
}


Measured memory_bytes: 26312
#include <iostream>
#include <cstdio>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

#define ll long long
#define vec vector
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
	ll a,b;

	scanf("%lld %lld", &a, &b);


	if (a < b)
		cout << "0" << endl;
	else
		cout << "10" << endl;

}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

  int i,j,tmp,count=0,flag=1,N,A[101];

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

  while(flag){

    flag=0;
    for(j=N-1;j>0;j--){
      if(A[j]<A[j-1]){
	tmp=A[j];
	A[j]=A[j-1];
	A[j-1]=tmp;
	count++;
	flag=1;
      }
    }
  }

    for(i=0;i<N-1;i++)
      printf("%d ",A[i]);

    printf("%d\n",A[N-1]);
    printf("%d\n",count);

    return 0;
  }

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  char s[h][w];
  int i,j;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      cin >> s[i][j];
    }
  }
 for(i=0;i<h;i++){
   for(j=0;j<w;j++){
     cout << s[i][j];
   }
   cout << endl;
   for(j=0;j<w;j++){
     cout << s[i][j];
   }
   cout << endl;
 }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int main(){
    //~ freopen("file.in", "r", stdin);
    string s,t,ans;
    cin>>s>>t;
    for(int i=0;i+t.size()<=s.size();i++){
		string tmp=s;
		int res=1;
		for(int j=0;j<(int)t.size();j++){
			if(s[j+i]=='?')
				tmp[j+i]=t[j];
			else{
				if(s[j+i]!=t[j])
					res=0;
			}	
		}
		if(res){
			for(int j=0;j<(int)s.size();j++)
				if(tmp[j]=='?')
					tmp[j]='a';
			if(ans.size()==0)
				ans=tmp;
			else
				umin(ans,tmp);
		}
	}
	if(ans.size()==0)
		puts("UNRESTORABLE");
	else	
		cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n,v,j;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++){
        v = a[i];
        j=i-1;
        while(j>=0 && a[j]>v){
            a[j+1] = a[j];
                j--;
        }
        a[j+1]=v;
    for(int i=0;i<n;i++){
    if(i!=n-1)cout<<a[i]<<" ";
    else cout<<a[i];
    }
    cout<<endl;
    }
}



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

int main()
{
  int a,b;
  char op;

  while(1){
    scanf("%d %c %d",&a,&op,&b);
    if(op=='?') break;
    else if(op=='+') printf("%d\n",a+b);
    else if(op=='-') printf("%d\n",a-b);
    else if(op=='*') printf("%d\n",a*b);
    else if(op=='/') printf("%d\n",a/b);
  }
    
  return 0;
}

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

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

pair<double,double> cur[3];

int main()
{
	double x,y;
	rep(i,3){
		scanf("%lf%lf",&x,&y);
		cur[i].first = x;
		cur[i].second = y;
	}
	double a,b,c;
	a = sqrt(pow((cur[0].first-cur[1].first),2) + pow((cur[0].second-cur[1].second),2));
	b = sqrt(pow((cur[1].first-cur[2].first),2) + pow((cur[1].second-cur[2].second),2));
	c = sqrt(pow((cur[2].first-cur[0].first),2) + pow((cur[2].second-cur[0].second),2));
	double nmax = max(a,max(b,c));
	double len = a+b+c;
	pair<double,double> A,B;
	A.first = cur[1].first - cur[0].first;
	A.second = cur[1].second - cur[0].second;
	B.first = cur[2].first - cur[0].first;
	B.second = cur[2].second - cur[0].second;
	double S = abs(A.first*B.second-A.second*B.first)/2;
	double ans = S/(len/2 + 2*S/nmax);
	printf("%.12f\n",ans);
}

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

using namespace std;

int main(void) {
    vector<int> vc;
    for (int i = 0; i < 5; i++) {
        int Z;
        cin>>Z;
        vc.push_back(Z);
    }
    int fi_index = -1;
    int mi = 10;
    for (int i = 0; i < 5; i++) {
        int amari = vc.at(i) % 10;
        if (amari > 0 && mi > amari) {
            fi_index = i;
            mi = amari;
        }
    }
    
    int sum = 0;
    if (fi_index >= 0) {
        for (int i = 0; i < 5; i++) {
            int tmp = vc.at(i);
            if (i != fi_index) {
                if (tmp % 10 == 0) sum += tmp;
                else sum += tmp + (10 - tmp % 10);
            } else sum += tmp;
        }
    } else {
        // 全部足すだけでOK
        for (int i = 0; i < 5; i++) {
            sum += vc.at(i);
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import math
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
s=input()
t=input()
ans=0
flag=0
for j in range(len(s)-len(t)+1):
    flag=0
    for i in range(len(t)):
        if s[i+j]==t[i]:
            flag=flag+1
    if flag>ans:
        ans=flag
print(len(t)-ans)

Measured memory_bytes: 67688
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
    int N,K,a,b,x,y;
    cin>>N>>K;
    for(int i=0;i<K;i++){
        cin>>a>>b;
        x=min(a,N-a+1);
        y=min(b,N-b+1);
        int ans;
        ans=min(x,y);
        ans=ans%3;
        if(ans==0)ans=3;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1160
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long h = sc.nextLong();
    System.out.println(func(h));
  }

  public static long func(long a) {
    if(a == 1) return 1;
    long t = func(a / 2);
    return (2 * t + 1);
  }
}

Measured memory_bytes: 21844
# %%time
from collections import Counter, deque
n = int(input())
s = input()


# n = 4000
# np.random.seed(1)
# s = np.random.randint(0, 3, n)
# s = (s)

c = Counter(s)
c = list(c.values())
if len(c) == 3:
    ans = c[0] * c[1] * c[2]
else:
    ans = 0
# print(ans)
if ans > 0:
    for k in range(n):
        for a in range(1, (n - k)//2 + 1):
            if k + 2 * a >= n:
                continue
            x, y,  = s[k], s[k + a]
            
            if x != y:
                z = s[k + 2 * a]
                if y != z:
                    if z != x:
                        ans -= 1

print(ans)

Measured memory_bytes: 9472
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#define mp(a, b) make_pair(a, b)
using namespace std;
typedef pair<long long, int> pp;
const int maxn = 200100;
const long long oo = 1e18;
int n;
long long a[maxn], b[maxn];
pp c[maxn];
bool flag[maxn] = {0};
long long ans;
int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n;
	long long suma = 0, sumb = 0;
	for(int i = 1; i <= n; i ++)
	{
		cin >> a[i] >> b[i];
		c[i].first = a[i];
		suma += a[i];
		c[i].second = i;
		c[i + n].first = b[i];
		sumb += b[i];
		c[i + n].second = i + n;
	}
	ans = min(suma, sumb);
	sort(c + 1, c + n * 2 + 1);
	long long sum = 0;
	for(int i = 1; i <= n; i ++)
	{
		sum += c[i].first;
		flag[c[i].second] = 1;
		//cout << c[i].first << " " << c[i].second << endl;
	}
	/*
	for(int i = 1; i <= n * 2; i ++)
		if(flag[i])
			cout << i << " " ;
	cout << endl;
	cout << "sum : " << sum << endl;
	*/
	for(int i = 1; i <= n; i ++)
	{
		if(flag[i] && flag[i + n])
		{
			cout << sum << endl;
			return 0;
		}
		if(flag[i])
		{
			if(c[n].second != i)
			{
				ans = min(ans, sum - c[n].first + b[i]);
				//cout << "asd1 " << c[n].first << " " << b[i] << endl;
			}
			else
			{
				ans = min(ans, sum - c[n - 1].first + b[i]);
				//cout << "asd2 " << c[n - 1].first << " " << b[i] << endl;
			}
		}
		else if(flag[i + n])
		{
			if(c[n].second != i + n)
			{
				ans = min(ans, sum - c[n].first + a[i]);
				//cout << "asd3 " << c[n].first << " " << a[i] << endl;
			}
			else
			{
				ans = min(ans, sum - c[n - 1].first + a[i]);
				//cout << "asd4 " << c[n - 1].first << " " << a[i] << endl;
			}
		}
		else
			ans = min(ans, sum - c[n].first - c[n - 1].first + a[i] + b[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6400
while True:
    c=0
    n,m=map(int,input().split())
    if n==0 and m==0:
        break
    if n<m:
        n,m=m,n
    while True:
        if m==0:
            print(n,c)
            break
        n=n%m
        n,m=m,n
        c=c+1


Measured memory_bytes: 5608
#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>
#include<bits/stdc++.h>
using namespace std;
struct UnionFind
{
    vector<int>par;
    UnionFind(int N):par(N)
    {
        for(int i=0;i<N;++i) 
			par[i]=i;
	}
    int root(int x)
	{
        if(par[x]==x) 	
			return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y)
	{
        int rx=root(x);
        int ry=root(y);
        if(rx==ry) 
			return;
        par[rx]=ry;
    }
    bool same(int x,int y)
	{
        int rx=root(x);
        int ry=root(y);
        return rx==ry;
    }
};
int main() 
{
    int N,M,i,cnt=1;
    cin>>N>>M;
    UnionFind tree(N);
    for(i=0;i<M;i++)
	{
        int x,y,z;
        cin>>x>>y>>z;
        tree.unite(x-1,y-1);
	}
    for(i=0;i<N;i++)
        if(!tree.same(0,i))
		{
            tree.unite(0,i);
            cnt++;
        }
    cout<<cnt;
    return 0;
}

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

int a[1001] = {};

int main() {
    int N;
    int cur;
    long long int A, B;
    int X[100001];
    long long int cost = 0;

    cin >> N >> A >> B;

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

    cur = 0;

    while (cur < N - 1) {
        cost += ((X[cur + 1] - X[cur]) * A < B) ? (X[cur + 1] - X[cur]) * A : B;
        cur++;
    }
    cout << cost << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (i=a;i<n;i++)
#define per(i,a,n) for (i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE 1000001
//#define ONLINE_JUDGE
//#define rd
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
auto clk=clock(); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;

int main(){
	/*srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(20);
	#ifdef rd
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif	*/

	/*
		Write here
	*/

	int n;
	bool ans=false;
	cin>>n;
	while(n){
		if(n%10==7){
			ans=true;
			break;
		}
		n=n/10;
	}
	if(ans) cout<<"Yes";
	else cout<<"No";


	/*#ifdef ONLINE_JUDGE
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
	#endif*/
	return 0;
}


Measured memory_bytes: 3644
#include<iostream>
using namespace std;
const int inf = 10e7;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
int dp[100000];
int main(){
  int hp,m;
  cin>>hp>>m;
  int ats[m];
  int mps[m];
  rep(i,m){int a,s;cin>>a>>s;ats[i]=a;mps[i]=s;}
  
  rep(i,hp+1){dp[i]=inf;}dp[0]=0;
  rep(j,hp+1){
    rep(k,m){
      int at=ats[k],mp=mps[k];
      if (j>at-1){ dp[j]=min(dp[j],dp[j-at]+mp);}
      else{dp[j]=min(dp[j],mp);}
  }
}
  cout<<dp[hp]<<endl;}


Measured memory_bytes: 256
n, h = map(int, input().split())
a = [0]*n
b = [0]*n
for i in range(n):
    a[i], b[i] = map(int, input().split())

A = max(a)
B = sorted([x for x in b if x > A], reverse=True)


cnt = 0
damage = 0
for b in B:
    cnt += 1
    damage += b
    if damage >= h:
        break
else:
    cnt += -(-(h-damage)//A)
print(cnt)


Measured memory_bytes: 12844
n,m=map(int,input().split())
*h,=map(int,input().split())
a=[list(map(int,input().split()))for _ in range(m)]
b=[1]*n
for i in range(m):
    if h[a[i][0]-1] > h[a[i][1]-1]:
        b[a[i][1]-1]*=0
    elif h[a[i][0]-1] < h[a[i][1]-1]:
        b[a[i][0]-1]*=0
    else:
        b[a[i][0]-1]*=0
        b[a[i][1]-1]*=0
#    print(b)
print(b.count(1))

Measured memory_bytes: 31944
#include <bits/stdc++.h>
#define lp(n) for(int i = 1; i <= n; i++)
using namespace std;
int A[500001];
int H;
void maxh(int i) {
  int l, r;
  int largest;
  l = i * 2;
  r = i * 2 + 1;
  if(l <= H && A[l] > A[i]) largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest]) largest = r;
  if(largest != i) {
    swap(A[i], A[largest]);
    maxh(largest);
  }
}
int main(){
  int i;
  cin >> H;
  lp(H) cin >> A[i];
  for(i = H/2; i >= 1; i--) maxh(i);
  lp(H) {
    printf(" %d", A[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 5092
n = input()
m = len(n)
K = int(input())
dp = [[[0] * (K + 1) for _ in range(2)] for _ in range(m + 1)]
dp[0][0][0] = 1
for i in range(1, m+1):
    l = int(n[i-1])
    for k in range(K+1):
        
        if l == 0:
            dp[i][0][k] += dp[i-1][0][k]
        else:
            if k >= 1:
                dp[i][0][k] += dp[i-1][0][k-1]
        

        dp[i][1][k] += dp[i-1][1][k]
        if l != 0:
            dp[i][1][k] += dp[i-1][0][k]
        if k >= 1:
            dp[i][1][k] += 9*dp[i-1][1][k-1]
            if l != 0:
                dp[i][1][k] +=  (l-1)*dp[i-1][0][k-1]

print(dp[m][0][K] + dp[m][1][K])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define Mod 1000000007
#define MAX 5002

vector<pii> ans;

ll check(){
	pii one = ans[0] , two = ans[1] , three = ans[2];
	return abs((one.fi-three.fi)*(two.se-three.se) - (two.fi-three.fi)*(one.se-three.se));
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll s;cin>>s;
	ans.pb({0,0});
	ll sq = sqrt(s)+1;

	if(s<=(ll(1e9))){
		ans.pb({0,1});
		ans.pb({s,0});
		for(pii x:ans){
			cout<<x.fi<<" "<<x.se<<" ";
		}
		cout<<endl;
		// trace(check());
		return 0;
	}

	if(sq>(ll(1e9))){
		sq = 1e9;
	}

	pii one(sq,1) , two(-1,sq);
	ll rem = sq*sq - s;
	two.fi = rem;
	ans.pb(one);
	ans.pb(two);

	for(pii x:ans){
		cout<<x.fi<<" "<<x.se<<" ";
	}
	cout<<endl;
	// trace(check());
	return 0;




























	
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int p[2100];
int dp[2100][2100][2];
int n;
int solve(int a,int b,int c){
	if(~dp[a][b][c])return dp[a][b][c];
	if(max(a,b)==n-1){
		return dp[a][b][c]=ABS(p[a]-p[b]);
	}
	int ret=0;
	int ch=max(a,b)+1;
	if(c==0){
		ret=max(solve(ch,b,1),solve(ch,b,0));
	}else{
		ret=min(solve(a,ch,1),solve(a,ch,0));
	}
	return dp[a][b][c]=ret;
}
int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	n=a+2;
	p[0]=b;
	p[1]=c;
	for(int i=0;i<a;i++)scanf("%d",p+i+2);
	for(int i=0;i<2100;i++)for(int j=0;j<2100;j++)dp[i][j][0]=dp[i][j][1]=-1;
	printf("%d\n",solve(0,1,0));
}

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

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  for(int i = 0; i < n; i++){
    cin >> l.at(i);
  }
  long int out = 0;
  sort(l.begin(), l.end());
  for(int i = 0; i < n-2; i++){
    for(int j = i+1; j < n-1; j++){
      int two = l.at(i) + l.at(j);
      for(int k = n - 1; k > j; k--){
        if(two > l.at(k)){
          out += (k - j);
          break;
        }
      }
    }
  }
  cout << out;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <atomic>
#include <thread>
#include <mutex>
#include <string>
#include <string.h>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <limits.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define P std::pair<int,int> 
#define INF LLONG_MAX/3
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int h, w, a, b;
int kaijo[200010];
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x%moder;
	return mypow(x, y / 2)*mypow(x, y / 2) % moder;
}
int comb(int x, int y) {
	if (y == 0)return 1;
	return kaijo[x] * mypow(kaijo[x - y], moder - 2) % moder*mypow(kaijo[y], moder - 2) % moder;
}
signed main() {
	cin >> h >> w >> a >> b;
	kaijo[1] = 1;
	for (int i = 2; i <= h + w; i++) {
		kaijo[i] = kaijo[i - 1] * i;
		kaijo[i] %= moder;
	}
	int ans = 0;
	int cnt = 0;
	for (int i = h - a - 1; i >= 0; i--) {
		ans += comb(b + i, i)*(comb(h + w - b - i - 2, w - b - 1) + moder - cnt) % moder;
		cnt += comb(h + w - b - i - 2, w - b - 1) - cnt;
		cnt %= moder;
		ans %= moder;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
sx, sy, tx, ty = map(int, input().split())
w, h = tx-sx+1, ty-sy+1

print('U'*(h-1) + 'R'*w + 'D'*h + 'L'*w + 'UL' + 'U'*h + 'R'*w + 'D'*h + 'L'*(w-1))

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import sys

(A, B, C, K) = (int(i) for i in input().split())

ans = 0
left = K

# 1
ans = min(A, left)

left -= A

if left <= 0:
    print(ans)
    sys.exit()

# 0
left -= B

if left <= 0:
    print(ans)
    sys.exit()

# -1
ans -= min(C, left)

print(ans)

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}



int main() {
  ll n, a, b, c, d; cin >> n >> a >> b >> c >> d;

  rep(i, n) {
    ll x = i*c;
    ll y = i*d;
    ll z = -(n-1-i)*d;
    ll w = -(n-1-i)*c;
    if (b-a >= x+z && b-a <= y+w) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main() {
	int n,m;
	cin >> n >> m;
 
	int a[100000]={0};
 
	rep(i,n) cin >> a[i];
 
	int b[100000]={0};
	int c[100000]={0};
 
	rep(i,m){
		cin >> b[i] >> c[i];
	}
 
	priority_queue<pair<int,int> > q;
 
	rep(i,n){
		q.push(make_pair(a[i],1));
	}
 
	rep(i,m){
		q.push(make_pair(c[i],b[i]));
	}
 
	long long ans = 0;
	rep(i,n){
		pair<int,int> p=q.top();
		q.pop();
		ans+=p.first;
		if(p.second>1){
			p.second --;
			q.push(p);
		}
	}
 
	cout << ans << endl;
}

Measured memory_bytes: 3572
N = int(input())
A = [int(x) for x in input().split()]
B = [int(y) for y in input().split()]
kouho = []
nowkouho = sum(A) + B[N - 1]
kouho.append(nowkouho)
for i in range(N - 1, 0, -1):
    nowkouho -= A[i]
    nowkouho += B[i - 1]
    kouho.append(nowkouho)
print(max(kouho))


Measured memory_bytes: 3060
#include <stdio.h>

int main() {

  int a,b,c,d;
  int m,s;
  int sum;

  scanf("%d %d %d %d",&a,&b,&c,&d);


  sum = a + b +c + d;

  m = sum / 60;
  s = sum % 60;

  printf("%d\n%d\n",m,s);


  return 0;

}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

#define PREP(i, m, n) for(int i = m; i < n; i++)
#define MREP(i, m, n) for(int i = m - 1; i >= n; i--)

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define prime first
#define weight second
#define MP make_pair
#define PB push_back

using namespace std;

int main(){
	map<char, int> table;
	table['I'] = 1;
	table['V'] = 5;
	table['X'] = 10;
	table['L'] = 50; 
	table['C'] = 100;
	table['D'] = 500;
	table['M'] = 1000;
	string input;
	while(cin >> input){
		int result = 0;
		if(cin.eof()) break;

		for(int i = 0; i < input.size(); i++){
			if(i ==  input.size() - 1){
				result += table[input[i]];
				break;
			}
			if(table[input[i]] < table[input[i + 1]]) result -= table[input[i]];
			else result += table[input[i]];
		}

		cout << result << endl;
	}

	return 0;
}

Measured memory_bytes: 1184
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    string s;
    cin >> s;
    if(s.find('7')!=string::npos){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


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

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

typedef long long LL;
typedef long double LD;

vector<int> uf;

int root(int x){
  if(x==uf[x]) return x;
  else return uf[x]=root(uf[x]);
}

void uni(int x,int y){
  x=root(x);
  y=root(y);
  if(x!=y) uf[x]=y;
}

int main(){
  while(1){
    int n;
    cin >> n;
    if(n==0) return 0;
    uf=vector<int>(n);
    for(int i=0;i<n;i++) uf[i]=i;
    vector<LD> x(n),y(n),z(n),r(n);
    for(int i=0;i<n;i++){
      cin >> x[i] >> y[i] >> z[i] >> r[i];
    }
    priority_queue<pair<LD,pair<int,int>>> kr;
    for(int i=0;i<n;i++){
      for(int j=0;j<i;j++){
        kr.push({-max(0,sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]))-r[i]-r[j]),{i,j}});
      }
    }
    pair<LD,pair<int,int>> now;
    LD d;
    int a,b;
    LD ans=0;
    while(!kr.empty()){
      now=kr.top();
      kr.pop();
      d=-now.first;
      a=now.second.first;
      b=now.second.second;
      if(root(a)!=root(b)){
        uni(a,b);
        ans+=d;
      }
    }
    cout << fixed << setprecision(3) << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3512
#include <iostream>
#include <string>
#define llint long long
#define mod 998244353

using namespace std;

string s;
llint sumR[2005], sumB[2005];
llint dp[4005][4005];

int main(void)
{
	cin >> s;
	int n = s.size();
	s = "#" + s;
	
	for(int i = 1; i <= n; i++){
		sumR[i] = sumR[i-1];
		sumB[i] = sumB[i-1];
		if(s[i] == '0') sumR[i] += 2;
		if(s[i] == '1') sumR[i]++, sumB[i]++;
		if(s[i] == '2') sumB[i] += 2;
	}
	
	dp[0][0] = 1;
	for(int i = 1; i <= 2*n; i++){
		for(int j = 0; j <= 2*n; j++){
			dp[i][j] += dp[i-1][j], dp[i][j] %= mod;
			if(j > 0) dp[i][j] += dp[i-1][j-1], dp[i][j] %= mod;
			if(i <= n && (j > sumR[i] || i-j > sumB[i])) dp[i][j] = 0;
		}
	}
	cout << dp[2*n][sumR[n]] << endl;
	
	return 0;
}

Measured memory_bytes: 125440
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,l,i,j;
    cin>>n>>l;
    string s[n],flag;
    cin.ignore();

    for(i=0;i<n;i++)
       getline(cin,s[i]);
    for(i=0;i<n;i++)
        for(j=i+1;j<n;j++)
           if(s[i]>s[j])
           {
              flag=s[i];
              s[i]=s[j];
              s[j]=flag;
           }
    for(i=0;i<n;i++)
        cout<<s[i];
    cout<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int a[200000];

int main()
{
    int n, c=0;
    cin>>n;
    for(int i=0; i<n; ++i){
        cin>>a[i];
    }
    for(int i=n-1; i>=0; i-=2){
        cout<<a[i]<<" ";
        ++c;
    }
    int j;
    if(n%2 == 1)
        j=1;
    else
        j=0;
    for(;j<n; j+=2){
        cout<<a[j];
        ++c;
        if(c==n)
            cout<<"\n";
        else
            cout<<" ";
    }
    return 0;
}


Measured memory_bytes: 3072
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
char t[100002];
int main()
{
	scanf("%s",t);
	int len=strlen(t);
	for(int i=0;i<len;i++)
	{
		if(t[i]==t[i+1])
		{
			printf("%d %d",i+1,i+2);
			return 0;
		}
		if(t[i]==t[i+2])
		{
			printf("%d %d",i+1,i+3);
			return 0;
		}
	}
	printf("-1 -1");
}

Measured memory_bytes: 384
import queue
N,M = map(int,input().split())
tree = [[] for _ in range(N+1)]
for i in range(M):
    a,b = map(int,input().split())
    tree[a].append(b)
    tree[b].append(a)

que = queue.Queue()
que.put(1)
result = [-1]*(N+1)
result[1] = 0
while(True):
    if que.empty():
        break
    start = que.get()
    for i in tree[start]:
        if result[i] == -1:
            result[i] = start
            que.put(i)

if -1 in result[2:]:
    print("No")
else:
    print("Yes")
    for i in result[2:]:
        print(i)






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

int main() {
  string N;
  cin >> N;
  if ( ( N[0] == N[1]  &&  N[0] == N[2] ) || ( N[3] == N[1]  &&  N[3] == N[2] ) ) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
Public Class Program
  Shared Sub Main()
    Dim h As Integer = Cin.Int()
    Dim w As Integer = Cin.Int()
    Dim n As Integer = Cin.Int()
    Dim b As Integer = Math.Max(h, w)
    Dim ans As Integer = Math.Ceiling(n / b)
    Console.WriteLine(ans.ToString())
  End Sub
End Class

Public Class Cin
  Public Shared Function Str() As String
    Return Console.ReadLine().Trim()
  End Function
  Public Shared Function Int() As Integer
    Return Integer.Parse(Str())
  End Function
  Public Shared Function Lng() As Long
    Return Long.Parse(Str())
  End Function
  Public Shared Function Dbl() As Double
    Return Double.Parse(Str())
  End Function
  Public Shared Function StrArr(Optional separator As String = " ") As String()
    Return Str().Split(separator)
  End Function
  Public Shared Function IntArr(Optional separator As String = " ") As Integer()
    Return Array.ConvertAll(Of String, Integer)(StrArr(separator), AddressOf Integer.Parse)
  End Function
  Public Shared Function LngArr(Optional separator As String = " ") As Long()
    Return Array.ConvertAll(Of String, Long)(StrArr(separator), AddressOf Long.Parse)
  End Function
  Public Shared Function DblArr(Optional separator As String = " ") As Double()
    Return Array.ConvertAll(Of String, Double)(StrArr(separator), AddressOf Double.Parse)
  End Function
End Class

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    int N,M; cin>>N>>M;
    //単一始点
    Graph G(N+1);
    rep(i,M){
        int a,b; cin>>a>>b;
        G.at(a).push_back(b);
        G.at(b).push_back(a);
    }
    vector<ll> dist(N+1,-1);
    vector<ll> mark(N+1);
    dist.at(1) = 0;
    queue<int> Q;
    Q.push(1);
    while(!Q.empty()){
        int v = Q.front();
        Q.pop();
        for(auto nv: G.at(v)){
            if(dist.at(nv)!=-1)continue;
            dist.at(nv)=dist.at(v)+1;
            Q.push(nv);
            mark.at(nv)=v;
        }
    }
    int res = 0;
    rep1(i,N)if(dist.at(i)==-1){
        res++;
        break;
    }
    if(res){
        cout<<"No"<<endl;
        return 0;
    }else{
        cout<<"Yes"<<endl;
        for(int i = 2; i <= N; i++)cout<<mark.at(i)<<endl;
    }
}


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

class BIT:
  def __init__(self,n):
    self.n=n+1
    self.BIT=[0]*self.n
  def add(self,i,x):
    idx=i
    while idx<self.n:
      self.BIT[idx]+=x
      idx+=(idx&-idx)
  def _sum(self,i):
    ret=0
    idx=i
    while idx>0:
      ret+=self.BIT[idx]
      idx-=(idx&-idx)
    return ret
  def sum(self,l,r):
    return self._sum(r)-self._sum(l-1)
  def value(self,i):
    return self._sum(i)-self._sum(i-1)

n,q=map(int,input().split())
arr=list(map(int,input().split()))
query=[]
for i in range(q):
  l,r=map(int,input().split())
  query.append((l,r,i))
query=sorted(query,key=lambda x:x[0])
ans=[0]*q
bit=BIT(n)
pos_now=[-1]*(n+1)
pos_prev=[-1]*(n+1)
dic={}
for i in range(n):
  val=arr[i]
  dic[i+1]=-1
  if pos_now[val]==-1:
    bit.add(i+1,1)
    pos_now[val]=i+1
  if pos_prev[val]!=-1:
    dic[pos_prev[val]]=i+1
  pos_prev[val]=i+1
prev=1
for l,r,id in query:
  while prev<l:
    val=arr[prev-1]
    if dic[pos_now[val]]!=-1:
      pos_now[val]=dic[pos_now[val]]
      bit.add(pos_now[val],1)
    prev+=1
  ans[id]=bit.sum(l,r)
for val in ans:
  print(val)

Measured memory_bytes: 308396
#include<stdio.h>
int main(){
    char s[101],p[101];
    int i,j,sn=0,pn=0,t;

    scanf("%s %s",s,p);

    while(s[sn]!='\0') sn++;
    while (p[pn]!='\0') pn++;

    for(i=0;i<sn;i++){
        t=1;
        for(j=0;j<pn;j++){
            if( s[(i+j)%sn] != p[j] ) t=0;
        }
        if(t) break;
    }

    if(t){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    
    return 0;
}



Measured memory_bytes: 2084
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

typedef long long ll;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int m1, d1, m2, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if(d2 == 1) cout << 1 << "\n";
  else cout << 0 << "\n";
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		long A = sc.nextLong();
		long B = sc.nextLong();
		long K = sc.nextLong();
		long tak = A - K;
		if (tak < 0) {
			System.out.println(0 + " " + Math.max(B + tak, 0));
		} else {
			System.out.println(tak + " " + B);
		}
	}
}

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

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 23764
from collections import Counter

s = input()
t = input()
s_chr_list = []
s_chr_num = 0
s_num_list = []
for i in range(len(s)):
    if s[i] in s_chr_list:
        s_same_chr = s_chr_list.index(s[i])
        s_num_list.append(s_same_chr)
    else:
        s_chr_list.append(s[i])
        s_chr_num += 1
        s_num_list.append(s_chr_num)
t_chr_list = []  
t_chr_num = 0
t_num_list = []        
for i in range(len(t)):
    if t[i] in t_chr_list:
        t_same_chr = t_chr_list.index(t[i])
        t_num_list.append(t_same_chr)
    else:
        t_chr_list.append(t[i])
        t_chr_num += 1
        t_num_list.append(t_chr_num)
if t_num_list == s_num_list:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 7592
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
using vl=vector<ll>;
using vb=vector<bool>;
using vs=vector<string>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
const ll oo =0x3f3f3f3f3f3f3f3fLL;
const double eps=1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

const ll MOD = 1e9 + 7;
const ll MAX_N = 100000 * 2 + 10;
int main(){
	ll N; cin >> N;
	vl cs(N);
	FOR(i, 0, N) {
		cin >> cs[i];
		/*
		ll tmp; cin >> tmp;
		if (sz(cs) == 0 || tmp != cs.back()) {
			cs.pb(tmp);
		}
		*/
	}

	vl dp(sz(cs)), last(MAX_N);
	dp[0] = 1;

	FOR(i, 0, sz(cs)) {
		if (i != 0) {
			if (cs[i] == cs[i-1]) dp[i] = dp[i-1];
			else dp[i] = (dp[i-1] + last[cs[i]]) % MOD;
		}
		last[cs[i]] = dp[i];
	}

	cout << dp.back() << endl;

	return 0;
} //cin.tie(0) bei schnellem Wechseln



Measured memory_bytes: 4992
#include <list>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,n-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);

int main() {
	int MAXN = (1<<16) + 1;
	vi prime(MAXN, 1);
	prime[0] = prime[1] = 0;
	
	FOR(i, 2, sqrt(MAXN)) {
		if(prime[i]) {
			for(int j = 2*i; j <= MAXN; j+=i) {
				prime[j] = 0;
			}
		}
	}
	
	int n;
	while(cin >> n, n) {
		int ans = 0;
		FOR(i, 2, (n+1)/2) {
			if(prime[i] && prime[n-i]) {
				ans++;
			}
		}
		cout << ans << endl;
	}

	return 0;
}

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

#define rick 1000000007

int main(void)
{
	int i_w,j_w;
	char S[100100];
	scanf("%s",S);
	int i,N = strlen(S);
	int c[N];
	for(i = 0 ; i < N; i++)
	{
		if(S[i] == '1') c[i] = 1;
		else if(S[i] =='2') c[i] = 2;
		else if(S[i] =='3') c[i] = 3;
		else if(S[i] =='4') c[i] = 4;
		else if(S[i] =='5') c[i] = 5;
		else if(S[i] =='6') c[i] = 6;
		else if(S[i] =='7') c[i] = 7;
		else if(S[i] =='8') c[i] = 8;
		else if(S[i] =='9') c[i] = 9;
		else if(S[i] =='0') c[i] = 0;
		else if(S[i] =='?') c[i] = 10;
	}
	long long int dp[N][13],k,j;
	for(i = 0; i < N; i++)
	{
		for(j=0;j < 13;j++)
		{
			dp[i][j] = 0;
		}
	}
	if(c[0] < 10) dp[0][c[0]] = 1;
	else if(c[0] == 10){
		dp[0][0] =1; dp[0][1]=1;dp[0][2]=1;dp[0][3]=1;dp[0][4]=1;dp[0][5]=1;dp[0][6]=1;dp[0][7]=1;dp[0][8]=1;dp[0][9]=1;
	}
	for(i = 1; i < N; i++)
	{
		for(j = 0; j < 13; j++)
		{
			if(dp[i-1][j] != 0&&c[i] != 10)
			{
				dp[i][(10*j+c[i])%13]+=dp[i-1][j];
				dp[i][(10*j+k)%13] = dp[i][(10*j+k)%13]%rick;
			}
			else if(dp[i-1][j] != 0 &&c[i]==10)
			{
				for(k = 0; k < 10; k++)
				{
					dp[i][(10*j+k)%13]+=dp[i-1][j];
					dp[i][(10*j+k)%13] = dp[i][(10*j+k)%13]%rick;
				}
				/*
				if(i == 1)
				{
					printf("j = %d\n",j);
					for(i_w = 0; i_w < 13; i_w++)
					{
						for(j_w=0;j_w < N;j_w++)
						{
							printf("%d ",dp[j_w][i_w]);
						}
						printf("\n");
					}
					printf("dp[0][7] = %d\n",dp[0][7]);
					printf("\n");
				}
				*/
				
			}
			
		}
	}
	/*
	printf("\n");
	for(i = 0; i < 13; i++)
	{
		for(j=0;j < N;j++)
		{
			printf("%d ",dp[j][i]);
		}
		printf("\n");
	}
	*/
	printf("%lld",dp[N-1][5]);
	return 0;
}


Measured memory_bytes: 10752