akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
// debug
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl;
#define dump(v) cerr<<#v":[ ";for (auto macro_vi:v){cerr<<macro_vi<< " ";}cerr<<"]"<<endl;
#define ddump(v) cerr<<#v":"<<endl;for(auto macro_row:v) {cerr<<"["; for (auto macro__vi:macro_row){cerr<<macro__vi<< " ";}cerr<<"]"<<endl;}
#define damp(m) for(auto macro_pair:m){cerr<< macro_pair.first<<":"<<macro_pair.second<<endl;}
#define dpair(p) cerr << #p":"<<"(" << p.first << "," << p.second << ")" << endl;
// iterate
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
// etc
#define chmin(mi, val) mi = min(mi, val);
#define chmax(ma, val) ma = max(ma, val);
using ll = long long;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,w;
    cin >> h >> w;

    dd(h,w)
    ll mi = 1e16;
    ll s1, s2, s3;
    for(int i=1; i<=h-1; i++){
        if((h-i)%2==0){
            s1 = w * i, s2 = w * (h - i) / 2, s3 = w * (h - i) / 2;
        }
        else if(w%2==0){
            s1 = w * i, s2 = (h - i)* w / 2, s3 = (h - i)* w / 2;
        }
        else{
            s1 = w * i, s2=((h*w-w*i)-min(w,h-i))/2+min(w,h-i), s3 = (h*w-w*i)-s2;
        }
        ddd(s1, s2, s3);
        chmin(mi, max({s1, s2,s3})-min({s1, s2,s3}));
    }
    int tmp=w;
    w=h, h=tmp;
    dd(h,w)
    for(int i=1; i<=h-1; i++){
        if((h-i)%2==0){
            s1 = w * i, s2 = w * (h - i) / 2, s3 = w * (h - i) / 2;
        }
        else if(w%2==0){
            s1 = w * i, s2 = (h - i)* w / 2, s3 = (h - i)* w / 2;
        }
        else{
            s1 = w * i, s2=((h*w-w*i)-min(w,h-i))/2+min(w,h-i), s3 = (h*w-w*i)-s2;
        }
        ddd(s1, s2, s3);
        chmin(mi, max({s1, s2,s3})-min({s1, s2,s3}));
    }
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int a,b,c;
	long long sharp=0,Dull=0,Ra=0;
	while(1){
		cin>>a>>b>>c;
		if(a+b<=c || b+c<=a || c+a<=b)break;
		int maxnum=max(max(a,b),c);
		if(maxnum==a){
			if(a*a==b*b+c*c)Ra++;
			else if(a*a>b*b+c*c)Dull++;
			else sharp++;
		}else if(maxnum==b){
			if(b*b==c*c+a*a)Ra++;
			else if(b*b>c*c+a*a)Dull++;
			else sharp++;
		}else{
			if(c*c==a*a+b*b)Ra++;
			else if(c*c>a*a+b*b)Dull++;
			else sharp++;
		}
	}
	cout<<sharp+Dull+Ra<<" "<<Ra<<" "<<sharp<<" "<<Dull<<endl;
	return 0;
}

Measured memory_bytes: 1160
n,m = map(int, input().split())
x = sorted(list(map(int, input().split())))
d = []

for i in range(len(x)-1):
    d.append(x[i+1] - x[i])

d.sort()

ans = 0
for i in range(m-n):
    ans += d[i]
    
    
print(ans)


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

signed main() {
    set <string> S;
    int n;
    cin >> n;
    while (n--) {
        string s;
        cin >> s;
        S.insert(s);
    }
    cout << S.size() << endl;

    return 0;
}

