akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cmath>
#include <set>
#include <algorithm>
#include <queue>
using namespace std;

const int INF = 0x3f3f3f3f;

const int N = 1000000;
int n, m, k;
char buf[N + 1];
int dist[N];
vector<int> rowblock[N];
vector<int> colblock[N];
set<int> row[N];
set<int> col[N];

int &get_dist(pair<int, int> a) 
{
	return dist[a.first * m + a.second];
}

int main() 
{
	scanf("%d%d%d", &n, &m, &k);
	pair<int, int> start, dest;
	scanf("%d%d%d%d", &start.first, &start.second, &dest.first, &dest.second);
	--start.first;
	--start.second;
	--dest.first;
	--dest.second;
	for (int i = 0; i < n; ++i) {
		scanf("%s", buf);
		for (int j = 0; j < m; ++j) {
			if (buf[j] == '@') {
				rowblock[i].push_back(j);
				colblock[j].push_back(i);
			}
			else {
				row[i].insert(j);
				col[j].insert(i);
			}
		}
	}
	for (int i = 0; i < n; ++i) {
		rowblock[i].push_back(-INF);
		rowblock[i].push_back(INF);
		row[i].insert(-INF);
		row[i].insert(INF);
		sort(rowblock[i].begin(), rowblock[i].end());
	}
	for (int i = 0; i < m; ++i) {
		colblock[i].push_back(-INF);
		colblock[i].push_back(INF);
		col[i].insert(-INF);
		col[i].insert(INF);
		sort(colblock[i].begin(), colblock[i].end());
	}
	queue<pair<int, int> > q;
	q.push(start);
	get_dist(start) = 0;
	row[start.first].erase(start.second);
	col[start.second].erase(start.first);
	while (!q.empty()) {
		pair<int, int> t = q.front();
		q.pop();
		int current_dist = get_dist(t);
		if (t == dest) {
			printf("%d\n", current_dist);
			return 0;
		}
		int next;
		int block;
		next = *row[t.first].upper_bound(t.second);
		block = *upper_bound(rowblock[t.first].begin(), rowblock[t.first].end(), t.second);
		while (next < block && next - t.second <= k) {
			get_dist(make_pair(t.first, next)) = current_dist + 1;
			row[t.first].erase(next);
			col[next].erase(t.first);
			q.push(make_pair(t.first, next));
			next = *row[t.first].upper_bound(t.second);
		}
		next = *prev(row[t.first].upper_bound(t.second));
		block = *(upper_bound(rowblock[t.first].begin(), rowblock[t.first].end(), t.second) - 1);
		while (next > block && t.second - next <= k) {
			get_dist(make_pair(t.first, next)) = current_dist + 1;
			row[t.first].erase(next);
			col[next].erase(t.first);
			q.push(make_pair(t.first, next));
			next = *prev(row[t.first].upper_bound(t.second));
		}
		next = *col[t.second].upper_bound(t.first);
		block = *upper_bound(colblock[t.second].begin(), colblock[t.second].end(), t.first);
		while (next < block && next - t.first <= k) {
			get_dist(make_pair(next, t.second)) = current_dist + 1;
			col[t.second].erase(next);
			row[next].erase(t.second);
			q.push(make_pair(next, t.second));
			next = *col[t.second].upper_bound(t.first);
		}
		next = *prev(col[t.second].upper_bound(t.first));
		block = *(upper_bound(colblock[t.second].begin(), colblock[t.second].end(), t.first) - 1);
		while (next > block && t.first - next <= k) {
			get_dist(make_pair(next, t.second)) = current_dist + 1;
			col[t.second].erase(next);
			row[next].erase(t.second);
			q.push(make_pair(next, t.second));
			next = *prev(col[t.second].upper_bound(t.first));
		}
	}
	printf("-1\n");
	return 0;
}


Measured memory_bytes: 365548
n, k = gets.chomp.split.map(&:to_i)

pro = 0.0
1.upto(n) do |i|
	if i >= k
		pro += 1.0 / n
		next
	end

	cnt = 1
	while i * 2 ** cnt < k
		cnt += 1
	end
	pro += (1.0 / n) * (1.0 / (2 ** cnt))
end

puts pro


Measured memory_bytes: 14256
function Main(input) {
  input = input.trim().split("\n").map(function(x) { return x.split(" ")});
  var N = parseInt(input[0],10);
  var S = input[1][0];
  var vec_R = Array.from({length: N + 1}, () => 0);
  var vec_G = Array.from({length: N + 1}, () => 0);
  var vec_B = Array.from({length: N + 1}, () => 0);
  var arr_chr = [vec_R,vec_G,vec_B];
  var ans = 0;
  for(var i = S.length - 1; i >= 0; i--){
    if(S.substr(i, 1) === 'R') {
      vec_R[i] = vec_R[i + 1] + 1;
      vec_G[i] = vec_G[i + 1];
      vec_B[i] = vec_B[i + 1]; 
    }
    if(S.substr(i, 1) === 'G') {
      vec_R[i] = vec_R[i + 1];
      vec_G[i] = vec_G[i + 1] + 1;
      vec_B[i] = vec_B[i + 1];
    }
    if(S.substr(i, 1) === 'B') {
      vec_R[i] = vec_R[i + 1];
      vec_G[i] = vec_G[i + 1];
      vec_B[i] = vec_B[i + 1] + 1;
    }
  }
  vec_R = vec_R.pop();
  vec_G = vec_G.pop();
  vec_B = vec_B.pop();
  var a, b, c;
  var tmp = 0;
  for (var i = 0; i < (S.length - 3); i++){
    a = S.substr(i, 1);
    for (var j = i + 1; j < (S.length - 1); j++){
      b = S.substr(j, 1);
      if (a !== b){
        ans += arr_chr[chrSk_i(S, a, b)][j + 1];
        if (j+(j-i) < N && S.substr(j+(j-i), 1) !== a && S.substr(j+(j-i), 1) !== b) {
          ans --;
          tmp ++;
        }
      }
    }
  }
  function chrSk_i(S, a, b){
    if (a !== 'R' && b !== 'R') return 0;
    if (a !== 'G' && b !== 'G') return 1;
    if (a !== 'B' && b !== 'B') return 2;
  }
  console.log(ans);
}   

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

