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

typedef long long ll; // -9,223,372,036,854,775,808 から 9,223,372,036,854,775,807

template <class T> using vec = std::vector<T>;
template <class T> using vec2 = vec<vec<T>>;
template <class T> using vec3 = vec<vec<vec<T>>>;

#define DEBUG

class UnionFind{
    private:
    vector<int> par; // 親
    vector<int> rank; // 木の深さ
    vector<long long> sizes_; 
    int num_of_conn;

    public:
    // n要素で初期化
    UnionFind(int n) {
        par = vector<int>(n);
        rank = vector<int>(n);
        sizes_ = vector<long long>(n);
        for (int i = 0; i < n; i++) {
            par.at(i) = i;
            rank.at(i) = 0;
            sizes_.at(i) = 1;
        }
        num_of_conn = n;
    }

    // 木の根を求める
    int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }

    long long getSize(int x){
        return sizes_[par[x]];
    }

    // xとyの属する集合を併合
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        auto sizex = getSize(x);
        auto sizey = getSize(y);
        if (x == y) return;
        if (rank.at(x) < rank.at(y)) {
            par.at(x) = y;
        } else {
            par.at(y) = x;
            if (rank.at(x) == rank.at(y)) rank.at(x)++;
        }
        num_of_conn--;
        sizes_.at(find(x)) = sizex + sizey;
    }

    // xとyが同じ集合に属するか否か
    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int numOfConnected(){
        return num_of_conn;
    }
};