Measured memory_bytes: 19100
#!/usr/bin/env python3
from collections import Counter
INF = 1e12


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    lA = Counter(A)
    lB = Counter(B)
    if max(Counter(A+B).values()) > N:
        print('No')
        exit()

    C = [0] * (N + 1)
    D = [0] * (N + 1)
    for i in range(N):
        C[i + 1] = lA[i + 1] + C[i]
        D[i + 1] = lB[i + 1] + D[i]
    shift = - INF
    for i in range(1, N + 1):
        shift = max(shift, C[i] - D[i - 1])
    print('Yes')
    ans = (B + B + B)[N-shift:2*N-shift]
    print(' '.join([str(a) for a in ans]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 83204
#include <iostream>
#include <string>
#include <map>
#include <cmath>
#include <vector>
#include<cstdio>
#include <iterator>
#include <sstream>
#include <algorithm>
#include <map>
#include <numeric>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
#define len(str) (int)(str.length())
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int a = 0; a < N; a++)
	{
		cin >> A[a];
	}
	vector<int> R;
	int count = 1;
	for (int a = 1; a < N; a++)
	{
		if (A[a-1]==A[a]) {
			count++;
		}
		else {
			if (count>1) {
				
				R.push_back(count);
			}
			count = 1;
		}
	}
	if (count > 1) {
		R.push_back(count);
	}
	count = 0;
	for (int a = 0; a < (int)R.size(); a++)
	{
		count += R[a] / 2;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    int N;
    cin >> N;
    bool YYMM = false;
    bool MMYY = false;
    if (N % 100 < 13 && N % 100 != 0) {
        YYMM = true;
    }
    N = floor(N / 100);
    if (N < 13 && N != 0) {
        MMYY = true;
    }
    if (YYMM && MMYY) {
        cout << "AMBIGUOUS" << endl;
        return 0;
    }
    if (YYMM) {
        cout << "YYMM" << endl;
        return 0;
    }
    if (MMYY) {
        cout << "MMYY" << endl;
        return 0;
    }
    cout << "NA" << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
typedef long long ll;

const int MAXN = 2*1000 + 7;
const int SS = 1<<20;
const int MOD = 1000*1000*1000 + 7;

int dp[MAXN];
int n;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0);

	int T;
	//cin >> T;
	T = 1;
	while(T--)
	{
		cin >> n;
		dp[0] = 1;
		for(int sum=3; sum<=n; sum++)
		{
			for(int last = sum-3; last >= 0; last--)
			{
				dp[sum] = (dp[sum] + dp[last])%MOD;
			}
			//cout << sum << ' ' << dp[sum] << '\n';
		}
		cout << dp[n] << '\n';
	}
	return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
#include<stdlib.h>
int compare(const void *a,const void *b){
  return *(long*)a - *(long*)b;
}

int main(){
  long n = 0;
  long k = 0;
  long a[200000] = {};
  long i = 0;
  long hoge[200000] = {};
  long hozon = 0; 
  long hogecnt = 0;
  long sum = 0;
  long hogem = 0;
  scanf("%lu %lu",&n,&k);
  for(i=0 ; i < n; i++){
    scanf("%lu",&a[i]);
  }
  qsort(a,n,sizeof(long),compare);
  hozon = a[0];
  for(i=0;i<n;i++){
    if(hozon == a[i]){
      hoge[hogecnt]++;
    }else{
      hozon = a[i];
      hoge[hogecnt+1]++;
      hogecnt++;
    }
  }
  qsort(hoge,n,sizeof(long),compare);
  if((hogecnt+1) <= k){
    sum = 0;
  }else{
    hogem = 0;
    for(i=0;hogem < (hogecnt+1)-k;i++){
      if(hoge[i] != 0){	
      	sum += hoge[i];
      	hogem++;
      }
  	}
  }
  printf("%lu",sum);
  return 0;
}
  
  

Measured memory_bytes: 4872
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n;
        cin >> n;
        vector<int> v(n);
        for(int &it : v){
            cin >> it;
            vis[it]++;
        }
        int ans = 0;
        for(int i = 0; i < n; i++){
            int cnt = 0;
            for(int j = 1; j * j <= v[i]; j++){
                if(v[i] % j == 0){
                    if(vis[j]){
                        cnt++;
                    }
                    if(vis[v[i] / j] and j != v[i] / j){
                        cnt++;
                    }
                }
            }
            if(cnt == 1 and vis[v[i]] == 1){
                ans++;
            }
        }
        cout << ans << '\n';
    }
}

Measured memory_bytes: 35936
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 40005

struct GROUP{
	vector<int> nodes;
};

GROUP group[NUM]; //強連結成分のグループ
vector<int> G[NUM];
vector<int> reverse_G[NUM];
stack<int> S;

bool check[NUM];
int N,X,A,O;
int POW[16];
int table[NUM],in_num[NUM];
double sleep[NUM];

int group_index;

void dfs(int node_id){
	check[node_id] = true;

	for(int i = 0; i < G[node_id].size(); i++){
		if(!check[G[node_id][i]])dfs(G[node_id][i]);
	}
	S.push(node_id);
}

void reverse_dfs(int node_id){
	check[node_id] = true;

	group[group_index].nodes.push_back(node_id); //group[group_index]にノードを突っ込む
	table[node_id] = group_index;

	for(int i = 0; i < reverse_G[node_id].size(); i++){
		if(!check[reverse_G[node_id][i]])reverse_dfs(reverse_G[node_id][i]);
	}
}


int main(){

	POW[0] = 1;
	for(int i = 1; i <= 15; i++){

		POW[i] = POW[i-1]*2;
	}

	scanf("%d %d %d %d",&N,&X,&A,&O);
	if(X == 0){

		printf("No\n");
		return 0;
	}

	for(int i = 0; i < POW[N+1]; i++){
		for(int k = 0; k < POW[N+1]; k++){
			if(((i^k) == X) || ((i&k) == A) || ((i|k) == O)){ //true,falseを別にするペア

				G[i].push_back(k^X);
				reverse_G[k^X].push_back(i);
			}
		}
	}

	for(int i = 0; i < POW[N+1]; i++)check[i] = false;

	//まずは帰りがけ順を計算
	for(int i = 0; i < POW[N+1];i++){
		if(!check[i])dfs(i);
	}

	for(int i = 0; i < POW[N+1];i++)check[i] = false;

	group_index = -1;
	//ノードを、帰りがけ順の逆順に、各強連結成分(グループ)に分解
	while(!S.empty()){
		if(!check[S.top()]){
			group_index++;

			reverse_dfs(S.top());
		}
		S.pop();
	}

	for(int i = 0; i < POW[N+1]; i++){
		if(i < (i^X) && table[i] == table[i^X]){
			printf("No\n");
			return 0;
		}
	}

	vector<int> ANS;
	for(int i = 0; i < POW[N+1]; i++){
		if(i > (i^X))continue;

		if(table[i] > table[i^X]){

			ANS.push_back(i);
		}else{

			ANS.push_back(i^X);
		}
	}

	printf("Yes\n");
	printf("%d",ANS[0]);

	for(int i = 1; i < ANS.size(); i++){

		printf(" %d",ANS[i]);
	}
	printf("\n");

	return 0;
}



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

#define all(x) (x).begin(),(x).end()
#define init() \
  ios::sync_with_stdio(false); \
  cin.tie(0)