typedef long long ll;
ll n, mx, a[105];
void f(ll p) {
	ll i, k = 0, t[105];
	if (p > n) {
		for (i =1; i <= n; i++) k += a[i];
		mx = max(mx, k);
		return;
	}
	f(p + 1);
	if (a[p] < 0) {
		for (i = 1; i <= n; i++) t[i] = a[i];
		for (i = p; i <= n; i += p) a[i] = 0;
		f(p + 1);
		for (i = 1; i <= n; i++) a[i] = t[i];
	}
}
int main()
{
	ll i, j, k;
	cin >> n;
	for (i = 1; i <= n; i++) scanf ("%lld", &a[i]);
	for (i = n; i > n / 6; i--) {
		k = 0;
		for (j = i; j <= n; j += i) k += a[j];
		if (k < 0) for (j = i; j <= n; j += i) a[j] = 0;
	}
	f(1);
	cout << mx;
    return 0;
}

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

using namespace std;

const int SN = 100 + 10;

int a[SN];

int n, ans = 0x3fffffff;

int main() {
	scanf("%d",&n);
	
	for(int i = 1; i <= n; i++) {
		scanf("%d",&a[i]);
	}
	
	sort(a+1, a+n+1);
	
	printf("%d\n",a[n]-a[1]);
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h> 
using namespace std;
#define li long long
li n,m,k;
struct edge{
	li f,t,v;
}e[2010];
bool cmp(edge q,edge w){
	return q.v < w.v;
}
int f[1010];
int gf(int q){
	return f[q] == q ? q : f[q] = gf(f[q]);
}
void mg(int q,int w){
	f[gf(q)] = gf(w);
}
bool pd(int q,int w){
	return gf(q) == gf(w);
}
const int mo = 1000000007;
li ksm(li q,int w){
	li as = 1;
	while(w){
		if(w & 1) as = as * q % mo;
		q = q * q % mo;
		w >>= 1;
	}
	return as;
}
int p1,p2;
void kru(int q){
	li as = e[q].v;
	mg(e[q].f,e[q].t);
	for(int i = 1;i <= m;++i){
		if(i == q) continue;
		if(!pd(e[i].f,e[i].t)){
			as += e[i].v;
			mg(e[i].f,e[i].t);
		}
	}
	//cout<<as<<endl;
	if(as < k) ++p1;
	if(as <= k) ++p2;
}
int main(){
	int i,j,u,v;
	cin>>n>>m>>k;
	for(i = 1;i <= m;++i) cin>>e[i].f>>e[i].t>>e[i].v;
	sort(e + 1,e + m + 1,cmp);
	for(i = 1;i <= m;++i){
		for(j = 1;j <= n;++j) f[j] = j;
		kru(i);
	}
	//cout<<p1<<" "<<p2<<endl;
	if(p1 == p2 || n <= 2){
		putchar('0');
		return 0;
	}
	li a1 = ksm(2,min(m,m - p1 + 1)),a2 = ksm(2,min(m,m - p2 + 1));
	cout<<(a1 - a2 + mo) % mo;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();

		int a = y+r;
		int b = x+r;
		int c = y-r;
		int d = x-r;

		if(a<=H&&c>=0&&b<=H&&d>=0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 26356
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n; scanf("%d", &n);
	std::string s; cin >> s;
	
	std::vector<std::vector<int>> vec(26);
	for(int i = 0; i < s.size(); i++) vec[s[i] - 'a'].push_back(i);
	
	i64 ans = 1;
	const int MOD = 1e9 + 7;
	for(int i = 0; i < vec.size(); i++) {
		ans *= (i64)(vec[i].size() + 1);
		ans %= MOD;
	}
	printf("%lld\n", (ans + MOD - 1) % MOD);
	return 0;
}


Measured memory_bytes: 1152
z[4000],*a=z,*b=z+2000,m,i,j,t,u;main(n){for(;m=scanf("%d",&n)-++n;printf("%d\n",m))for(i=n;i--;j=a,a=b,b=j)for(j=n;j--;t>m?m=t:0)t=b[j]=n+~i&&getchar()>45?1+fmin(u=a[j],t<u?t:u):0;}

Measured memory_bytes: 0
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int N;
    R(N);
    VI p(N),q(N),a(N);
    REP(i,N)R(p[i]);
    REP(i,N)R(q[i]);
    FOR(i,1,N){
        a[i-1]=i;
    }
    int x=0,y=0,it=0;
    do{
        if(a==p)x=it;
        if(a==q)y=it;
        it++;
    }while(next_permutation(ALL(a)));
    W(abs(x-y));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int A, B, C, D, L, R;

	cin >> A >> B >> C >> D;
	L = A + B;
	R = C + D;

	if (L == R) {
		cout << "Balanced" << endl;
	}
	else if (L > R) {
		cout << "Left" << endl;
	}
	else {
		cout << "Right" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <iterator>
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <regex>
#include <stdexcept>
#include <unordered_set>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <cassert>
#include <time.h>
#include <numeric>
#include <complex>

using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define fill(x, y) memset(x, y, sizeof(x))
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define itn int
#define re return
#define prev PREV
#define next NEXT

#define sz(x) ((int)x.size())

const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int maxn = 2*1000005;

#define FILENAME ""

ll dp[101][100000 + 100];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k;
    cin >> n >> k;
    vector <pair<ll, ll>> a(n + 1);
    for (int i = 1; i <= n; i++) {
        ll x, y;
        cin >> x >> y;
        a[i] = {y, x};
    }
    for (int i = 0; i <= k; i++) {
        dp[0][i] = 0;
    }
    for (int i = 0; i <= n; i++) {
        dp[i][0] = 0;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= k; j++) {
            if (j >= a[i].se) {
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - a[i].se] + a[i].fi);
            }
            else {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    cout << dp[n][k];
    return 0;
}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;



int main(){
   ll n;
   cin >> n;


    ll a, b;
    ll res=1e9;
    for(int i=1; i<=sqrt(n); i++){
        if(n % i == 0){
            a = i;
            b = n/i;
            res = min(res,max(a,b));
        }
    }
    
    ll cnt=0;
    while(res>0){
        res /= 10;
        cnt++;
    }
    cout << cnt << endl;
}

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

bool kaibunsu(int x) {
  int d1 = x % 10;
  int d2 = x / 10 % 10;
  int d4 = x / 1000 % 10;
  int d5 = x / 10000;
  if (d1 == d5 && d2 == d4) return true;
  else return false;
}

int main() {
  int a, b;
  cin >> a >> b;
  int answer = 0;
  for (int i = a; i <= b; i++) if (kaibunsu(i)) answer++;
  cout << answer;
}

Measured memory_bytes: 3624
#include <stdio.h>

int partition(int *A, int p, int r){
  int x,i,j,re,m;
  x = A[r];
  i = p-1;
    for(j=p;j<=r-1;j++){
      if (A[j] <= x){
	i = i+1;
	re=A[i];
	A[i]=A[j];
	A[j]=re;
      }
    }
    m=A[i+1];
    A[i+1]=A[r];
    A[r]=m;
  return i+1;
}

int main(){
  int n,A[100000],i,ans;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
      scanf("%d",&A[i]);
    }
    ans=partition(A,1,n);
    for(i=1;i<=n;i++){
      if(i==ans){
	printf("[%d] ",A[i]);
      }
      else if(i==n){
	printf("%d\n",A[i]);
      }
      else {
	printf("%d ",A[i]);
      }
    }
    return 0;
}



Measured memory_bytes: 2156
#include <iostream>

using namespace std;

int main(){
    int H,W;

    
    int i=0;
    int j=0;
    int num=0;
    while(num<1000){
    
    cin>>H>>W;
    if(H!=0 && W!=0){    
        while(i<H){
        
            while(j<W){
                cout<<"#";
                j++;
            }
            cout<<endl;
         j=0;
            i++;
        
        }
        cout<<endl;
        i=0;
    }
    if(H==0 && W==0){
        break;
    }
    
    }
    
    
    
}


Measured memory_bytes: 3096
N, W = (int(x) for x in input().split())
A = [[int(x) for x in input().split()] for i in range(N)]
dp = [[0] * (W + 1) for i in range(N + 1)]
for i in range(N):
  w, v = A[i]
  for j in range(W+1):
    dp[i+1][j] = max(dp[i+1][j], dp[i][j])
    if j >= w:
      dp[i+1][j] = max(dp[i+1][j], dp[i][j - w] + v) 
print(dp[N][W])

Measured memory_bytes: 121196
nodes = None


class Node:
    def __init__(self, key=None, parent=None, left=None, right=None):
        self.key = key
        self.parent = parent
        self.left = left
        self.right = right


def insert(z):
    global nodes
    y = None
    x = nodes

    while x is not None:
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right

    z.parent = y

    if y is None:
        nodes = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z


def find(node, key):
    # if node is None:
    #     return "no"
    #
    # if node.key == key:
    #     return "yes"
    # elif node.key > key:
    #     return find(node.left, key)
    # else:
    #     return find(node.right, key)
    while node is not None and node.key != key:
        if node.key > key:
            node = node.left
        else:
            node = node.right

    if node is None:
        return "no"
    if node.key == key:
        return "yes"
    raise AssertionError()


def get_inorder(inorder, node):
    if node.left is not None:
        get_inorder(inorder, node.left)
    inorder.append(node.key)
    if node.right is not None:
        get_inorder(inorder, node.right)
    return inorder


def get_preorder(preorder, node):
    preorder.append(node.key)
    if node.left is not None:
        get_preorder(preorder, node.left)
    if node.right is not None:
        get_preorder(preorder, node.right)
    return preorder


def p(node):
    print("", " ".join([str(i) for i in get_inorder([], node)]))
    print("", " ".join([str(i) for i in get_preorder([], node)]))


n = int(input())
for _ in range(n):
    s = input().split()
    if s[0] == "insert":
        key = int(s[1])
        insert(Node(key=key))
    elif s[0] == "find":
        key = int(s[1])
        print(find(nodes, key))
    else:
        p(nodes)



Measured memory_bytes: 115152
#include <iostream>
#include <vector>
#include <cmath>

long ipow(long x, long e)
{
	long y = 1;
	while (e > 0) {
		if (e%2 == 1)
			y *= x;
		x *= x;
		e /= 2;
	}
	return y;
}

std::vector<long> make_prime_table(long P, long N) // PのN乗根以下の素数のテーブルを作る
{
	long pmax = std::pow(P, 1.0/N) + 2;
//	std::cout << "make prime to " << pmax << "\n";
	std::vector<long> ret;

	ret.push_back(2);
	for (long i = 3; i <= pmax; i += 2) {
		long sqrti = std::sqrt((double)i) + 1;
		int j = 0;
		for (; j < ret.size(); ++j) {
			if (ret[j] > sqrti)
				break;
			if (i % ret[j] == 0)
				goto next;
		}
		ret.push_back(i);
	next:
		NULL;
	}

	return ret;
}

int main()
{
	long N, P;
	std::cin >> N >> P;
	long result = 1;

	if (N >= 63) {
		std::cout << "1\n";
		return 0;
	}
	if ((1 << N) > P) {
		std::cout << "1\n";
		return 0;
	}
	if (N == 1) {
		std::cout << P << "\n";
		return 0;
	}

	auto primes = make_prime_table(P, N);
//	for (auto x : primes)
//		std::cout << x << ", ";
//	std::cout << "\n";

	long p = P;
	for (auto it = primes.begin(); it != primes.end(); ++it) {
		long v = ipow(*it, N);
		if (p < v)
			break;
		while (p % v == 0) {
			p /= v;
			result *= *it;
		}
	}
	std::cout << result << "\n";
}

Measured memory_bytes: 1400
def computeMinimumNoOfOperations(candies, x):
    noOfOperations = 0
    for i in range(len(candies) - 1):
        if (candies[i] > x):
            candiesToEat = candies[i] - x
            candies[i] -= candiesToEat
            noOfOperations += candiesToEat
        if (candies[i] + candies[i + 1] > x):
            candiesToEat = candies[i] + candies[i + 1] - x
            candies[i + 1] -= candiesToEat
            noOfOperations += candiesToEat 
    return noOfOperations


def start():
    n, x = list(map(int, input().split()))
    candies = list(map(int, input().split()))
    return computeMinimumNoOfOperations(candies, x)

print(start())


Measured memory_bytes: 14548
import java.io.InputStream;
import java.util.Scanner;

public class Main{
	static Scanner sc;

	public static void main(String[] args) throws Exception {
		//InputStream in = new FileInputStream("src/input.txt");
		InputStream in = System.in;

		sc = new Scanner(in);

		String str = sc.next();
		char c = str.charAt(0);

		switch(c){
		case 'a':
		case 'e':
		case 'i':
		case 'o':
		case 'u':
			System.out.println("vowel");
			break;
		default:
			System.out.println("consonant");
			break;
		}
	}
}

Measured memory_bytes: 9684
"""
1.4種類の文字ATGC
2.AGCを作ってはならない
3.隣り合う文字を1箇所だけ入れ替えても、AGCになってはならない

3. が厄介
変えないAGC 
0-1 A*GC
1-2 GAC
2-3 ACG
3-4 AG*C

とりあえず3文字分テーブルに持たせながらdp？
"""

mod = 10**9 + 7
N = int(input())
dp =[[[[0]*5 for i in range(5)] for j in range(5)] for n in range(108)]

nul = 0
A = 1
G = 2
C = 3
T = 4

"""
AGC
0-1 A*GC
1-2 GAC
2-3 ACG
3-4 AG*C
"""
dp[0][0][0][0] = 1
for n in range(N):
    for n3 in range(5):             # 3つ前
        for n2 in range(5):         # 2つ前
            for n1 in range(5):     # 1つ前
                for s in range(1,5):  # 今
                    if n2 == A and n1 == G and s == C: continue
                    if n3 == A and n1 == G and s == C: continue
                    if n2 == G and n1 == A and s == C: continue
                    if n2 == A and n1 == C and s == G: continue
                    if n3 == A and n2 == G and s == C: continue
                    # print(n,n1,n2,n3,s)
                    dp[n+1][n2][n1][s] += dp[n][n3][n2][n1]                    
ans = 0
for i in range(5):
    for j in range(5):
        for k in range(5):
            ans += dp[N][i][j][k]
print(ans%mod)

Measured memory_bytes: 3572
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#define inf 2147483647
#define eps 1e-9
using namespace std;
typedef long long ll;
ll n,k,ans,cnt=0,t[500001],f[100001],num[100001],l[100001],r[100001],pre[100001],a[100001],b[100001];
void pd(ll u){
    if(!t[u])return;
    t[u*2]=t[u*2+1]=t[u];
    t[u]=0;
}
void updata(int l,int r,int u,int L,int R,int v){
    if(L>R)return;
    if(L<=l&&r<=R){
        t[u]=v;
        return;
    }
    int mid=(l+r)/2;
    pd(u);
    if(L<=mid)updata(l,mid,u*2,L,R,v);
    if(mid<R)updata(mid+1,r,u*2+1,L,R,v);
}
int query(int l,int r,int u,ll x){
    if(l==r)return t[u];
    int mid=(l+r)/2;
    pd(u);
    if(x<=mid)return query(l,mid,u*2,x);
    else return query(mid+1,r,u*2+1,x);
}
ll _query(ll x){
    ll t=query(1,cnt,1,x);
    if(!t)return t;
    return f[t]+(num[l[t]]-num[x]+k)%k;
}
int main(){
    scanf("%lld%lld",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%lld%lld",&a[i],&b[i]);
        pre[i]=a[i]+pre[i-1];
        if(a[i]*2>k&&b[i]==1)return printf("-1"),0;
    }
    for(int i=i;i<=n;i++){
        if(b[i]==1){
            l[i]=(-2*pre[i-1]%k+k)%k;
            r[i]=(-2*pre[i]%k+k)%k;
        }else l[i]=0,r[i]=k-1;
        num[++cnt]=l[i];
        num[++cnt]=r[i];
    }
    sort(num+1,num+cnt+1);
    cnt=unique(num+1,num+cnt+1)-num-1;
    for(int i=n;i;i--){
        l[i]=lower_bound(num+1,num+cnt+1,l[i])-num;
        r[i]=lower_bound(num+1,num+cnt+1,r[i])-num;
        f[i]=_query(l[i]);
        if(l[i]>r[i])updata(1,cnt,1,r[i]+1,l[i]-1,i);
        else updata(1,cnt,1,1,l[i]-1,i),updata(1,cnt,1,r[i]+1,cnt,i);
    }
    ans=f[1];
    for(int i=cnt;i;i--){
        ans=min(ans,_query(i));
    }
    printf("%lld",ans+pre[n]*2);
    return 0;
}

Measured memory_bytes: 8448
#include <stdio.h>
#include <string.h>
    
int main(int argc, const char * argv[]) {
    int i,j,m,h;
    char s[301],s1[301],s2[301];
    
    while(1){
        scanf("%s",s);
        if(s[0] == '-') break;
        scanf("%d",&m);
        for(i=0;i<m;i++){
            scanf("%d",&h);
            strcpy(s1,s);
            strcpy(s2,s);
            strcat(s1,s2);
            for(j=0;j<strlen(s)*2;j++){
                s1[j] = s1[j+h];
            }
            for(j=0;j<strlen(s);j++){
                s[j] = s1[j];
            }
        }
        for(i=0;i<strlen(s);i++){
            printf("%c",s[i]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 588
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    fast;
    ll a; cin>>a;
    vec<ll> x(a), y(a);
    for(int q=0; q<a; q++) cin>>x[q]>>y[q];
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    if(a&1){
        ll L = x[a/2], R = y[a/2];
        cout<<R-L+1;
    }
    else{
        ll L = x[a/2-1] + x[a/2];
        ll R = y[a/2-1] + y[a/2];
        cout<<R-L+1;
    }
}

Measured memory_bytes: 6404
#include<stdio.h>

int isPrime(int x){

  int i;

  if(x < 2) return 0;
  else if(x == 2) return 1;
  if(x % 2 == 0) return 0;
  for(i = 3;i*i <= x;i+=2){
    if(x % i == 0) return 0;
  }
  return 1;
}

int main(){

  int n,x,i;
  int count = 0;

  scanf("%d",&n);
  for(i = 0;i < n;i++) {
    scanf("%d",&x);
    if(isPrime(x))count++;
  }
  printf("%d\n",count);

  return 0;
}

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

int main(){
    int n;
    scanf("%d", &n);
    int x[n], y[n];
    for(int i = 0; i < n; i++) scanf("%d%d", &x[i], &y[i]);
    //int counter = 0;
    double a[n], b[n];
    for(int i = 0; i < n; i++) {
        a[i] = (double) x[i];
        b[i] = (double) y[i];
    }
    double l = 0;
    if (n == 2)  l = sqrt(pow((a[0] - a[1]),  2) +  pow((b[0] - b[1]),  2));
    else{
        for(int i = 0; i < n; i++){
            for(int j = i + 1; j < n; j++){
                l += sqrt(pow((a[i] - a[j]),  2) +  pow((b[i] - b[j]),  2));
            }
        }
        l = l*2/n;
    }
    printf("%f", l);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int N = Integer.parseInt(sc.next());
      int X = Integer.parseInt(sc.next());
      
      int i = 0;
      int D = 0;
      while(D <= X && i < N) {
          D = D + Integer.parseInt(sc.next());
          i++;
      }
      if(D<=X)
	      System.out.println(N+1);
	  else
	      System.out.println(i);

      sc.close();
      
  }
}

Measured memory_bytes: 22996
### constant

QMAT = [
  [[ 1, 0], [ 1, 1], [ 1, 2], [ 1, 3]],
  [[ 1, 1], [-1, 0], [ 1, 3], [-1, 2]],
  [[ 1, 2], [-1, 3], [-1, 0], [ 1, 1]],
  [[ 1, 3], [ 1, 2], [-1, 1], [-1, 0]],
]

### main

while true
  n = gets.strip.to_i
  break if n == 0

  n.times do
    quats = gets.strip.split(' ').map{|s| s.to_i}
    q0 = quats[0, 4]
    q1 = quats[4, 4]
    #p [q0, q1]

    qa = [0] * 4

    for i in (0..3)
      q0i = q0[i]
      for j in (0..3)
        q1j = q1[j]
        sign, k = QMAT[i][j]
        qa[k] += q0i * q1j * sign
      end
    end

    puts qa.join(' ')
  end
end

Measured memory_bytes: 6128
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int x = c-a;
    int y = d-b;
    cout<<c-y<<' '<<d+x<<' '<<a-y<<' '<<b+x;
    return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d%d", $N, $C);
for($i = 0; $i < $N; $i++){
    fscanf(STDIN, "%d%d%d", $f, $t, $c);
    $F[$c][] = $f;
    $T[$c][] = $t;
}
for($c = 1; $c <= $C; $c++){
    sort($F[$c]);
    sort($T[$c]);
}
for($c = 1; $c <= $C; $c++){
    for($i = 0, $I = count($F[$c]) - 1; $i < $I; $i++){
        if($T[$c][$i] == $F[$c][$i+1]){
            unset($T[$c][$i]);
            unset($F[$c][$i+1]);
        }
    }
}
for($i = 0; $i <= 100010; $i++){
    $imos[$i] = 0;
}
foreach($F as $ff){
    foreach($ff as $f){
        $imos[$f-1]++;
    }
}
foreach($T as $tt){
    foreach($tt as $t){
        $imos[$t]--;
    }
}
$current = 0;
$max = 0;
for($i = 0; $i <= 100010; $i++){
    $current+=$imos[$i];
    if($current > $max){
        $max = $current; 
    }
}
echo $max,"\n";

Measured memory_bytes: 25080
H, W, K = map(int, input().split())
dp = [[0]*(W+2) for _ in range(H+1)]
dp[0][1] = 1
mod = 10**9+7
for i in range(H):
    for j in range(1, W+1):
        t_1 = 0
        t_2 = 0
        t_3 = 0
        for k in range(2**(W-1)):
            s = format(k, "b")
            p = 0
            if len(s) != W-1:
                s = "0"*(W-1-len(s)) + s
            for l in range(1, len(s)):
                if s[l-1] == "1" and s[l] == "1":
                    p = 1
                    break
            q = 0
            if p == 0:
                if 0 <= j - 2 < len(s):
                    if s[j-2] == "1":
                        t_1 += 1
                        q = 1
                if j-1 < len(s):
                    if s[j-1] == "1":
                        t_3 += 1
                        q = 1
                if q == 0:
                    t_2 += 1
        dp[i+1][j-1] += dp[i][j]*t_1
        dp[i+1][j] += dp[i][j]*t_2
        dp[i+1][j+1] += dp[i][j]*t_3
        dp[i+1][j-1] %= mod
        dp[i+1][j] %= mod
        dp[i+1][j+1] %= mod

print(dp[H][K])

Measured memory_bytes: 75108
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(ll i=(x);i<(y);i++)
#define RREP(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
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();}

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class BDigits {
public:
    void solve(std::istream& in, std::ostream& out) {
        ll N, K;
        in >> N >> K;
        REP(i,0,100) {
            if (pow(K,i)<= N && N < pow(K,i+1)) {
                out << i+1 << endl;
                return;
            }
        }
    }
};


signed main() {
    BDigits solver;
    std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 512
import java.io.*;

public class Main {
  
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s = r.readLine();
    String sl[] = s.split(" ");
    int a = Integer.parseInt(sl[0]);
    int b = Integer.parseInt(sl[1]);
    int v = 0;
    for(int i = a; i <= b; i++)
    {
      if(i % 10 == i / 10000 && i / 10 % 10 == i / 1000 % 10)
      {
        v++;
      }
    }
    System.out.println(v);
  }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
using ll=long;
#define V v[i]

int main(){
  ll t;cin>>t;
  while(t--){
    ll n,Q=0;cin>>n;
    vector<ll>v(n),N;
    for(ll &p:v)cin>>p;
    string s;cin>>s;
    for(ll i=n-1;i>=0;i--){
      for(ll p:N)V=min(V,V^p);
      N.push_back(V);
      Q|=s[i]=='1'&&V;
    }
    cout<<Q<<endl;
  }
}


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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)

int main(void){
  long long a,b,c,k;
  cin>>a>>b>>c>>k;
  long long maxi= max(a,b);
  maxi=max(maxi,c);

  long long sum=a+b+c-maxi;
  r(i,k)maxi*=2;
  cout<<sum+maxi<<endl;


return 0;}


Measured memory_bytes: 256
package main

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

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)
	writer := bufio.NewWriter(os.Stdout)

	var n int

	fmt.Sscan(getNextLine(scanner), &n)

	fmt.Printf("%.8f %.8f\n", 0.0, 0.0)
	koch(Point{x: 0.0, y: 0.0}, Point{x: 100.0, y: 0.0}, n)
	fmt.Printf("%.8f %.8f\n", 100.0, 0.0)

	writer.Flush()
}