void solve(long long N, long long M, std::vector<long long> a, std::vector<long long> b){
    // shift
    for(int i=0; i < a.size(); i++){
        a.at(i)--;
        b.at(i)--;
    }


    // solve
    ll res = 0;
    // nozoku hen
    for(int ex=0; ex < M; ex++){
        UnionFind uf(N);
        // nozoku hen
        for(int i=0; i < M; i++){
            if(i == ex){
                continue;
            }
            uf.unite(a.at(i), b.at(i));
        }

        if(uf.numOfConnected() != 1){
            res++;
        }
    }
    cout << res << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(M);
    std::vector<long long> b(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    solve(N, M, std::move(a), std::move(b));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
using namespace std;
int exec();

class Line {
  public:
    string line;
    int i, n;
    Line(string _line) {
      line = _line;
      i = 0;
      read();
    }
    int read() {
      stringstream ss;
      ss << line[i];
      ss >> n;
      // n = static_cast<int>(line[i]);
    }
    bool next() {
      ++i;
      if(i == line.size()) return false;
      read();
      return true;
    }
    int get() {
      return n;
    }
};

int main() {
  int n;
  cin >> n;
  for(int i = 0; i < n; ++i) exec();
  return 0;
}

int exec() {
  vector<vector<char> > chars = {{'.', ',', '!', '?', ' '}, {'a', 'b', 'c'}, {'d', 'e', 'f'}, {'g', 'h', 'i'}, {'j', 'k', 'l'}, {'m', 'n', 'o'}, {'p', 'q', 'r', 's'}, {'t', 'u', 'v'}, {'w', 'x', 'y', 'z'}};
  int n, count;
  string line;
  cin >> line;
  Line pattern(line);
  while(true) {
    count = 0;
    while(!(n = pattern.get())) if(!pattern.next()) {
      cout << endl;
      return 0;
    }
    while(pattern.next(), pattern.get()) ++count;
    cout << chars[n - 1][count % (chars[n - 1].size())];
  }
  return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define int long long
#define boost() ios_base :: sync_with_stdio(0); cin.tie(); cout.tie(); cout << fixed; cout << setprecision(15); srand(time(NULL))
#define all(x) x.begin(), x.end()
using namespace std;

vector <int> v[500010];
int n, m, res = 0;

signed main () {
  cin >> n >> m;
  while (n--) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
  }
  multiset <int> rew;
  for (int i = 1; i <= m; i++) {
    for (auto x: v[i]) {
      rew.insert(x);
    }
    if (!rew.empty()) {
      res += *prev(rew.end());
      rew.erase(prev(rew.end()));
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 17664
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX = 100;
const int NIL = -1;

struct Node
{
	int pa;
	int left;
	int right;
	unsigned degree;
	int depth;
	int height;
};

Node biTree[MAX];

void set_depth(int, int);
int set_height(int);
void print(int);

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		biTree[i].pa = biTree[i].left = biTree[i].right = NIL;
		biTree[i].degree = biTree[i].depth = biTree[i].height = 0;
	}
		

	for (int i = 0; i < n; i++)
	{
		int num, l, r;
		cin >> num >> l >> r;
		biTree[num].left = l;
		biTree[num].right = r;
		if (l != NIL)
		{
			biTree[l].pa = num;
			biTree[num].degree++;
		}
		if (r != NIL)
		{
			biTree[r].pa = num;
			biTree[num].degree++;
		}
	}
	
	int root = 0;
	for (int i = 0; i < n; i++)
	{
		if (biTree[i].pa == NIL)
		{
			root = i;
			break;
		}
	}

	set_depth(root, 0);
	set_height(root);

	for (int i = 0; i < n; i++)
		print(i);

// 	int junk;
// 	cin >> junk;
	return 0;
}


void print(int num)
{
	cout << "node " << num << ": ";
	cout << "parent = " << biTree[num].pa << ", ";

	cout << "sibling = ";
	if (biTree[num].pa == NIL)
		cout << NIL;
	else if (biTree[biTree[num].pa].left == num)
		cout << biTree[biTree[num].pa].right;
	else
		cout << biTree[biTree[num].pa].left;
	cout << ", ";

	cout << "degree = " << biTree[num].degree << ", ";
	cout << "depth = " << biTree[num].depth << ", ";
	cout << "height = " << biTree[num].height << ", ";

	if (biTree[num].pa == NIL)
		cout << "root";
	else if (biTree[num].degree == 0)
		cout << "leaf";
	else
		cout << "internal node";

	cout << endl;
	return;
}

void set_depth(int num, int d)
{
	biTree[num].depth = d;
	if (biTree[num].left != NIL)
		set_depth(biTree[num].left, d + 1);
	if (biTree[num].right != NIL)
		set_depth(biTree[num].right, d + 1);
	return;
}

int set_height(int num)
{
	int h1 = 0, h2 = 0;
	if (biTree[num].left != NIL)
		h1 = set_height(biTree[num].left) + 1;
	if (biTree[num].right != NIL)
		h2 = set_height(biTree[num].right) + 1;
	return biTree[num].height = max(h1, h2);
}

Measured memory_bytes: 3088
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
using namespace std;
int main() {
	long long n, t, a[200010];
	cin >> n >> t;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	long long ans = 0;
	long long f = 0;
	for (int i = 0; i < n; i++) {
		ans += t;
		if (f > a[i]) {
			ans -= f - a[i];
		}
		f = a[i] + t;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mp(x,y)     make_pair(x,y) 
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,a,n)   for(ll i=a;i<n;i++)
#define frr(i,a,n)  for(ll i=n-1;i>=a;i--)


const ll N   =  500005;
const ll mod = 1e9 + 7;

using namespace std;


void solve()
{
string s;
cin>>s;
//reverse(s.begin(), s.end());

ll x = (s[3]-'0') + (s[2]-'0')*10 + (s[1]-'0')*100 + (s[0]-'0')*1000;
if(x>2019)
{
  c("TBD");
  return;
}
ll y = (s[6]-'0') + (s[5]-'0')*10;

if(y>4 and x==2019)
{
 c("TBD");
  return;
}
ll z = (s[9]-'0') + (s[8]-'0')*10;
if(z>30 and y==4 and x==2019)
{
  c("TBD");
  return; 
}
c("Heisei");

}

signed main(){
 
      ios_base::sync_with_stdio(false);   
      cin.tie(NULL);
      ll T=1;
      //cin>>T;
      while(T--)
      {
      solve();
      }
      return 0;
    }


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

int stone[150][1000],m,n;
int dp[150][1000][76];

int main(){
	int i,j,k,r;
	int min,danger;
	while(1){
		scanf("%d %d",&n,&m);
		if(n==0)  break;
		memset(stone,0,sizeof(stone));
		memset(dp,-1,sizeof(dp));
		for(i=0;i<n;i++){
			scanf("%d",&k);
			for(j=0;j<k;j++){
				scanf("%d",&r);
				scanf("%d",&stone[i][r-1]);
			}
		}
		for(i=0;i<n;i++){
			for(j=0;j<1000;j++){
				if(stone[i][j]>0){
					if(i==0){
						dp[0][j][0]=0;
					}else{
						for(k=0;k<=m;k++){
							for(r=0;r<1000;r++){
								if(dp[i-1][r][k]>-1){
									if(dp[i][j][k]==-1) dp[i][j][k]=dp[i-1][r][k]+(stone[i-1][r]+stone[i][j])*abs(j-r);
									else{
										danger=dp[i-1][r][k]+(stone[i-1][r]+stone[i][j])*abs(j-r);
										dp[i][j][k]=(dp[i][j][k]>danger)?danger:dp[i][j][k];
									}
								}
							}
						}
						if(i==1){
							if(0<m){
								dp[i][j][1]=0;
							}
						}else{
							for(k=0;k<m;k++){
								for(r=0;r<1000;r++){
									if(dp[i-2][r][k]>-1){
										if(dp[i][j][k+1]==-1) dp[i][j][k+1]=dp[i-2][r][k]+(stone[i-2][r]+stone[i][j])*abs(j-r);
										else{
											danger=dp[i-2][r][k]+(stone[i-2][r]+stone[i][j])*abs(j-r);
											dp[i][j][k+1]=(dp[i][j][k+1]>danger)?danger:dp[i][j][k+1];
										}
									}
								}
							}
						}
					}
				}
			}
		}
		min=-1;
		for(i=0;i<1000;i++){
			for(j=0;j<=m;j++){
				if(dp[n-1][i][j]>-1){
					if(min==-1) min=dp[n-1][i][j];
					else min=(dp[n-1][i][j]<min)?dp[n-1][i][j]:min;
				}
				if(j<m){
					if(dp[n-2][i][j]>-1){
						if(min==-1) min=dp[n-2][i][j];
						else min=(dp[n-2][i][j]<min)?dp[n-2][i][j]:min;
					}
				}
			}
		}
		printf("%d\n",min);
	}
	return 0;
}

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

void swap(char *a,char *b){
	char c = *a;
	*a = *b;
	*b = c;
}

void parser(char s[],int n){
	char dir[8],p[1000],buf;
	int a,b,i,j;

	for(i=0;i<n;i++){
		scanf("%s",dir);
		if(!strcmp(dir,"print")){
			scanf("%d %d",&a,&b);
			while(a<=b)putchar(s[a++]);
			putchar('\n');
		}
		else if(!strcmp(dir,"reverse")){
			scanf("%d %d",&a,&b);
			while(b>a)swap(&s[a++],&s[b--]);
		}
		else if(!strcmp(dir,"replace")){
			scanf("%d %d %s",&a,&b,p);
			j=0;
			while(j<(b-a+1))s[j+a]=p[j],j++;
		}
	}
}

int main(){
	char s[1000];
	int i,n;
	scanf("%s",s);
	scanf("%d",&n);
	parser(s,n);
	return 0;
}

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

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

    vector<string> S(n);
    map<string, int> mp;
    int _max = 0;

    for (auto &&i : S)
    {
        cin >> i;
        mp[i]++;
    }

    int maxv = 0;
    for (auto &&i : mp)
        maxv = max(maxv, i.second);

    for (auto &&i : mp)
    {
        if (i.second == maxv)
            cout << i.first << endl;
    }

    return 0;
}

Measured memory_bytes: 26752
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int D = sc.nextInt();
        if (D==25) {
            System.out.println("Christmas");
        }else if (D==24) {
            System.out.println("Christmas Eve");
        }else if (D==23) {
            System.out.println("Christmas Eve Eve");
        }else if (D==22) {
            System.out.println("Christmas Eve Eve Eve");
        }else{
        }
    }
}

Measured memory_bytes: 20692
/*
  A - Haiku
  Contest 051
  Rakesh Kumar --> 04/08/2020
 */

#include <bits/stdc++.h>

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0); std::cout.tie(0);

    std::string s;
    std::getline(std::cin, s);
    for (char c : s)
        if (c == ',')
            std::cout << " ";
        else
            std::cout << c;
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int maxn = 30;

