akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using LL = long long;
LL n, m;

signed main() {
  // freopen("in", "r", stdin);
  while(cin >> n >> m) {
    cout << (100LL * (n - m) + 1900 * m) * (1LL << m) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
N, W = map(int, input().split())
v = [0]*110
w = [0]*110
dp = [[0]*10010 for _ in range(110)]
for i in range(N):
    v[i], w[i] = map(int, input().split())

for i in range(N):
    for j in range(W+1):
        if j >= w[i]:
            dp[i+1][j] = max(dp[i][j-w[i]] + v[i], dp[i][j], dp[i+1][j-w[i]]+ v[i])
        else:
            dp[i+1][j] = dp[i][j]

print(dp[N][W])


Measured memory_bytes: 42608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define all(v) (v).begin(), (v).end()

int main() {
    string s;
    cin >> s;
    int q;
    cin >> q;

    bool rev = false;

    rep(i, q){
        int qt;
        cin >> qt;
        if(qt == 1){
            // 反転処理
            rev = !rev;
        }
        if(qt == 2){
            int pos;
            string qs;
            cin >> pos;
            cin >> qs;
            if(pos == 2){
                if(rev){
                    s.insert(0, qs);
                }
                else{
                    s += qs;
                }
            }
            else{
                if(!rev){
                    s.insert(0, qs);
                }
                else{
                    s += qs;
                }               
            }
        }
    }
    if(rev)reverse(all(s));

    cout << s;
}

Measured memory_bytes: 900
($n,$a,$b) = glob<>;
$ans=0;
for (1..$n){
    $sum = 0;
    $i = $_;
    while ($i > 0){
        $sum += $i % 10;
        $i /= 10;
    }
    $ans += $_ if $a <= $sum && $sum <= $b;
}
print $ans;

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

int main() {
  int N;
  cin >> N;
  
  int MAX=0;
  int SUM=0;
  
  for(int i=0;i<N;i++){
    int p;
    cin >> p;
    
    if(p>=MAX)
      MAX=p;
    
    SUM+=p;
  }
  int a=SUM-(MAX/2);
  
  cout << a<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

vector<int> fact;
vector<int> ifact;
vector<int> inv;
vector<int> pow2;
const int MOD = 998244353;
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}
int choose(int a, int b)
{
	if(a<b) return 0;
	if(b==0) return 1;
	if(a==b) return 1;
	return mult(fact[a],mult(ifact[b],ifact[a-b]));
}
int inverse(int a)
{
	return modpow(a,MOD-2);
}
void init(int _n)
{
	fact.clear(); ifact.clear(); inv.clear(); pow2.clear();
	fact.resize(_n+1);
	ifact.resize(_n+1);
	inv.resize(_n+1);
	pow2.resize(_n+1);
	pow2[0]=1;
	ifact[0]=1;
	fact[0]=1;
	for(int i=1;i<=_n;i++)
	{
		pow2[i]=add(pow2[i-1],pow2[i-1]);
		fact[i]=mult(fact[i-1],i);
		//ifact[i]=mult(ifact[i-1],inv[i]);
	}
	ifact[_n] = inverse(fact[_n]);
	for(int i=_n-1;i>=1;i--)
	{
		ifact[i] = mult(ifact[i + 1], i + 1);
	}
	for(int i=1;i<=_n;i++)
	{
		inv[i] = mult(fact[i-1],ifact[i]);
	}
}


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	init(900000);
	ll n,a,b,k; cin>>n>>a>>b>>k;
	int ans = 0;
	for(ll i=0;i<=n;i++)
	{
		int red = i;
		ll sum = k - a*red;
		if(sum%b==0)
		{
			sum/=b;
			if(sum>=0&&sum<=n)
			{
				int blue = sum;
				int coeff = mult(ifact[red], mult(ifact[n-red], fact[n]));
				coeff = mult(coeff, choose(n,blue));
				//coeff = combi.mult(coeff, combi.pow2[red]);
				/*
				for(int j=0;j<=min(red,blue);j++)
				{
					if(red+blue-j>n) continue;
					int coeff1 = mult(ifact[j],ifact[red-j]);
					int coeff2 = mult(fact[n], mult(ifact[n-red-blue+j], ifact[blue-j]));
					ans = add(ans, mult(coeff1,coeff2));
				}
				*/
				ans = add(ans,coeff);
			}
		}
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 14336
# coding: utf-8

max_v = 450

# デバッグ用の関数, 折り紙の状態を表示する
def show(origami):
    print "-----------"
    for i in origami:
        for j in i:
            print j,
        print
    print "-----------"

5
# 縦におる処理
def fold_a(origami, c, katan):
    t = max_v-1-katan-c

    for i in range(max_v):
        for j in range(c):
            origami[t-j][i] += origami[t+1+j][i]
            origami[t+1+j][i] = 0

    # show(origami)


# 横におる処理
def fold_b(origami, c, satan):
    t = satan+c

    for i in range(max_v):
        for j in range(c):
            origami[i][t+j] += origami[i][t-1-j]
            origami[i][t-1-j] = 0

    # show(origami)

while True:
    # n: 折り紙の幅, m: 折り紙の高さ
    # t: おる操作の回数 p: 穴を開ける操作の回数
    n, m, t, p = map(int, raw_input().split())

    # 終了条件
    if n == 0 and m == 0 and t == 0 and p == 0:
        break

    # 折り紙の初期条件, 大きめなリストを作る
    origami = [[0] * max_v for _ in range(max_v)]

    for i in range(n):
        for j in range(m):
            origami[-1-j][i] = 1

    # 下端, 左端
    katan, satan = 0, 0

    # t回折り紙をおる
    for i in range(t):
        d, c = map(int, raw_input().split())
        # dが1なら横に折る
        if d == 1:
            fold_b(origami, c, satan)
            satan += c
        # dが2なら縦に折る
        if d == 2:
            fold_a(origami, c, katan)
            katan += c

    # p回穴を開ける
    for i in range(p):
        x, y = map(int, raw_input().split())

        print origami[max_v-1-katan-y][satan+x]



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

#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define FORN(i, m, n) for(int (i) = (m); (i) <= (n); (i)++)
#define FORR(i, m, n) for(int (i) = (m); (i) >= (n); (i)--)
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

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

	co((n-1)/2);

	return 0;
}


Measured memory_bytes: 256
//template code, C343, 2019
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	public void printAdjMatrix() {
		int[][] adjMatrix = new int[totalVertex][totalVertex];
		//complete the following
		for (int i = 0; i < adjList.size(); i++) {
			for (int ii = 0; ii < adjList.get(i).size(); ii++) {
				adjMatrix[i][adjList.get(i).get(ii)] = 1;
			}
		}
		
		for (int i = 0; i < totalVertex; i++) {
			String out = "";
			for (int ii = 0; ii < totalVertex; ii++) {
				out += adjMatrix[i][ii];
				if (ii < totalVertex - 1) {
					out += " ";
				}
			}
			System.out.println(out);
		}
		
	}
}

//change class name GraphRepresentation to Main() for submission to AIZU
public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.printAdjMatrix();
	}
}


