akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{

    class Program
    {
        private const long COMDIV = 1000000007;

        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var Ls = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();
            int ret = 0;
            for (int i = 0; i < N; i++)
            {
                for (int j = i + 1; j < N; j++)
                {
                    if (Ls[i] == Ls[j])
                    {
                        continue;
                    }
                    for (int k = j + 1; k < N; k++)
                    {
                        if (Ls[i] == Ls[k] || Ls[j] == Ls[k])
                        {
                            continue;
                        }

                        if (Ls[i] + Ls[j] > Ls[k] &&
                            Ls[j] + Ls[k] > Ls[i] &&
                            Ls[k] + Ls[i] > Ls[j])
                        {
                            ret++;
                        }
                    }
                }
            }

            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 28496
N,*A=gets(p).split.map &:to_i
O = []
a = A.max
b = A.min
if a + b >= 0
  ai = A.index a
  N.times do |i|
    if A[i] < 0
      A[i] += a
      O << [ai, i]
    end
  end
  (N-1).times do |i|
    A[i+1] += A[i]
    O << [i, i+1]
  end
else
  bi = A.index b
  N.times do |i|
    if A[i] > 0
      A[i] += b
      O << [bi, i]
    end
  end
  (N-1).downto 1 do |i|
    A[i-1] += A[i]
    O << [i, i-1]
  end
end
p O.size
puts O.map{|x,y| "#{x+1} #{y+1}"}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(long long i=(l);i<(r);i++)
#define dec(i, l, r)   for(long long i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

// Union-Find (short) {{{
struct UF_short {
    vector<int> p;  // parent

    UF_short(int n) {
        p.resize(n);
        for(int i=0;i<n;i++){
            p[i] = i;
        }
    }

    int find(int x) {
        if(x == p[x]){
            return x;
        }else{
            return p[x] = find(p[x]);
        }
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if(x == y) return;
        p[y] = p[x];
    }
}; // }}}


int main() {
    std::ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<LL> A(n);
    UF_short uf(n);
    inc(i, 0, n) cin >> A[i];
    inc(i, 0, m){
        int x, y;cin >> x >> y;
        uf.unite(x, y);
    }
    using T = priority_queue<LL, vector<LL>, greater<LL>>;
    map<int, T> mmap;
    inc(i, 0, n){
        mmap[uf.find(i)].push(A[i]);
    }

    LL ans = 0;

    for(auto &kv : mmap){
        ans += kv.second.top();
        kv.second.pop();
    }

    T pq;
    for(auto &kv : mmap){
        while(!kv.second.empty()){
            pq.push(kv.second.top());
            kv.second.pop();
        }
    }

    int l = mmap.size();

    if(l == 1){
        cout << 0 << endl;
        return 0;
    }
    inc(i, 0, (l-1)*2-l){
        if(pq.empty()){
            cout << "Impossible" << endl;
            return 0;
        }
        ans += pq.top();
        pq.pop();
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
	int a,b;
	cin >> a;
	cin >> b;
	vector<bool> ans(4,true);
	ans[a] = false;
	ans[b] = false;
	for(int i=1;i<=3;i++) if (ans[i]) cout << i << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<ll, ll>P;
#define PI 3.14159265359
#define MOD 1000000007
const int MAX = 510000;
ll gcd(ll a, ll b){
    if (a % b == 0)
    {  return(b);}
    else{return(gcd(b, a % b));}
}
ll lcm(ll a, ll b)
{return a * b / gcd(a, b);}

int main(){
  int N;string S;
  cin >>N>>S;
  vector<ll>turntoE(N);//i-1番目までの人が、i番目のヒトを向くとき、その人数
  vector<ll>turntoW(N);
  turntoE[0]=0;turntoW[N-1]=0;
  for(ll i=1;i<N;i++){
  	if(S[i-1]=='W'){turntoE[i]=turntoE[i-1]+1;}
    else{turntoE[i]=turntoE[i-1];}
  }
  for(ll i=N-2;i>=0;i--){
  	if(S[i+1]=='E'){turntoW[i]=turntoW[i+1]+1;}
    else{turntoW[i]=turntoW[i+1];}
  }
  ll memo=N;
  rep(i,N){
  	memo=min(memo,turntoE[i]+turntoW[i]);
  }
  cout<<memo;
}

Measured memory_bytes: 5380
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

template<typename Monoid, typename InputIterator> typename Monoid::value_type fold(InputIterator first, InputIterator last) {
  Monoid m;
  auto acc = m.id();
  std::for_each(first, last, [&](auto &x) { acc = m(acc, x); });
  return acc;
}

constexpr int gcd(int a, int b) {
  while (b) b ^= a ^= b ^= a %= b;
  return a;
}

constexpr int lcm(const int a, const int b) { return a / gcd(a, b) * b; }

struct lcmMonoid {
  using value_type = int;
  constexpr value_type id() { return 1; }
  constexpr value_type operator()(const value_type &a, const value_type &b) { return lcm(a, b); }
};

main {
  vi v(6);
  while (cin >> v, accumulate(all(v), 0LL)) {
    vi w(3, 1);
    rep(i, 3) {
      for (int m = v[i * 2] % v[i * 2 + 1]; m != 1; w[i]++) m = (m * v[i * 2]) % v[i * 2 + 1];
    }
    cout << fold<lcmMonoid>(all(w)) << endl;
  }
}

Measured memory_bytes: 3008
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

cost = []
### 0 より大きい1分台の数を求めて、それを最後に注文する
min_minute = 10
for c in [A, B, C, D, E]:
    t = int(c // 10) * 10
    if c % 10 != 0:
        t += 10
        min_minute = min(c % 10, min_minute)
    cost += [t]
print(sum(cost) - 10 + min_minute)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;
const int MAXN = 220005;

int n, a[MAXN], b[MAXN];

struct bit{
	int tree[MAXN];
	void add(int x, int v){
		while(x < MAXN){
			tree[x] += v; 
			x += x & -x;
		}
	}
	void clear(){
		memset(tree, 0, sizeof(tree));
	}
	int query(int x){
		int ret = 0;
		while(x){
			ret += tree[x];
			x -= x & -x;
		}
		return ret;
	}
}bit;

lint trial(int x){
	bit.clear();
	b[0] = n + 2;
	for(int i=1; i<=n; i++){
		if(a[i] <= x) b[i] = 1;
		else b[i] = -1;
		b[i] += b[i-1];
	}
	lint ret = 0;
	for(int i=1; i<=n; i++){
		bit.add(b[i-1], 1);
		ret += bit.query(b[i] - 1);
	}
	return ret;
}

int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++){
		scanf("%d",&a[i]);
	}
	lint pcnt = 1ll * n * (n + 1) / 2;
	pcnt = (pcnt + 2) / 2;
	int s = 0, e = 1e9;
	while(s != e){
		int m = (s+e)/2;
		if(trial(m) < pcnt) s = m + 1;
		else e = m;
	}
	cout << s << endl;
}


Measured memory_bytes: 1920
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        Set<Integer> all = new HashSet<>();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        all.add(a);
        all.add(b);
        all.add(c);
        if(all.size()==2){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");

        }
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
//double pi=3.1415926535898;
//double pi=acos(-1.0);
#define scarr(a,s,e) for(int i=s;i<=int(e);i++) scanf("%d ",&a[i]);
#define prarr(a,s,e) for(int i=s;i<=int(e);i++) printf("%d ",a[i]);
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define rep(i,a,b) for(int i=a;i<=int(b);++i)
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define mkp        make_pair
#define fr         first
#define se         second
#define sc(x)      scanf("%d",&x)
#define pr(x)      printf("%d ",x)
#define scl(x)     scanf("%lld",&x)
#define prl(x)     printf("%lld ",x)
#define prln(x)    printf("%d\n",x)
#define r0         return 0;
#define CC         continue;
#define scd(x)     scanf("%lf",&x)
#define prd(x)     printf("%.10f\n",x);
#define bb(x)      cerr<< x <<endl;
#define ii         pair<int,int>
//#define max(a,b) a<b?b:a
//#define min(a,b) a<b?a:b
const ll M   = 1e7+9 ;
const ll inf = 1e19  ;
const int si = 1e5+9 ;
//////////////////////    Hi    ^_^  hack me if you can :P

int main()
{
    int n,a,b,p;
    int ans = 0;
    cin>>n>>a>>b;
    lop(i,n){
    cin>>p;
    if(p<a||p>=b){
        ++ans;
    }
    }
   cout<<ans<<endl;

    r0;
}


/*

ll pwmod(ll a, ll n, ll mod) {
    ll ret = 1;
    while (n) {
        if (n & 1) ret = ret * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ret;
}

*/
/*
freopen("output.txt","w",stdout);
freopen("input.txt","r",stdin);
for (int i=0;i<n;i++)            Hi    ^_^  hack me if you can :P
int mx[]= {0,0,1,1,1,-1,-1,-1};
int my[]= {1,-1,0,1,-1,0,1,-1};
bool inside (int i,int j) {return (i>=0 && i<n && j>=0 && j<m);}
*/


Measured memory_bytes: 256
use List::Util qw(max min sum);
use Time::HiRes qw(gettimeofday tv_interval);

my ($ssec, $smsec) = gettimeofday();

my ($d) = split(/\s+/, <>);
my (@c) = (-1, split(/\s+/, <>));

my @s = ();
for my $i (1..$d) {
    $s[$i] = [-1, split(/\s+/, <>)];
}

sub score {
    my (@contest) = @_;
    my $ret = 0;
    my @last = (-1); for (1..26) { push @last, 0; }
    my $j = 1;

    for my $i (@contest) {
	$ret += $s[$j][$i];
	$last[$i] = $j;
	for (1..26) {
	    $ret -= $c[$_] * ($j-$last[$_]);
	}
	$j++;
    }
    return $ret;
}

sub max_index {
    my (@list) = @_;
    my $maxi = 0;
    for (my $i=0; $i<scalar(@list); $i++) {
	$maxi = $i if $list[$maxi] < $list[$i];
    }
    return $maxi;
}

sub over_index {
    my ($val, @list) = @_;
    my @ret = ();
    for (my $i=0; $i<scalar(@list); $i++) {
	push @ret, $i if $list[$i] > $val;
    }
    return @ret;
}

my @last = (-1); for (1..26) { push @last, 0; }
my @cont = ();
for my $j (1..$d) {
    my $max = max(@{$s[$j]});
    my @can = (1..26);
    #my @can = over_index($max*0.9, @{$s[$j]});
    #print "$j: ", join(",", @can), "\n";
    
    my $index = -1;
    my $maxre = 0;
    for my $i (@can) {
	my $re = $s[$j][$i] + $c[$i] * ($j-$last[$i]);
	if ($maxre < $re) { $maxre=$re; $index = $i; }
    }
    #push @cont, max_index(@{$s[$j]});
    push @cont, $index;
    $last[$index] = $j;
}

my $score = score(@cont);
while (1) {
    my ($sec, $msec) = gettimeofday();
    #print "$score : $sec $msec\n";
    last if ($sec+$msec/1000000 - $ssec-$smsec/1000000 > 1.7);
    my @new = @cont;
    $new[int(1+rand($d))] = int(1+rand(26));
    my $new_score = score(@new);
    if ($new_score > $score) {
	$score = $new_score;
	@cont = @new;
    }
}


print join("\n", @cont), "\n";
#print score(@cont), "\n";


Measured memory_bytes: 7080
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
public class Main {
	static String a;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int x = stdIn.nextInt();
		int y = stdIn.nextInt();
		
		if(x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		
		int ans = gcd(x,y);
		System.out.println(ans);
	}
	public static int gcd(int x, int y) {
		if(x == 0) return y;
		if(x == y) return x;
		return gcd(y%x,x);
	}
}

Measured memory_bytes: 17360
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = (1 << 29);
const long long INFL = (1LL<<60);
const double eps = (1e-9);

ll count(int a)
{
  ll ans = 0;
  while (true) {
    if (a % 2 == 0) {
      a /= 2;
      ans++;
    } else {
      break;
    }
  }
  return ans;
}

int main(int argc, char* argv[])
{
  int n;
  cin >> n;
  ll ans = 0;
  rep(i, n) {
    int a;
    cin >> a;
    ans += count(a);
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  if (a + b >= 2 * c)
  {
    long long ans = min(x, y) * 2 * c;
    if (x < y)
    {
      ans += min((y - x) * b, 2 * (y - x) * c);
    }
    else if (x > y)
    {
      ans += min((x - y) * a, 2 * (x - y) * c);
    }
    cout << ans << endl;
  }
  else
  {
    long long ans = x * a + y * b;
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[200001],sa[200001],ans[200001];
int main(void){
	ll n,q,s,t,l,r,x,pl,mi,i,j;
	cin>>n>>q>>s>>t;
	for(i=0;i<=n;i++) cin>>a[i];
	pl=0; mi=0;
	for(i=1;i<=n;i++){
		sa[i]=a[i]-a[i-1];
		if(sa[i]>=0) pl+=sa[i];
		else mi+=sa[i];
//		cout<<sa[i]<<' ';
	}
//	cout<<endl;
//	cout<<pl<<' '<<mi<<' '<<(pl*s+mi*t)*-1<<endl;
	for(i=0;i<q;i++){
		cin>>l>>r>>x;
		if(sa[l]>=0){
			if(sa[l]+x<0){
				pl-=sa[l];
				sa[l]+=x;
				mi+=sa[l];
			}
			else {
				sa[l]+=x;
				pl+=x;
			}
		}
		else if(sa[l]<0){
			if(sa[l]+x>=0){
				mi-=sa[l];
				sa[l]+=x;
				pl+=sa[l];
			}
			else {
				sa[l]+=x;
				mi+=x;
			}
		}
		if(r+1<=n){
			if(sa[r+1]>=0){
				if(sa[r+1]-x<0){
					pl-=sa[r+1];
					sa[r+1]-=x;
					mi+=sa[r+1];
				}
				else {
					sa[r+1]-=x;
					pl-=x;
				}
			}
			else if(sa[r+1]<0){
				if(sa[r+1]-x>=0){
					mi-=sa[r+1];
					sa[r+1]-=x;
					pl+=sa[r+1];
				}
				else {
					sa[r+1]-=x;
					mi-=x;
				}
			}
		}
/*		for(j=1;j<=n;j++){
			cout<<sa[j]<<' ';
		}*/
//		cout<<endl;
//		cout<<pl<<' '<<mi<<' '<<(pl*s+mi*t)*-1<<endl;
		ans[i]=(pl*s+mi*t)*-1;
	}
	for(i=0;i<q;i++) cout<<ans[i]<<endl;
	return 0;
}

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

int main(){
	int N;
	cin >> N;
	int A[N];
	for(int i = 0; i < N; i++) cin >> A[i];
	sort(A, A+N);
	cout << abs(A[0] - A[N-1]) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef int int__;
#define int long long
#define pb push_back
#define pi pair<int,int>
#define vpi vector<pi>
#define vi vector<int>
#define vvi vector<vi>
#define fi first
#define se second
#define forn(i, n)for(int i=0;i<int__(n);i++) 
#define sz(a)int__(a.size())
template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a){return out << "(" << a.first << ", " << a.second << ")";}
template<class A>ostream& operator<<(ostream& out,const vector<A>&v){out<<"[";forn(i,sz(v)){if(i)out<<", ";out<<v[i];}return out<<"]";}
const int MAX = 1e9 + 100;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
int Mod(int x){const int mm=2019;x%=mm;if(x<0)x+=mm;return x;}
int Pow(int x,int n){if(n==0)return 1;int t=Pow(x,n/2);t=Mod(t*t);if(n&1)t=Mod(t*x);return t;}
#define watch(x) cout << #x << " : " << x << endl;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
#define all(x) x.begin(), x.end()

int c[200005] = {0}; vector<int > a;
vector<int> cycle_path,final_path;
 
void dfs(int x,int h,vi& path) {
 
	c[x] = h;
	path.pb(x);
 
	int next = a[x];
 
	if(c[next] > 0 ) {


		while(path.back() != next) {
			cycle_path.pb(path.back());
			path.pop_back();
		}
 		

		cycle_path.pb(path.back());
		path.pop_back();
 
		reverse(all(cycle_path));
		final_path = path;
	}
	else {
		dfs(next,h+1,path);
	}

	path.pop_back();
}

int__ main() {
	fast;
	int n,k; cin >> n >> k;
 
	a = vector<int>(n+1);
 
	for(int i=1;i<=n;i++) cin >> a[i];
 	
 	vi temp;
	dfs(1,1,temp);
 
	if(k < final_path.size()) {
		cout << final_path[k] << endl; return 0;
	}
 
	k -= final_path.size();
 
	k %= cycle_path.size();
 
	cout << cycle_path[k] << endl;
	
}

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

int main(){
  int K, len, i;
  char S[101];
  
  scanf("%d", &K);
  scanf("%s", S);
  
  len = strlen(S);
  
  if (len <= K) {
    printf("%s", S);
  }
  else {
    for(i = 0; i < K; i++) {
      printf("%c", S[i]);
    }
    printf("...\n");
  }
  return 0;
}
    

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

int main(){
 int a,b;
 cin >> a >> b;
 if(a<6){
     cout << 0 << endl;
 }
 else if(a<13){
     cout << b/2 << endl;
 }
 else{
     cout << b << endl;
 }

 
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int A,B;
  cin>>A;
  cin>>B;
  int count=1;
  while((B-A)-((count-1)*(A-1))>0){
    count++;
  }
  if(B==1){
    cout<<0<<endl;
  }
  else{
    cout<<count<<endl;
  }
}

Measured memory_bytes: 256
import heapq

######## クラス ############
class MaxHeap:
    def __init__(self, H=[]):
        self.heapify(H)

    def heapify(self, H):
        self._neg_heap = [ -a for a in H ] # マイナスをかける
        heapq.heapify( self._neg_heap )

    def push(self, value):
        heapq.heappush(self._neg_heap, -value)

    def pop(self):
        return (-1) * heapq.heappop(self._neg_heap)

    def get_heap(self):
        return [ -a for a in self._neg_heap ]



##### プログラム ###############

# 入力を受け取る
N, M = input().strip().split()
N, M = [int(N), int(M)]
A = input().strip().split()
A = [int(a) for a in A] # 整数に変換

price_heap = MaxHeap(A)

i = 0
for i in range(M):# 各割引券1枚ずつ、一番高い品物に使っていく
    price = price_heap.pop() # 一番高い品物
    price //= 2  # 一番高い商品に割引券を使って半額にする
    price_heap.push(price) # 半額になった商品をheapに戻す
    i += 1

total_price = 0
new_prices = price_heap.get_heap()

for i in range(N):
    total_price += new_prices[i]

print(total_price)


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

int main(void){
    string s;
    cin >> s;
    int count = 0;

    for(int i = 0; i < s.length()-1; i++){
        for(int j = i+1; j < s.length(); j++){
            if(s[i] == s[j])
                count++;
        }
    }
    if(count == 0)
        cout << "yes" << endl;
    else
        cout << "no" << endl;
    
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))

n0,n2,n4 = 0,0,0
for a in A:
    if a%4==0: n4+=1
    elif a%2==0: n2+=1
    else: n0+=1

if n2==0:
    print('Yes' if n0<=n4+1 else 'No')
else:
    print('Yes' if n0<=n4   else 'No')

Measured memory_bytes: 14252
#include<iostream>
#include<string>
using namespace std;
int main()
{
  long long k,i;
  string s;
  cin >> s >> k;
  for(i=0;i<s.size();i++)
    if(s[i]!='1'||i==k-1){
      cout << s[i] << endl;
      return 0;
    }
  return 0;
}

Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
class Combination {
    int powmod(int a, int p) {
        int ans = 1;
        int mul = a;

        for (; p > 0; p >>= 1, mul = (mul * mul) % mod) {
            if ((p & 1) == 1) ans = (ans * mul) % mod;
        }

        return ans;
    }
public:
    int N;
    int mod;
    vector<int> fact;
    vector<int> revFact;

    Combination(int n, int m) : N(n), mod(m), fact(n+1), revFact(n+1) {
        fact[0] = 1;
        for (int i = 1; i <= N; i++) {
            fact[i] = fact[i-1] * i;
            fact[i] %= mod;
        }

        // Fermat's little theorem
        revFact[N] = powmod(fact[N], mod - 2);

        for (int i = N-1; i >= 0; i--) {
            revFact[i] = revFact[i+1] * (i+1);
            revFact[i] %= mod;
        }
    }

    int get(int a, int b) {
        if (a < 0 || b < 0) return 0;
        if (b > a) return 0;
        return (((fact[a] * revFact[b]) % mod) * revFact[a-b]) % mod;
    }
};

signed main() {
    int N, K;
    cin >> N >> K;
    auto comb = new Combination(2 * N + 5, MOD);

    if (K >= N-1) {
        cout << comb->get(2 * N - 1, N) << endl;
    } else {
        int ret = 0;
        for (int j= K; j >= 0; j--) {
            ret += comb->get(N, j) * comb->get(N-1, j);
            ret %= MOD;
        }
        cout << ret << endl;
    }
    return 0;
}

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

a_max = A[0]
steps = [0]
for a in A[1:]:
    if a < a_max:
        steps.append(a_max - a)
    else:
        steps.append(0)
    a_max = max(a, a_max)
print(sum(steps))


Measured memory_bytes: 32228
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  ll ans;
  rep(i, n){
    ll t;
    cin >> t;
    if(i == 0) ans = t;
    else{
      ll g = __gcd(ans, t);
      ans = t / g * ans;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(50)
#define _popcnt __builtin_popcount

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

int fact[800000], invfact[800000];

int invmod(int a, int p){ // a^-1 mod p
	int b = p, u = 1, v = 0;
	while(b){
		int t = a / b;
		a -= t*b; swap(a, b);
		u -= t*v; swap(u, v);
	}
	u %= p;
	if(u < 0) u += p;
	return u;
}

void factmod(int m){
	fact[0] = invfact[0] = 1;
	for(int i = 1; i < 800000; i++){
		fact[i] = (fact[i-1] * i) % m;
		invfact[i] = (invfact[i-1] * invmod(i, m)) % m;
	}
}

int nCrmod(int n, int r, int m){
	return (((fact[n] * invfact[r]) % m) * invfact[n-r]) % m;
}

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

	int N, K; cin >> N >> K;
	factmod(MOD);
	if(K >= N) cout << nCrmod(2*N-1, N-1, MOD) << endl;
	else {
		int ans = 0;
		for(int zero = 0; zero <= K; zero++){
			int plus = nCrmod(N, zero, MOD);
			plus *= nCrmod(N-1, (N-zero)-1, MOD);
			plus %= MOD;
			ans += plus; ans %= MOD;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 12800
H, W = map(int, input().split(' '))

canvas = [' ' + input() + ' ' for _ in range(H)]
canvas.insert(0, ' ' * (W + 2))
canvas.append(' ' * (W + 2))

for y in range(1, H + 1):
    for x in range(1, W + 1):
        if canvas[y][x] == '#':
            if '#' not in {canvas[y - 1][x], canvas[y + 1][x], canvas[y][x - 1], canvas[y][x + 1]}:
                print('No')
                break
    else:
        continue
    break
else:
    print('Yes')


Measured memory_bytes: 3064
import java.util.*;
class Main
{
  public static void main(String args[])
  {
    Scanner in=new Scanner(System.in);
    int a=in.nextInt();
     int b=in.nextInt();
     int c=in.nextInt();
     int d=in.nextInt();
    int flag=0;
    while(flag==0)
    {
       if(c-b<=0)
       {
         System.out.print("Yes");
         flag=1;
       }
       else
         c=c-b;
      if(flag==0 && (a-d)<=0)
      {
        flag=1;
        System.out.print("No");
      }
      else
        a=a-d;
    }
    
      
      
      
    
    
    
    
  }
}

Measured memory_bytes: 35796
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
public class Hello
{
    private const int INF = 1000000007;
    private struct Pair { public long x, y; public Pair(long xx, long yy) { x = xx; y = yy; } }
    public static void Main()
    {
        int A = NextInt();
        int B = NextInt();
        if (A <= 5) Console.WriteLine(0);
        else if (A <= 12) Console.WriteLine(B / 2);
        else Console.WriteLine(B);
        
    }
}

public class Input
{
    private static Queue<string> queue = new Queue<string>();
    private static void Confirm() { if (queue.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(queue.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(queue.Dequeue()); }
    public static string NextString() { Confirm(); return queue.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(queue.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;

int main(){
    ll x, y; cin >> x >> y;
    ll ans = 0;
    if(x == 0 || y == 0){
        if(x == 0 && y == 0) {cout << 0 << endl; return 0;}
        if(x == 0){
            if(y < 0) {cout << abs(y) + 1 << endl; return 0;}
            else if(y > 0) {cout << y << endl;return 0;}
        }
        else if(y == 0){
            if(x < 0) {cout << -x << endl; return 0;}
            else if(x > 0) {cout << abs(x) + 1 << endl;return 0;}
        }
        
    }
    if(x < y){
        if(0 < x) ans = y-x;
        else if(x < 0 && 0 < y){
            if(abs(x) <= abs(y)) ans = 1+abs(abs(x)-abs(y));
            else ans = abs(abs(x)-abs(y))+1;
        }
        else if(y < 0) ans = abs(abs(x)-abs(y));
        
    }

    else if(y < x){
        if(0 < y) {
            ans = abs(x-y) + 2;
        }
        else if(y < 0 && 0 < x) {
            /*if(abs(x) < abs(y))*/ ans = 1+ abs(abs(y) - abs(x));
            //else ans = 1 + abs(abs(x) - abs(y));
        }
        else if(x < 0) ans = 1 + abs(abs(y) - abs(x)) + 1;
    }  
    cout << ans << endl;
}


Measured memory_bytes: 256
#define NAME "a"

#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <ctime>
#include <cctype>
#include <cassert>
#include <memory>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <iterator>

#define pb push_back
#define mp make_pair
#define frs first
#define snd second

using namespace std;

#ifdef WIN32
    #define lld "%I64d"
#else
    #define lld "%lld"
#endif

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const int INF = (int) 1e9 + 7;
const ll INFLONG = (ll) 1e18 + 7;
const double EPS = 1e-9;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<string> vs;

typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;

template <typename T>
T sqr(T a) {
    return a * a;
}

int main() {
    srand(time(0));

//    freopen(NAME".in", "r", stdin);
  //  freopen(NAME".out", "w", stdout);

    int n;
    scanf("%d", &n);
    set<string> s;

    for (int i = 0; i < n; i++) {
        char tmp[20];
        scanf("%s", tmp);
        s.insert((const char*) tmp);
    }

    printf("%d\n", (int) s.size());

//    printf("%.3lf\n", (double) clock() / CLOCKS_PER_SEC);
    return 0;
}


Measured memory_bytes: 19352
from itertools import *
n=104730;a=list(range(n));a[:2]=0,0
for i in range(2,323):a[i*2::i]=[0]*len(a[i*2::i])
p=list(compress(range(n),a))
print('\n'.join(str(sum(p[:int(e)]))for e in iter(input,'0')))


Measured memory_bytes: 10464
package main

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

var H, W int
var S []string

var dy = []int{1, 0, -1, 0}
var dx = []int{0, 1, 0, -1}

var cnt int
var blackCnt int

// var points []Point
var pass [][]int

func main() {
	H = nextInt()
	W = nextInt()
	S = make([]string, H)
	for i := 0; i < H; i++ {
		S[i] = nextString()
	}
	ans := 0
	pass = make([][]int, H)
	for i := 0; i < H; i++ {
		pass[i] = make([]int, W)
	}
	check := make([]int, H*W)
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			cnt = 0
			blackCnt = 0
			if S[i][j] == '#' && pass[i][j] == 0 {
				blackCnt++
				check[i*W+j]++
				s(i, j, check)
				ans += cnt * blackCnt
			}
		}
	}
	fmt.Println(ans)
}

var queueX []int
var queueY []int

func s(h int, w int, check []int) {
	check[h*W+w]++
	queueX = make([]int, 0)
	queueY = make([]int, 0)
	queueX = append(queueX, w)
	queueY = append(queueY, h)
	idx := 0
	for len(queueX) > idx {
		h = queueY[idx]
		w = queueX[idx]
		idx++
		for d := 0; d < 4; d++ {
			ny := h + dy[d]
			nx := w + dx[d]
			if ny >= 0 && ny < H && nx >= 0 && nx < W {
				if check[ny*W+nx] > 0 {
					continue
				}
				if S[ny][nx] != S[h][w] {
					if S[ny][nx] == '.' {
						cnt++
					} else {
						pass[ny][nx]++
						blackCnt++
					}
					check[ny*W+nx]++
					queueX = append(queueX, nx)
					queueY = append(queueY, ny)
				}
			}
		}
	}
}

func intPow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func intMax(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func intMin(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func intSum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func intAbs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	return p[i].b < p[j].b
}

var nextReader func() string

func init() {
	nextReader = newScanner()
}

func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 12288
#include<vector>
#include<algorithm>
#include<set>
#include<iostream>

using namespace std;

const int MX = 4005;
const int MM = 1000000007;

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

ll tot[MX];
int C[MX][MX];
vector<int> E[MX*2];
pii D[200005];

int main()
{
	for(int i = 0; i < MX*2; i++){
		E[i] = vector<int>(i+1);
		E[i][0] = E[i][i] = 1;
		for(int j = 1; j < i; j++){
			E[i][j] = (E[i-1][j-1] + E[i-1][j]) % MM;
		}
	}

	int N, ans = 0;
	scanf("%d", &N);
	for(int i = 1; i <= N; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		D[i] = pii(a+MX/2, b+MX/2);
		C[MX/2-a][MX/2-b]++;
		ans = (ans + MM - E[2*(a+b)][a*2]) % MM;
	}

	for(int i = 1; i < MX; i++){
		for(int j = 1; j < MX; j++){
			C[i][j] = ((ll)C[i-1][j] + C[i][j-1] + C[i][j]) % MM;
		}
	}
	for(int i = 1; i <= N; i++){
		ans = (ans + C[D[i].first][D[i].second]) % MM;
	}

	 ans = (ll)ans * ((MM+1)/2) % MM;
	printf("%d\n", ans);
}


Measured memory_bytes: 190080
fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let mut xi: Vec<(u32, usize)> = (0..n).map(|i| (sc.read(), i)).collect();
    xi.sort();

    let mut ans = vec![0; n];
    for i in 0..n {
        let (_, j) = xi[i];
        let m = n / 2;
        if i < m {
            let (a, _) = xi[m];
            ans[j] = a;
        } else {
            let (a, _) = xi[m - 1];
            ans[j] = a;
        }
    }

    for &b in &ans {
        println!("{}", b);
    }
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner { ptr: 0, length: 0, buf: vec![0; 1024], small_cache: vec![0; 1024] }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool { b == b'\n' || b == b'\r' || b == b'\t' || b == b' ' }

    fn read<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug, {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)]).parse().unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}



Measured memory_bytes: 12412
N,M,C=map(int,input().split())
B=list(map(int,input().split()))

ans = 0

for n in range(N):
	evalu = C
	A = list(map(int,input().split()))
	for m in range(M):
		evalu += A[m]*B[m]

	if 0 < evalu:
		ans += 1

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

int main()
{
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);


    ll N;
    cin >> N;

    vector<ll> a(N);
    vector<ll> b(N), c(N);

    map<ll, ll> mp;
    rep(i, N)
    {
        cin >> a[i];

        b[i] = a[i] + i;
        c[i] = a[i] - i;

        mp[b[i]]++;
    }

    /*for (auto i : mp) {
        cout << i.first << ' ' << i.second << endl;
    }*/
    ll ans = 0;
    rep(i, N)
    {
        ans += mp[-c[i]];
    }

    cout << ans << endl;
}


Measured memory_bytes: 30656
#include<bits/stdc++.h>
using namespace std;
vector<int>v[100003];
int n,c,a[100003],b[100003],ans[100003];
bool used[100003];
int vis[100003];
void dfs(int x){
	used[x]=1;
	int j=0;
	for(int i=0;i<v[x].size();i++)
		if(!used[b[v[x][i]]]){
			if(j==vis[x])j++;
			vis[b[v[x][i]]]=j;
			ans[v[x][i]]=j++;
			dfs(b[v[x][i]]);
		}
	c=max(c,j);
}
int main(){
	cin>>n;
	for(int i=1;i<n;i++){
		cin>>a[i-1]>>b[i-1];a[i-1]--;b[i-1]--;
		v[a[i-1]].push_back(i-1);
	}
	for(int i=0;i<n;i++)vis[i]=-1;
	dfs(0);
	cout<<c;
	for(int i=0;i<n-1;i++)cout<<endl<<ans[i]+1;
}

Measured memory_bytes: 8192
import java.io.*;
import java.util.*;

public class Main {
  private static boolean all9(String str) {
    for (char c : str.toCharArray()) {
      if (c != '9') {
        return false;
      }
    }
    return true;
  }
  
  private static int solve(String str) {
    return (str.length() - 1) * 9 + (str.charAt(0) - '0' - 1) + (all9(str.substring(1)) ? 1 : 0);
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    String str = reader.next();
    out.println(solve(str));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public int[] nextIntArray(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLongArray(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
}

class Algorithm {
  private static void swap(Object[] list, int a, int b) {
    Object tmp = list[a];
    list[a] = list[b];
    list[b] = tmp;
  }
  
  public static <T extends Comparable<? super T>> boolean nextPermutation(T[] ts) {
    int rightMostAscendingOrderIndex = ts.length - 2;
    while (rightMostAscendingOrderIndex >= 0 &&
        ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostAscendingOrderIndex + 1]) >= 0) {
      rightMostAscendingOrderIndex--;
    }
    if (rightMostAscendingOrderIndex < 0) {
      return false;
    }
    
    int rightMostGreatorIndex = ts.length - 1;
    while (ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostGreatorIndex]) >= 0) {
      rightMostGreatorIndex--;
    }
    
    swap(ts, rightMostAscendingOrderIndex, rightMostGreatorIndex);
    for (int i = 0; i < (ts.length - rightMostAscendingOrderIndex - 1) / 2; i++) {
      swap(ts, rightMostAscendingOrderIndex + 1 + i, ts.length - 1 - i);
    }
    return true;
  }
}



Measured memory_bytes: 21204
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <string>
using namespace std;

int main(){
  string str, word;
  int sum = 0;
  cin >> word;
  for(int i=0;i<(int)word.size();i++){
    word[i] = toupper(word[i]);
  }
  while(1){
    cin >> str;
    if(str.find("END_OF_TEXT") != string::npos)break;
    for(int i=0;i<(int)str.size();i++){
      str[i] = toupper(str[i]);
    }
    if(str == word){
      sum++;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	cin>>n;

	ll an=0;
	for(i=1;i<=n;i++){
		k=i; l=0;
		while(k>0){
			l++;
			k=k/10;
		}
		if(l%2) an++;
	}
	cout<<an;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <deque>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long gcd(long long a, long long b){if(b==0)return a;return gcd(b,a%b);}
int main() {
    string S; cin >> S;
    int N = S.size();
    int countS = 0;
    int res = N;
    repp(i, 0, N) {
        if (S[i] == 'S') ++countS;
        else {
            if (countS == 0) continue;
            --countS;
            res -= 2;
        }
    }
    cout << res << endl;
}



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

int main()
{
	string a;
	cin >> a;
	for (int i = 0; i < a.size(); i++)
	{
		switch (a[i])
		{
			case 'D':
				a[i] = 'A';
				break;
			case 'E':
				a[i] = 'B';
				break;
			case 'F':
				a[i] = 'C';
				break;
			case 'G':
				a[i] = 'D';
				break;
			case 'H':
				a[i] = 'E';
				break;
			case 'I':
				a[i] = 'F';
				break;
			case 'J':
				a[i] = 'G';
				break;
			case 'K':
				a[i] = 'H';
				break;
			case 'L':
				a[i] = 'I';
				break;
			case 'M':
				a[i] = 'J';
				break;
			case 'N':
				a[i] = 'K';
				break;
			case 'O':
				a[i] = 'L';
				break;
			case 'P':
				a[i] = 'M';
				break;
			case 'Q':
				a[i] = 'N';
				break;
			case 'R':
				a[i] = 'O';
				break;
			case 'S':
				a[i] = 'P';
				break;
			case 'T':
				a[i] = 'Q';
				break;
			case 'U':
				a[i] = 'R';
				break;
			case 'V':
				a[i] = 'S';
				break;
			case 'W':
				a[i] = 'T';
				break;
			case 'X':
				a[i] = 'U';
				break;
			case 'Y':
				a[i] = 'V';
				break;
			case 'Z':
				a[i] = 'W';
				break;
			case 'A':
				a[i] = 'X';
				break;
			case 'B':
				a[i] = 'Y';
				break;
			case 'C':
				a[i] = 'Z';
				break;
		}
	}
	cout << a << endl;
}

Measured memory_bytes: 3164
/*
    アリナ・グレイはかわいい
*/

#include<bits/stdc++.h>
using namespace std;
#define itn int
#define endl "\n"

int main(void){
    int k;
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin >> k;
    cout << a[k-1] << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()
A = sorted(li())
#A = sorted(li(), reverse= True)
max_a = A[-1]

flag = [0] * (A[-1]+1)
cnt = 0

for i, num in enumerate(A):
    #print(flag)
    if i == N-1 and not flag[num]:
        cnt += 1
    elif not flag[num] and A[i+1]!=num:
        cnt += 1
    x = num
    while True:
        flag[x] = 1
        x += num
        if x > max_a:
            break

print(cnt)

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

namespace ABC
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var result = "";

            for (var i = 0; i < s.Length; i++)
            {
                if (i % 2 == 0)
                {
                    result += s[i];
                }
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 42336