int n, m;
char a[maxn][maxn];
int dx[] = {1, -1, 0 ,0};
int dy[] = {0, 0, 1, -1};

bool valid(int x, int y){
	return x >= 0 && x < n && y >= 0 && y < m;
}

int bfs(int x, int y){
	vector<vector<int>> d(n, vector<int>(m, -1));
	d[x][y] = 0;
	queue<pii> Q;
	Q.push({x, y});
	int ans = 0;
	while(!Q.empty()){
		x = Q.front().first;
		y = Q.front().second;
		Q.pop();
		ans = max(ans, d[x][y]);
		
		for(int i  =0; i < 4; i++){
			int nx = x + dx[i];
			int ny = y + dy[i];
			if(valid(nx, ny) && a[nx][ny] != '#' && d[nx][ny] == -1){
				d[nx][ny] = d[x][y] + 1;
				Q.push({nx,ny});
			}
		}
	}
	return ans;
}

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	cin >> n >> m;
	
	for(int i = 0; i < n; i++)
		cin >> a[i];
	
	int ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			
			if(a[i][j] == '.'){
				
				ans = max(ans, bfs(i, j));
				
			}
			
		}
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
a = Array.new(n + 1){[]}
m.times do
    x, y = gets.split.map(&:to_i)
    a[x] << y
    a[y] << x