Measured memory_bytes: 48776
import unittest


class TestC(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think([2, 3, 1]), [3, 1, 2])

    def test_2(self):
        self.assertEqual(think([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5])

    def test_3(self):
        self.assertEqual(think([8, 2, 7, 3, 4, 5, 6, 1]), [8, 2, 4, 5, 6, 7, 3, 1])


def solve():
    a = read()
    result = think(a)
    write(result)


def read():
    n = read_int(1)[0]
    return read_int(n)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a):
    list_of_index_and_a = []
    for index, e in enumerate(a):
        list_of_index_and_a.append((index + 1, e))

    list_of_index_and_a.sort(key=lambda x: x[1])
    return [x[0] for x in list_of_index_and_a]


def write(result):
    print(' '.join(list(map(lambda x: str(x), result))))


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 25764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n= in.nextInt();
		int [] a= new int[n];
		for (int i = 0; i < a.length; i++) {
			a[i]= in.nextInt();
		}
		int [] b= new int[n];
		int midodd= n/2;
		int midev= n/2;
		if(n%2==0){
			for (int i = 0; i < b.length; i++) {
				if(i%2!=0){
					midodd--;
					b[midodd]= a[i];
				}
				else{
					b[midev]= a[i];
					midev++;
				}
			}
		}
		else{
			for (int i = 0; i < b.length; i++) {
				if(i%2!=0){
					midev++;
					b[midev]= a[i];
				}
				else{
					b[midodd]= a[i];
					midodd--;
				}
			}
		}
		
		for (int i = 0; i < b.length; i++) {
			out.print(b[i]+" ");
		}
		out.close();
		
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}

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

		public String next() throws IOException {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
				return next();
			}
			return st.nextToken();
		}

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

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



Measured memory_bytes: 55904
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }
        long ans = 0;
        for(int i = 0; i < n; i++){
            ans += a[i]-1;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 25764
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<map>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a>=b){
        for(int i=0;i<a;i++){
            cout<<b;
        }
    }
    else{
        for(int j=0;j<b;j++){
            cout<<a;
        }
    }
    cout<<endl;

    return 0;
}

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

#define NUM_MAX		1000001

int prime(int num_max)
{
	static int numary[NUM_MAX];
	static int primeary[NUM_MAX];
	static int primeary_len = 1;
	static int num = 2;
	primeary[0] = 2;
	numary[0] = 0;
	numary[1] = 0;
	numary[2] = 1;
	if(num_max > num)
	{
		for(num++;num <= num_max;num++)
		{
			int i;
			for(i = 0;i < primeary_len;i++)
			{
				if(!(num % primeary[i]))
				{
					numary[num] = numary[num-1];
					break;
				}
				else if(num < (primeary[i] * primeary[i]))
				{
					numary[num] = numary[num-1] + 1;
					primeary[primeary_len] = num;
					primeary_len++;
					break;
				}
			}
		}
	}
	return numary[num_max];
}

int main()
{
	int n;
	prime(999999);
	while(scanf("%d",&n) != EOF)
	{
		printf("%d\n",prime(n));
	}
}

