akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(ll i=0;i<(ll)n;++i)
const ll INF = 999999999999999;
int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n){
    scanf("%ld",&(a.at(i)));
    --a.at(i);
  }
  vector<bool> b(n,false);
  
  //cnt : テレポート回数
  ll cnt = 0;
  //now : 現在の街のid , lp_id : ループの始まりであり、終わりでもある街
  ll now = 0,lp_id;
  while(1){
    // k回テレポートした場合
    if( cnt == k ){
      cout << now+1 << endl;
      return 0;
    }
    //すでに訪れたかどうか <- 訪れているのならループしている
    if( b.at(now) ){
      lp_id = now;
      break;
    }else{
      b.at(now) = true;
    }
    //テレポートする
    now = a.at(now);
    ++cnt;
  }
  
  k -= cnt;
  ll lp_len = 0;
  //ループの長さを数える
  while(1){
    if( lp_len != 0 && now == lp_id ) break;
    now = a.at(now);
    ++lp_len;
  }
  
  //kの残り
  k %= lp_len;
  
  cnt = 0;
  now = lp_id;
  
  while(1){
    if( cnt == k ){
      cout << now+1 << endl;
      return 0;
    }
    now = a.at(now);
    ++cnt;
  }
 
  
  return 0;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define vi vector<ll>
# define vvi vector<vi>
# define rep(i, N) for (int i = 0; i < N; i++)
# define Rep(i, N) for (int i = 1; i <= N; i++)
# define deb(x) cerr << #x << ": " << x << endl;
# define deb2(x, i) cerr << #x << "[" << i << "]: " << x[i] << endl;
/*
vi v(10, 2); 
rep(i, 10) deb2(v, i); 
*/

/*
int a; cin >> a;
int a, b; cin >> a >> b;
rep(i, n){cin >> v[i];}
cout <<   << endl;
*/

signed		main()
{
	int n, m, x; cin >> n >> m >> x;
	vector<int> c(n);
	vector<vector<int>> a(n, vector<int>(m));
	for (int i = 0; i < n; i++)
	{
		cin >> c[i];
		for (int j = 0; j < m; j++)
		{
			cin >> a[i][j];
		}
		
	}
	int res = 1000000000;
	for (int bit = 0; bit < (1 << n); bit++)
	{
		//cout << "bit=" << bit << endl;
		int tmp = 0;
		int power = 0;
		vector<int> v(m, 0);
		for (int i = 0; i < n; i++)
		{
			if (bit & (1 << i))
			{
				tmp += c[i];
				for (int j = 0; j < m; j++)
				{
					v[j] += a[i][j];
				}
			}
			//cout << "v[" << i << "]=" << v[i] << endl;
		}

		int f = 0;
		for (int i = 0; i < m; i++)
		{
			if (v[i] < x)
			{
				f = 1;
				break;
			}
		}
		
		if (f == 0)
		{
			res = min(res, tmp);
		}
	}
	cout << (res == 1000000000 ? -1 : res) << endl;
}



Measured memory_bytes: 3640
n, k = map(int, input().split())
list_X = list(map(int, input().split()))
ans = pow(10, 18)
for i in range(n-k+1):
    ans = min(ans, abs(list_X[i])+list_X[i+k-1]-list_X[i], abs(list_X[i+k-1])+list_X[i+k-1]-list_X[i])
if n == 1:
    ans = list_X[0]
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }
int dx[] = { 0, 0, -1, 1 };
int dy[] = { 1, -1, 0, 0 };
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	int N;
	cin >> N;
	vi A(N - 1);
	vi B(N);
	rep(i, N - 1) {
		cin >> A.at(i);
	}
	rep(i, N) {
		B.at(i) = 0;
	}
	rep(i, N - 1) {
		B.at(A.at(i) - 1) += 1;
	}
	rep(i, N) {
		cout << B.at(i) << endl;
	}
	return 0;
}


Measured memory_bytes: 4784
#include<bits/stdc++.h>
#define int long long 
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(a) a.begin(),a.end()
#define ld long double
#define ub upper_bound
#define lb lower_bound
#define pii pair<int,int>
using namespace std;
signed main(){
    fast;
    int k,n;
    cin>>k>>n;
    int a[n+1];
    int sum = 0;
    for(int i = 1;i<=n;i++){
        cin>>a[i];
    }
    for(int i = 1;i<=n-1;i++){
        sum+= a[i+1] - a[i];
    }
    int last = k - a[n] + a[1];
    sum+= k - a[n] + a[1];
    int ans = 1e18;
    for(int i = 1;i<=n;i++){
        int temp1,temp2;
        if(i == 1){
            temp1= sum - last;
            temp2 = sum - (a[2]-a[1]);
        }
        else if(i == n){
            temp1 = sum - (a[n] - a[n-1]);
            temp2 = sum - last;
        }
        else{
            temp1 = sum - (a[i] - a[i-1]);
            temp2 = sum - (a[i+1] - a[i]);
        }
        ans = min(ans,min(temp1,temp2));
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
    int a, b, ab;
    scanf("%d %d", &a, &b);
    if (a < 0)
        a = a * -1;
    if (b < 0)
        b = b * -1;
    ab = (a + b) % 2;
    if (ab == 0)
        printf("%d", (a + b) / 2);
    else
        printf("IMPOSSIBLE");
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 1000; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j])%mod;
//       }
//     }
//   }
//   return 0;
// }