end
c = Array.new(n + 1)
c[1] = 1
que = []
que << 1
while que.size > 0
  e = que.shift
  a[e].each do |i|
    next if c[i]
    c[i] = e
    que << i
  end
end
puts "Yes", c[2..-1]

Measured memory_bytes: 32600
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a[4],b;
  cin>>a[0]>>a[1]>>a[2];
  sort(a,a +3);
  cout<<a[2]*10+a[1]+a[0]<<'\n';
  return 0;
}


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;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define INT_INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define MOD 998244353
#define MOD2 1494318097
#define SEED 131
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

#define MAXN 200005
#define MAXV 1000005

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unordered_map<int,int> umii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

mt19937 g1(time(0));

int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);}
ll randlong(ll a,ll b){return uniform_int_distribution<long long>(a, b)(g1);}

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

int len,arr[MAXN];
vector<int> nums[MAXV];
ll dp[MAXV],res;

int main(){
	scanf("%d",&len);
	for(int i=1; i<=len; i++){
		scanf(" %d",&arr[i]);
		for(int k=1; k<=sqrt(arr[i]); k++){
			if(arr[i]%k == 0){
				nums[k].pb(arr[i]);
				if(k*k != arr[i])
					nums[arr[i]/k].pb(arr[i]);
			}
		}
	}
	for(int n=1000000; n>=1; n--){
		if(!nums[n].size()) continue;
		ll sum = 0, tot = 0;
		for(int check:nums[n]) sum = (sum+check)%MOD;
		for(int i=0; i<nums[n].size(); i++){
			sum = (sum-nums[n][i]+MOD)%MOD;
			tot = (tot+nums[n][i]*sum)%MOD;
		}
		for(int v=n+n; v<=1000000; v+=n)
			tot = (tot-dp[v]+MOD)%MOD;
		res = (res+divmod(tot,n,MOD))%MOD;
		dp[n] = tot;
	}
	printf("%lld\n",res);
}

Measured memory_bytes: 67028
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}
long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a*b/gcd(a,b);
}

long long com(long long n,long long k){
	
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	string t;
	int a,b,c;
	cin>>a>>b;
	int ans=0;
	for(int i=1;i<=a;i+=2)ans++;
	if(ans>=b)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
}

	


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

struct Rect {
  int h;
  int w;
  Rect(int h, int w) : h(h), w(w) {;}
  bool operator<(const Rect &rhs) const {
    if (diag() != rhs.diag()) { return diag() < rhs.diag(); }
    return h < rhs.h;
  }
  //bool operator>(const Rect &rhs) const { return rhs < *rect; }
  int diag() const { return h * h + w * w; }
};

int main() {
  int h, w;
  while (cin >> h >> w, h|w) {
    Rect base(h, w);
    Rect ans(150, 150);
    FOREQ(y, 1, 150) {
      FOREQ(x, y + 1, 150) {
        Rect cand(y, x);
        if (x == w && y == h) { continue; }
        if (cand < base) { continue; }
        ans = min(ans, cand);
      }
    }
    printf("%d %d\n", ans.h, ans.w);
  }
}

Measured memory_bytes: 1144
s = input()
lenth = len(s)
plus = lenth - 1
ans = 0
for i in range(1 << plus):
    right = lenth
    i_two = format(i,'b')
    ilen= len(format(i,'b'))
    for j in range(ilen):
        if i_two[ilen - 1 - j] == '1':
            ans += int(s[lenth - 1 - j:right])
            right = lenth - 1 - j
    ans += int(s[0:right])
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

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

    std::cout << (n + 2*d) / (2*d + 1) << '\n';

    return 0;
}


Measured memory_bytes: 256
import queue
N,M = map(int,input().split())

G = list([set() for i in range(N)])
for i in range(M):
  A,B = map(int,input().split())
  G[A-1].add(B-1)
  G[B-1].add(A-1)

q = queue.Queue()
dist = [-1] * N
dist[0] = 0
q.put(0)

while(q.empty() != True):
  nextNode = q.get()
  nextDist = dist[nextNode] + 1
  for i in G[nextNode]:
    if dist[i] == -1:
      q.put(i)
      dist[i] = nextNode

if len([0 for i in dist if i == -1]) == 0:
  print('Yes')
  for i in dist[1:]:
    print(i + 1)
else:
  print('No')

Measured memory_bytes: 63768
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int,int> pii;
typedef pair <db,db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

const int N=200005;

void solve()
{
    int x;
    cin>>x;
    if(x>=30)
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;
    
    
}