Measured memory_bytes: 4260
def readinput():
    n,m=list(map(int,input().split()))
    a=[]
    for _ in range(n):
        a.append(input())
    b=[]
    for _ in range(m):
        b.append(input())
    return n,m,a,b

def main(n,m,a,b):
    for i in range(n-m+1):
        for j in range(n-m+1):
            for k in range(m):
                #print(a[i+k][j:j+m],b[k])
                if a[i+k][j:j+m]!=b[k]:
                    break
            else:
                return 'Yes'
    return 'No'

if __name__=='__main__':
    n,m,a,b=readinput()
    ans=main(n,m,a,b)
    print(ans)


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

/*
 * template.cpp
 *
 *  Created on: 2016/10/30
 *      Author: jin
 */
#define MYDEBUG
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <algorithm>

#ifdef MYDEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif
#define LL long long
#define ULL unsigned long long
#define eps 1e-14
using std::max;
using std::min;
using std::swap;
using std::cout;
using std::cin;
using std::scanf;
using std::printf;
using std::ostream;
using std::vector;
using std::endl;
using std::string;
using namespace std;

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
	out << "[";
	size_t last = v.size() - 1;
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i];
		if (i != last)
			out << ",";
	}
	out << "]";
	return out;
}

class AGC011 {
public:
	void A() {
		int N, C, K;
		cin >> N >> C >> K;
		vector<int> t(N);
		for (int i = 0; i < N; ++i) {
			cin >> t.at(i);
		}
		sort(t.begin(), t.end(), greater<int>());
		int i = 0;
		int ans = 0;
		while (i < t.size()) {
			int gotime = t.at(i);
			int count = 1;
			i++;
			while (i < t.size() && ((gotime - t.at(i)) <= K) && count < C) {
				count++;
				i++;
			}
			ans++;
		}
		cout << ans << endl;
	}

	void B() {

	}

	void C() {

	}

};

int main() {
	AGC011 p;
	p.A();
}


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



int main(){
    ll N,a[100010],b[100010],cn=0;
    cin>>N;
    rep(i,0,N)cin>>a[i]>>b[i];
    rep(i,0,N){
        a[N-1-i]+=cn;
        if(a[N-1-i]%b[N-1-i]!=0){
            cn+=b[N-1-i]-(a[N-1-i]%b[N-1-i]);
        }
    }
    cout<<cn<<endl;
}






Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;

namespace AtCoder
{
	public class Program
	{
		static void Main()
		{
			int n = int.Parse(Console.ReadLine());
			var s = new int[n];
			for (int i = 0; i < n; i++) {
				s[i] = int.Parse(Console.ReadLine());
			}

			int m = 10001;
			var dp = new bool[n + 1, m];
			dp[0, 0] = true;

			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					if (dp[i, j] == false) {
						continue;
					}

					dp[i + 1, j] = true;
					if (j + s[i] < m) {
						dp[i + 1, j + s[i]] = true;
					}
				}
			}

			for (int i = m - 1; i >= 0; i--) {
				if (dp[n, i] && i % 10 != 0) {
					Console.WriteLine(i);
					return;
				}
			}

			Console.WriteLine(0);
		}
	}
}

Measured memory_bytes: 28180
let int = parseInt;

function main(input){
    let lines = input.split("\n");
    let length = int(lines[0]);
    let cards = lines[1].split(" ");
    let bubbleSorted = bubble(length,cards);
    echoArray(bubbleSorted);
    judgeStable(cards,bubbleSorted);
    let selectSorted = select(length,cards);
    echoArray(selectSorted);
    judgeStable(cards,selectSorted);

}

function judgeStable(original,sorted){
    let stableSorted = bubble(original.length,original);
    let isStable = true;
    for(let i=0;i<stableSorted.length;i++){
        if(stableSorted[i]!==sorted[i]){
            isStable = false;
            break;
        }
    }
    if(isStable){
        console.log("Stable");
    }else{
        console.log("Not stable");
    }
    
    
}

function devide(array){
    let strArray = array.map(item=>item.slice(0,1));
    let numArray = array.map(item=>int(item.slice(1)));
    return {
        "strArray":strArray,
        "numArray":numArray
    }
}
function combine(strArr,numArr){
    let arr=[];
    for(let i=0;i<strArr.length;i++){
        arr[i] = strArr[i]+String(numArr[i])+" ";
    }
    return arr;
    
}
function echoArray(array){
    let put ="";
    for(let i=0;i<array.length;i++){
        put+=array[i];
    }
    console.log(put.trim());
}

function bubble(N,array){
    const devided = devide(array);
    let strArray = devided.strArray;
    let numArray = devided.numArray;
    let swapped;
    let sortedIndex=0;
    
    do{
        swapped = false;
        for(let i=N;i>sortedIndex;i--){
         if(numArray[i]<numArray[i-1]){
             let temp = numArray[i];
             numArray[i] = numArray[i-1];
             numArray[i-1] = temp;
             let strTemp = strArray[i];
             strArray[i] = strArray[i-1];
             strArray[i-1] = strTemp;
             swapped = true;
             
         }
        }
        sortedIndex++;
    }while(swapped);
    
    let result = combine(strArray,numArray);
    return result;
}