func koch(p1, p2 Point, n int) {
	if n == 0 {
		return
	}
	th := math.Pi / 3.0
	points := make([]Point, 3)
	points[0].x = p1.x + (p2.x-p1.x)/3.0
	points[0].y = p1.y + (p2.y-p1.y)/3.0
	points[2].x = p1.x + (p2.x-p1.x)*2.0/3.0
	points[2].y = p1.y + (p2.y-p1.y)*2.0/3.0
	points[1].x = (points[2].x-points[0].x)*math.Cos(th) - (points[2].y-points[0].y)*math.Sin(th) + points[0].x
	points[1].y = (points[2].x-points[0].x)*math.Sin(th) + (points[2].y-points[0].y)*math.Cos(th) + points[0].y

	koch(p1, points[0], n-1)
	fmt.Printf("%.8f %.8f\n", points[0].x, points[0].y)
	koch(points[0], points[1], n-1)
	fmt.Printf("%.8f %.8f\n", points[1].x, points[1].y)
	koch(points[1], points[2], n-1)
	fmt.Printf("%.8f %.8f\n", points[2].x, points[2].y)
	koch(points[2], p2, n-1)

}

type Point struct {
	x float64
	y float64
}



Measured memory_bytes: 1256
# Your code here!
use strict;
use warnings;
#use bignum;