int32_t main()
{
    IOS;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        
        solve();
    }
    return 0;
}


Measured memory_bytes: 3636
class combination:
    def __init__(self, n, mod):
        fact = [0]*(n+1)
        ifact = [0]*(n+1)
        fact[0] = 1
        for i in range(1, n+1):
            fact[i] = (fact[i-1]*i) % mod
        # 1/n!を逆元で求める
        ifact[n] = pow(fact[n], mod-2, mod)
        for i in range(n, 0, -1):
            ifact[i-1] = (ifact[i]*i) % mod

        self.n = n
        self.mod = mod
        self.fact = fact
        self.ifact = ifact

    def choose(self, n, r):
        if r < 0 or r > n:
            return 0
        ret = (self.fact[n]*self.ifact[r]) % self.mod
        return (ret*self.ifact[n-r]) % self.mod


MOD = 998244353
N, M, K = map(int, input().split())
c = combination(N, MOD)

ans = 0
for k in range(K+1):
    ncr = c.choose(N-1, k) if k > 0 else 1
    t = ncr*M*pow(M-1, N-k-1, MOD)
    ans = (ans+t) % MOD
print(ans)


Measured memory_bytes: 75732
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <cmath>
#include <random>
using namespace std;
typedef pair<int, int>p;

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	int cnt[100005] = { 0 };
	int a, b;
	string ans = "YES";
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		cnt[a] += 1;
		cnt[b] += 1;
	}
	for (int i = 1; i <= n; i++) {
		if (cnt[i] % 2)ans = "NO";
	}
	cout << ans;
}

Measured memory_bytes: 640
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define ull unsigned long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, A, B;
	cin >> N >> A >> B;

	cout << ((B - A) % 2 == 0 ? "Alice" : "Borys") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    string in; cin >> in;
    int n = in.size();
    {
        string f = in.substr(0, (n - 1) / 2);
        string lrev = in.substr(n / 2, (n - 1) / 2);
        cerr << f << ", " << lrev << endl;
        reverse(_all(lrev));

        if(in.back() == '1' or
           f[0] == '0' or
           f != lrev){
            cout << -1 << endl;
            return 0;
        }
    }

    vi pa(n);
    int cur = 0;
    rep(i, n - 1){
        if(in[i] == '1'){
            pa[cur] = i + 1;
            cur = i + 1;
        }
        else {
            pa[i + 1] = cur;
        }
    }

    rep(i, n - 1){
        cout << i + 1 << " " << pa[i] + 1 << endl;
    }

    return 0;
}


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

const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.14159265;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()