function select(N,array){
    const devided = devide(array);
    let strArr = devided.strArray;
    let numArr = devided.numArray;
    
    let minIndex=0;
    
    for(let i=0;i<N;i++){
        minIndex = i;
        for(let j=i;j<N;j++){
            if(numArr[j]<numArr[minIndex]){
                minIndex = j;
            }
        }
        let temp = numArr[i];
        numArr[i] = numArr[minIndex];
        numArr[minIndex] = temp;
        let strTemp = strArr[i];
        strArr[i] = strArr[minIndex];
        strArr[minIndex] = strTemp;
    }
    let result = combine(strArr,numArr);
    return result;
    
    
    
}

main(require("fs").readFileSync("/dev/stdin","utf-8"));


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

#define rep(i, n) for(int i = 0; i < n; ++i)

using namespace std;

int a, b, c, d, e, t;

int main(){
  scanf("%d%d%d%d%d", &a, &b, &c, &d, &e);
  if(0 < a){
    t = (b - a) * e;
  }
  else if(b < 0){
    t = (b - a) * c;
  }
  else{
    t = b * e - a * c + d;
  }
  printf("%d\n", t);
  return 0;
}

Measured memory_bytes: 2672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n, k; cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h[i];

    sort(ALL(h));
    ll mini = INF;
    for (int i = 0; i + k - 1 < n; i++)
    {
        ll tmp = h[i + k - 1] - h[i];
        mini = min(mini, tmp);
    }
    cout << mini << endl;
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  cin >> n;
  int cnt[6] = {};
  for (int i = 0; i < n; i++) {
    double h;
    cin >> h;
    if (h < 165) cnt[0]++;
    else cnt[int(h - 165) / 5 + 1]++;
  }
  for (int i = 0; i < 6; i++) {
    cout << i + 1 << ":" << string(cnt[i], '*') << endl;
  }

  return 0;
}


Measured memory_bytes: 3232
#include <cmath>
#include <complex>
#include <algorithm>
#include <cassert>
using namespace std;

typedef long double Real;
typedef complex<Real> Point;
#define PCR Point const &
#define X real()
#define Y imag()

const Real EPS = 1e-10;
const Real INF = 1e100;
const Real PI = acos(-1);

struct Segment {
    Point p[2];
    Segment (PCR a = Point(), PCR b = Point()){
        p[0] = a, p[1] = b;
    }
    Point & operator [] (int k) { return p[k]; }
    Point const & operator [] (int k) const { return p[k]; }
};
typedef vector<Point> Polygon;
struct Circle { Real radius; Point center; };

Real dot(PCR a, PCR b){
    return a.X*b.X + a.Y*b.Y;
}
Real cross(PCR a, PCR b){
    return a.X*b.Y - a.Y*b.X;
}

Point pSP(Segment const & s, PCR p){
    Point base = s[1] - s[0];
    Real r = dot(p - s[0], base) / norm(base);
    return s[0] + base * r;
}

Point rSP(Segment const & s, PCR p){
    Point v = pSP(s,p) - p;
    return p + v * Real(2);
}

enum { LEFT = 1, RIGHT = -1, BACK = 2, FRONT = -2, ON = 0 };
// Includes end-points. Comment in to exclude.
int ccw(PCR x, PCR p, PCR q){
    Point a = p - x, b = q - x;
    if(cross(a,b) > EPS) return LEFT;
    if(cross(a,b) < -EPS) return RIGHT;
    if(/* abs(a) < EPS || */ dot(a,b) < -EPS) return BACK;
    if(/* abs(b) < EPS || */ norm(a) < norm(b)) return FRONT;
    return ON;
}

bool isParallel(Segment const & s, Segment const & t){
    return abs(cross(s[1]-s[0],t[1]-t[0])) < EPS;
}

bool isOrthogonal(Segment const & s, Segment const & t){
    return abs(dot(s[1]-s[0],t[1]-t[0])) < EPS;
}

// Includes end-points. Modify CCW to exclude
bool iSS(Segment const & s, Segment const & t){
    bool f1 = ccw(s[0],s[1],t[0]) * ccw(s[0],s[1],t[1]) <= 0;
    bool f2 = ccw(t[0],t[1],s[0]) * ccw(t[0],t[1],s[1]) <= 0;
    return f1 && f2;
}

bool iSP(Segment const & s, PCR p){
    return ccw(s[0],s[1],p) == ON;
}

Point cSS(Segment const & s, Segment const & t){
    assert(iSS(s,t));
    assert(!isParallel(s,t));
    Real d = cross(t[1]-t[0], s[1]-s[0]);
    return s[0] + (s[1] - s[0]) * cross(t[1]-t[0], t[1]-s[0]) * (1.0 / d);
}

Real dSP(const Segment & s, PCR p) {
    const Point r = pSP(s, p);
    if(iSP(s,r)) return abs(r-p);
    return min(abs(s[0]-p), abs(s[1]-p));
}