my $N = <STDIN>;
my @a = split(/ /, <STDIN>);
chomp($a[$N-1]);
print(calc());


sub calc
{
    for( my $i=0; $i < $N; $i ++ )
    {
        
        if( $a[$i] == 0 )
        {
            return 0;
        }
    }
    
    my $val = 1;
    for( my $i=0; $i < $N; $i ++ )
    {
        
        if( 1e18 / $a[$i] < $val )
        {
            return -1;
        }
        
        $val *= $a[$i];
    }
    
    use bignum;
    if( 1e18 < $val )
    {
        return -1;
    }
    
    return $val;
}

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

double ave(vector<double> &vd) {
    double sum = 0;
    for (auto n : vd) sum += n;
    return sum / vd.size();
}

double variance(vector<double> vd, double m) {
    double sum = 0;
    for (auto n : vd) sum += pow((n - m), 2);
    return sqrt(sum / vd.size());
}

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

    while (true) {
        int n;
        cin >> n;
        if (n == 0)
            break;

        vector<double> vd;
        rep(i, n) {
            int input;
            cin >> input;
            vd.push_back(input);
        }

        double m = ave(vd);
        double var = variance(vd, m);

        cout << fixed << setprecision(10) << var << endl;
    }
    return 0;
}


Measured memory_bytes: 3284
n,t = map(int, input().split())