#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;

template<typename M, typename N>
constexpr common_type_t<M, N> gcd(M a, N b) {
  return a == 0 ? b
    : b == 0 ? a
    : gcd(b, a % b);
}

template <typename M, typename N>
constexpr common_type_t<M, N> lcm(M a, N b) {
  return a * b / gcd(a, b);
}

template <long long MAX>
class CombinationCalculator {
  long long mod_;
  long long fac[MAX];
  long long finv[MAX];
  long long inv[MAX];

public:
  CombinationCalculator(long long mi = MOD): fac(), finv(), inv() {
    mod_ = mi;
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i - 1] * i % mod_;
      inv[i] = mod_ - inv[mod_ % i] * (mod_ / i) % mod_;
      finv[i] = finv[i - 1] * inv[i] % mod_;
    }
  }

  long long c(long long n, long long k) const {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod_) % mod_;
  }
};

template <long long MAX = 210000>
using CC = CombinationCalculator<MAX>;

template<typename T>
T modpow(T a, T n, T mod = MOD) {
    T res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

template<typename T>
T modinv(T a, T m = MOD) {
    T b = m, u = 1, v = 0;
    while (b) {
        T t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int main() {
  init();

  int h, n;

  cin >> h >> n;
  int s = 0;
  for (size_t i = 0; i < n; i++)
  {
    int a;
    cin >> a;
    s += a;
  }

  cout << (s >= h ? "Yes" : "No") << '\n';
  
  return 0;
}


Measured memory_bytes: 256
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
    
k = int(input())
ans = 0
    
for i in range(1, k+1):
    for j in range(i, k+1):
        for x in range(j, k+1):
            s = gcd(i,j,x)
            if i == j and j == x:
                pass
            elif i == j or i == x or j == x:
                s *= 3
            else:
                s *= 6
                
            ans += s
print(ans)


Measured memory_bytes: 9628
al=["z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y"]
n=int(input())
ans=[]
while n>=1:
    n1=n//26
    a=n%26
    if a==0:
        ans.append("z")
        n=n1-1
        
    else:
        ans.append(al[a])
        n=n1

ans2=list(reversed(ans))
for i in range(len(ans2)):
    print(ans2[i], end="")

Measured memory_bytes: 9248
#include <iostream>
#include <string>
using namespace std;
char m[12][13];
int f(int y,int x){
  m[y][x]='0';
  if(x-1>=0&&m[y][x-1]=='1') f(y,x-1);
  if(y-1>=0&&m[y-1][x]=='1') f(y-1,x);
  if(x+1<12&&m[y][x+1]=='1') f(y,x+1);
  if(y+1<12&&m[y+1][x]=='1') f(y+1,x);
  return 0;
}
int main(){
  string s;
  while(1){
    int c=0;
    for(int i=0;i<12;++i){
      cin>>m[i];
    }
    for(int i=0;i<12;++i){
      for(int j=0;j<12;++j){
	if(m[i][j]=='1'){
	  f(i,j);
	  c++;
	}
      }
    }
    cout<<c<<endl;
    cin.ignore();
    if(getline(cin,s).eof()) break;
  }
  return 0;
}

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

typedef long long ll;


int main() {
  string S,T;
  cin >> S >> T;
  map<char,int> ms,mt;
  for(int i=0; i<S.length(); i++){
    ms[S[i]]++;
    mt[T[i]]++;
  }
  bool F=true;
  if(ms.size() != mt.size()){
    cout << "No" << endl;
    return 0;
  }
  vector<int> cnts,cntt;
  int i=0;
  for(auto itrs=ms.begin(), itrt=mt.begin(); itrs!=ms.end(); itrs++,itrt++,i++){
    cnts.push_back(itrs->second);
    cntt.push_back(itrt->second);
  }
  sort(cnts.begin(),cnts.end()); sort(cntt.begin(),cntt.end());
  
  for(int i=0; i<cnts.size(); i++){
    if(cnts[i]!=cntt[i]){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}

Measured memory_bytes: 776
N = int(input())
A = list(map(int, input().split()))

def f():
    for i in range(1, N):
        if A[i-1] < A[i]:
            state = 0
            break
        if A[i-1] > A[i]:
            state = 1
            break
    else:
        print(1)
        return

    cnt = 1

    for i in range(1, N):
        if A[i-1] < A[i]:
            if state == 1:
                state = 2
                cnt += 1
            else:
                state = 0

        if A[i-1] > A[i]:
            if state == 0:
                state = 2
                cnt += 1
            else:
                state = 1
    
    print(cnt)

f()

Measured memory_bytes: 20000
#include<stdio.h>
#include<string.h>
int main(void){
  char str[100];
  char *adr;
  scanf("%s",str);
  adr = strchr(str,(int)'7');
  if(adr == '\0'){
		printf("No");
  }else{
    printf("Yes");
  }
return 0;
}


Measured memory_bytes: 1732
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
pre_a = -1
ans = 0

for a in A:
    ans += B[a-1]
    if a == pre_a + 1:
        ans += C[pre_a-1]
    pre_a = a

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
using namespace std;

int N;
int B[100];
void Input()
{
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		cin >> B[i];
	}
}

int main()
{
	Input();
	int count = B[0];
	for (int i = 0; i < N - 2; i++) {
		count += min(B[i], B[i + 1]);
	}
	count += B[N - 2];
	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
from collections import deque
import numpy as np
H,W = map(int,input().split())
s = [list(input()) for _ in range(H)]

state = [[-1]*W for _ in range(H)]
start_list = []
for i in range(H):
    for j in range(W):
        if s[i][j] == '.':
            start_list.append((i,j))
            state[i][j] = 0

def dfs(black_cells,state):
    d = 0
    dist = [[0]*W for _ in range(H)]
    while black_cells:
        h, w =  black_cells.popleft()
        d = dist[h][w]
        for dy, dx in ((1,0), (0,1), (-1,0), (0,-1)):
            new_h = h+dy
            new_w = w+dx
            if new_h < 0 or H <= new_h or new_w < 0 or W <= new_w:
                continue
            if state[new_h][new_w] == 0 and dist[new_h][new_w] == 0:
                dist[new_h][new_w] = d+1
                if d == 0:dist[h][w] = 1
                black_cells.append((new_h, new_w))
    #print(dist)
    return np.array(dist).max()

ans = 0
for start in start_list:
    black_cells = deque()
    black_cells.append((start))
    ans = max(ans, dfs(black_cells,state))
print(ans)

Measured memory_bytes: 12516
#include<bits/stdc++.h>
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 1000000007 
#define eps 1e-9
#define PI 3.14159265358979323846
#define F first
#define S second
#define ll long long
#define pb push_back
#define mp make_pair
#define Fr(i,a,b) for(int i=a;i<=b;i++)
#define RF(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pii>
using namespace std;
vvi a;
ll dp[22][(1<<22)];
ll rec(int x,int mask){
    if(x>=a.size()){
        return 1;
    }
    if(dp[x][mask]!=-1){
        return dp[x][mask];
    }
    long long  sum=0;
    for(int i=0;i<a.size();i++){
        if(a[x][i]==1&&(mask&(1<<i))==0){
            sum=(sum+rec(x+1,(mask|(1<<i))))%mod;
        }
    }
    return dp[x][mask]=sum;
}
signed main(){
    SPEED;
   
    int t=1;
    //cin>>t;
    while(t--){
        int n;
        cin>>n;
        a.clear();
        a.resize(n,vi(n,0));
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                cin>>a[i][j];
            }
        }
        memset(dp,-1,sizeof(dp));
       cout<<rec(0,0)<<endl;
    }   
    return 0;
}

Measured memory_bytes: 721280
/*Bismillahir Rahmanir Rahim*/


#include<bits/stdc++.h>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#define ll long long int
#define dd double
using namespace std;
#define M 1000001
ll ara[M];

void sieve()
   {
      int i, j, root;
      for(i = 2; i < 1000001; i++) {
            ara[i] = 1;
         }
   root = sqrt(1000001);

      for(i = 2; i <= root; i++) {
   if(ara[i] == 1) {
for(j = 2; i * j <= 1000001; j++) {
ara[i * j] = 0;
}



}
      }
   }

int main()
{
   ll t,n,i,j,x,a,b,y;
  
   
      sieve();
      cin>>n;
     
      if(ara[n]==1)
      cout<<n<<endl;
      else{
         for(i=n+1;;i++)
         {
            if (ara[i]==1)
            {
            cout<<i<<endl;
               break;
            }
         
      }
      
    
   }

  
   
  

}

//Apna Time Aayega :)

Measured memory_bytes: 11448
a = input()
if a == 'MON':
    b = 6
if a == 'TUE':
    b = 5
if a == 'WED':
    b = 4
if a == 'THU':
    b = 3
if a == 'FRI':
    b = 2
if a == 'SAT':
    b = 1
if a == 'SUN':
    b = 7
print(b)


Measured memory_bytes: 2940
import java.util.*;
import java.io.*;

public class Main {
	static int[] distance;
	static int[] result;
	private static void solve(){
		//Implement solution here.
		
		int N = ni();
		int M = ni();
		
		result = new int[N + 1];
		ArrayList<Integer>[] graph = new ArrayList[N + 1];
		for(int i = 0; i < N + 1; i++)graph[i] = new ArrayList<Integer>();
		for(int i = 0; i < M; i++) {
			int A = ni();
			int B = ni();
			graph[A].add(B);
			graph[B].add(A);
		}
		
		Queue<Integer> q = new ArrayDeque<Integer>();
		q.add(1);
		while(!q.isEmpty()) {
			int idx = q.poll();
			for(int next: graph[idx]) {
				if(result[next] == 0) {
					result[next] = idx;
					q.add(next);
				}
			}
		}

		boolean ok = true;
		for(int i = 2; i <= N; i++) {
			if(result[i] == 0) {
				ok = false;
			}
		}
		
		if(ok) {
			System.out.println("Yes");
			for(int i = 2; i <= N; i++) {				
				System.out.println(result[i]);
			}
		} else {
			System.out.println("No");
		}
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 68208
let n, x = Scanf.scanf " %d %d" @@ fun a b -> a, b
let ls = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let ans, d = ref 1, ref 0
let _ = Array.iter (fun l -> d := !d + l; if !d <= x then incr ans) ls; Printf.printf "%d\n" !ans

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<queue>
typedef long long ll;
using namespace std;
int n;
ll a[300010],A[100010],B[100010],sum,ans;
priority_queue<ll> BQ;
priority_queue<ll,vector<ll>,greater<ll> >AQ;
int main(){
	cin>>n;
	for(int i=0;i<3*n;i++)cin>>a[i];
	
	sum=0; for(int i=0;i<n;i++){AQ.push(a[i]);sum+=a[i];} A[0]=sum;
	for(int i=n;i<2*n;i++){
		if(a[i]>AQ.top()){
			sum-=AQ.top();sum+=a[i];
			AQ.pop();AQ.push(a[i]);
		}A[i-n+1]=sum;
	}
	//前半
	sum=0; for(int i=2*n;i<3*n;i++){BQ.push(a[i]);sum+=a[i];} B[n]=sum;
	for(int i=2*n-1;i>=n;i--){
		if(a[i]<BQ.top()){
			sum-=BQ.top();sum+=a[i];
			BQ.pop();BQ.push(a[i]);
		}B[i-n]=sum;
	}
	//後半
	ans=-114514114514810;
	for(int i=0;i<=n;i++)ans=max(ans,A[i]-B[i]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5876
#!/usr/bin/python3

M = 998244353

def facts(n, MOD):
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
     
    return factorials, invs


(n, m, k) = map(int, input().split())

(fcs, invs) = facts(n, M)

c = 0
for i in range(k + 1):
    c = (c + m * fcs[n - 1] * invs[i] * invs[n - 1 - i] * pow(m - 1, n - 1 - i, M)) % M

print(c)

    


Measured memory_bytes: 84408
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a , b = [0] , [0]
for i in range(N):
    a.append(a[i]+A[i])
for j in range(M):
    b.append(b[j]+B[j])

ans , j = 0 , M
for i in range(N+1):
    if(a[i]>K):
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans , i+j)
   
print(ans)

Measured memory_bytes: 47272
#include<stdio.h>

int main(void){

  char str[20][20];
  int H,W,h,w;
  int i,j,result = 0;
  
  scanf("%d %d",&H,&W);
  scanf("%d %d",&h,&w);
  
  for(i = 0;i < H;i++){
    for(j = 0;j < W;j++){
      str[i][j] = 0;
    }
  }
  
  for(i = 0;i < h;i++){
    for(j = 0;j < W;j++){
      str[i][j] = 1;
    }
  }
  
  for(i = 0;i < w;i++){
    for(j = 0;j < H;j++){
      str[j][i] = 1;
    }
  }
  
  for(i = 0;i < H;i++){
    for(j = 0;j < W;j++){
      if(str[i][j] != 1){
       result++; 
      }
    }
  }
  
  printf("%d",result);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#define int long long
using namespace std;

int n;
int A[100000];
int a[100000];

signed main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> A[i];
	for (i = 0; i < n; i++) a[i] = A[(i + 1) % n] - A[i];
	
	int sumA = 0;
	for (i = 0; i < n; i++) {
		sumA += A[i];
	}
	int wa = n * (n + 1) / 2;
	if (sumA % wa != 0) { cout << "NO" << endl; return 0; }
	int T = sumA / wa;
	
	for (i = 0; i < n; i++) {
		a[i] -= T;
	}
	
	int ssum = 0;
	for (i = 0; i < n; i++) {
		if (a[i] > 0) { cout << "NO" << endl; return 0; }
		int b = -a[i];
		if (b % n != 0) { cout << "NO" << endl; return 0; }
		ssum += b / n;
	}
	
	if (ssum != T) { cout << "NO" << endl; return 0; }
	
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
  #include <set>
  #include <array>
  #include <map>
  #include <unordered_map>
  #include <unordered_set>
  #include <stack>
  #include <queue>
  #include <vector>
  #include <tuple>
  #include <string>
  #include <math.h>
  #include <time.h>
  #include <bitset>
  #include <stdio.h>
  #include <string.h>
  #include <iostream>
  #include <algorithm>
  #include <limits>
  #include <climits>
  #include <numeric>
  #include <functional>
  #include <iomanip>
  #include <cmath>

  #define lnd '\n'
  // #define reverse(i, n) for(ll i = n-1; i >= 0; --i)
  #define from(i, n) for (ll i = 0; i < n; ++i)
  #define loop(i, n) for(ll i = 0; i < n; i++)
  #define REPN(i, n) for (ll i = 1; i <= n; ++i)
  #define ALL(s) (s).begin(), (s).end()
  #define rALL(s) (s).rbegin(), (s).rend()
  #define sz(s) (int)(s).size()
  #define mk make_pair
  #define pb push_back
  #define sqr(s) ((s) * (s))

  using namespace std;

  typedef long long ll;
  typedef long long int lli;
  typedef long double ld;
  typedef unsigned long long ull;
  typedef unsigned int ui;

  template <class T>
  T GCD (T a, T b) {
    if(a == 0) return b;
    return GCD(b%a, a);
  }

  template <class T>
  T LCM(T a, T b){
    return a*b/GCM(a,b);
  }

  template <class T>
  T modpow(T x, T p){
      T res = 1;
      while(p > 0){
          if(p&1) res *= x;
          x *= x;
          p /= 2;
      }
      return res;
  }

  template <class T>
  T modpow(T x, T p, ll mod){
      T res = 1;
      while(p > 0){
          if(p&1) res = (res*x)%mod;
          x = (x*x)%mod;
          p /= 2;
      }
      return res%mod;
  }

  template <class T>
  void print(T a[], ll n){
      for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
      cout << endl;
  }

  template<class T>
  void printc(T c){
      for(auto const& v: c) std::cout << v << ' ';
      cout << endl;
  }

  struct HASH{
    size_t operator()(const pair<long,long>&x)const{
      return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
    }
  };

  bool pair_sort(const pair<int, int> &p1, const pair<int,int> &p2){
      if(p1.first != p2.first) return p1.first < p2.first;
      else return p1.second < p2.second;
  }

  const int INF = std::numeric_limits<int>::max();
  const ll M_INF = std::numeric_limits<ll>::min();
  const ll LL_INF = std::numeric_limits<ll>::max();

  void solution();
  int main(){
      ios_base::sync_with_stdio(0);
      cin.tie(0);
      cout.tie(0);
      solution();
      return 0;
  }

  void solution(){
    ll x, n;
    cin >> x >> n;
    set<ll> nums;
    loop(i, n){
      ll tmp;
      cin >> tmp;
      nums.insert(tmp);
    }

    ll ans = 1000;
    ll res = 1000;
    ll r = x;
    while(nums.count(r)){
      r++;
    }

    if(abs(x-r) < ans){
      ans = abs(x-r);
      res = r;
    }

    ll l = x;
    while(nums.count(l)){
      --l;
    }

    if(abs(l-x) <= ans){
      ans = abs(l-x);
      res = l;
    }

    cout << res << endl;
  }    





Measured memory_bytes: 3172
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
    int n;
    int m;
 
   cin >> n >> m;
  
   for(int i = m-n+1;i<m+n;i++){
     
     if(i!=m+n-1){
     cout << i << " ";
     }else{
       cout << i << endl;
     }
     

    }
  
  return 0;
}

Measured memory_bytes: 256
num=int(input().rstrip())
m=input().rstrip().split()
main=[]
for i in m:
    main.append(int(i))
sample=sorted(main,reverse=True)
result=0
for i in range(2,num+1):
    if i%2==0:
        y=i/2-1
        result+=sample[int(y)]
    else:
        y=(i+1)/2-1
        result+=sample[int(y)]
print(result)


Measured memory_bytes: 33220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
   ll n;
   cin>>n;
   ll a[n];
   for(ll i=0;i<n;i++){
   	cin>>a[i];
   } 
   //sort(a,a+n);
   ll p,q,c=0;
   for(ll i=0;i<n-2;i++){
   	for(ll j=i+1;j<n-1;j++){
   		 if(a[j]!=a[i]){
   		 	p=a[j];
   		 	for(ll k=j+1;k<n;k++){
   		 		if(a[k]!=p&&a[k]!=a[i]){
   		 			if(a[i]+p>a[k]&&a[k]+p>a[i]&&a[i]+a[k]>p){
   		 				//cout<<a[i]<<" "<<a[k]<<" "<<p<<"\n";
   		 				c++;
   		 				
						}
					}
				}
			}
	   }
   }
   cout<<c<<"\n";
   
	    return 0;
	    
	}


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

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;

void pretty_print(vector<int> &A) {
  cout << A[0];
  rep (i, A.size()-1) cout << ' ' << A[i+1];
  cout << endl;
}

void isort(vector<int> &A) {
  rep (i, A.size()) {
    int key = A[i];
    int j = i - 1;

    while (j >= 0 && A[j] > key) {
      A[j+1] = A[j];
      j--;
    }

    A[j+1] = key;

    pretty_print(A);
  }
}


int main() {
  int N;
  cin >> N;

  vector<int> A(N);
  rep (i, N) cin >> A[i];

  isort(A);
}

Measured memory_bytes: 1196
loop do
  s = gets

  break unless s

  n = s.to_i

  cnt = 0
  10.times do |a| ; 10.times do |b| ; 10.times do |c| ; 10.times do |d|
    cnt += 1 if a+b+c+d == n
  end ; end ; end ; end

  puts cnt
end

Measured memory_bytes: 8628
import numpy as np

N = int(input())
XY_set = np.array(list(set(tuple(map(int, input().split())) for _ in range(N))))

XpY = XY_set[:, 0] + XY_set[:, 1]
XmY = XY_set[:, 0] - XY_set[:, 1]

ans = max(XpY.max() - XpY.min(), XmY.max() - XmY.min())
print(ans)


Measured memory_bytes: 61784
K, N = [int(s) for s in input().split()]
A = [int(s) for s in input().split()]
maximum = 0
for i in range(N):
  if i == 0:
    continue
  elif maximum < A[i]-A[i-1]:
    maximum = A[i]-A[i-1]
if maximum < A[0]+(K-A[N-1]):
  maximum = A[0]+(K-A[N-1])

print(K-maximum)

Measured memory_bytes: 26444
from collections import Counter,deque
from scipy import special
S = input()
l = [int(n) for n in S]
a = [0]
t = 0
m = 1
d = deque(l)
mod = 2019
while d:
    temp = d.pop()
    t = (t + (temp * m)) % mod
    m = (m * 10) % mod
    a.append(t%mod)
b = [special.comb(kv,2,exact=True) for kv in Counter(a).values() if kv > 1]
print(sum(b))

Measured memory_bytes: 52648
#include <stdio.h>

int main(void)
{
	int x;
	int s;
	int i;
	int j;
	
	scanf("%d", &x);
	
	for (i = 0; i < x; i++){
		scanf("%d", &s);
		printf("Case %d:\n", i + 1);
		
		for (j = 0; j < 10; j++){
			s *= s;
			s /= 100;
			s %= 10000;
			printf("%d\n", s);
		}
	}
	
	return (0);
}

Measured memory_bytes: 592
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

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

    cin >> A;

    string S;
    
    cin >> S;

    if(A<3200) S = "red";
    cout << S << endl;    

}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main()
{
    int n;cin>>n;
    VL c(n),s(n),f(n);
    REP(i,n-1){
        cin>>c[i]>>s[i]>>f[i];
    }

    REP(j,n){
        LL now = 0;
        FOR(i,j,n-1){
            if(now <= s[i]){
                now = s[i];
            }
            else if(now%f[i] == 0){

            }  
            else{
                now += (f[i]-now%f[i]);
            }

            now += c[i];
        }
        cout<<now<<endl;
    }
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.math.*;


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

	class score implements Comparable<score>{
		int id;
		int t;
		public int compareTo(score tar){
			return t - tar.t;
		}
		
		score(Scanner sc){
			id = sc.nextInt();
			t=0;
			t += sc.nextInt()*60+sc.nextInt();
			t += sc.nextInt()*60+sc.nextInt();
			t += sc.nextInt()*60+sc.nextInt();
			t += sc.nextInt()*60+sc.nextInt();
					
		}
		
	}
	
	void run() {
		
		boolean isH [] = new boolean[2000000];
		
		isH[0] = true;
		isH[1] = true;

		for(int i = 1; i < 2000000/2;i++){
			if(isH[i]){
				isH[i*2] = isH[i];
			}
		}
		for(int i = 1; i < 2000000/3;i++){
			if(isH[i]){
				isH[i*3] = isH[i];
			}
		}
		for(int i = 1; i < 2000000/5;i++){
			if(isH[i]){
				isH[i*5] = isH[i];
			}
		}
		int sum[] = new int[2000000];
		
		for(int i = 1; i < 2000000;i++){
			if(isH[i]){
				sum[i] = sum[i-1]+1;
			}else{
				sum[i] = sum[i-1];
			}
		}
		for (;;) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}
			int m = sc.nextInt();
			
			System.out.println(sum[m]-sum[n-1]);
		}

	}

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

}

Measured memory_bytes: 22000
from math import factorial

def comb(n, k):
    f = factorial
    return f(n) / f(k) / f(n-k)

N, A, B = map(int, raw_input().split())
v = map(int, raw_input().split())

v.sort(reverse = True)

print float(sum(v[0:A]))/A

X, Y = 0, 0
ans = 0

for i in range(N):
    if (v[i] == v[A-1]):
        X += 1
    if (v[i] == v[A-1]) and (i < A):
        Y += 1

if (v[0] != v[A-1]):
    ans = comb(X, Y)

else:
    for i in range(A, B+1):
        if(i <= X):
            ans += comb(X, i)

print ans

Measured memory_bytes: 2820
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  printf("%d",x);
#define pl(x)  printf("%lld",x);
#define pf(x)  printf("%.10lf",x);
#define ps(x)  printf("%s",x);
#define en() printf("\n");
#define random_shuffle(r...)random_shuffle(r,[](int _){return rand()%_;})
#define SQR(a) (a)*(a)
#define sp(x) fixed<<setprecision(x)
#define mod 1000000007
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define bug cout<<"Here"<<endl
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
ll powmod(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod;a = a*a%mod;b >>= 1;}return ans;}


#define mxn 200005

vector<int>g[mxn];
int vis[mxn];


int bfs(int x)
{
    vis[x]=1;
    int cnt=1;

    queue<int>q;
    q.push(x);
    while(!q.empty())
    {
        int u=q.front();
        q.pop();

        for(auto v:g[u])
        {
            if(vis[v]) continue;
            vis[v]=1;
            cnt++;
            q.push(v);
        }
    }

    return cnt;
}



int main()
{
    int n,m;
    cin>>n>>m;
    map<pii,int>mp;
    set<int>s;
    int mx=0;
    if(m==0) mx=1;
    while(m--)
    {
        int a,b;
        cin>>a>>b;
        if(mp[{a,b}] || mp[{b,a}]  ) continue;
        g[a].pb(b);
        g[b].pb(a);
        mp[{a,b}]++;
        mp[{b,a}]++;
        s.insert(a);
        s.insert(b);
    }


    for(auto u:s)
    {
        if(vis[u]==0)
        {
            mx=max(mx,bfs(u));
        }
    }



    cout<<mx<<endl;



	return 0;
}


Measured memory_bytes: 49712
x = int(input())

def checker(x):
    found = False
    upper = x ** (1/2)

    for i in range(2, round(upper)):
        if x % i == 0:
            found = True
            break

    return False if found == True else True

x -= 1
ok = False

while not ok:
    x += 1
    ok = checker(x)

print(x)

Measured memory_bytes: 3060
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
const long long int MOD=1e9+7;

using namespace std;

long long n, k, check[100009];
vector<long long> nei[100009];

void solve(){
    long long ans = k;
    check[0] = 1;
    queue<pair<int, int> > Q1;
    long long now_p=0, cur=k-1;
    for(int i=0;i<nei[0].size();i++){
        Q1.push(make_pair(nei[0][i], now_p));
        check[nei[0][i]] = 1;
        ans = (ans * cur)%MOD;
        cur--;
    }
    while(!Q1.empty()){
        long long now = Q1.front().first, par = Q1.front().second;
        Q1.pop();
        cur = k-2;
        for(int i=0;i<nei[now].size();i++){
            if(check[nei[now][i]]==0){
                Q1.push(make_pair(nei[now][i], now));
                check[nei[now][i]]=1;
                ans = (ans * cur)%MOD;
                cur--;
            }
        }
    }
    cout << ans << endl;
}

int main(){
    cin >> n >> k;
    for(int i=0;i<n-1;i++){
        int tmp_a,tmp_b;
        cin >> tmp_a >> tmp_b;
        tmp_a--;
        tmp_b--;
        nei[tmp_a].push_back(tmp_b);
        nei[tmp_b].push_back(tmp_a);
    }
    solve();
}

Measured memory_bytes: 8052
S=input()

L=len(S)
ANS=0
SET={"A","C","G","T"}
for i in range(L):
    for j in range(i,L+1):
        X=S[i:j]

        for x in X:
            if x in SET:
                continue
            else:
                break

        else:
            ANS=max(ANS,len(X))

print(ANS)


Measured memory_bytes: 3060
import java.io.*
import java.util.*

val pw = PrintWriter(System.out)
fun solve(D: Long){
    when(D){
        25L -> {println("Christmas")}
        24L -> {println("Christmas Eve")}
        23L -> {println("Christmas Eve Eve")}
        22L -> {println("Christmas Eve Eve Eve")}
        else -> {println("null")}
    }
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val D = sc.next().toLong()
    solve(D)
}



Measured memory_bytes: 31260
#include<iostream>
#include<queue>
#include<set>
#include<algorithm>
using namespace std;
struct Puzzle{
        int a[4][4];
        int calcDist(){
                int u,v, sum=0;
                for(int i=1;i<16;i++){
                        for(int j=0;j<16;j++){
                                if(i==a[j/4][j%4]){
                                        u = j/4;
                                        v = j%4;
                                        break;
                                }
                        }
                        sum += abs((i-1)/4-u) + abs((i-1)%4-v);

                }
                return sum;
        }
};

bool operator< (const Puzzle &s, const Puzzle &t){
        for(int i=0;i<16;i++){
                if(s.a[i/4][i%4]==t.a[i/4][i%4]) continue;
                return s.a[i/4][i%4] < t.a[i/4][i%4];
        }
        return false;
}

struct Status{
        Puzzle p;
        int c,i,j;
        int distFromTarget;
        Status(Puzzle p1, int cnt){
                p = p1;
                for(int k=0;k<16;k++) {
                        if(p.a[k/4][k%4]==0){
                                i=k/4;
                                j=k%4;
                        }
                }
                distFromTarget = p.calcDist();
                c = cnt;
        }
};

bool operator< (const Status &s, const Status &t){
        return -(s.c + s.distFromTarget) < -(t.c + t.distFromTarget);
}


int solve(Puzzle p0){
        set<Puzzle> visited;
        priority_queue<Status> que;
        Status s0(p0,0);
        que.push(s0);
        while(!que.empty()){
                Status s = que.top();que.pop();
                Puzzle p = s.p;
                if(visited.find(p)!=visited.end()) continue;
                if(s.distFromTarget==0) return s.c;
                visited.insert(p);

                Puzzle tmp;
                if(s.i!=0) {
                        tmp = p;
                        swap(tmp.a[s.i][s.j], tmp.a[s.i-1][s.j]);
                        if(visited.find(tmp)==visited.end()) que.push(Status(tmp, s.c+1));
                }
                if(s.j!=0) {
                        tmp = p;
                        swap(tmp.a[s.i][s.j], tmp.a[s.i][s.j-1]);
                        if(visited.find(tmp)==visited.end()) que.push(Status(tmp, s.c+1));
                }
                if(s.i!=3) {
                        tmp = p;
                        swap(tmp.a[s.i][s.j], tmp.a[s.i+1][s.j]);
                        if(visited.find(tmp)==visited.end()) que.push(Status(tmp, s.c+1));
                }
                if(s.j!=3) {
                        tmp = p;
                        swap(tmp.a[s.i][s.j], tmp.a[s.i][s.j+1]);
                        if(visited.find(tmp)==visited.end()) que.push(Status(tmp, s.c+1));
                }
        }
        return -1;
}

int main(){
        Puzzle p;
        for(int i=0;i<16;i++) {
                cin>>p.a[i/4][i%4];
        }

        cout<<solve(p)<<endl;
}




Measured memory_bytes: 159216
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;
using ll = long long int;

int main(){
    int N;
    cin>>N;
    vector<ll> A(N);
    for(int i=0;i<N;i++) cin>>A[i];
    
    int min_count=100000;
    for(int i=0;i<N;i++){
        int count=0;
        while(A[i]%2==0){
            count++;
            A[i]/=2;
        }
        if(count<min_count) min_count=count;
    }
    
    cout<<min_count<<endl;
    
    return 0;
}




Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <numeric>
using namespace std;
using ll = long long;
int main(){
    ll N, ans = 0, x, a[100];
    scanf("%lld %lld%*c", &N, &x);
    for (int i = 0; i < N; i++) scanf("%lld%*c", &a[i]);
    sort(a, a + N);
    if (x >= accumulate(a, a + N, 0LL)) {
        ans = N - 1;
        if (x == accumulate(a, a + N, 0LL)) ans = N;
        printf("%lld\n", ans);
        return 0;
    }
    for (int i = 0; i < N; i++) {
        if (x < a[i]) break;
        x -= a[i];
        ans++;
    }
    
    printf("%lld\n", ans);
}


Measured memory_bytes: 128
#include <stdio.h>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,x;
    int ans = 0;
    scanf("%d %d %d",&a,&b,&c);
    for(int x=a;x<=b;x++){
        if(c % x == 0)
        {
            ans++;
        }
        //c%x=0
    }
    printf("%d\n",ans);
}



Measured memory_bytes: 2736