Real dSS(Segment const & s, Segment const & t){
    if(iSS(s,t)) return Real(0);
    return min(min(dSP(s,t[0]), dSP(s,t[1])), min(dSP(t,s[0]), dSP(t,s[1])));
}

#include <iostream>
#include <cstdio>

int main(){
    Segment s,t;
    Real x,y;
    int n; cin >> n;
    for(int i=0;i<n;i++){
        cin >> x >> y;
        s[0] = Point(x,y);
        cin >> x >> y;
        s[1] = Point(x,y);
        cin >> x >> y;
        t[0] = Point(x,y);
        cin >> x >> y;
        t[1] = Point(x,y);
        Real d = dSS(s,t);
        printf("%.10Lf\n", d);
    }
}

Measured memory_bytes: 1252
#include <iostream>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
using namespace std;

int H, A[10][5];
bool v[10][5];

int main(void) {
  while(cin >> H, H) {
    REP(i, 0, H) REP(j, 0, 5) cin >> A[H - i - 1][j];
    int ans = 0;
    bool cont = true;
    while(cont) {
      cont = false;
      REP(i, 0, H) REP(j, 0, 5) v[i][j] = false;
      REP(i, 0, H) REP(j, 0, 3) {
        if(A[i][j] != 0 && A[i][j] == A[i][j + 1] && A[i][j] == A[i][j + 2]) {
          v[i][j] = v[i][j + 1] = v[i][j + 2] = true;
          cont = true;
        }
      }
      REP(i, 0, H) REP(j, 0, 5) if(v[i][j]) ans += A[i][j];
      REP(j, 0, 5) REP(i, 0, H) {
        if(v[i][j]) {
          REP(k, i + 1, H) {
            A[k - 1][j] = A[k][j];
            v[k - 1][j] = v[k][j];
          }
          A[H - 1][j] = 0;
          v[H - 1][j] = false;
          i--;
        }
      }
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 3004
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s;
    int a[26] = {};
    cin >> s;
    for (char i : s) a[i - 'a']++;
    for (int i = 0; i < 26; i++) if (a[i] % 2) {
        cout << "No";
        return 0;
    }
    cout << "Yes";
}


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

#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define endl '\n'
#define int long long

typedef pair<int,int> pii;
const int N = 2e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, m, k;
int d;
int fact[N], r[N], rfact[N];
void init(){
	r[1] = 1;
	for(int i=2; i<N; i++){
		r[i] = MOD - (MOD/i)*r[MOD%i]%MOD;
	}
	fact[0] = rfact[0] = 1;
	for(int i=1; i<N; i++){
		fact[i] = fact[i-1]*i % MOD;
		rfact[i] = rfact[i-1]*r[i] % MOD;
	}
}
int C(int n, int k){
	if (n<0 || k<0 || k>n) return 0LL;
	return fact[n]*rfact[k] % MOD * rfact[n-k] % MOD;
}
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> m >> k;
	//calculate sum of all pairs manhatan distance
	int dx = 0, dy = 0;
	for(int i=1; i<n; i++){
		dx = (dx + i*(i+1)/2*m % MOD * m) % MOD;
	}
	for(int j=1; j<m; j++){
		dy = (dy + j*(j+1)/2*n % MOD *n) % MOD;
	}
	init();
	d = (dx + dy) % MOD;

	int ans = C(n*m-2, k-2)* d % MOD;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int a, b, t;
	cin >> a >> b >> t;

	cout <<  t / a * b << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

class UnionFind {
	vector<int>par, high;
public:
	UnionFind(int n) {
		par = high = vector<int>(n);
		for (int i = 0; i < n; i++)par[i] = i;
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (high[x] > high[y])par[y] = x;
		else {
			par[x] = y;
			if (high[x] == high[y])high[y]++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};
int a[10000],b[10000];
signed main(){
	int n,m;cin>>n>>m;
	rep(i,m){
		cin>>a[i]>>b[i];a[i]--;b[i]--;
	}
	int cnt=0;
	rep(i,m){
		UnionFind uf(n);
		rep(j,m){
			if(i==j)continue;
			uf.unite(a[j],b[j]);
		}
		bool flag=true;
		rep(j,n)rep(k,n){
			if(!uf.same(j,k))flag=false;
		}
		if(!flag)cnt++;
	}
	cout<<cnt<<endl;
}

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

int main(){
  long long int n,i;
  scanf("%lld",&n);
  long long int a[n];
  for(i=0;i<n;i++) {
    scanf("%lld",&a[i]);
  }
  long long int temp = a[0];
  for(i=1;i<n;i++) {
    long long int p = temp;
    long long int b = a[i];
    long long int r = p % b;
    while (r > 0) {
      p = b;
      b = r;
      r = p % b;
    }
    temp = b;
  }
  printf("%lld\n",temp);
  return 0;
}


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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
typedef long long ll;

int main() {
	string s; cin >> s;
	int N = s.length();
	cout << s.substr(0, N - 8) << endl;
}


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

template< class T >
int slide_smallest2(const vector<T>& v, T k) {
    map<T, int> m;
    int l=0, r;
    int ret = v.size() + 1;
    for (r = 0; r < v.size(); ++r) {
        if (v[r] > k) continue;
        m[v[r]] = r;
        while (m.size() == k) {
            ret = min(ret, r - l + 1);
            if (v[l] <= k && m[v[l]] == l) m.erase(v[l]);
            l++;
        }
    }
    if (ret == v.size() + 1) return 0;
    return ret;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> v(N);
    for (int i = 0; i < N; ++i) {
        cin >> v[i];
    }
    cout << slide_smallest2(v, K) << endl;
}



Measured memory_bytes: 7808
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
        int x,y;
        int tmp;
        while(true){
            x=scan.nextInt();
            y=scan.nextInt();
            if(x==0&&y==0)System.exit(0);
            if(x>y){
                tmp=x;
                x=y;
                y=tmp;
            }
            System.out.println(x+" "+y);
        }
   }
}


Measured memory_bytes: 36512
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	string s;
	cin>>s;
	int ans=700;
	fx(s.size()){
		if(s.at(x)=='o'){
			ans+=100;
		}
	}
	ce(ans)
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  string S,T;
  cin>>S>>T;
  ll ans=0;
  for(ll i=0;i<3;i++) {
if(S[i]==T[i]) {
ans++;
}
  }
  
  cout<<ans<<endl;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

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

ll N;
ll ans = 0;

void solve() {
    cin >> N;
    multiset<ll> st;
    ll cur = 0;
    rep(i,N) {
        ll a;
        cin >> a;
        st.insert(a^(a-1));
        cur ^= a;
    }
    for (ll i = 30; i >= 0; --i) {
        if ((cur >> i) & 1) {
            if (!st.count((1 << (i+1)) - 1)) {
                cout << -1 << endl;
                return;
            }
            cur ^= (1 << (i+1)) - 1;
            ans++;
        }
    }
    cout << ans << endl;
}

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


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

vector<vector<int>>arr;
vector<int>vis;

void dfs(int a)
{
    if(vis[a]==1)
    {
        return ;
    }
    vis[a]=1;
    for(int i=0;i<arr[a].size();i++)
    {
        dfs(arr[a][i]);
    }
    return ;
}

int main()
{
    int n,m;
    cin>>n>>m;
    arr.resize(n+1,vector<int>());
    vis.resize(n+1,0);
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        arr[x].push_back(y);
        arr[y].push_back(x);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(vis[i]==0)
        {
            dfs(i);
            ans++;
        }
    }
    cout<<ans-1<<endl;
    

    return 0;
}

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

int main(){
  int m, n, i, j;
  int flag = 0;
  cin >> n >> m;
  char a[n][n];
  char b[m][m];
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      cin >> a[i][j];
    }
  }
  
  for(i = 0; i < m; i++){
    for(j = 0; j < m; j++){
      cin >> b[i][j];
    }
  }
  
  int h = 0;
  int w = 0;
  int num = 0;
  int mm = m * m;
  int sub = n - m;
  while(w <= sub){
    while(h <= sub){
      for(i =  h; i < m + h; i++){
	for(j = w; j < m + w; j++){
	  if(a[i][j] == b[i - h][j - w]) {
	    num++;
	  }
	}
      }
      if(num == mm){
	flag = 1;
	break;
      }
      num = 0;
      h++;
    }
    h = 0;
    w++;
  }
  
  if(flag) printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 256