a = list(map(int,input().split()))

ans = 0
for i in range(0,n):
  if i != n-1:
    if t > a[i+1] - a[i]:
      ans += a[i+1] - a[i]
    else:
      ans += t
  else:
    ans += t
print(ans)

Measured memory_bytes: 26708
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorders
{
	public class Program
	{
		static void Main(string[] args)
		{
			var xy = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int x1 = xy[0];
			int y1 = xy[1];
			int x2 = xy[2];
			int y2 = xy[3];

			int dx = x2 - x1;
			int dy = y2 - y1;
			string ans = $"{x2 - dy} {y2 + dx} {x1 - dy} {y1 + dx}";
			Console.WriteLine(ans);
		}
	}
}

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

signed main(){
  int n,t,nt;
  double f,nf,a,x,y,na,nx,ny;
  cin>>n;
  cin>>f>>a>>t>>x>>y;
  vector<P>v[2];
  r(i,n-1){
    cin>>nf>>na>>nt>>nx>>ny;

    if(t==nt && a!=na){
      double len = sqrt((x-nx)*(x-nx)+(y-ny)*(y-ny));
      v[t].push_back(P(-len,(nf-f)/60));
    }
    a=na;
    f=nf;
    x=nx;
    y=ny;
    t=nt;
  }

  r(i,2)sort(v[i].begin(),v[i].end());

  r(i,2){
    if((int)v[i].size()==0)cout<<"-1 -1"<<endl;
    else{
      printf("%.9f %.9f\n",-v[i][0].first,v[i][0].second);
    }
  }
}



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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl



