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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}
template<class Abel>
class WeightedUnionFind{
private:
	::std::vector<int_fast32_t> par;
	::std::vector<Abel> diff_weight;
	size_t n;

public:
	WeightedUnionFind(){}
	WeightedUnionFind(size_t n, Abel identity = 0):n(n){
		par.resize(n, -1);
		diff_weight.resize(n, identity);
	}

	uint_fast32_t find(uint_fast32_t x){
		if (par[x] < 0) {
			return x;
		} else {
			uint_fast32_t root = find(par[x]);
			diff_weight[x] += diff_weight[par[x]];
			return par[x] = root;
		}
	}

	Abel weight(uint_fast32_t x){
		find(x);
		return diff_weight[x];
	}

	size_t size(uint_fast32_t x){
		return -par[find(x)];
	}

	bool unite(uint_fast32_t x, uint_fast32_t y, Abel w){
		w += weight(x); w -= weight(y);
		x = find(x); y = find(y);
		if(x == y) return false;
		if(size(x) < size(y)) std::swap(x, y), w = -w;
		par[x] += par[y];
		par[y] = x;
		diff_weight[y] = w;
		return true;
	}

	Abel diff(uint_fast32_t x, uint_fast32_t y){
		return weight(y) - weight(x);
	}

	bool same(uint_fast32_t x, uint_fast32_t y){
		return find(x) == find(y);
	}
};