using System.Collections.Generic;
using System.Linq;
using System;

public class P
{
    public int L { get; set; }
    public int r { get; set; }
}

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var te = new List<P>();
        for (int i = 0; i < m; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var a = int.Parse(line[0]);
            var b = int.Parse(line[1]);
            te.Add(new P { L = a, r = b });
        }
        var ps = te.OrderBy(x => x.r).ToArray();
        var ans = new List<int>();
        ans.Add(ps[0].r - 1);
        for (int i = 1; i < m; i++)
            if (!check(ans, ps, i)) ans.Add(ps[i].r - 1);
        Console.WriteLine(ans.Count());
    }
    public static bool check(List<int> ans, P[] ps, int i)
    {
        foreach (var x in ans)
            if (x >= ps[i].L && x <= ps[i].r) return true;
        return false;
    }
}


Measured memory_bytes: 27716
A,B,H,M=map(int,input().split())
import numpy as np
X=(H/12+M/(12*60)-M/60)*2*np.pi
if X<=np.pi:
  Y=X
else:
  Y=2*np.pi-X
print(np.sqrt((A-B*np.cos(Y))**2+(B*np.sin(Y))**2))

Measured memory_bytes: 27208
#include<bits/stdc++.h>
using namespace std;
int n,i,z,lst;
struct edge{
	int u,v,w;
};
vector<edge>e;
int main(){
	scanf("%d",&n);
	if(n==2) {
		puts("2 2");
		puts("1 2 0");
		puts("1 2 1");
		return 0;
	}
	for(z=1;1<<z<=n;++z);
	for(i=1;i<z;++i)e.push_back((edge){i,i+1,0}),e.push_back((edge){i,i+1,1<<(i-1)}); 
	lst=1<<(z-1);
	for(i=z-1;i;--i){
		int x=1<<(i-1);
		if(lst+x<=n)e.push_back((edge){i,z,lst}),lst+=x;
	}
	cout<<z<<' '<<e.size()<<'\n';
	for(i=0;i<e.size();++i)cout<<e[i].u<<' '<<e[i].v<<' '<<e[i].w<<'\n';
	return 0;
}


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