signed main() {

	int N, K;
	cin >> N >> K;

	double ans = 0.0;

	for (int i = 1; i <= N; i++) {
		double p = 1.0;
		int i1 = i;
		while (i1 < K) {
			i1 *= 2;
			p *= 0.5;
		}
//		cerr << p / N << endl;
		ans += p / N;
	}
	cout << setprecision(15) << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <cmath>
#include <math.h>
#include <ctime>
#include <cstring>
#include <climits>
#include <sstream>
#include <array>
#include <tuple>
#include <set>
#include <iterator>
#include <cstdio>
#include <string>
#include <stack>
#include <valarray>
#include <utility>
#include <iomanip>
#include <list>
#include <numeric>
#include <regex>
#include <map>
#include <queue>
#include <deque>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll          long long
#define PI          3.1415926535897932384626433832795028841971 
#define pb          push_back
#define ins         insert
#define INF         LLONG_MAX
#define mk          make_pair
#define lb(v,x)     lower_bound(all(v),x)
#define ub(v,x)     upper_bound(all(v),x)
#define ff          first
#define ss          second
#define rev         reverse
#define uset        unordered_set
#define umap        unordered_map
#define endl        "\n"
#define max3(x,y,z)  max(x,max(y,z))
#define min3(x,y,z)  min(x,min(y,z))
#define sz(a)       (ll)a.size()
#define double      long double
#define minpq       priority_queue <ll,vector<ll>,greater<ll> > 
#define fill(x,y)   memset(x,y,sizeof(x))
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define MOD         1000000007 //1e9+7
#define bp(n)       __builtin_popcountll(n)
#define mxt(a)      *(max_element(a.begin(),a.end()))
#define mnt(a)      *(min_element(a.begin(),a.end())
#define unique_sort(c) (sort(all(c)), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define rep(i, a, b) for(ll i = (a); i<= (b); ++i)
#define trav(a, x) 	 for(auto &a : x)
#define re(i,n)      for(ll i = 0; i < n; ++i) 
const ll N = 2e5 + 7;
typedef pair<ll,ll>   pii;
typedef vector<pii>   vpii;
typedef vector<ll>    vll;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x);y=y>>1;x=(x*x);}return res;}
template<typename T> T gcd(T a,T b){ if(a==0) return b; return gcd(b%a,a); }
template<typename T> T powm(T a,T b, ll m){T cnt=1; while(b>0){ if(b%2==1) cnt=(cnt*a)%m; b/=2; a=(a*a)%m; }return cnt%m;}
ll ncr(ll n,ll r){ll res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}
ll sqr(ll x) { return x * x;}
// always use 1ll*ans to avoid signed integer overflow; 
void prec(){
	
}
ll n,m,u,v,dis[N];
vll ad[N];
bool vis[N];
void solve(){
	cin>>n>>m;
	while(m--){
		cin>>u>>v;
		ad[u].pb(v);
		ad[v].pb(u);
	}
	dis[1]=0;
	queue <ll> q;
	q.push(1);
	vis[1]=true;
	while(!q.empty()){
		ll to=q.front();
		q.pop();
		for(auto it:ad[to]){
			if(!vis[it]){
				dis[it]=to;
				vis[it]=1;
				q.push(it);
			}
		}
	}
	int flag=1;
	rep(i,1,n) if(!vis[i]) flag=0;
	if(flag){
		cout<<"Yes\n";
		rep(i,2,n) cout<<dis[i]<<endl;
	}
	else cout<<"No\n";
}
int main()
{
    ios;
    int tc=1;
    //cin>>tc;
    prec();
    while(tc--)
    	solve();
    return 0; 
}