// int factorial(int n){
//   if(n == 0) return 1;
//   return n*factorial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   pascal_triangle();
//   return memo[n][k];
// }

// int cans(bool f){
//   if(f) cout << "Yes" << endl;
//   else cout << "No" << endl;
//   return 0;
// }







//二項係数(mod剰余)----------------------------

// const int MAX = 3000010;
// const int M = 1000000007;

// vector<ll> fac(MAX); //n!(mod M)
// //a,bの範囲的にこれだけ配列を用意していけば十分
// vector<ll> ifac(MAX); //k!^{M-2} (mod M)

// ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
//     ll ans = 1;
//     while(n != 0){
//         if(n&1) ans = ans*x % M;
//         x = x*x % M;
//         n = n >> 1;
//     }
//     return ans;
// }

// ll COMinit(){
//   //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
//   fac[0] = 1;
//   ifac[0] = 1;
//   for(ll i = 0; i<MAX; i++){
//     fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
//     ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
//   }
//   return 0;
// }

// ll COM(ll a, ll b){ //aCbをmod計算
//   if(a == 0 && b == 0)return 1;
//   if(a < b || a < 0)return 0;
//   ll tmp = ifac[a-b]* ifac[b] % M;
//   return tmp * fac[a] % M;
// }

//-----------------------------------------


int main(){
  ll A,B,K;
  cin >> A >> B >> K;

  cout << max(ll(0),(A-K)) <<" "<< min(B,max((B+A-K),ll(0)))<< endl;
  return 0;
}




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

#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
const int MN = 2e5 + 5, LN = 17, MOD = 1e9 + 7, INF = 0x3f3f3f3f;
int N, a[MN], pre[MN], suf[MN];

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    memset(pre, -0x3f, sizeof(pre));
    memset(suf, -0x3f, sizeof(suf));
    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
        pre[i] = max(pre[i - 1], a[i]);
    }
    for (int i = N; i >= 1; i--) suf[i] = max(suf[i + 1], a[i]);
    for (int i = 1; i <= N; i++) {
        cout << max(pre[i - 1], suf[i + 1]) << '\n';
    }
    return 0;
}


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

using namespace std;

int main()
{
    int k;
    string s;

    cin >> k;
    cin >> s;

    if( k < s.length())
    {
        cout << s.substr( 0, k ) << "..." << endl;
    }
    else
        cout << s << endl;
    
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <math.h>
using namespace std;

int main() {
  long long int A, B, C, K;
  cin >> A >> B >> C >> K;
  long long int Z;
  
  if (K % 2 == 1) {
    Z = B - A;
  } else {
    Z = A - B;
  }

  if (Z > pow(10, 18) ) {
    cout << "Unfair" << endl;
  } else {
    cout << Z << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int a,b;
    cin >> a >> b;
    cout << a*b << " " << 2*(a+b) << endl; 
    return 0;
}


Measured memory_bytes: 3088
n=int(input())
a=list(map(int,input().split()))
import collections
c=collections.Counter(a)
d=sorted(c)
maxi=0
if n>=3 and len(d)>=3:
    for i in range(len(d)-2):
        total=c[d[i]]+c[d[i+1]]+c[d[i+2]]
        maxi=max(maxi,total)
    print(maxi)
if n>=3 and len(d)==2:
    print(n if abs(d[0]-d[1])<=2 else 2)
if n>=3 and len(d)==1:
    print(n)
if n==2:
    print(2 if abs(a[0]-a[1])<=2 else 1)
if n==1:
    print(1)

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

int main() {
  int x,y;
  cin >> x >> y;
  if (x==y) cout << "Yes" << endl;
  else if ((x==4||x==6||x==9||x==11) && (y==4||y==6||y==9||y==11)) cout << "Yes" << endl;
  else if ((x==1||x==3||x==5||x==7||x==8||x==10||x==12) && (y==1||y==3||y==5||y==7||y==8||y==10||y==12)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] args){
		FastScanner sc = new FastScanner(System.in);
		int N = sc.nextInt();
		long Tmin = 1;
		long Amin = 1;
		long T,A,n;

		for (int i=0;i<N;i++) {
			T = sc.nextLong();
			A = sc.nextLong();
			n = Math.max((Tmin+T-1)/T, (Amin+A-1)/A);
			Tmin = T * n;
			Amin = A * n;
		}

		System.out.println(Tmin + Amin);


	}
	static int lcm (int a, int b) {
		int temp;
		long c = a;
		c *= b;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return (int)(c/b);
	}

}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

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

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (int k = 0; k < n; ++k) cin >> a[k];
    ll q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        ll t, b, e;
        cin >> t >> b >> e;
        if (t == 0) {
            ll ans = 1001001001001001001;
            for (int j = b; j < e; ++j) ans = min(ans, a[j]);
            cout << ans << endl;
        } else {
            ll ans = -1001001001001001001;
            for (int j = b; j < e; ++j) ans = max(ans, a[j]);
            cout << ans << endl;
        }
    }
}



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