using namespace std;

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

    set<pair<size_t, size_t>> st;
    map<pair<size_t, size_t>, size_t> cnt;
    for (size_t i = 0; i < 6; ++i) {
        size_t h, w; cin >> h >> w;
        if (h > w) swap(h, w);
        pair<size_t, size_t> p = make_pair(h, w);
        st.insert(p);
        cnt[p]++;
    }

    if (st.size() == 3) {
        vector<size_t> h, w;
        for (auto &si: st) {
            if (cnt[si] != 2) {
                cout << "no" << "\n";
                return 0;
            }
            h.emplace_back(si.first);
            w.emplace_back(si.second);
        }

        vector<size_t> cnt(1010);
        for (size_t i = 0; i < 3; ++i) {
            if (h[i] == w[i]) {
                cout << "no" << "\n";
                return 0;
            }
            cnt[h[i]]++, cnt[w[i]]++;
        }

        for (size_t i = 0; i < 3; ++i) {
            if (cnt[h[i]] != 2 || cnt[w[i]] != 2) {
                cout << "no" << "\n";
                return 0;
            }
        }

        cout << "yes" << "\n";
    }

    else if (st.size() == 2) {
        for (auto &si: st) {
            if (cnt[si] != 2 && cnt[si] != 4) {
                cout << "no" << "\n";
                return 0;
            }
            if (cnt[si] == 2) {
                if (si.first != si.second) {
                    cout << "no" << "\n";
                    return 0;
                }
            }
        }
        cout << "yes" << "\n";
    }

    else if (st.size() == 1) {
        for (auto &si: st) {
            if (si.first != si.second) {
                cout << "no" << "\n";
                return 0;
            }
        }
        cout << "yes" << "\n";
    }

    else {
        cout << "no" << "\n";
    }

    return 0;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int n,k;
    cin>>n>>k;
    int h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    sort(h,h+n);
    int ans=INF;
    for(int i=0;i<=n-k;i++){
        ans=min(ans,abs(h[i+k-1]-h[i]));
    }
    cout<<ans<<endl;
 return 0;   
}

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

int main() {
	int n, num[200000],maxv,minv;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> num[i];
	}
	maxv = num[1] - num[0];
	minv = num[0];
	for (int i = 1; i < n; i++)
	{
		maxv = max(maxv, num[i] - minv);
		minv = min(minv, num[i]);
	}
	cout << maxv <<endl;
	//system("pause");
	return 0;
}


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