Measured memory_bytes: 15080
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = (int)1e7;  
using  p = pair<string,int>;
int h,w;
auto s = vector<vector<char> >();
auto dx = vector<int>({-1,0,1,0});
auto dy = vector<int>({0,1,0,-1});
      
int dfs(int x,int y){

   if(s[x][y]=='#'){
      s[x][y]='.';
   }else{
      return 0;
   }

   ll ans = 0;
   for (int i = 0; i < 4; i++)
   {
      auto nx = dx[i]+x;
      auto ny = dy[i]+y;
      if(0<=nx&&nx<h&&0<=ny&&ny<w){
         if(s[nx][ny]=='#')
            ans +=dfs(nx,ny)+1;
      }
   }
   
   return ans;
}

int main(){
   cin >> h >> w;
   s = vector<vector<char> >(h+1,vector<char>(w+1,'.'));

   ll check = 0;
   for (int i = 0; i < h; i++)
   {
      for (int j = 0; j < w; j++)
      {
         char t;
         cin >> t;
         if(t=='#') check++; 
         s[i][j] =t;
      }
   }
   
   ll ans = 0;
   for (int i = 0; i < h; i++)
   {
      for (int j = 0; j < w; j++)
      {
         auto c = dfs(i,j);
         if(c!=0) ans += c+1; 
      }
   }
   
   if(ans==check){
      cout << "Yes";
   }else{
      cout << "No";
   }
}
  
  

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// leave to tomorrow anything that can be done today
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e17 + 9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int vet[5];
    int ans=0;
    rep(i,0,5){
        cin>>vet[i];
        if(vet[i]==0)ans=i;
    }
    cout<<ans+1<<"\n";
    return 0;   
}   