#define cout cout << setprecision(12)

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void dbg(T a) { cout << a << ' '; }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main() {
    cin >> c;
    n = (int)c + 1;
    cout << (char)n << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	int x,y,z;
	cin >> x >> y >> z;
	
	int ans = 1;
	x -= (2*z+y);
	
	ans += (x/(y+z));
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys

n = int(input())

res = 0
if n == 1:
    print(1)
    sys.exit()
for i in reversed(range(2, n+1)):
    cnt = 2
    while True:
        if pow(i, cnt) > n:
            break
        else:
            if res < pow(i, cnt):
                res = pow(i, cnt)
        cnt += 1
print(res)

Measured memory_bytes: 3060
import java.util.*;

class Main{
	
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int X = sc.nextInt();
		int M[] = new int[N];


		for(int n=0;n<N;n++){
			M[n] = sc.nextInt();
		}

		int total = M[0];
		int min = M[0];

		for(int n=1;n<N;n++){
			total += M[n];
			if(min > M[n])
				min = M[n];
		}

		System.out.println((X - total)/min +N);

	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
typedef long long ll;
using namespace std;
int main(void){
    ll A,B,M;cin>>A>>B>>M;
    vector<ll> a(A),b(B);
    ll mina=1e+5+1,minb=1e+5+1;
    rep(i,A){
        cin>>a[i];
        mina=min(mina,a[i]);
    }
    rep(i,B){
        cin>>b[i];
        minb=min(minb,b[i]);
    }
    ll res=mina+minb;
    rep(i,M){
        ll x,y,c;
        cin>>x>>y>>c;x--;y--;
        ll now=a[x]+b[y]-c;
        res=min(res,now);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 1792
N = int(input())
S = input()

if N%2 == 0:
    s1 = []
    s2 = []
    s1 = S[:int(N/2)]
    s2 = S[int(N/2):]
    
    if s1 == s2:
        print("Yes")
    else:
        print("No")
else:
    print("No")


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

set<int> st;
int a, b, c;

int main() {
    cin >> a >> b >> c;
    st.insert(a);
    st.insert(b);
    st.insert(c);

    if (st.size() == 2) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    int a,b;
    cin >> a >> b;
    int x;
    cin >> x;
    if((a+b)>=x&& a<= x){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
#define pb                emplace_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (ll)((x).size())
#define ff                first
#define ss                second
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll
#define isBitset(S,i)     ((S>>i)&1)
#define print(x) 		  for(auto it:x) cout<<it<<" "; cout<<"\n"; 
#define gcd(a,b)		  __gcd(a,b)
#define lcm(a,b) 		  (a/gcd(a,b))*b
#define MOD 1000000007 
ll powerMod(ll x,ll y){
    ll res = 1;
    x %= MOD;
    while(y > 0){
        if(y & 1)res = (res*x)%MOD;
        y = y >> 1;
        x = (x * x)%MOD;
    }
    return res%MOD;
}
string binary(ll s) {
    string res = "";
    while(s != 0) {
        res += (char)('0' + s % 2);
        s /= 2;
    }
    reverse(res.begin() , res.end());
    return res;
}
void solve()
{
	ll n;cin>>n;
	string s;
	for(ll i=0;i<n;++i)
	{
		s+="ACL";
	}
	cout<<s;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);   
        solve();
    return 0;
}

Measured memory_bytes: 3616
/*
Though leaves are many, the root is one;
Through all the lying days of my youth
I swayed my leaves and flowers in the sun,
Now may I wither into the truth.

- William Butler Yeats
*/
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <iomanip>
#include <bitset>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;

#define ll long long
#define pii pair<int,int>
#define qi ios::sync_with_stdio(0)
/**==Info==
*Program:
*Problem:
*Date:
*Algorithm:
*Status:*/

bool debug=false;

ll a,b,n;
int main(int argc,char* argv[]){
	cin>>n>>a>>b;
	
	if(a>b){
		swap(a,b);
	}
	
	if((b-a)%2==0){
		cout<<(b-a)/2;
	}else{
		cout<<min(a-1+1+(b-a)/2,n-b+1+(b-a)/2);
	}
//	ll ans1=((b-a)%2==0?(b-a)/2:1e18);
	
	
//	cout<<min({ans1,ans2,ans3});
	return 0;
}



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

using namespace std;

int main() {
	int N;
	vector<int> L(20);
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> L[i];
	}
	int max_val = *max_element(L.begin(), L.end());
	int sum_val = accumulate(L.begin(), L.end(), 0);

	if (sum_val - max_val > max_val) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define debug1(a) cout<<"------\n"<<#a<<" = "<<a<<endl<<"------"<<endl
#define debug2(a,b) cout<<"--------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<endl<<"--------------"<<endl
#define debug3(a,b,c) cout<<"----------------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<" ; "<<#c<<" = "<<c<<endl<<"----------------------"<<endl
#define sz(a) (ll)(a.size())
#define debug4(a) cout<<"chu "<<a<<endl
#define endl "\n"

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  ll n;
  cin>>n;
  vector<ll> a(n);
  string s;
  cin>>s;
  forn(i,0,n){
    if(s[i]=='W')
      a[i]=1;
    else
      a[i]=0;
  }
  ll zeros=0,ones=0,ans=0;
  forn(i,0,n){
    if(a[i]==0)
      zeros++;
    else
      ones++;
  }
  forn(i,0,zeros){
    if(a[i]==1)
      ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 5176
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: i64 = read();
    let a: i64 = read();
    let b: i64 = read();

    let ans = if a % 2 == b % 2 {
        (b - a) / 2
    } else {
        std::cmp::min(a - 1, n - b) + 1 + (b - a - 1) / 2
    };

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
#define LONG LLONG_MAX/3;
#define INT INT_MAX/3;
#define mod 1000000007
#define S second
#define F first
#define int long long
using namespace std;
int x[100000];
int mypow(int a,int b,int c){
	if(b==1) return a%c;
	if(b%2) return a*mypow(a,b-1,c)%c;
	int d=mypow(a,b/2,c);
	return d*d%c;
}
signed main(){
	int n,a=0,b=mod,c;
	cin>>n;
	f(i,n){
		cin>>x[i];
		a+=x[i];
	}
	f(i,n){
		if(abs(a-x[i]*n)<b){
			b=abs(a-x[i]*n);
			c=i;
		}
	}
	cout<<c<<endl;
	return 0;
}


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

typedef long long ll;
const int mo = 998244353, X = 1e4 + 7, Y = 1e7 + 7;
const int N = 2.5e5 + 10;
int n;
ll cnt[N], pre[N], X1, cnt2[N], pre2[N], Y1;
char s[N];

ll ksm(ll x, ll y) {
	ll ret = 1; for (; y; y >>= 1) {
		if (y & 1) ret = ret * x % mo;
		x = x * x % mo;
	}
	return ret;
}

map<pair<ll, ll>, int> h;
pair<ll, ll> tj(int x) {
	return make_pair(((pre[n] * cnt[x] % mo + pre[x]) % mo + mo) % mo,
		((pre2[n] * cnt2[x] % mo + pre2[x]) % mo + mo) % mo);
}

int main() {
	cin >> n;
	scanf("%s", s + 1);
	cnt[0] = 1; cnt2[0] = 1;
	X1 = ksm(X, mo - 2); Y1 = ksm(Y, mo - 2);
	for (int i = 1; i <= n; i++) {
		cnt[i] = cnt[i - 1];
		pre[i] = pre[i - 1];
		cnt2[i] = cnt2[i - 1];
		pre2[i] = pre2[i - 1];
		if (s[i] == '>') {
			cnt[i] = cnt[i] * X % mo;
			cnt2[i] = cnt2[i] * Y % mo;
		}
		else if (s[i] == '<') {
			cnt[i] = cnt[i] * X1 % mo;
			cnt2[i] = cnt2[i] * Y1 % mo;
		}
		else if (s[i] == '+') {
			pre[i] = (pre[i] + cnt[i]) % mo;
			pre2[i] = (pre2[i] + cnt2[i]) % mo;
		}
		else {
			pre[i] = (pre[i] - cnt[i]) % mo;
			pre2[i] = (pre2[i] - cnt2[i]) % mo;
		}
	}
	ll ans = 0;
	h[tj(0)] = 1;
	for (int i = 1; i <= n; i++) {
		pre[i] = (pre[i] + mo) % mo;
		pre2[i] = (pre2[i] + mo) % mo;
		ans += h[make_pair(pre[i], pre2[i])];
		h[tj(i)] ++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 39552
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int main()
{
	int n,k;
	
	cin >> n >>k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
	}

	sort(a.begin(), a.end(), greater<int>());

	int length = 0;

	for (int i = 0; i < k; ++i) {
		length += a.at(i);
	}

	cout << length << endl;
	return 0;
}

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

def factorize(x):
    """xの素因数分解を表す辞書 {素因数: 指数}"""
    f = {}
    d = 2
    while x > 1:
        c = 0
        while x % d == 0:
            c += 1
            x //= d
        if c > 0:
            f[d] = c
        d += 1 if d == 2 else 2
        if d * d > x > d:
            f[x] = 1
            break
    return f

def factorizeWithSet(x, D):
    f = {}
    for d in D:
        c = 0
        while x % d == 0:
            c += 1
            x //= d
        if c > 0:
            f[d] = c
    return f

def dropmin(ls):
    """[min(ls[:i] + ls[i + 1:]) for i in range(len(ls))]"""
    # l = [min(ls[:i]) for i in range(len(ls))]
    l = [float('inf')] * N
    for i in range(1, N):
        l[i] = min(l[i - 1], ls[i - 1])
    # r = [min(ls[i + 1:]) for i in range(len(ls))]
    r = [float('inf')] * N
    for i in range(N - 2, -1, -1):
        r[i] = min(r[i + 1], ls[i + 1])
    return [min(a, b) for a, b in zip(l, r)]

def prod(ls):
    p = 1
    for x in ls:
        p *= x
    return p

# 各A_iの素因数
A = list(A)
F = [factorize(a) for a in A[:2]]

# 素因数の集合 (2要素に出現しない素因数は無視)
D =  set(F[0].keys())
D.update(F[1].keys())

E = set()
for d in D:
    c = 0
    for a in A:
        if a % d != 0:
            c += 1
            if c >= 2:
                E.add(d)
                break
D -= E

F = [factorizeWithSet(a, D) for a in A]

# Dの要素 d -> i -> dがA_iに含まれる個数
X = {d: [f[d] if d in f else 0 for f in F] for d in D}

# Dの要素 d → A_iを削除したときのdの個数の最小値のリスト
X = {d: dropmin(X[d]) for d in D}

S = [prod(d ** X[d][i] for d in D) for i in range(N)]
print(max(S))


Measured memory_bytes: 120940
'use strict';

function Main(INPUT) {
    const N = INPUT.split("\n")[0].split("").map(n => Number(n));
    if (N[0] == 9 || N[1] == 9) {
        console.log("Yes");
    } else {
        console.log("No");
    }
}

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


Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
constexpr int maxn = 100000;
int a[maxn + 1];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int N, L;
    cin >> N >> L;
    for(int i = 1; i <= N; i += 1) cin >> a[i];
    for(int i = 1; i < N; i += 1) if(a[i] + a[i + 1] >= L){
        cout << "Possible\n";
        for(int j = 1; j < i; j += 1) cout << j << "\n";
        for(int j = N - 1; j > i; j -= 1) cout << j << "\n";
        cout << i;
        return 0;
    }
    cout << "Impossible";
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;
typedef pair<double, double> dd;
#define mp make_pair
#define pb push_back
#define debug(x) cerr << #x << " = " << x << " "

const int N = 8e2+1;
char s[N][N];
bool vis[N][N];
int n, m, k;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, -1, 0, 1};
int solve()
{
  for (int i = 0; i < n; ++i) scanf("%s", s[i]);
  memset(vis, 0, sizeof(vis));
  int sx, sy;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
      if (s[i][j] == 'S')
	sx = i, sy = j;
  queue<ii> q;
  auto push = [&](int x, int y)
	      {
		vis[x][y] = true;
		q.push(mp(x, y));
	      };
  push(sx, sy);
  for (int i = 1; i <= k && !q.empty(); ++i)
    {
      int sz = q.size();
      for (int i = 0; i < sz; ++i)
	{
	  ii cur = q.front(); q.pop();
	  for (int dir = 0; dir < 4; ++dir)
	    {
	      int nx = cur.first + dx[dir];
	      int ny = cur.second + dy[dir];
	      if (nx < 0 || nx >= n || ny < 0 || ny >= m || vis[nx][ny] || s[nx][ny] == '#')
		continue;
	      push(nx, ny);
	    }
	}
    }
  int ans = n * m + 1;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
      if (vis[i][j])
	ans = min(ans, min(min(i,n-i-1), min(j, m-j-1)));
  ans = 1 + (ans + k-1)/k;
  return ans;
}


int main()
{
  while (~scanf("%d %d %d", &n, &m, &k)) printf("%d\n", solve());
}


Measured memory_bytes: 1536
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>v(n);
    bool even=true;
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
        if(v[i]%2!=0)
        {
            even=false;
        }
    }
    int count=0;
    while(even)
    {
        count++;
        for(int i=0;i<n;i++)
        {
            v[i]/=2;
            if(v[i]%2!=0)
            {
                even=false;
                break;
            }
        }
    }
    cout<<count;
}

Measured memory_bytes: 3520
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  if(a>=max(b,c)){
    cout<<a*pow(2,k)+b+c<<endl;
  }else if(b>=max(a,c)){
    cout<<b*pow(2,k)+a+c<<endl;
  }else{
    cout<<c*pow(2,k)+a+b<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, mut k) = scan!(i64, i64);
    let mut vs = scan!(i64, i64;n as usize);
    vs.sort();
    for v in vs.iter() {
        k -= v.1;
        if k <= 0 {
            println!("{}", v.0);
            return;
        }
    }
    panic!("not found");
}


Measured memory_bytes: 6396
K=int(input())

l=["1","2","3","4","5","6","7","8","9"]
la=["1","2","3","4","5","6","7","8","9"]
c=9

if K<=9:
    print(K)
    exit()

while c<K:
    lb=[]
    for i in la:
        if i[-1]=="0":
            l.append(i+"0")
            l.append(i+"1")
            lb.append(i+"0")
            lb.append(i+"1")
            c+=2
        elif i[-1]=="9":
            l.append(i+"8")
            l.append(i+"9")
            lb.append(i+"8")
            lb.append(i+"9")
            c+=2
        else:
            j=int(i[-1])
            l.append(i+str(j-1))
            l.append(i+str(j))
            l.append(i+str(j+1))
            lb.append(i+str(j-1))
            lb.append(i+str(j))
            lb.append(i+str(j+1))
            c+=3
    la=lb

print(l[K-1])




Measured memory_bytes: 30360
#include<iostream>
#include<math.h>
#include<algorithm>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)

using namespace std;

int main(){
	int n, a, b;;
	cin >> n;
	if(n == 1) cout << "Hello World" << endl;
	else if(n == 2){
		cin >> a >> b;
		cout << a+b << endl;
	}
	return 0;
}


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

signed main() {
    int n,m;
    cin >> n >> m;

    priority_queue<int> que;
    rep(i,n){
        int a;
        cin >> a;
        que.push(a);
    }

    while(m--){
        int x = que.top();
        que.pop();
        x /= 2;
        que.push(x);
    }

    int ans = 0;
    while(!que.empty()){
        int x = que.top();
        que.pop();
        ans += x;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1400