int main() {
    int N;
    cin>>N;
    
    ll A[N+1];
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    A[N]=0;
    ll ans=0;
    
    for(int i=0;i<N;i++){
        ans+=A[i]/2;
        A[i]%=2;
        
        if(A[i]>0 && A[i+1]>0){
            ans++;
            A[i+1]--;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <stack>
#include <queue>
#include <deque>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

// template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//  order_of_key (k) : Number of items strictly smaller than k .
//  find_by_order(k) : K-th element in a set (counting from zero).
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
//#define int ll

const int N = 2e5 + 5;
const int oo = 1e9 + 5;

int d[N], ans[N];
vector <int> g[N];
queue <int> q;

void solve() {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= m; ++i) {
        int a, b;
        cin >> a >> b;
        g[a].pb(b);
        g[b].pb(a);
    }
    for (int i = 2; i <= n; ++i) { d[i] = oo; }
    d[1] = 0;
    q.push(1);
    while (sz(q)) {
        int v = q.front();
        q.pop();
        for (int i = 0; i < sz(g[v]); ++i) {
            int to = g[v][i];
            if (d[to] > d[v] + 1) {
                d[to] = d[v] + 1;
                ans[to] = v;
                q.push(to);
            }
        }
    }
    for (int i = 2; i <= n; ++i) {
        if (d[i] == oo) {
            cout << "No\n";
            return;
        }
    }
    cout << "Yes\n";
    for (int i = 2; i <= n; ++i) {
        cout << ans[i] <<'\n';
    }
}

 main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tt = 1;
	while (tt --) {
		solve();
	}
	return 0;
}
/*
	“I’m not gonna run away, I never go back on my word! That’s my nindo: my ninja way.” Naruto
*/


Measured memory_bytes: 13320
n=int(input())
a=[int(input()) for _ in range(n)]
a_max=max(a)
x=a.index(a_max)
a_sort=sorted(a)
y=a_sort[-2]
for i in range(n):
  if i==x:
    print(y)
  else:
    print(a_max)

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

int main(void){
  int limits=0;
  int people=0;
  scanf("%d %d",&people,&limits);
  int * height=(int *)malloc(people*sizeof(int));
  for(int i=0;i<people;i++)
	  scanf("%d",&height[i]);
  int ret_val=0;
  for(int i=0;i<people;i++)
	  if(height[i]>=limits)
		  ret_val++;
  printf("%d",ret_val);
  return 0;
}

Measured memory_bytes: 512
def read():
    return int(input())


def readlist():
    return list(map(int, input().split()))


def readmap():
    return map(int, input().split())


H, W = readmap()
N = read()
A = readlist()

C = [[0] * W for _ in range(H)]

i = 0
j = 0
for n in range(N):
    a = A[n]
    while a:
        C[i][j] = n + 1
        if (j == 0 and i % 2 == 1) or (j == W - 1 and i % 2 == 0):
            i += 1
        elif i % 2 == 0:
            j += 1
        else:
            j -= 1
        a -= 1

for i in range(H):
    print(" ".join(list(map(str, C[i]))))

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

int main(void){
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(abs(a-c)<=d)printf("Yes\n");
    else if(abs(a-b)<=d && abs(b-c)<=d)printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 128
j = 0
lists = []
flag = 0
cnt = 0
while 1:
    cnt = 0
    flag_max = 0
    flag_min = 0
    lists = []
    n = int(input())
    if n == 0:
        break
    for i in range(n):
        s = int(input())
        lists.append(s)
    for i in range(n):
        if lists[i] == max(lists):
            flag_max += 1
            pass
        elif lists[i] == min(lists):
            flag_min += 1
            pass
        else:
            cnt += lists[i]
    n -= 2
    if flag_max >= 2:
        cnt += max(lists)
    elif flag_min >= 2:
        cnt += min(lists)
    print(cnt // n)



Measured memory_bytes: 5600
p=10**9+7
def pow(x, n):
    res = 1
    while n > 0:
        if n & 1 == 1:
            res *= x
        x *= x
        res = res%p
        n >>= 1
    return res

n=int(input())
print((pow(10,n)-2*pow(9,n)+pow(8,n))%p)

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

using namespace std;

#define REP(i,m) for(ll i=0; i<m; i++)
#define FOR(i,n,m) for(ll i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
	int n;
	cin >> n;
	map<string, ll> m;
	REP(i, n){
		string s;
		cin >> s;
		sort(ALL(s));
		m[s]++;
	}
	ll ans = 0;
	for(auto i = m.begin(); i != m.end(); i++){
		ans += i->second * (i->second-1) /2;
	}
	cout << ans << endl;
	return 0;
} 


Measured memory_bytes: 11136
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String s = sc.next();
		Set<Character> set1 = new HashSet<>();
		Set<Character> set2 = new HashSet<>();
		int max = 0;
		
		for (int i = 1; i < N; i++) {
			int count = 0;
			
			String s1 = s.substring(0, i);
			String s2 = s.substring(i);
			
			for (int j = 0; j < s1.length(); j++) {
				set1.add(s1.charAt(j));
			}
			for (int j = 0; j < s2.length(); j++) {
				set2.add(s2.charAt(j));
			}
			for (char c : set1) {
				if (set2.contains(c)) {
					count++;
				}
			}
			set1.clear();
			set2.clear();
			//System.out.println(s1 + ":" + s2 + "=" + count);
			max = Math.max(count, max);
		}
		System.out.println(max);
	}
}


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

int main (){

  int n;
  long sum=0;
  
  cin>>n;
  
  vector <int> b(n);
  
  for(int i=0 ; i<n-1 ;i++){
  	cin>>b.at(i);
  }
  b.at(n-1)=100000;
  sum+=b.at(0);//a0はb0と一緒
  
  for(int i = 1; i < n; i++){
    sum+=min(b.at(i-1),b.at(i));
  }
 cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
n, x = map(int,input().split())
origdat = list(map(int, input().split()))
from copy import deepcopy

res = 0

cnt = 0
dat = deepcopy(origdat)
for i in range(n):
    if dat[i] == 0:
        continue
    if dat[i] > x: # もし、xよりも大きな数なら、xにする
        res += dat[i] - x
        dat[i] = x
    if i == n-1:
        break
    if dat[i] + dat[i+1] > x:
        res += (dat[i] + dat[i+1]) - x
        dat[i+1] -= (dat[i] + dat[i+1]) - x
#print(dat)
print(res)

Measured memory_bytes: 85484
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int n, ans = 0;
    cin >> n;
    
    vector<int> v(2*n);
    for (auto &x : v) cin >> x;
    sort(ALL(v));
    
    for (int i = 0; i < 2*n; i += 2) ans += v[i];
    
    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define NUM 100

int main(){
  int i,j,n,count=0,minj,hoji;
  int a[NUM];

  scanf("%d",&n);

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

  for(i=0;i<=n-1;i++){
    minj=i;
    for(j=i;j<=n-1;j++){
      if(a[j]<a[minj]){
	minj=j;
      }
    }
    if(i!=minj){
      hoji=a[i];
      a[i]=a[minj];
      a[minj]=hoji;
      count++;
    }
  }

  for(i=0;i<n;i++){
    if(i!=n && i!=0){
      printf(" ");
    }
    printf("%d",a[i]);
  }

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

  return 0;
}



Measured memory_bytes: 2140