int main(void){
	int64 N, M;
	scanf("%lld %lld", &N, &M);
	WeightedUnionFind<int64> wuf(N);
	REP(i, M){
		int64 l, r, d;
		scanf("%lld %lld %lld", &l, &r, &d);
		--l; --r;
		if (!wuf.unite(l, r, d)) {
			if (wuf.diff(l, r) != d) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 1920
#![allow(non_snake_case)]
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read_option<T: FromStr>() -> Option<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()
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let MOD: i64 = 10_i64.pow(9) + 7;
    let h: usize = read();
    let w: usize = read();
    let mut map: Vec<Vec<Option<i64>>> = vec![ vec![None; w]; h ];
    for i in 0..h {
        let str: String = read();
        for (j, c) in str.chars().into_iter().enumerate() {
            map[i][j] = match c {
                '.' => Some(0),
                '#' => None,
                _ => panic!("strange char")
            };
        }
    }
    map[0][0] = Some(1);
    for i in 0..h {
        for j in 0..w {
            if map[i][j].is_none() || (i == 0 && j == 0) {
                continue;
            }

            map[i][j] = if (i == 0 || map[i - 1][j].is_none()) && (j == 0 || map[i][j - 1].is_none()) {
                Some(0)
            } else if i == 0 || map[i - 1][j].is_none() {
                map[i][j - 1]
            } else if j == 0 || map[i][j - 1].is_none() {
                map[i - 1][j]
            } else {
                Some((map[i - 1][j].unwrap() + map[i][j - 1].unwrap()) % MOD)
            };
        }
    }
    println!("{}", map[h - 1][w - 1].unwrap());
}


Measured memory_bytes: 24828
n = int(input())
a = list(map(int, input().split()))
B = []
ans = 0
for i in range(n):
  B.append(a[i] - i - 1)
b = sorted(B)[len(B) // 2]
for i in range(n):
  ans += abs(B[i] - b)
print(ans)

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

using namespace std;

//mem(a, b) memset(a, (b), sizeof(a))

typedef long long ll;

#define f(i,a,b) for (ll i=a ; i<b ; i++)
#define fr(i,a,b) for (ll i=a ; i>=b ; i--)

#define faster ios::sync_with_stdio(0);cin.tie(0);
typedef pair<int, int> p;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<p> vii;
typedef vector<vi> vvi;
typedef map<int,int> mp;
typedef set<int> se;
typedef multiset<int> MSETI;


// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal


// find if a given value is present in a container. Container version. Runs in log(n) for set and map
#define present(c,x) ((c).find(x) != (c).end())

//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())

// Avoiding wrap around of size()-1 where size is a unsigned int.
#define sz(a) int((a).size())


#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

struct duo{
    ll x,y;
};

bool mycomp(duo a,duo b) { return a.x < b.x ;}

bool comp(int a,int b){
	return a<b;
}


int main()
{
    faster

	//freopen("input.txt","r",stdin);
	//g++ myC.cpp -o myC
        //myC
	/*ofstream myfile;
   	myfile.open ("example.txt");
  	myfile << "Writing this to a file.\n";
 	 myfile.close();*/
   	 
	ll t,n,a=0,b=0,d,i,j,k,c,sum;
    	string s;
  cin >> n >> s;
   c = 0;
  f(i,0,1000) {
    string y;
    b = i;
    f(j,0,3) {
      y += '0'+b%10;
      b /= 10;
    }
 
     d = 0;
    f(j,0,n) {
      if (s[j] == y[d]) {
        d++;
        if (d == 3) break;
      }
    }
    if (d == 3) c++;
  }
  cout << c << endl;
}
    
    
	


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

int main()
{
    int n, m, i, j, a, w;
    int* adj[100];
    int* dist[100];
    cin >> n;
    for(i = 0; i < n; i++){
        cin >> i >> m;
        adj[i] = new int [m + 1];
        dist[i] = new int [m + 1];
        for(j = 0; j < m; j++){
            cin >> a >> w;
            adj[i][j] = a;
            dist[i][j] = w;
        }
        adj[i][m] = -1;
        dist[i][m] = -1;
    }
    int *d, *prev, *Q;
    d = new int [n];
    prev = new int [n];
    Q = new int [n];
    for(i = 0; i < n; i++){ d[i] = 200000; prev[i] = -1; Q[i] = i; }
    int rest = n;
 
    int u, v, min;
    d[0] = 0;
    while(rest > 0){
        min = 200000;
        for(i = 0; i < n; i++){
            if(min > d[i] && Q[i] >= 0){ min = d[i]; u = i; }
        }
        Q[u] = -1;
        rest--;

        for(j = 0; adj[u][j] >= 0; j++){
            v = adj[u][j];
            if(d[v] > d[u] + dist[u][j]){
                d[v] = d[u] + dist[u][j];
                prev[v] = u;
            }
        }
    };
    for(i = 0; i < n; i++){ cout << i << " " << d[i] << endl; }
    for(i = 0; i < n; i++){
        delete adj[i]; delete dist[i]; }
    delete d;
    delete prev;
    delete Q;
    cin >> n;
 
    return 0;
}

Measured memory_bytes: 1236
i = 0
while i < 5:
    fee = int(input())
    if fee == 0:
        break
    
    refee = 1000 - fee
    
    C500 = refee     // 500
    C100 = refee%500 // 100
    C50  = refee%100 // 50
    C10  = refee%50  // 10
    C5   = refee%10  // 5
    C1   = refee%5
    
    sum = C500 + C100 + C50 + C10 + C5 + C1
    print(sum)


Measured memory_bytes: 5584
#include <bits/stdc++.h>
using namespace std;
#define ll long long  
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define prec(y,x) fixed<<setprecision(y)<<x
#define inf 1e18
#define pi 3.1415926535
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int n=s.size();
    ll arr[3][2021];
    for(ll i=0;i<=2;i++)
    {
        for(ll j=0;j<=2020;j++)
        arr[i][j]=0;
    }
    int u=s[0]-'0'; ll ans=0;
    arr[0][u]=1;
    for(int i=1;i<n;i++)
    {
        int  u=s[i]-'0';
        arr[1][u]=1;
        for(int j=0;j<2019;j++)
        {
            int y=10*j+u;
            y%=2019;
            arr[1][y]+=arr[0][j];
        }
        ans+=arr[1][0];
        for(ll j=0;j<=2020;j++)
        {arr[0][j]=arr[1][j];arr[1][j]=0;}
        
    }
   
    
    cout<<ans;
    return 0;
}
//make all values ll


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


int main()
{
    string S;
    cin >> S;

    if( S[2] == S[3] and S[4] == S[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

require 'pp'

N,K=gets.chomp.split(' ').map{|n| n.to_i}
sum = [0,0]
A = gets.chomp.split(' ').map{|n| n.to_i}
F = Array.new(A.size) { true }
max0 = A.each_with_index.select{|a| a[1]%2 == 0}.max{|a,b| a[0]<=>b[0]}
max1 = A.each_with_index.select{|a| a[1]%2 != 0}.max{|a,b| a[0]<=>b[0]}
max = [max0,max1].max{|a,b| a[0] <=> b[0]}
A.each_with_index{|n,i|
	if(n > 0)
		i%2==0 ? sum[0]+=n : sum[1]+=n
	else
		F[i] = false
	end
}
summax = sum.max
if(summax == sum[0])
	1.step(F.size-1,2){|i|
		F[i] = false
	}
else
	0.step(F.size-1,2){|i|
		F[i] = false
	}
end
if(sum[0] == 0 && sum[1] == 0)
	puts max[0]
	puts A.size-1
	delnum = 0
	arr = []
	thei = A.index(max[0])
	for i in 0..(thei-1)
		puts 1
	end
	(A.size-1).downto(thei+1){|i|
		puts i+1-thei
	}
else
	puts sum.max
	# first F
	# last F
	# T -> T (initial)
	# TF -> TF
	# TFT -> T
	# TFF -> TF
	# TFFT -> T, last merge in the range
	arr = []
	i = 0
	delnum = 0
	while(true)
		if(!F[i])
			arr << i+1-delnum
			delnum += 1
		else
			break
		end
		i += 1
	end
	itmp = i
	i = A.size-1
	while(true)
		if(!F[i])
			arr << i+1-delnum
		else
			break
		end
		i -= 1
	end
	ifinal = i
	i = itmp + 2
	ibase = itmp+1+1-delnum
	while(i <= ifinal)
		# p F
		# puts "i is #{i}, #{F[i]}"
		if(!F[i])
			arr << i+1-delnum
			delnum += 2
		else
			arr << ibase
			# puts "ibase"
			# puts ibase
			delnum += 2
			ibase = i+1+1-delnum
			# puts "newibase"
			# puts ibase
		end
		i += 2
	end	
	puts arr.size
	puts arr
end



Measured memory_bytes: 2428
/// Solution No.:

/// Approach:

/// Comment:

/// Verdict:

/// Report:


#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>
#include <sstream>
#include <cstdio>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <string.h>
#include <climits>
#include <set>
#include <cassert>
#include <cfloat>
#include <stack>

///using namespace std;         /// Recommended not to use

#define p(x) std::cout<<#x<<" = "<<x<<"\n"
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define absolute(x) (((x)<0)?(-(x)):(x))
/// #define _DEBUG

typedef long long int ll;
typedef unsigned long long llu;
typedef long double lld;

/// lld pi = 2 * acos(0.0);   /// precision error
lld pi = 2 * acosl(0.0);

int test_case_number, test_case=1;

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
/// Direction Array
/// int dx[]={0, 0, 1, -1, -1, 1, -1, 1};
/// int dy[]={-1, 1, 0, 0, 1, 1, -1, -1};

///place for problem specific functions


void function_name()
{
    ll a, b;
    scanf("%lld %lld", &a, &b);
    printf("%lld\n", a*b);
}
void function_name(int v1, int v2, int v3)
{

}
void function_name(std::string line)
{

}
class initial_works
{
public:

    void with_test_case_number()
    {
        scanf("%d", &test_case_number);
        ///getchar();
        while(test_case <= test_case_number)
        {
            function_name();
            test_case++;
        }
    }

    void single_iteration()
    {
        function_name();
    }

    void without_test_case_number()
    {
        int v1, v2, v3;
        while(scanf("%d %d %d", &v1, &v2, &v3)==3 && v1!=0)
        {
            function_name(v1, v2, v3);
            test_case++;
        }
    }

    void eoof()
    {
        char dummy_char_array[100];
        while(scanf("%[^\n]", dummy_char_array)!=EOF)
        {
            ///it only takes the absence of one getchar to ruin your life. Don't understand remove the getchar below and then input the sample input
            getchar();
            ///if not given getchar. the dummu_char_array will not take new input as there is newline after the first input is taken. It will continue with the previous value.
            /// So, the function will run with same argument.
            std::string line = dummy_char_array;
            function_name(line);
            test_case++;
        }
    }
};


int main()
{
    //std::ios_base::sync_with_stdio(false);
    initial_works a;
    a.single_iteration();

    return 0;
}


Measured memory_bytes: 3764
from collections import defaultdict
s = input()
n = len(s)
ans = -1

if len(s) < 26:
    alphabet_ls = [chr(i) for i in range(97, 97+26)]
    alphabet_dict = defaultdict(int)
    for i in range(n):
        alphabet_dict[s[i]] = 1
    for alphabet in alphabet_ls:
        if alphabet_dict[alphabet] == 0:
            ans = s + alphabet
            break

else:
    stock_ls = []
    for i in range(25,-1,-1):
        now = s[i]
        greater = []
        for stock in stock_ls:
            if now < stock:
                greater.append(stock)
        if greater:
            replacer = min(greater)
            ans = s[:i] + replacer
            break
        else:
            stock_ls.append(s[i])
print(ans)




Measured memory_bytes: 65068
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <cstring>
using namespace std;

int main(void)
{
	int n, m, k;
	scanf("%d%d%d", &n, &m, &k);

	for(int i = 0;i <= n;i++)
	{
		for(int j = 0;j <= m;j++)
		{
			if(i*(m-j)+j*(n-i) == k)
			{
				printf("Yes\n");
				exit(0);
			}
		}
	}
	printf("No\n");
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
#define ll long long
#define MAXN 200005
using namespace std;
ll a[MAXN], pre[MAXN], mn = (1ll << 62);
int main() {
	ll n;
	scanf("%lld", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		pre[i] += a[i] + pre
		[i-1];
	}
	for(int i = 1; i < n; i++) 
		mn = min(abs(pre[n]-pre[i]-pre[i]), mn);
		
	printf("%lld\n", mn);
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
   int n;
   cin >> n;
   VI a(n);
   rep(i,n)cin >> a.at(i);
   int cnt=0;
   rep(i,n){
      if(i%2==0 && a.at(i)%2==1)cnt++;
   }
   cout << cnt << endl;
}

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


#define M_MAX 20
#define N_MAX 50000
#define INFTY 1 << 29

int main(){
int n;
cin >> n;
string s[n];
set<string> setn;
string pre;
cin >> s[0];
pre=s[0];
setn.insert(s[0]);
int flag=0;
for(int i=1;i<n;i++){
cin >> s[i];
setn.insert(s[i]);
if(pre[(int)pre.size()-1]!=s[i][0])flag=1;
pre=s[i];
}

if(flag==1 || (int)setn.size()!=n)
cout << "No";
else
cout << "Yes";

}


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

A = [0] + A + [0] # 数はN+2こ
kane = []
for i in range(1, N+2):
    kane.append(abs(A[i] - A[i-1]))
skane = sum(kane)

for i in range(1, N+1):
    print(skane - kane[i-1] - kane[i] + abs(A[i+1] - A[i-1]))

Measured memory_bytes: 14048
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>

using namespace std;

int main()
{
    int d,n;
    cin >> d >> n;
    if(n==100) n++;
    int ans = (int)pow(100, d);
    cout << ans*n;
    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <math.h>

int main() {

	int N;
	int H;
	int a[100000];
	int b[100000];

	std::cin >> N >> H;

	int maxAtk = 0;//最大の"振り攻撃"威力
	int Atacked = 0;//攻撃した回数
	for (int i = 0; i < N; i++) {
		std::cin >> a[i] >> b[i];//入力
		if (maxAtk < a[i])maxAtk = a[i];//最大振り攻撃威力を更新します
	}
	std::sort(b, b + N,std::greater<int>());//投げ攻撃威力をソートします

	for (int i = 0; i < N; i++) {

		if (H <= 0)break;//相手の体力が0になった時、投げ攻撃探索を中断します

		if (b[i] > maxAtk) {
			H -= b[i];
			Atacked++;
		}

	}
	
	if(H > 0)	Atacked += ceil((double)H / maxAtk);//相手の体力が残っている場合、何回振り攻撃をすればよいか求めます

	std::cout << Atacked;


	return 0;
}

Measured memory_bytes: 1024
class Position
  def initialize(x, y, count = 0)
    @x, @y = x, y
    @count = count
  end
  attr_accessor :x, :y, :count

  def up
    Position.new(x, y - 1, @count + 1)
  end

  def down
    Position.new(x, y + 1, @count + 1)
  end

  def left
    Position.new(x - 1, y, @count + 1)
  end

  def right
    Position.new(x + 1, y, @count + 1)
  end
end

class Matrix
  def initialize(map)
    @map    = map
  end

  def get(pos)
    @map[pos.y][pos.x]
  end
  
  def set(pos, newVal)
    @map[pos.y][pos.x] = newVal
  end

  def blank_count
    cnt = 0
    @map.each do |row|
      row.each do |e|
        cnt += 1 if e == Maze::BLANK || e == Maze::GOAL
      end
    end
    return cnt
  end
end

class Maze
  GOAL  = 'G'
  BLANK = '.'
  WALL  = '#'

  def initialize(maze, visited)
    @maze    = maze
    @visited = visited
  end

  def is_goal?(pos)
    @maze.get(pos) == GOAL
  end

  def available?(pos)
    @maze.get(pos) == BLANK && !@visited.get(pos)
  end
  
  def steps_to_goal
    q = [Position.new(1, 1)]
    @visited.set(q.first, true)
    while (s = q.shift)
      [s.up, s.down, s.left, s.right].each do |nxt|
        return nxt.count if is_goal?(nxt)
        if available?(nxt)
          @visited.set(nxt, true)
          q << nxt
        end
      end
    end
    return -1
  end

  def blank_count
    @maze.blank_count
  end

  def turnable_cell_count
    used_cell_count = steps_to_goal + 1
    return -1 if used_cell_count <= 0
    blank_count - used_cell_count
  end
end

H, W = STDIN.gets.split(' ').map(&:to_i)
maze = []
maze << Array.new(H + 2, '#')
H.times do
  maze << ['#'] + STDIN.gets.chomp.split('') + ['#']
end
maze << Array.new(H + 2, '#')
maze[H][W] = Maze::GOAL

map     = Matrix.new(maze)
visited = []
(H+2).times do
  visited << Array.new(W + 2, false)
end
visited = Matrix.new(visited)

puts Maze.new(map, visited).turnable_cell_count


Measured memory_bytes: 2300
n = int(input())
A = list(map(int,input().split()))

count1 = 0
accum1 = 0
for i in range(n):
    if i % 2 == 0:
        if accum1 + A[i] <= 0:
            count1 += 1 - accum1 - A[i]
            accum1 = 1
        else:
            accum1 += A[i]
    else:
        if accum1 + A[i] >= 0:
            count1 += 1 + accum1 + A[i]
            accum1 = -1
        else:
            accum1 += A[i]
            
count2 = 0
accum2 = 0
for i in range(n):
    if i % 2 != 0:
        if accum2 + A[i] <= 0:
            count2 += 1 - accum2 - A[i]
            accum2 = 1
        else:
            accum2 += A[i]
    else:
        if accum2 + A[i] >= 0:
            count2 += 1 + accum2 + A[i]
            accum2 = -1
        else:
            accum2 += A[i]
            
print(min(count1,count2))

Measured memory_bytes: 63216
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;


int main(){
    int N; cin >> N;
    vector<int> a(N+1,0);
    rep(i,N+1){
        if (i==0) continue;
        cin >> a[i];
    }
    vector<int> counter(N+1,0);

    for(int i = N; i >= 1; i--){
        int cnt = 0;
        int multiple = 2;
        while(i * multiple <= N){
            cnt += counter[i*multiple];
            multiple++;
        }
        if ((cnt % 2) != a[i]){
            counter[i]++;
        }
    }

    vector<int> ans;
    rep(i,N+1){
        if (counter[i] == 1){
            ans.push_back(i);
        }
    }

    cout << ans.size() << endl;
    for (auto a : ans){
        cout << a << endl;
    }    
}

Measured memory_bytes: 3064
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


N,P = map(int,input().split())
from collections import Counter
aa = Counter(prime_factorize(P))
#print(aa)
ans = 1
for key in aa.keys():
    ans *= key**(aa[key]//N)
print(ans)


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

int main(){
    string number;
    cin >> number;

    int counter = 0;
    if(number[0] == '1') ++counter;
    if(number[1] == '1') ++counter;
    if(number[2] == '1') ++counter;

    cout << counter << endl;
    return 0;
}

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

using namespace std;

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

    int N, L;

    cin >> N >> L;

    int min = L;
    int count = 0;

    for(int i = 2; i <= N; i++)
    {
        if(abs(i + L - 1) < abs(min))
        {
            count += min;
            min = i + L - 1;
        } else {
            count += i + L - 1;
        }
    }

    cout << count;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int a = sc.nextInt();

		if (x < a)
			System.out.println(0);
		else
			System.out.println(10);
	}

}


Measured memory_bytes: 21844
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;//例: VVI dp(10, vector<int>(10, INF);
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int INF = 2 * pow(10, 9) + 1;//+1しないとREになるかも(out of rangeになるんかな?? )

vector<int> dx = { -1, 0, 1, 0, -1, -1, 1, 1 };
vector<int> dy = { 0, -1, 0, 1, -1, 1, -1, 1 };

int main(void) {
	string S;
	cin >> S;

	for (int i = 0; i < S.size(); i++) {
		S[i] = 'x';
	}

	cout << S << endl;
}



Measured memory_bytes: 256
N=int(input())
CSF=[list(map(int,input().split())) for _ in range(1,N)]

for i,csf in enumerate(CSF):
    c,s,f=csf[0],csf[1],csf[2]
    ans=c+s
    for j in range(i+1,N-1):
        csf_=CSF[j]
        c_,s_,f_=csf_[0],csf_[1],csf_[2]
        while True:
            if (ans>=s_) and (ans%f_==0):
                ans+=c_
                break
            ans+=1
    print(ans)
print(0)

Measured memory_bytes: 3316
/////////////////////////////////////////
////////// ^\/^ *_* :) :-D '~' \\\\\\\\\\
/////////////////////////////////////////
//#include <bits/stdc++.h>
//#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
//#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
//#include <string.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

bool same(int a,int b,int c)
{
	return a==b||a==c||b==c;
}

int main()
{
	int a[3],ans=1e9;
	cin>>a[0]>>a[1]>>a[2];
	rep(i,3)
	rep(j,3)
	rep(k,3)
	{
		if(same(i,j,k)) continue;
		ans=min(ans,abs(a[i]-a[j])+abs(a[j]-a[k]));
	}
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 256
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

string s[50], t[50];
bool b[256];

int main(){
  each(c, "aiueo") b[c] = true;
  int n;
  while (cin >> n, n){
    rep(i, n) cin >> s[i];
    rep(i, n){
      t[i] = s[i][0];
      rep(j, s[i].size()){
        if (b[s[i][j]]) t[i] += s[i][j + 1];
      }
    }
    [&](){
      rep(i, 1, 51){
        set<string> st;
        rep(j, n) st.insert(t[j].substr(0, min<size_t>(t[j].size(), i)));
        if (st.size() == n){
          cout << i << endl;
          return;
        }
      }
      cout << "-1\n";
    }();
  }
}

Measured memory_bytes: 3192
tmp = list(map(int, input().split()))
N = tmp[0]
Y = tmp[1]

ans_x = -1
ans_y = -1
ans_z = -1

for x in range(0 ,N+1):
    for y in range(0, (N+1) - x):
        z = N - (x + y)
        if 10000*x + 5000*y + 1000*z == Y:
            ans_x = x
            ans_y = y
            ans_z = z
        else:
            continue

print(ans_x,ans_y,ans_z)  

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
#define ll long long 
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {    
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    ll sum = 0;
    rep(i, 0, n) sum += a[i];
    ll x = sum;
    for(int i = 1; i < n; i+=2) {
        x -= 2*a[i];
    }
    rep(i, 0, n) {
        cout << x << " ";
        x = 2*a[i]-x;        
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2048
fun main(args: Array<String>) {
    val (N, M) = listOfInt()
    val MAX = 1 shl N
    val SW = (0 until M).map { it to listOfInt().drop(1).map { MAX ushr it } }
    val P = listOfInt()
    var ans = 0
    for (n in 0 until MAX) {
        val d = SW.count {
            val c = it.second.count { n and it != 0 }
            //c > 0 &&
            c % 2 == P[it.first]
        }
        if (d == M) ans += 1
    }
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)

Measured memory_bytes: 38064
H,W,D=map(int,input().split())

remmap = {}
for v, i, j in sorted(sum([[(v, i, j) for j, v in enumerate(map(int, input().split()), start=1)] for i in range(1, H+1)], [])):
    rem = v%D
    if not rem in remmap:
        remmap[rem] = [(v,i,j)]
    else:
        remmap[rem].append((v,i,j))

accmap = {}
# print(remmap)
for rem, lis in remmap.items():
    for i in range(len(lis)):
        if i == 0:
            accmap[rem] = (lis[0][0], [0])
        else:
            fv, l = accmap[rem]
            l.append(l[i-1] + abs(lis[i][1]-lis[i-1][1])+abs(lis[i][2]-lis[i-1][2]))

# print(accmap)
for i in range(int(input())):
    L,R=map(int,input().split())
    rem=L%D
    fv, lis = accmap[rem]
    print(lis[(R-fv)//D]-lis[(L-fv)//D])

Measured memory_bytes: 51252
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
long long inf = 1e9 + 7;
int main(){
  long long N;
  cin >> N;
  vector<int> A(N);
  rep(i,N) cin >> A[i];
  
  sort(A.begin(), A.end());
  bool flag = true;
  long long res = 1;
  
  if(A[0] == 0){
    for(int i = 1; i < N; i += 2){
      res *= 2;
      res = res % inf;
      if(A[i] != i +1 || A[i+1] != i + 1){
        flag = false;
        break;
      }
    }
  }else if(A[0] == 1){
    for(int i = 0; i < N; i += 2){
      res *= 2;
      res = res % inf;
      if(A[i] != i + 1 || A[i+1] != i + 1){
        flag = false;
        break;
      }
    }
  }else{
    flag = false;
  }
  
  res = res % inf;
    //出力
    if(flag){
      cout << res << endl;
    }else{
      cout << 0 << endl;
    }
  return 0;
}

Measured memory_bytes: 640
using namespace std;

#include <iostream>
#include <vector>
#include <cmath>

typedef long long ll;

int N, M;
bool edge[8][8];

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

ll LCM(ll a, ll b) {
  ll g = GCD(a, b);
  return a / g * b;
}

int main() {
  cin >> N;
  ll t[N];
  for (int i = 0; i < N; i++) cin >> t[i];
  
  ll lcm = 1;
  for (int i = 0; i < N; i++) {
    lcm = LCM(lcm, t[i]);
  }
  
  
  cout << lcm << endl;
  
  
  return 0;
  
  
}

Measured memory_bytes: 256
function main(input) {
  const A = parseInt(input.split(" ")[0] , 10);
  const B = parseInt(input.split(" ")[1] , 10);
  const K = parseInt(input.split(" ")[2] , 10);
  var chibi=Math.min.apply(null, [A,B]);
  var arr=[];
  for(var i=1; i<=chibi; i++){
    if(A%i==0&&B%i==0){
      arr.push(i)
    }
  }
  console.log(arr[arr.length-K]);
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int par[200000];
int rrank[200000];
void init(int n){
for (int i=0;i<n;i++){
par[i]=i;
rrank[i]=0;
}}
int find(int x){
if (par[x]==x) return x;
else return par[x]=find(par[x]);
}
void unite(int x,int y){
x=find(x);
y=find(y);
if (x==y) return;
if (rrank[x]<rrank[y]) par[x]=y;
else {par[y]=x;
if (rrank[x]==rrank[y]) rrank[x]++;}}
bool same(int x,int y){
return find(x)==find(y);}

int main() {
  int n,m;
  cin >> n >> m;
  init(n);
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  if (n-(n-m-1)*2<0) {cout << "Impossible" << endl; return 0;}
  vector<ll> c(n,INF),d(0);
  rep(i,m){
      int f,g;
      cin >> f >> g;
      unite(f,g);
  }
  rep(i,n){
      if (c[find(i)]>a[i]){
          if (c[find(i)]!=INF) d.push_back(c[find(i)]);
          c[find(i)]=a[i];
      }
      else d.push_back(a[i]);
  }
  ll u=0,ans=0;
  sort(all(d));
  rep(i,n){
      if (c[i]!=INF){
          u++;
          ans+=c[i];
      } 
  }
  if (u==1) cout << 0 << endl;
  else {
      rep(i,u-2){
          ans+=d[i];
      }
      cout << ans << endl;
  }
}


Measured memory_bytes: 3704
#include <iostream>

int main(){
   int N;
   std::cin >> N;
   int temp = N % 10;
   if (temp == 3){
      std::cout << "bon" << std::endl;
   } else if ((temp == 0) || (temp == 1) || (temp == 6) || (temp == 8)){
      std::cout << "pon" << std::endl;
   } else{
      std::cout << "hon" << std::endl;
   }
}



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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;


template <typename M>
class lazy_segment_tree {
	using T1 = typename M::t1;
	using T2 = typename M::t2;
	const int n;
	vector<T1> data;
	vector<T2> lazy;
	int size(int n) {
		int res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	void push(int node) {
		if (lazy[node] == M::id2()) return;
		if (node < n) {
			lazy[node * 2] = M::op3(lazy[node * 2], lazy[node]);
			lazy[node * 2 + 1] = M::op3(lazy[node * 2 + 1], lazy[node]);
		}
		data[node] = M::op2(data[node], lazy[node]);
		lazy[node] = M::id2();
	}
	void suc(int l, int r, int node, int lb, int ub, T2 val) {
		if (ub <= l || r <= lb) return;
		if (l <= lb && ub <= r) {
			lazy[node] = M::op3(lazy[node], val);
			return;
		}
		push(node);
		int c = (lb + ub) / 2;
		suc(l, r, node * 2, lb, c, val);
		suc(l, r, node * 2 + 1, c, ub, val);
		data[node] = M::op1(M::op2(data[node * 2], lazy[node * 2]), M::op2(data[node * 2 + 1], lazy[node * 2 + 1]));
	}
	T1 sub(int l, int r, int node, int lb, int ub) {
		if (ub <= l || r <= lb) return M::id1();
		if (l <= lb && ub <= r) return M::op2(data[node], lazy[node]);
		int c = (lb + ub) / 2;
		return M::op2(M::op1(sub(l, r, node * 2, lb, c), sub(l, r, node * 2 + 1, c, ub)), lazy[node]);
	}
public:
	lazy_segment_tree(int n_) : n(size(n_)), data(n * 2, M::id1()), lazy(n * 2, M::id2()) {}
	lazy_segment_tree(int n_, T1 v1) : n(size(n_)), data(n * 2, v1), lazy(n * 2, M::id2()) {}
	lazy_segment_tree(const vector<T1>& data_) : n(size(data_.size())), data(n * 2, M::id1()), lazy(n * 2, M::id2()) {
		init(data_);
	}
	void init() {
		for (int i = n - 1; i >= 1; i--) data[i] = M::op1(data[i * 2], data[i * 2 + 1]);
	}
	void init(const vector<T1>& data_) {
		for (int i = 0; i < (int)data_.size(); i++) data[i + n] = data_[i];
		init();
	}
	void update(int l, int r, T2 val) {
		suc(l, r + 1, 1, 0, n, val);
	}
	T1 find(int l, int r) {
		return sub(l, r + 1, 1, 0, n);
	}
};

struct RURM {
	using t1 = int;
	using t2 = int;
	static t1 id1() { return INT_MAX; }
	static t2 id2() { return -1; }
	static t1 op1(const t1& l, const t1& r) { return min(l, r); }
	static t1 op2(const t1& l, const t2& r) { return r != id2() ? r : l; }
	static t2 op3(const t2& l, const t2& r) { return r != id2() ? r : l; }
};

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

	lazy_segment_tree<RURM> seg(N);
	seg.init();

	REP(i,Q){
		LL y;
		cin >> y;
		if(y==0){
			LL s, t, x;
			cin >> s >> t >> x;
			seg.update(s, t, x);
		}
		else
		{
			LL s;
			cin >> s;
			cout << seg.find(s, s) << endl;
		}
	}
}



Measured memory_bytes: 4948
#include <bits/stdc++.h>
#define MAXN 100
#define MOD 1000000007

int main(){
    FILE*fi,*fo;
    //fi = fopen("a.in","r");
    //fo = fopen("a.out","w");
    fi = stdin;
    fo = stdout;


    int n;
    fscanf(fi,"%d", &n);
    for(int i = 1; i <= n; i++){
        long long a, b, c, d;
        fscanf(fi,"%lld%lld%lld%lld", &a, &b, &c, &d);
        if(a < b){fprintf(fo,"No\n"); continue;}
        if(c >= b){
            if(d < b){fprintf(fo,"No\n"); continue;}
            else{fprintf(fo,"Yes\n"); continue;}
        }
        else{
            if(d < b){fprintf(fo,"No\n"); continue;}
            else{
                long long x = b, y = d, r;
                while(y > 0){
                    r = x % y;
                    x = y;
                    y = r;
                }
                long long rem = a % b;
                rem = b - rem;
                rem = rem % x;
                if(rem == 0) rem += x;
                if(b - rem <= c){fprintf(fo,"Yes\n"); continue;}
                else{fprintf(fo,"No\n"); continue;}
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
  	cin>>s;
  	int n=s.size();
  	int count=0;
  for(int i=0;i<n;i++){
  if(i%2==0){
    if(s.at(i)=='R'||s.at(i)=='U'||s.at(i)=='D'){
    count++;
    }
    else{
    count=count+0;
    }
  }
  if(i%2==1){
  	if(s.at(i)=='L'||s.at(i)=='U'||s.at(i)=='D'){
  	count++;
  	}
    else{
    count=count+0;
    }
  }
  	
	}
  if(count==n){
  cout<<"Yes"<<endl;
  }
  else{
  cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
// #define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(12);const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};

const int N=1<<18;
int a[N],u[N];
int32_t main(){
    int n;cin>>n;
    n=1<<n;
    forn(i,n)cin>>a[i];
    sort(a,a+n);
    reverse(a,a+n);
    vector<int> v={a[0]};
    u[0]=1;
    while(sz(v)<n){
        int j=0,c=sz(v);
        forn(i,n){
            if(!u[i]&&a[i]<v[j]){
                u[i]=1;
                v.pb(a[i]);
                if((++j)==c)break;
            }
        }
        if(j<c){
            cout<<"No\n";
            return 0;
        }
        sort(v.begin(), v.end());reverse(v.begin(), v.end());
    }
    cout<<"Yes\n";

    return 0;
}


Measured memory_bytes: 6512
import java.util.Scanner;
import java.util.Arrays;;
 
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
        	int m = sc.nextInt();
        	int nmin = sc.nextInt();
        	int nmax = sc.nextInt();
        	if(m+nmin+nmax==0) {
        		break;
        	}
        	int[] P = new int[m+1];
        	for(int i=1; i<=m; i++) {
        		P[i] = sc.nextInt();
        	}
        	int gap = 0;
        	int n = 0;
        	for(int i=nmin; i<=nmax; i++) {
        		if(gap<=P[i]-P[i+1] && n<i) {
        			gap = P[i]-P[i+1];
        			n = i;
        		}
        	}
        	System.out.println(n);
        }
    }
}


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

using namespace std;

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

  vector<set<string>> a = vector<set<string>>(5, set<string>());
  while (N--) {
    string s;
    cin >> s;
    switch (s.at(0)) {
      case 'M': a[0].insert(s); break;
      case 'A': a[1].insert(s); break;
      case 'R': a[2].insert(s); break;
      case 'C': a[3].insert(s); break;
      case 'H': a[4].insert(s); break;
    }
  }

  long long res = 0;
  for (int i = 0; i < 5; i++) {
    if (a[i].empty()) continue;
    for (int j = i + 1; j < 5; j++) {
      if (a[j].empty()) continue;
      for (int k = j + 1; k < 5; k++) {
        if (a[k].empty()) continue;

        res += a[i].size() * a[j].size() * a[k].size();
      }
    }
  }

  cout << res << "\n";
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
#define mod  200003//1000000007
#define pub(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main(){
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int a,b;
   cin>>a>>b;
   if(a>9 || b>9){
      cout<<-1;
   }else{
      cout<<a*b;
   }
   return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

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

int n, m;
V<int> G[100009];

int d[100009];

int ans[100009];

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

    cin >> n >> m;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    memset(d, -1, sizeof(d));

    queue<int> que;
    que.push(0);
    d[0] = 0;

    while(!que.empty()) {
        int v = que.front();
        que.pop();
        for(int u : G[v])
            if(d[u] == -1) {
                d[u] = d[v] + 1;
                ans[u] = v;
                que.push(u);
            }
    }

    cout << "Yes" << endl;
    FOR(i, 1, n) cout << ans[i] + 1 << endl;

    return 0;
}

Measured memory_bytes: 10844
// vim:ts=4:sts=4:sw=4:et
// MOSCOW IPT JINOTEGA
// Table #14
#include <bits/stdc++.h>
using namespace std;
#define forn(i,n) for (int i = 0; i < int(n); ++i)
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
typedef long double ld;
typedef long long ll;
typedef long long i64;

int main() {
#ifdef LOCAL
    assert(freopen("a.in", "r", stdin));
#endif
    //ios_base::sync_with_stdio(false);

    string s;
    cin >> s;
    cout << s.substr(0, s.length() - 8) << endl;
    return 0;
}



Measured memory_bytes: 256
def resolve():
    N, W = map(int, input().split())    
    w_v = [list(map(int, input().split())) for _ in range(N)]  # [N][0:weight, 1:value]

    dp = [[0] * (W+1) for _ in range(N+1)] 

    for i in range(N-1,-1,-1):
        for j in range(W+1):
            w = w_v[i][0]
            v = w_v[i][1]
            if j < w_v[i][0]:
                dp[i][j] = dp[i+1][j]
            else:
                dp[i][j] = max(dp[i+1][j], dp[i+1][j - w] + v)
 
    print(dp[0][W])
 
if __name__ == "__main__":
    resolve()

Measured memory_bytes: 118768
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		int a = Integer.parseInt(strArr[0]);
		int b = Integer.parseInt(strArr[1]);
		int k = Integer.parseInt(strArr[2]);
		for (int ans = Integer.min(a, b);; ans--) {
			if (a % ans == 0 && b % ans == 0)
				k--;
			if (k <= 0) {
				System.out.println(ans);
				return;
			}
		}
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 21076
import sys
from collections import deque, defaultdict
import copy
import bisect
input=sys.stdin.readline
#sys.setrecursionlimit(10 ** 9)
import math
import heapq

Q = int(input())
#Q = 100000
q = []
for i in range(Q):
	q.append(list(map(int, input().split())))
	#q.append([1, (i*17) % 10000, i])

a_list = []
a_list2 = []
b_sum = 0
a_sum = 0
a_sum_half = 0
length = 0
for i in range(Q):
	if len(q[i]) == 3:
		if len(a_list2) == 0:
			D = True
		else:
			x = heapq.heappop(a_list2)
			heapq.heappush(a_list2,x)
			D = (x <= q[i][1])
		length += 1
		if length % 2 == 0 and not D:
			a_sum_half += q[i][1]
			heapq.heappush(a_list, -q[i][1])
		elif length % 2 == 0 and D:
			heapq.heappush(a_list2, q[i][1])
			x = heapq.heappop(a_list2)
			heapq.heappush(a_list, -x)
			a_sum_half += x
		elif length % 2 == 1 and not D:
			a_sum_half += q[i][1]
			heapq.heappush(a_list, -q[i][1])
			x = heapq.heappop(a_list)
			a_sum_half += x
			heapq.heappush(a_list2, -x)
		else:
			heapq.heappush(a_list2, q[i][1])
		a_sum += q[i][1]
		b_sum += q[i][2]
	else:
		if length % 2 == 0:
			argmin_x = -heapq.heappop(a_list)
			heapq.heappush(a_list, -argmin_x)
		else:
			argmin_x = heapq.heappop(a_list2)
			heapq.heappush(a_list2, argmin_x)
		min_x = argmin_x*(length//2) - a_sum_half
		min_x += (a_sum - a_sum_half) - (argmin_x*(length - length//2))
		min_x += b_sum
		print("{0} {1}".format(argmin_x, min_x))

Measured memory_bytes: 123740
#include<iostream>
#include<climits>
#include<algorithm>

using namespace std;

int calc_longest_subseq(string, string);

int main() {
	int q;
	cin >> q;
	string msg1, msg2;
	for (int i = 0;i < q;i++) {
		cin >> msg1>>msg2;
		cout << calc_longest_subseq(msg1, msg2) << endl;
	}
}

int calc_longest_subseq(string a, string b) {
	int* last_index = new int[b.length()+1];
	pair<char, int>* sorted_a = new pair<char, int>[a.length()];
	int tmp;
	for (int i = 0;i < a.length();i++) {
		sorted_a[i] = make_pair(a[i], i);
	}
	sort(sorted_a, sorted_a + a.length());
	last_index[0] = -1;
	int count = 0;
	for (int i = 1;i <= b.length();i++) {
		last_index[i] = INT_MAX;
	}
	for (int i = 0;i < b.length();i++) {
		for (int j = count;j >= 0;j--) {
			tmp = upper_bound(sorted_a, sorted_a + a.length(), make_pair(b[i], last_index[j]))-sorted_a;
			if (tmp < a.length()) {
				if (sorted_a[tmp].first == b[i]) {
					last_index[j + 1] = min(last_index[j + 1], sorted_a[tmp].second);
					count = max(j + 1, count);
				}
			}
		}
	}
	return count;

}





Measured memory_bytes: 3252
#include <stdio.h>
#include <stdbool.h>

#define MAX 100000
#define SEN 10000000

typedef struct {
    char gara;
    int value;
}Huda;

void merge(Huda[],int,int,int);
void mergeSort(Huda[],int,int);
int partition(Huda[],int,int);
void swap(Huda*,Huda*);
void quickSort(Huda[],int,int,int);
void printArray(Huda [],int);
bool isStable(Huda [],Huda[],int N);



Huda L[MAX],R[MAX];

int main(){
  int n;
  int i;
  Huda H1[MAX],H2[MAX];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %c%d",&H1[i].gara,&H1[i].value);
    H2[i].gara=H1[i].gara;
    H2[i].value=H1[i].value;
  }

mergeSort(H1,0,n);
quickSort(H2,n,0,n-1);


if(isStable(H1,H2,n)){
  printf("Stable\n");
}else printf("Not stable\n");
 printArray(H2,n);


return 0;
}


void  merge(Huda A[],int left,int mid,int right){
  int i,j=0,k=0;
  int nm1=mid-left;
  int nm2=right-mid;
  for(i=0;i<nm1;i++){
    L[i]=A[left+i];
  }
  for(i=0;i<nm2;i++){
    R[i]=A[mid+i];
  }
  L[nm1].value=SEN;
  R[nm2].value=SEN;
  i=0;
  for(k=left;k<right;k++){
    if(L[i].value<=R[j].value){
      A[k]=L[i++];
    }else{
      A[k]=R[j++];
    }
  }
}

void mergeSort(Huda A[],int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

int partition(Huda A[],int p,int r){
  Huda x;
  int i,j;
  
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      i++;
      swap(&A[i],&A[j]);
    }
  }
  swap(&A[i+1],&A[r]);
  return i+1;
}

void swap(Huda *a,Huda *b){
  Huda  v;
  v=*a;
  *a=*b;
  *b=v;
}

void quickSort(Huda A[],int n,int p,int r){
  int q;
  if(p<r){
    q=partition(A,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}


bool isStable(Huda H1[],Huda H2[],int N){
  int i;
  for(i=0;i<N;i++){
    if(H1[i].gara!=H2[i].gara)return false;
  }
return true;
}

void printArray(Huda A[],int N){
  int i;
  for(i=0;i<N;i++){
    printf("%c %d\n",A[i].gara,A[i].value);
  }
}

Measured memory_bytes: 2952
object Main extends App{
  val List(a,b) = readLine.split(" ").map(_.toInt).toList
  val ab = (1 to b).map(x => a).mkString
  val ba = (1 to a).map(x => b).mkString
    
  val ans = if(ab <= ba) ab else ba
  println(ans)
}

Measured memory_bytes: 25416