int main() {
	int a,b;
	cin>>a>>b;
	if(b>=0){
		if(a*b>a+b){
			cout<<a*b<<endl;
		}
		else{
			cout<<a+b<<endl;
		}
		
	}
	else{
		if(a*b>=a-b){
			cout<<a*b<<endl;
		}
		else{
			cout<<a-b<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int min_mul(int m, int n){
    if (n == 0) return m;
    else
        min_mul(n, m % n);
}
 
int max_mul(int m, int n){
    return m*n/min_mul(m,n);
}
 
 
 
 
int main(){
    int n;
    cin>>n;
    int* data = new int(n);
    for(int i=0;i<n;i++)
        cin>>data[i];
    int ans = data[0];
    for(int j=1;j<n;j++){
        ans = max_mul(ans,data[j]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3096
#include <algorithm>
#include <iostream>
#include <string>
#include <unordered_map>
#include <vector>

long solve(int n, std::vector<std::string> strings)
{
  std::unordered_map<std::string, long> s_to_counts;
  for (auto& s : strings) {
    std::sort(s.begin(), s.end());
    auto it = s_to_counts.find(s);
    if (it == s_to_counts.end()) {
      s_to_counts.emplace(s, 1);
    } else {
      ++(it->second);
    }
  }

  long result = 0;
  for (auto& pair : s_to_counts) {
    result += pair.second * (pair.second - 1) / 2;
  }
  return result;
}

int main()
{
  int n;
  std::cin >> n;

  std::vector<std::string> strings(n);
  for (auto& s : strings) {
    std::cin >> s;
  }

  std::cout << solve(n, std::move(strings)) << std::endl;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
  string S;
  cin >> S;
  int ans = 1e9;
  for(int i = 0; i + 2 < S.size(); i++) {
    string now = S.substr(i, 3);
    //cout << stoi(now) << endl;
    ans = min(ans, abs(753-stoi(now)));
  }
  cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
vector<ll>pos[21];
ll inp[100];
map<ll,ll>mp;
vector<ll>triangle;
vector<ll>::iterator upper1, upper2;
int main()
{
  ll i,j,k,l,t,n,x=0,y=0,p,q,z=0;
  cin>>n;
  for(i=0;i<n;i++)
  {
    cin>>p;
    triangle.push_back(p);
    mp[p]++;	
  }
  sort(triangle.begin(),triangle.end());
  for(i=0;i<n;i++)
  {
   z=0;	
    for(j=i+1;j<n;j++)
    {
      p=triangle[i]+triangle[j];
      q=upper_bound(triangle.begin()+j+1,triangle.end(),p)-triangle.begin();
      k=binary_search(triangle.begin(),triangle.end(),p);
      if(k==1)
      {
         z=z+mp[p];	
      }
       
     // x=x+max(y,q-j);
     //cout<<p<<" "<<q-j-1<<'\n';	
     x=x+max(y,q-j-1);
    }
    x=x-z;	
    //cout<<x<<'\n';
  }
  cout<<x;
     
     
     	
  	
}

Measured memory_bytes: 3644
N = int(input())
s = [0]*N
t = [0]*N
for i in range(N):
  s[i],t[i] = input().split()
X = input()

a = 0

while a == 0:
  for j in range(N):
    if s[j] == X:
      a = 1
      b = j + 1
#print(b)

A = 0
for n in t[b:]:
  A+= int(n)
print(A)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.next();

		String sub1 = s.substring(0, 5);
		String sub2 = s.substring(6, 13);
		String sub3 = s.substring(14, 19);

//		System.out.println(sub1);
//		System.out.println(sub2);
//		System.out.println(sub3);

		System.out.println(sub1 + " " + sub2 + " " + sub3);
	}

}

Measured memory_bytes: 23892
#!/usr/bin/env python
# coding: utf-8

# In[28]:


import numpy as np


# In[29]:


N = int(input())
A = np.array([int(x) for x in input().split()])


# In[33]:


A = A.astype('int64')


# In[34]:


if np.count_nonzero(A < 0) % 2 == 0:
    print(sum(abs(A)))
else:
    print(sum(abs(A)) - 2 * min(abs(A)))


# In[ ]:





# In[ ]:






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

public class Ice
{
    public int L { get; set; }
    public int p { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var ices = new List<Ice>();
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var L = int.Parse(line[1]);
        var a = new int[n, 2];
        for (int i = 0; i < n; i++)
        {
            var w = int.Parse(Console.ReadLine().Trim());
            a[i, 0] = w;
            ices.Add(new Ice { p = i, L = w });
        }
        var ret = getAnswer(a, ices, L);
        Console.WriteLine(ret);
    }
    public static int getAnswer(int[,] a, List<Ice> ices, int L)
    {
        var n = a.GetLength(0);
        var ret = 0;
        foreach (var x in ices.OrderByDescending(y => y.L))
        {
            if (x.p == 0 && x.L > a[1, 0]) { a[0, 1] = L - x.L; ret = Math.Max(a[0, 1], ret); }
            else if (x.p == 0 && x.L < a[1, 0]) { a[0, 1] = L - x.L + a[1, 1]; ret = Math.Max(a[0, 1], ret); }
            else if (x.p == n - 1 && x.L > a[n - 2, 0]) { a[n - 1, 1] = L - x.L; ret = Math.Max(a[n - 1, 1], ret); }
            else if (x.p == n - 1 && x.L < a[n - 2, 0]) { a[n - 1, 1] = L - x.L + a[n - 2, 1]; ret = Math.Max(a[n - 1, 1], ret); }
            else if (x.L > a[x.p - 1, 0] && x.L > a[x.p + 1, 0]) { a[x.p, 1] = L - x.L; ret = Math.Max(a[x.p, 1], ret); }
            else if (x.L > a[x.p - 1, 0] && x.L < a[x.p + 1, 0]) { a[x.p, 1] = L - x.L + a[x.p + 1, 1]; ret = Math.Max(a[x.p, 1], ret); }
            else if (x.L < a[x.p - 1, 0] && x.L > a[x.p + 1, 0]) { a[x.p, 1] = L - x.L + a[x.p - 1, 1]; ret = Math.Max(a[x.p, 1], ret); }
            else { a[x.p, 1] = L - x.L + Math.Max(a[x.p + 1, 1], a[x.p - 1, 1]); ret = Math.Max(a[x.p, 1], ret); }
        }
        return ret;
    }
}






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

int main() {
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S[i];
  }
  sort(S.begin(), S.end());
  for (auto str : S) {
    cout << str;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {



	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		while(a < -1000);

		int b = scanner.nextInt();
		while(b > 1000);

		if(a > b) {
			System.out.println("a > b");
		}else if(a < b){
			System.out.println("a < b");
		} else {
			System.out.println("a == b");
		}
	}
}



Measured memory_bytes: 26264
h, w = gets.chomp.split(' ').map(&:to_i)
a = []
h.times do |i|
  a << gets.chomp.split('')
end
h.times do |i|
  r = 0
  w.times do |j|
    if a[i][j] == '.' || a[i][j] == '3'
      r += 1
    end
  end
  if r == w
    w.times do |j|
      a[i][j] = '3'
    end
  end
end
w.times do |i|
  c = 0
  h.times do |j|
    if a[j][i] == '.' || a[j][i] == '3'
      c += 1
    end
  end
  if c == h
    h.times do |j|
      a[j][i] = '3'
    end
  end
end

h.times do |i|
  c = 0
  w.times do |j|
    if a[i][j] == '3'
      c += 1
    end
  end
  if c != w
    w.times do |j|
      unless a[i][j] == '3'
        print a[i][j]
      end
    end
    print "\n"
  end
end


Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }






int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	string s;cin >> s;
	int ans = 0;
	for(int i = 1; i < n; i++){
		vector<int> cnt1(26), cnt2(26);
		rep(j,i) cnt1.at(s.at(j) - 'a')++;
		for(int j = i; j < n; j++) cnt2.at(s.at(j) - 'a')++;
		int cnt = 0;
		rep(j,26) if(cnt1.at(j) && cnt2.at(j)) cnt++;
		ans = max(ans, cnt);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
from sys import stdin

N, X = [int(x) for x in stdin.readline().rstrip().split()]
L = [int(x) for x in stdin.readline().rstrip().split()]
Sum = 0
cnt = 1
for i in range(N):
    if Sum + L[i] <= X:
        cnt += 1
        Sum += L[i]
    else:
        break
print(cnt)

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define pb push_back


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

  cout << N-K+1<< endl;

}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int n, m;
	cin >> n >> m;
	
	vector< vector< int > > edge(n);
	for_(i,0,m) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	
	vector< vector< int > > dp(1 << n, vector< int >(n, 0));
	dp[1][0] = 1;
	for_(S,1,(1<<n)) for_(v,0,n) {
		for (int u : edge[v]) {
			if (S >> u & 1) continue;
			dp[S | (1 << u)][u] += dp[S][v];
		}
	}	
	cout << accumulate(dp[(1 << n) - 1].begin(), dp[(1 << n) - 1].end(), int()) << endl;
}

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

int main() {
    char ACGT[] = {'A', 'C', 'G', 'T'};
    std::string S;
    std::cin >> S;
    int len = (int)S.size();
    int t_len=0, max_len=0, i;
    bool all_can = true;
    for (i = 0; i < len; i++) {
        bool can = false;
        for (auto elem : ACGT) {
            if (S[i] == elem)  {
                t_len++;
                can = true;
            }
        }
        if (!can) {
            t_len = 0;
            all_can = false;
        }
        max_len = (max_len < t_len ? t_len : max_len);
    }
    if (all_can) max_len = len;
    std::cout << max_len << '\n';
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

bool checkdist(vector<ll> D1, vector<ll> D2) {
  ll sum = 0;
  for (ll i = 0; i < D1.size(); i++) {
    ll a = abs(D1[i] - D2[i]);
    sum += a * a;
  }
  double num = sqrt(sum);
  ll numi = (ll)num;
  if (fabs(num - (double)numi) <= EPS) {
    return true;
  }
  return false;
}

int main() {
  ll N, D;
  cin >> N >> D;
  vector<vector<ll>> X(N, vector<ll>(D));
  for (ll i = 0; i < N; i++) {
    for (ll j = 0; j < D; j++) {
      cin >> X[i][j];
    }
  }
  ll count = 0;
  for (ll i = 0; i < N - 1; i++) {
    for (ll j = i + 1; j < N; j++) {
      if (checkdist(X[i], X[j])) {
        count++;
      }
    }
  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
import math

while 1:
    n = input()
    if n == -1:
        break
    x, y = 0.0, 0.0
    radian = math.radians(-90)
    for i in xrange(n):
        radian = (radian + math.pi / 2)
        x += math.cos(radian)
        y += math.sin(radian)
        radian = math.atan2(y, x)
    print "%.2f" % x
    print "%.2f" % y

Measured memory_bytes: 4496
# coding: utf-8
data={}
for i in range(1,151):#w
    for j in range(1,151):#h
        if (i>j):
            data[(i,j)]=i*i+j*j
data=sorted(data.items(),key=lambda x:(x[1],x[0][1]))
while 1:
    n,m=map(int,input().split())
    if n==0:
        break
    for i in range(len(data)):
        if data[i][0]==(m,n):
            print(*data[i+1][0][::-1])
            break


Measured memory_bytes: 8552
#include <bits/stdc++.h>
const int mod=1e9+7;
using namespace std;
int n,du[100010],vis[100010],nxt[100010],L[100010],ans=1,cir_len[100010],f[100010];
bool cir[100010];
void work_cir(int u){
	int now=0,pre=0,f_pos=0,f_L=0;
	while(cir[u]){
		cir[u]=false,now++;
		if(L[u]){
			if(!f_pos) f_pos=pre=now,f_L=L[u];
			else{
				int k=(L[u]<now-pre)+(L[u]<=now-pre);
				ans=1ll*ans*k%mod,pre=now;
			}
		}
		u=nxt[u];
	}
	if(!f_pos) ++cir_len[now];
	else{
		int k=(f_L<now-pre+f_pos)+(f_L<=now-pre+f_pos);
		ans=1ll*ans*k%mod;
	}
}
int main(){ 
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&nxt[i]),++du[nxt[i]];
	for(int i=1;i<=n;i++){
		if(vis[i]) continue;
		int now=i;
		while(!vis[now]) vis[now]=i,now=nxt[now];
		if(vis[now]!=i) continue;
		while(!cir[now]) cir[now]=true,now=nxt[now];
	}
	for(int i=1;i<=n;i++){
		if((cir[i]&&du[i]>2)||(!cir[i]&&du[i]>1)){
			puts("0\n");
			return 0;
		}
	}
	for(int i=1;i<=n;i++){
		if(du[i]) continue;
		int now=i,len=0;
		while(!cir[now]) ++len,now=nxt[now];
		L[now]=len;
	}
	for(int i=1;i<=n;i++) if(cir[i]) work_cir(i);
	for(int i=1;i<=n;i++){
		if(!cir_len[i]) continue;
		f[0]=1;
		for(int j=1;j<=cir_len[i];j++){
			if(i>1&&(i&1)) f[j]=(2ll*f[j-1])%mod;
			else f[j]=f[j-1];
			if(j>1) f[j]=(f[j]+(1ll*f[j-2]*(j-1)%mod)*i%mod)%mod;
		}
		ans=1ll*ans*f[cir_len[i]]%mod;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 1920
#include <stdio.h>
using namespace std;
int main(void){
   int r,c,i,j,q,w;
   scanf("%d%d",&r,&c);
   int a[101][101]={0,0};
  i=0;j=0;q=0;w=r;
  
        while(i<r){
              while(j<c){
                  scanf("%d",&a[i][j]);
                 j=j+1;
             }
            while(j>=0){
                q=q+a[i][j];
                j=j-1;
            }
            a[i][c]=q;
            q=0;  i=i+1;j=0;
                         }
           
            while(j<c){
          while(i>=0){
                q=q+a[i][j];
                i=i-1;
            }
                 a[r][j]=q;
                  q=0;  j=j+1;i=r;
                         }
i=0;j=0;
    
    while(w>i){
        a[r][c]=a[i][c]+a[r][c];i=i+1;
    }
    i=0;
    while(i<=r){
        while(j<=c){
           printf("%d",a[i][j]); 
            if(j<c){
                printf(" ");
            }
            
            j=j+1;
        }
 // if(r>i){
  
    printf("\n"); 
//  }
    i=i+1; j=0;
    
    }
}


Measured memory_bytes: 2724
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            int X = int.Parse(Console.ReadLine());
            int ans = 0;
            for(var i = 1; i <= X; i++)
            {
                if (i == 1)
                {
                    ans = Math.Max(ans, i);
                    continue;
                }
                int k = i * i;
                while (k <= X)
                {
                    ans = Math.Max(ans, k);
                    k *= i;
                }

            }

            Console.WriteLine(ans);

            //Console.Out.Flush();
            
        }
    }



    public class Calculation
    {

    }

    public class Graph
    {

    }
}



Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  int check;
 
  while(cin>>n>>m,n+m!=0){
 int num[100]={0};
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	cin>>check;
	if(check==1)
	  num[j]++;
      }
    }
    int bra=0;
    for(int j=n;j>=0;j--){
      for(int i=0;i<m;i++){
	if(num[i]==j){
	  bra++;
	  cout<<i+1;
	  if(bra!=m)
	    cout<<" ";
	}
      }
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 2964
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
using namespace std;
long long n,k,res;
int main(){
	#ifdef FILIN
		#ifndef LOCAL
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k;
	n-=(n/k)*k;
	cout<<min(n,k-n)<<endl; 
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n - 1); i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
using priority_queuel = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-9;
ll mod = static_cast<ll>(1e9 + 7);
template <class T>
constexpr int sz(const T &a) { return (int)a.size(); }
template <class T>
constexpr T pow2(const T a) { return a * a; }
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class A, int N, class T>
void fillArray(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

int n, m;
vector<ll> c[100005];
void solve() {
    cin >> n >> m;
    rep(i, n) {
        int a;
        ll b;
        cin >> a >> b;
        if (a <= m) c[m - a].push_back(b);
    }

    priority_queue<ll> que;
    ll ans = 0;
    repd(i, m) {
        for (auto &val : c[i])
            que.push(val);
        if (!que.empty()) {
            ans += que.top();
            que.pop();
        }
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 5632
N=int(input())


A=[int(c) for c in input().split()]

dic={}
for e in A:
    if e in dic:
        dic[e]+=1
    else:
        dic[e]=1
        
for i in range(1,N+1):
    if i in dic:
        print(dic[i])
    else:
        print(0)

Measured memory_bytes: 33664
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		if(A==B && B==C) System.out.println("Yes");
		else System.out.println("No");
	}
	
}

Measured memory_bytes: 23124
while True:
    a,op,b=input().split()
    a=int(a)
    b=int(b)
    
    if op=="?":
        break
    if op=="+":
        print(a+b)
    if op=="-":
        print(a-b)
    if op=="*":
        print(a*b)
    if op=="/":
        print(a//b)


Measured memory_bytes: 5596
#include<bits/stdc++.h>
#define M 1000000007
#define pi ld(acos(-1.0))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define ii pair<int,int>
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    cs
    int n;cin>>n;
    vector<int> v(n);
    for(auto &i:v) cin>>i;
    vector<int> ans(n);
    ans[0]=0;
    ans[1]=abs(v[1]-v[0]);
    repp(i,2,n-1) ans[i]=min(ans[i-2]+abs(v[i]-v[i-2]),ans[i-1]+abs(v[i]-v[i-1]));
    cout<<ans[n-1];
}

Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;

fn main() {
	let (h, a): (f32, f32) = (read(), read());
	let ans = (h / a).ceil() as u32;
	println!("{}", ans);
}

fn read<T: FromStr>() -> T {
	let stdin = stdin();
	let stdin = stdin.lock();
	let token: String = stdin
		.bytes()
		.map(|c| c.expect("failed to read char") as char)
		.skip_while(|c| c.is_whitespace())
		.take_while(|c| !c.is_whitespace())
		.collect();
	token.parse().ok().expect("failed to parse token")
}



Measured memory_bytes: 4352
N, A, B, C, D = map(int, input().split())
S = input()

c_swap = True 
# 飛び越し条件整理
if C > D:
    # 飛び越せるか
    if "..." in S[B-2:min(C, D+1)]:
        reset = S.find("...") + 1
        A = reset + 1
        B = reset + 2
    else:
        c_swap = False
    
# funukeとDの間に##がないかチェック
is_f_ok = "##" not in S[B-1:D]

# sunukeとCの間に##がないかチェック
is_s_ok = "##" not in S[A-1:C]

print("Yes") if (is_f_ok & is_s_ok & c_swap) else print("No")

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define in(e,l) (std::find(l.begin(), l.end(), e) != l.end())
#define asort(l) (std::sort(l.begin(), l.end()))
#define dsort(l) (std::sort(l.rbegin(), l.rend()))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;

int main() {
  ll A, B;
  cin >> A >> B;
  ll ans = 1;
  ll cnt = A;
  while(cnt < B) {
    cnt += (A - 1);
    ++ans;
  }
  if(B == 1){
    cout << "0" << endl;
  }else {
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
using ll = long long;

int main()
{
  int n, k;
  cin >> n >> k;
  ll ans = 0;
  //int cnt = 0;
  for (ll i = k; i <= n + 1; i++)
  {
    ll first = i * (i - 1) / 2;
    ll final = (n * 2 - i + 1) * i / 2;
    ll add = final - first + 1;
    ans = (ans + add) % 1000000007;
    //cnt++;
  }
  //long long a = (ll)141421 * 141421;
  //int b = 141421 * 141421;
  cout << ans << endl;
  //cout << a << endl;
  //cout << b << endl;
}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(i=0;i<n;i++)
#define test(a) cout << "*" << a << endl
int main (){
  int n;
  string s;
  int i,j;
  int count=0;
  
  cin >> n >> s;
  
  rep0(i,n-2){
    string substr = s.substr(i,3);
    if(substr=="ABC"){
      count++;
    }
  }     
  cout << count << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    for(int i = 0; i < n; i++) cin >> l[i];

    sort(l.begin(), l.end());

    int sum = 0;
    for(int i = 0; i < n-1; i++) sum += l[i];

    if(l[n-1] < sum) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define SIZE 10
#define PI 3.141592653589793

using namespace std;
typedef long long ll;

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

	int i,j;
	int tmp;
	int counter=0;
	double A,B,H,M;
	double answer;
	double degH,degM;
	double radH,radM;
	vector<int> given;

	cin >> A >> B >> H >> M;


	// 12*30=360
	degH=H*30.0;
	// 60*6=360
	degM=M*6.0;
	degH+=30*(M/60);

	radH=(degH*PI)/180.0;
	radM=(degM*PI)/180.0;
	answer=sqrt((pow(A,2.0)+pow(B,2.0))-(long double)(2.0*A*B)*cos(abs(radH-radM)));
	cout << fixed << setprecision(15) << answer << endl;

	return 0;
}



Measured memory_bytes: 4116
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iostream>
#include<cmath>
#include<map>
#include<set>
using namespace std;
typedef vector<string>vs;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<double>vd;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll>pll;
typedef vector<ll>vl;
#define rrep(i,x,n) for(int i=(x);i<(n);++i)
#define rep(i,x) rrep(i,0,(x))
#define fi first
#define se second
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define maxs(a,b) (a)=max(a,b)
#define mins(a,b) (a)=min(a,b)

int N,M;
vector<vector<pii> >G;

int solve(int s,int g){
    bool visited[500]={0};
    priority_queue<pii,vector<pii>,greater<pii> >Q;
    Q.push(pii(0,s));
    while(!Q.empty()){
        pii p=Q.top();Q.pop();
        if(visited[p.se])continue;
        visited[p.se]=true;
        if(p.se==g)return p.fi;
        rep(i,G[p.se].size()){
            pii e=G[p.se][i];
            Q.push(pii(p.fi+e.se,e.fi));
        }
    }

    return 0;
}
int main(){
    while(cin>>N>>M,N||M){
        G=vector<vector<pii> >(N);
        map<string,int>conv;
        string s,p,g;
        cin>>s>>p>>g;
        rep(_,M){
            string a,b;
            int dist,late;
            cin>>a>>b>>dist>>late;
            if(conv.find(a)==conv.end())conv[a]=conv.size()-1;
            if(conv.find(b)==conv.end())conv[b]=conv.size()-1;
            int x=conv[a];
            int y=conv[b];
            G[x].pb(pii(y,dist/40+late));
            G[y].pb(pii(x,dist/40+late));
        }
        cout<<solve(conv[s],conv[p])+solve(conv[p],conv[g])<<endl;
    }
    return 0;
}

Measured memory_bytes: 1548
#include<iostream>
#include<vector>
#include<queue>
#define pb push_back
using namespace std;
vector<int> adj[100005];
bool v[100005];
int pred[100005];
int main(){
  int N,M;
  cin>>N>>M;
  for(int i=0; i<M; i++){
    int a,b;
    cin>>a>>b;
    adj[a].pb(b);
    adj[b].pb(a);
  }
  queue<int> myq;
  myq.push(1);
  v[1]=true;
  pred[1]=-1;
  while(!myq.empty()){
    int cur_room=myq.front();
    myq.pop();
    for(int i=0; i<adj[cur_room].size(); i++){
      int next=adj[cur_room][i];
      if(!v[next]){
        myq.push(next);
        v[next]=true;
        pred[next]=cur_room;
      }
    }
  }
  for(int i=1; i<=N; i++){
    if(!v[i]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  for(int i=2; i<=N; i++){
    cout<<pred[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 10612
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <deque>
#include <utility>
#include <algorithm>
using namespace std;

int main(void){
   
    int n, m;
    cin>>n>>m;
    
    vector<long long int> a(n), b(n);
    vector<long long int> c(m), d(m);
    
    for(int i=0; i<n; i++){
        cin>>a[i]>>b[i];
    }
    for(int i=0; i<m; i++){
        cin>>c[i]>>d[i];
    }
    
    for(int i=0; i<n; i++){
        int idx=1;
        long long int minlen=fabs(a[i]-c[0])+fabs(b[i]-d[0]);
        
        for(int j=1; j<m; j++){
            long long int temp=fabs(a[i]-c[j])+fabs(b[i]-d[j]);
            
            if(minlen>temp){
                minlen=temp;
                idx=(j+1);
            }
        }
        
        cout<<idx<<endl;
    }
    
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};


int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());

  combination c(n+5);

  mint ans = 0;
  rep(ri,2) {
    rep(i,n) {
      mint now = c(i,k-1);
      if (ri == 1) now = -now;
      ans += now*a[i];
    }
    reverse(a.begin(), a.end());
  }

  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 4980
# include <iostream>
# include <cmath> 
using namespace std;
void dfs(int n,double x1,double y1,double x2,double y2)
{
	if(n == 0) return ;
	double x = sqrt(3)/2;
	double x3 = (2*x1+x2)/3,y3 = (2*y1+y2)/3;
	double x4 = (2*x2+x1)/3,y4 = (2*y2+y1)/3;
	double x5 = x3+(x4-x3)/2-(y4-y3)*x;
	double y5 = y3+(x4-x3)*x+(y4-y3)/2;
	dfs(n-1,x1,y1,x3,y3);
	printf("%.8f %.8f\n",x3,y3);
	dfs(n-1,x3,y3,x5,y5);
	printf("%.8f %.8f\n",x5,y5);
	dfs(n-1,x5,y5,x4,y4);
	printf("%.8f %.8f\n",x4,y4);
	dfs(n-1,x4,y4,x2,y2);
}
int main(void)
{
	int n;
	scanf("%d",&n);
	printf("0.00000000 0.00000000\n");
	dfs(n,0,0,100,0);
	printf("100.00000000 0.00000000\n");
	return 0;
}


Measured memory_bytes: 3228
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

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

    float odd, even;
    odd = 0;
    even = 0;

    for (int i = 1; i <= n; ++i) {
        if (i % 2 == 0) {
            even += 1;
        }
        else {
            odd += 1;
        }
    }

    cout << fixed;
    cout << setprecision(10) << odd / n << endl;
}


Measured memory_bytes: 256
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 1000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
bitset<maxx/2>vis;
vector<ll>prime;
void sieve(){
    ll x=maxx/2, y=sqrt(maxx)/2;
    for(ll i=1;i<=y;i++){
        if(vis[i]==0){
            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
                vis[j]=1;
        }
    }
    prime.push_back(2);
    for(ll i=3;i<maxx;i+=2)
        if(vis[i/2]==0)
        prime.push_back(i);
}
bool isprime(ll a)
{
    if(a==2){
        return true;
    }
    if(a%2==0){
        return false;
    }
    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++){
        if(a%prime[i]==0){
            return false;
        }
    }
    return true;
}
ll lcm(ll a,ll b)
{
    return (a*b)/__gcd(a,b);
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
ll arr[200005],arr2[200005];
ll n,m,t;
void Dufaux()
{
    cin>>n>>m>>t;
    for(ll i=1;i<=n;i++){
        cin>>arr[i];
        arr[i]+=arr[i-1];
    }
    for(ll i=1;i<=m;i++){
        cin>>arr2[i];
        arr2[i]+=arr2[i-1];
    }
    ll z=0;
    for(int i=0;i<=n;i++){
        ll c=t-arr[i];
        if(c<0)continue;
        ll x=upper_bound(arr2,arr2+m+1,c)-arr2;
        z=max(z,i+x-1);
    }
    cout<<z<<endl;
}
int main()
{
	FastIO;
	///sieve();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}






Measured memory_bytes: 6736
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::collections::HashMap;

fn score_prime_numbers(n: i64, score: &mut HashMap<i64, i64>) {
    let mut d = 2;
    let mut tmp = n;

    while d <= n {
        while tmp % d == 0 {
            let current = score.entry(d).or_insert(0);
            *current += 1;
            tmp /= d;
        }
        d += 1;
    }
}

fn main() {
    let n: i64 = read();
    let mut score: HashMap<i64, i64> = HashMap::new();

    for i in 1..n + 1 {
        score_prime_numbers(i, &mut score)
    }
    let mut a = vec![];
    for (k, v) in score.iter() {
        a.push(v);
    }
    let cnt_74 = a.iter().filter(|&x| **x >= 74).count();
    let cnt_24 = a.iter().filter(|&x| **x >= 24).count();
    let cnt_2 = a.iter().filter(|&x| **x >= 2).count();
    let cnt_4 = a.iter().filter(|&x| **x >= 4).count();
    let cnt_14 = a.iter().filter(|&x| **x >= 14).count();

    let mut ans = 0;
    // 74
    ans += cnt_74;
    // 24 * 2
    ans += cnt_24 * (cnt_2 - 1);
    // 14 * 4
    ans += cnt_14 * (cnt_4 - 1);
    // 2 * 4 * 4
    ans += cnt_4 * (cnt_4 - 1) / 2 * (cnt_2 - 2);
    println!("{}", ans)
}


Measured memory_bytes: 4352
#include<stdio.h>

void judge(int pm, int pe, int pj)
{
	char class;
	if(pm == 100 || pe == 100 || pj == 100){
		class='A';
	}else if(pm + pe >= 180){
		class='A';
	}else if(pm + pe + pj >= 240){
		class='A';
	}else if(pm + pe + pj >= 210){
		class='B';
	}else if(pm + pe + pj >= 150 && (pm >= 80 || pe >= 80)){
		class='B';
	}else{
		class='C';
	}
	printf("%c\n", class);
}
int main(void)
{
	int n,pm,pe,pj;
	
	while(1){
		scanf("%d", &n);
		if(n == 0){
			break;
		}
		while(n--){
			scanf("%d%d%d", &pm, &pe, &pj);
			judge(pm, pe, pj);
		}
	}
	return 0;
}

Measured memory_bytes: 600