Measured memory_bytes: 3572
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iterator>
#include <set>
#include <functional>

using namespace std;

#define DT long long
#define forn(i,n)for(i=0;i<n;i++)
#define forc(i,c,n)for(i=c;i<=n;i++)
#define all(x) (x).begin(), (x).end()


int main() {
	ifstream fin("Text.txt");
	DT i, j, q;
	DT a=-1, b, n, m,x;
	string st;
	cin >> x;
	a = x / 11;
	b = x % 11;
	a *= 2;
	if (b) {
		if (b > 6)
			a += 2;
		else
			a++;
	}
	cout << a << endl;
	return 0;
}

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

/*?????????????????¨????§???????*/
typedef struct pp 
{
    char name[100];
    int t;
} p;

p q[LEN];
int head, tail, n;

void enqueue(p x)
{
    q[tail] = x;
    tail = (tail + 1) % LEN;
}

p dequeue() 
{
    p x = q[head];
    head = (head + 1) % LEN;
    return x;
}

int min(int a, int b) 
{
    return a < b ? a : b;
    
}

int main() 
{
    int elaps = 0, c;
    int i, time;
    p u;
    scanf("%d %d", &n, &time);

    /*??¨??????????????????????????\??????????????????????????????*/

    for ( i = 1; i <= n; i++) {
        scanf("%s", q[i].name);
        scanf("%d", &q[i].t);
        
    }
    head = 1;
    tail = n + 1;
    /*????????\??¬????????§???*/
    while ( head != tail) {
        u = dequeue();
        c = min(time, u.t);
        u.t -= c;
        elaps += c;
        if (u.t > 0) {
            enqueue(u);
            
        } else {
            printf("%s %d\n", u.name, elaps);
            
        }
        
      
        
    }
    return 0;
    

}

Measured memory_bytes: 11184
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  string a, b; cin >> a >> b;
  if (a.size() == b.size()) {
    for (int i = 0; i < b.size(); i++) {
      cout << a[i] << b[i];
    }
    cout << endl;
  } else {
    for (int i = 0; i < b.size(); i++) {
      cout << a[i] << b[i];
    }
    cout << a.back() << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> color(210); // R : 0, B : 1
vector<int> ans(210);
int n = 0;
void pcolor(int pos)
{
    cout << "? ";
    for(int i = pos; i < pos+n; i++)
    {
        cout << i << " ";
    }
    cout << endl << flush;
    string c;
    cin >> c;
    if(c == "Red") color[pos] = 0;
    else color[pos] = 1;
}
void detcolor(int cand, int pos)
{
    cout << "? ";
    for(int i = pos; i < pos+n-1; i++)
    {
        cout << i << " ";
    }
    cout << cand;
    cout << endl << flush;
    string c;
    cin >> c;
    if(c == "Red") ans[cand] = 0;
    else ans[cand] = 1;
}
void detcolor(int cand, int pos1, int pos2)
{
    cout << "? ";
    for(int i = 1; i <= pos1; i++)
    {
        cout << i << " ";
    }
    for(int i = pos2; i <= 2*n; i++)
    {
        cout << i << " ";
    }
    cout << cand;
    cout << endl << flush;
    string c;
    cin >> c;
    if(c == "Red") ans[cand] = 0;
    else ans[cand] = 1;
}

int main()
{
    cin >> n;
    int h = n+1;
    int l = 1;
    pcolor(l);
    pcolor(h);
    while(h - l > 1)
    {
        int m = (h+l) >> 1;
        pcolor(m);
        if(color[m] == color[h]) h = m;
        else l = m;
    }
    ans[l] = color[l];
    ans[l+n] = color[h];

    for(int i = 1; i < l; i++)
    {
        detcolor(i, l+1);
    }
    for(int i = l+n+1; i <= 2*n; i++)
    {
        detcolor(i, l+1);
    }
    for(int i = l+1; i < l+n; i++)
    {
        detcolor(i, l-1, l+n+1);
    }
    cout << "! ";
    for(int i = 1; i <= 2*n; i++)
    {
        if(ans[i] == 0) cout << 'R';
        else cout << 'B';
    }
    cout << endl << flush;
    return 0;
}


Measured memory_bytes: 724
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let s: String = read!(String);
    let sc: Vec<char> = s.chars().collect();

    let mut cnt_a = 0;
    let mut ans = 0usize;
    let mut i = 0;
    while i < sc.len() - 1 {
        if sc[i] == 'A' {
            cnt_a += 1;
            i += 1;
        } else if sc[i] == 'B' && sc[i + 1] == 'C' {
            ans += cnt_a;
            i += 2;
        } else {
            cnt_a = 0;
            i += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int a;
  if(N%2==0){
	a=N/2;
  }else{
    a=N/2+1;
  }
	double p;
  	double n=N;
  	double A=a;
  p=A/n;
  cout<<p<<endl;
}

Measured memory_bytes: 256