akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
using namespace std;
int main()
{
    int n, k, s;
    cin >> n >> k >> s;
    vector<int> ans;
    rep(i,k){
        ans.push_back(s);
    }
    if(s!=1'000'000'000){
        rep(i,n-k){
        ans.push_back(1'000'000'000);
        }
    }else{
        rep(i,n-k){
            ans.push_back(999'999'999);
        }
    }
    rep(i,n){
        cout << ans[i] << ' ';
    }
    cout << endl;
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int d, n;
  n = 26;
  cin >> d;
  vi c(n);
  rep(i, n) cin >> c[i];
  vvi s(d, vi(n));
  rep(i, d) rep(j, n) cin >> s[i][j];
  ll sc = 0;
  vi l(n);
  rep(i, d) {
    vl g(n);
    rep(j, n) {
      g[j] = s[i][j];
      rep(k, n) {
        if (j == k) {
        } else {
          g[j] -= (ll)c[k] * (i - l[k]);
        }
      }
    }
    int mi = 0;
    ll mx = g[0];
    rep(j, n) {
      if (mx < g[j]) {
        mx = g[j];
        mi = j;
      }
    }
    sc += mx;
    l[mi] = 0;
    cout << mi + 1 << endl;
  }
  dump(sc);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  
  string s;
  cin >>s;
  bool flg=1;
  for(int i=0; i<s.size(); i++){
  	if(i%2==0){ if(s[i]=='L') flg=0;}
    else{ if(s[i]=='R') flg=0;}
  }
  
  if(flg) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int main()
{
    int  c , b , i , j ;

    char a[55][55] , cou='0';
    while(cin >> c >> b)
    {
        for(i = 0; i < c; i++)
        {
            for(j = 0; j < b; j++)
            {
                cin >> a[i][j];
            }
        }
         for(i = 0; i < c; i++)
        {
            for(j = 0; j < b; j++)
            {
                cou = '0';
                if(a[i][j] == '.')
                {
                    if(a[i-1][j-1] == '#')
                        cou++;
                    if(a[i-1][j] == '#')
                        cou++;
                    if(a[i-1][j+1] == '#')
                        cou++;
                    if(a[i][j-1] == '#')
                        cou++;
                    if(a[i][j+1] == '#')
                        cou++;
                    if(a[i+1][j-1] == '#')
                        cou++;
                    if(a[i+1][j] == '#')
                        cou++;
                    if(a[i+1][j+1] == '#')
                        cou++;
                    a[i][j]=cou;
                }
                else a[i][j]='#';

            }
        }
        for(i = 0; i < c; i++)
        {
            for(j = 0; j < b; j++)
            {
                cout << a[i][j];
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int N,A,B;			//N,number, A:min, B:max
	long long n;

	scanf("%d %d %d",&N,&A,&B);

	n = (long)(B-A)*(N-2)+1; //(A+B+(N-2)*B) - (A+B+(N-2)*A) + 1;
	if(A>B) n = 0;
	if(A != B && N == 1) n = 0;
	printf("%lld\n",n);

	return 0;
}


Measured memory_bytes: 128
N, A, B, C = gets.split.map(&:to_i)
Commands = N.times.map{gets.chomp}

def bfs(state, hist)
  a, b, c = state
  if (a < 0) or (b < 0) or (c < 0)
    return
  end

  level = hist.size
  if level == N
    puts 'Yes'
    hist.each{|s| puts(s)}
    exit(0)
  end

  command = Commands[level]
  case command
  when 'AB'
    hist.push 'A'
    bfs([a+1, b-1, c], hist)
    hist.pop
    hist.push 'B'
    bfs([a-1, b+1, c], hist)
    hist.pop
  when 'BC'
    hist.push 'B'
    bfs([a, b+1, c-1], hist)
    hist.pop
    hist.push 'C'
    bfs([a, b-1, c+1], hist)
    hist.pop
  when 'AC'
    hist.push 'A'
    bfs([a+1, b, c-1], hist)
    hist.pop
    hist.push 'C'
    bfs([a-1, b, c+1], hist)
    hist.pop
  end
end

bfs([A, B, C], [])
puts 'No'


Measured memory_bytes: 50100
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String arg[])
	{
		Scanner scan = new Scanner(System.in);
		
	
		int w = scan.nextInt();
		int n = scan.nextInt();
		int ans[]= new int[w+1];
		for(int i = 1; i <= w; i++)
		{
			ans [i]= i;
		}

		for(int i=0; i < n; i++)
		{
			
			String str = scan.next();
			StringTokenizer st = new StringTokenizer(str, ",");
			swap(ans, st.nextToken(),st.nextToken());
		}

		for(int i = 1; i <= w; i++)
		{
			System.out.println(ans[i]);
		}

	}

	public static void swap(int a[], String b, String c)
	{
	    int  tmp = a[Integer.valueOf(b)];
		a[Integer.valueOf(b)] = a[Integer.valueOf(c)];
		a[Integer.valueOf(c)] = tmp;
	}

}

Measured memory_bytes: 11000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200025,M=1000005,inf=0x3f3f3f3f,p=998244353;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,m,inv[M],f[M],h[M],ans;
void check(int &x,int y){x=(x+y<p) ? (x+y) : (x+y-p);}
int main(){
//	freopen("balance.in","r",stdin);
//	freopen("balance.out","w",stdout);
	n=read();m=1000000;
	for (int i=1;i<=n;i++){
		int x=read();
		check(h[x],x);
		check(ans,p-x);
	}
	inv[1]=1;
	for (int i=2;i<=m;i++) inv[i]=p-(ll)p/i*inv[p%i]%p;
	for (int i=1;i<=m;i++){
		check(f[i],inv[i]);
		for (int j=i+i;j<=m;j+=i){
			check(h[i],h[j]);
			check(f[j],p-f[i]);
		}
		check(ans,(ll)h[i]*h[i]%p*f[i]%p);
	}
	ans=(ll)ans*inv[2]%p;
	printf("%d\n",ans);
	return 0;
}

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

int main(){
  int i;
  ll N,M;
  cin >> N >> M;
  vector<pair<ll,ll>> a(N);
  for(i=0;i<N;i++){
    cin >> a[i].first >> a[i].second;
  }
  sort(a.begin(),a.end());
  ll bottles=0,money=0;
  for(i=0;i<N;i++){
    if(M-bottles < a[i].second){
      money += (M-bottles)*a[i].first;
      break;
    }
    money += a[i].second*a[i].first;
    bottles += a[i].second;
  }
  cout << money << endl;
}

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

int main()
{
  int x;
  cin >> x;
 if(x==7||x==5||x==3) cout <<"YES" << endl;
 else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
MOD = 924844033

def pow_mod(a, n)
  ret = 1
  while n != 0 do
    if n % 2 == 1 then
      ret = ret * a % MOD
    end
    a = a * a % MOD
    n /= 2
  end
  ret
end

def list_to_int(data, first, last)
  if last - first == 1 then
    data[first]
  else
    middle = (first + last) / 2
    sub_first = list_to_int(data, first, middle)
    sub_last = list_to_int(data, middle, last)
    sub_first + (sub_last << (middle - first) * 80)
  end
end

def int_to_list(data, first, last, ret)
  if first < ret.length then
    if last - first == 1 then
      ret[first] = data
    else
      middle = (first + last) / 2
      first_width = (middle - first) * 80
      sub_first = int_to_list(data & ((1 << first_width) - 1), first, middle, ret)
      sub_last = int_to_list(data >> first_width, middle, last, ret)
    end
  end
end

def get_graph()
  input_array = STDIN.read.split
  n = input_array[0].to_i
  graph = Array.new(n){[]}
  for i in 1..(n - 1)
    a = input_array[i * 2 - 1].to_i - 1
    b = input_array[i * 2].to_i - 1
    graph[a] << b
    graph[b] << a
  end
  [n, graph]
end

def get_size_dist()
  n, graph = get_graph()

  size_table = [1] * n
  ret = 0
  stack = [-1, 0,
           0, 0]

  while stack.length > 2 do
    node = stack[-2]
    index = stack[-1]
    size_table[node] += ret
    if index < graph[node].length then
      dtr = graph[node][index]
      stack[-1] += 1
      if dtr != stack[-4] then
        stack.push(dtr, 0)
      end
      ret = 0
    else
      stack.pop(2)
      ret = size_table[node]
    end
  end

  size_dist = [0] * n
  size_table.each{|s|
    if s != n then
      size_dist[s - 1] += 1
      size_dist[n - s - 1] += 1
    end
  }
  [n, size_dist]
end


n, answer = get_size_dist()

$fac = [0] * (n + 1)
$fac[0] = 1
for i in 1..n
  $fac[i] = $fac[i - 1] * i % MOD
end

$ifac = [0] * (n + 1)
$ifac[n] = pow_mod($fac[n], MOD - 2)
n.downto(1).each{|i|
  $ifac[i - 1] = $ifac[i] * i % MOD
}

def comb(x, y)
  $fac[x] * $ifac[y] % MOD * $ifac[x - y] % MOD
end

for i in 0..(n - 1)
  answer[i] = answer[i] * $fac[i + 1] % MOD
end
answer.reverse!

ifac_int = list_to_int($ifac.slice(0, n), 0, n)
answer_int = list_to_int(answer, 0, n)
answer_int *= ifac_int
int_to_list(answer_int, 0, n + 1, answer)

answer.reverse!
for i in 0..(n - 1)
  a = n * comb(n, i + 1) % MOD
  b = answer[i] * $ifac[i + 1] % MOD
  answer[i] = (a - b + MOD) % MOD
end

puts answer.join("\n")


Measured memory_bytes: 119796
#include<bits/stdc++.h>
long long t,n,x,a,b,ans;
using namespace std;
int main()
{
	cin>>n>>x>>a;
	if(a>x)
	{
		ans+=a-x;
		a=x;
	}
	for(int i=2;i<=n;i++)
	{
		cin>>b;
		if(a+b>x)
		{
			t=a+b-x;
			ans+=t;
			b=b-t;
		}
		a=b;
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	int a[3];
	for (int i=0;i<3;i++) cin >> a[i];
	sort (a,a+3);
	if (a[0]==5 && a[1]==5 && a[2]==7) cout << "YES\n";
	else cout << "NO\n";
}



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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;
typedef tuple<long long, long long, long long> tllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
bool compTuple(const tllint& arg1, const tllint& arg2) { return get<2>(arg1) > get<2>(arg2); }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    vector<int> v(n);
    for(int in=0;in<n;++in) {
        cin >> v[in];
    }

    int m = min(n,k), ans = 0;
    for(int a=0;a<=m;++a) {
        for(int b=0;b<=m-a;++b) {
            vector<int> d;
            int anstmp = 0;
            
            for(int ia=0;ia<a;++ia) {
                d.push_back(v[ia]);
            }
            for(int ib=0;ib<b;++ib) {
                d.push_back(v[n-ib-1]);
            }

            sort(d.begin(), d.end());
            for(int ik=0;ik<k-a-b;++ik) {
                if(d.empty()) break;
                if(d[ik]>=0) break;
                d[ik] = 0;
            }

            for(auto id:d) anstmp += id;
            chmax(ans, anstmp);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int N;
	cin >> N;

	for( int i = 1; i <= N; i++ ) {
		int ans = 0;
		for( int x = 1; x * x <= i; x++ ) {
			for( int y = 1; y * y <= i; y++ ) {
				int b = x + y;
				int c = x * x + x * y + y * y - i;
				int r = b * b - 4 * c;
				if( r < 0 ) continue;
				double sr = sqrt(r);
				if( sr != floor( sr ) ) continue;
				int rr = sr;
				int z1 = (-b + rr ) / 2;
				if( z1 >= 1 ) {
					ans++;
				}
				int z2 = (-b - rr ) / 2;
				if( z2 >= 1 ) {
					ans++;
				}
			}
		}
		cout << ans << endl;
	}
}


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

int main()
{
	int a, b, c;
	cin >> a >> b >> c;

	if( c == a + b or a == b + c or b == c + a ) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No"  << endl;
	}

	return 0;
}

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

int main(){
    char c;
    int n;

    cin>>n;
    while(n--){
        vector<int> big,sml;
        int mx,mn;
        for(int i=0;i<8;i++){
            cin>>c;
            big.push_back(c-'0');
            sml.push_back(c-'0');
        }
        cin.ignore();

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

        stringstream ss;

        for(auto x:big){
            ss<<x;
        }
        ss >> mx;

        ss.clear();

        for(auto x:sml){
            ss << x;
        }

        ss >> mn;

        cout<<mx-mn<<endl;
    }

    return 0;
}

Measured memory_bytes: 1236
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	const int dis = 114514;
	int a[dis];
	int n; cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	int now = 1;
	int ans = 0;
	while (now != 2){
		now = a[now - 1];
		ans++;
		if (ans >= dis) {
			cout << "-1\n";
			return 0;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

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

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


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

int main() {

  int H1, H2, M1, M2;

  cin >> H1 >> M1 >> H2 >> M2;
  int K;
  cin >> K;

  int min1, min2;
  min1 = H1 * 60 + M1;
  min2 = H2 * 60 + M2;

  int diff, ans;
  diff = min2 - min1;
  ans = diff - K;

  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define hyperspeed ios::sync_with_stdio(false);cin.tie(NULL);
#define ll long long  
#define ull unsigned long long
#define ui unsigned int
#define li long int
#define uli unsigned long int
#define pb push_back
#define ld long double
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
const int MOD = 1e9+7;
const ll mx = (ll)1e18;

void solve() {
    ll n;
    cin >> n;
    ll a[n];
    for(ll i=0;i<n;++i) {
        cin >> a[i];
        if(a[i]==0) {
            cout << 0 << endl;
            return;
        }
    }
    ll prd = 1LL;
    for(ll i=0;i<n;++i) {
        if((prd*a[i])>mx || mx/prd < a[i]) {
            cout << "-1\n";
            return;
        }
        else {
            prd*=a[i];
        }
    }
    cout << prd << endl;
}

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

//--n1m5


Measured memory_bytes: 4372
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair
#define ff first
#define ss second
#define pri 1000000007
using namespace std;
void run()
{	
	ll m,k;
	cin>>m>>k;
	ll ze=pow(2,m)-1;
	if(m==0){
		if(k==0)cout<<0<<" "<<0;
		else cout<<-1;
	}
	else if(m==1){
		if(k==0){
			cout<<0<<" "<<0<<" "<<1<<" "<<1;
		}
		else{
			cout<<-1;
		}
		
	}
	else {
		if(k>ze){cout<<-1;}
       else{
       	cout<<k<<" ";
       	for(ll za=0;za<=ze;za++){
       		if(za==k)continue;
       		cout<<za<<" ";
       	}
       		cout<<k<<" ";
       	for(ll za=ze;za>=0;za--){
       		if(za==k)continue;
       		cout<<za<<" ";
       	}
       	
       }
		
	}
	
}
int main() {
	ll t=1;
	//cin>>t;
	for(ll j=0;j<t;j++)run();
	// your code goes here
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner scn = new Scanner(System.in);
		int n = Integer.parseInt(scn.next());
		/*
		 * すぬけくん行きつけのレストランは何を食べても 1 食 800 円で、15 食食べる毎にその場で 200 円もらえます。

すぬけくんは今までで合計 N 食食べました。 今までに払った金額を x 円、レストランからもらった金額を y 円として、x−y を求めなさい。
		 */

		int y = n / 15 * 200;
		int x = n * 800;
		System.out.println(x - y);

	}
}

Measured memory_bytes: 24020
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n);++i)
const int INF =1001001001;
using ll=long long;
using P = pair<ll,ll>;
using Graph =vector<string>;
Graph field;
queue<P> q;

int main() {
ll a,v,b,w,t;
cin >>a>>v>>b>>w>>t;
if(a-b+(v-w)*t>=0&&a<b){
//if(a+t*v>=b+w*t){
  cout<<"YES"<<endl;
  return 0;
}

if(a-b-(v-w)*t<=0&&a>b){
//if(a+t*v>=b+w*t){
  cout<<"YES"<<endl;
  return 0;
}
cout <<"NO"<<endl;
}


Measured memory_bytes: 3608
#import<atcoder/all>
using namespace std;int o(int a,int b){return a<b?b:a;}int e(){return 0;}int K,A,T=3<<17;main(){atcoder::segtree<int,o,e>P(T);for(cin>>K>>K;cin>>A;)P.set(A,P.prod(o(0,A-K),-o(-T,~K-A))+1);cout<<P.prod(0,T);}

Measured memory_bytes: 8656
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ones = N % 10;
		
		if(ones == 1){
			System.out.println("pon");
		} else if (ones == 2){
			System.out.println("hon");
		} else if (ones == 3){
			System.out.println("bon");
		} else if (ones == 4){
			System.out.println("hon");
		} else if (ones == 5){
			System.out.println("hon");
		} else if (ones == 6){
			System.out.println("pon");
		} else if (ones == 7){
			System.out.println("hon");
		} else if (ones == 8){
			System.out.println("pon");
		} else if (ones == 9){
			System.out.println("hon");
		} else if (ones == 0){
			System.out.println("pon");
		}
	}
}

Measured memory_bytes: 35540
n, k = map(int, input().split())
p = list(map(int, input().split()))
for i in range(n):
    p[i] = p[i] * (p[i] + 1) / 2 / p[i]
    if i != 0:
        p[i] += p[i - 1]

ans = p[k - 1]
tmp = ans
for i in range(k, n):
    ans = max(ans, p[i] - p[i - k])

print(ans)

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

const int maxn = 2e5 + 100;
int n;
struct node {
    int val, x;
} e[maxn];

bool cmp(node a, node b)
{
    return a.val > b.val;
}

int main()
{

    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &e[i].val);
        e[i].x = i;
    }
    sort(e, e + n, cmp);
    for (int i = 0; i < n; i++) {
        if (i == e[0].x)
            printf("%d\n", e[1].val);
        else
            printf("%d\n", e[0].val);
    }
    return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<cstdlib>
#include<algorithm>
using namespace std;
int N,a[100000],ans=0,last,cnt=1;
int main(void){
	cin>>N;
	for(int i=0;i<N;i++)cin>>a[i];
	sort(a,a+N);
	last=a[0];
	for(int i=1;i<=N;i++){
		if(a[i]!=last||i==N){
			if(cnt>=last)ans+=(cnt-last);
			else ans+=cnt;
			last=a[i];
			cnt=1;
			continue;
		}
		cnt++;
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

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

    int X;
    cin >> X;
    vector<int> dp(X + 1, 0);
    dp[0] = 1;
    for (int i = 0; i < X; ++i) {
        if (dp[i]) {
            for (int j = 100; j <= 105 && i + j <= X; ++j) {
                dp[i + j] = 1;
            }
        }
    }
    cout << dp[X] << "\n";

    return 0;
}

Measured memory_bytes: 640
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
D, X = MAP()
A = [INT() for i in range(N)]

ans = X
for a in A:
    ans += (1 + (D - 1) // a)
print(ans)


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

int main() {
  int N, K;
  cin >> N >> K;
  int ans=0;
  for (int i = 0; i < N; i++) {
    int h;
    cin >> h;
    if (h>=K) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc084/tasks/abc084_c

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define LEN(x) (sizeof(x) / sizeof(*(x)))
ll gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
ll lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    n--;
    vector<int> c(n), s(n), f(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i] >> s[i] >> f[i];
    }
    for (int i = 0; i < n; i++) {
        int start = 0;
        for (int j = i; j < n; j++) {
            if (start % f[j] == 0) {
                start = max(s[j], start) + c[j];
            } else {
                start = max(s[j], start + f[j] - start % f[j]) + c[j];
            }
        }
        cout << start << endl;
    }
    cout << "0\n";

    return 0;
}

Measured memory_bytes: 256
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include<bitset>

using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;



#define ll long long




/*
class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d, e, H, W, L;
long long A[200005] = {};
long long B[500][500] = {};
long long C[205][205] = {};
long long D[200005] = {};
long long E[200005] = {};
bool f, ff;
string S[2];
set <long long>sll;
pl bufpl;
vector <long long>vl[3];
vector <pl>vpl;
vector <string> vs;
set<ll> llset;

/*struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}


bool fs[2005][2005] = {};

int main() {


	cin >> a;

	
	if (a == 7 || a == 5 || a == 3) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}


	return 0;

}


Measured memory_bytes: 2304
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan,sqrt
import cmath as cma
import copy as cp
import sys
import re
import bisect as bs
sys.setrecursionlimit(10**7)
EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
MOD = 10**9 + 7

def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
def adj(n): return [[] for _ in range(n)]

n = iinput()
div,mod = divmod(n,1000)
ans = 1000*(div+1) - n if mod else 0
print(ans)


Measured memory_bytes: 37752
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  rep(i,n-1) if(s[i]!=s[i+1]) ++ans;
  cout << ans << endl;
}


Measured memory_bytes: 3744
#include <iostream>  
using namespace std; 
class gfg 
{ 
 public : long long int gcd(long long int a,long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 long long int lcm(long long int a,long long  int b)  
 {  
    return (a*b)/gcd(a, b);  
 }  
} ; 
int main()  
{  
    gfg g; 
    long long int a , b ;
    cin>>a>>b;
    long long int res=0;
    res=g.lcm(a, b);  
    cout<<res;
    return 0;  
}  

Measured memory_bytes: 3204
n, k = map(int, input().split())

if n >= k:
    ans = (n-k+1)
else:
    ans = 0

for i in range(1, min(n+1, k)):
    cnt = 0
    score = i
    while score < k:
        score *= 2
        cnt += 1
    ans += pow(1/2, cnt)

ans /= n
print(ans)


Measured memory_bytes: 9268
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;

    vector<ll> count(2e5+10,0);
    ll dp[n+1];
    dp[0]=1;
    int before=-1;
    for (int i = 1; i <= n; i++)
    {
        int temp;
        cin >> temp;
        dp[i]=dp[i-1];
        if(before==temp)continue;
        before=temp;
        //if(count[temp].size()!=0){
            /*
            for(auto iter=count[temp].begin();iter!=count[temp].end();iter++){
                if(i-*iter>1){
                    dp[i]+=dp[*iter-1];
                    dp[i]%=MOD;
                }
            }
            */
        dp[i]+=count[temp];
        dp[i]%=MOD;
        //}
        count[temp]+=dp[i-1];
        count[temp]%=MOD;
    }
    cout << dp[n] << "\n";
}


Measured memory_bytes: 3328
import sys

def input():
    return sys.stdin.readline().rstrip()

if __name__ == "__main__":
    l, r = map(int, input().split())

    n = r // 2019 - l // 2019

    if n >= 1:
        print(0)
    else:
        minvalue = float("inf")
        for i in range(l, r):
            for j in range(i+1, r+1):
                minvalue = min(minvalue, i * j % 2019)
        print(minvalue)


Measured memory_bytes: 2940
h,w = map(int,input().split())
if h == 1 or w == 1:
  print(1)
elif h % 2 == 0:
  print(h//2*w)
else:
  if w % 2 == 0:
    print(h*w//2)
  else:
    print(h*(w-1)//2+h//2+1)

Measured memory_bytes: 38384
# S = input()
# if len(S) % 2 == 1:
#     print('No')
#     exit()
# else:
#     if S[0] != "h":
#         print('No')
#         exit()
#     for i in range(len(S)-1):
#         flag = True
#         if S[i] == "i":
#             if S[i-1] != "h":
#                 flag = False
#         elif S[i] == "h":
#             if S[i-1] != "i":
#                 flag = False
#         else:
#             flag = False
# if flag:
#     print('Yes')
# else:
#     print('No')

S = input()
c = S.count("hi")
if c == len(S)/2:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> P;
typedef unsigned long long int ull;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e9;
const ll MOD=1e9+7;

int main(){
    int A,B;cin>>A>>B;
    vector<string> S(100,"");
    for(int i=0;i<50;++i){
        for(int j=0;j<100;++j){
            S[i]+='.';
            S[50+i]+='#';
        }
    }
    A--;B--;
    int i=0,j=0;
    while(B--){
        S[i][j]='#';
        j+=2;
        if(j>=100){
            j=0;
            i+=2;
        }
    }
    i=51;j=0;
    while(A--){
        S[i][j]='.';
        j+=2;
        if(j>=100){
            j=0;
            i+=2;
        }
    }
    cout<<100<<' '<<100<<endl;
    for(int i=0;i<100;++i){
        cout<<S[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <cstdint>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <tuple>

static size_t const m1 = -1;
static size_t const di[] = {m1, 0, 1, 0};
static size_t const dj[] = {0, m1, 0, 1};

int testcase_ends() {
  size_t h, w;
  scanf("%zu %zu", &w, &h);
  if (h == 0 && w == 0) return 1;

  std::vector<std::vector<int>> s(h+h-1);
  for (size_t i = 0; i < h+h-1; ++i) {
    if (i % 2 == 0) {
      s[i].resize(w-1);
      for (auto& sij: s[i]) scanf("%d", &sij);
    } else {
      s[i].resize(w);
      for (auto& sij: s[i]) scanf("%d", &sij);
    }
  }

  int inf = h*w;
  std::vector<std::vector<int>> dp(h, std::vector<int>(w, inf));
  dp[0][0] = 1;
  std::queue<std::pair<size_t, size_t>> q;
  q.emplace(0, 0);
  while (!q.empty()) {
    size_t i, j;
    std::tie(i, j) = q.front();
    q.pop();
    for (size_t k = 0; k < 4; ++k) {
      size_t ni = i + di[k];
      size_t nj = j + dj[k];
      if (!(ni < h && nj < w)) continue;
      if (s[i+ni][(j+nj)/2]) continue;
      if (!(dp[ni][nj] > dp[i][j] + 1)) continue;

      dp[ni][nj] = dp[i][j] + 1;
      q.emplace(ni, nj);
    }
  }
  if (dp[h-1][w-1] == inf) return puts("0"), 0;
  printf("%d\n", dp[h-1][w-1]);
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



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

int main(){
	int ds;
	cin >> ds;
	for(int r=0; r<ds; r++){
		int x1,x2,y1,y2;
		cin >> x1 >> y1 >> x2 >> y2;
		x2 += x1;
		y2 += y1;
		
		int n;
		cin >> n;
		int ans = 0;
		for(int i=0; i<n; i++){
			int cx,cy;
			cin >> cx >> cy;
			if(x1<=cx && cx<=x2 && y1<=cy && cy<=y2){
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 3092
n,m,k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

sum_a = [0]
sum_b = [0]

for i in range(n):
    sum_a.append(sum_a[i] + a[i])
for j in range(m):
    sum_b.append(sum_b[j] + b[j])

temp = 0
j = m
ans = 0
for i in range(n+1):
    if sum_a[i] > k:
        temp = i -1
        if temp > ans:
            ans = temp
        break
    else:
        while k - sum_a[i] < sum_b[j]:
            j -= 1
        temp = i + j
        if temp > ans:
            ans = temp
            
print(ans)

Measured memory_bytes: 47544
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}

ll lcm(ll a,ll b){
	return (a*b)/(__gcd(a,b));
}
int main(){
    fastIO();
  	ll n,m,L,G;
    string s,t;
    cin>>n>>m>>s>>t;
    L=lcm(m,n);
    G=__gcd(m,n);
    for(ll i=0;i<G;i++){
        if(s[n/G*i]!=t[m/G*i]){
        	cout<<-1;
        	return 0;
        }
    }
    cout<<L;
}  




Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
ll n;
string s;
 
int main() {
  cin >> n;
  cin >> s;
  string res = "";
  for(ll i=0; i<s.length(); i++){
    int num = (int)s[i];
    num += n;
    if(num >= 91)num -= 26;
    cout << (char)num;
  }
  cout << endl;
  return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    string S;
    cin >> S;
    bool step = true;
    REP(i,S.size()){
        if(i % 2 == 1){
            if(S[i] == 'R') step = false;
        }
        else{
            if(S[i] == 'L') step = false;
        }
    }
    if(step) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String[] w = new String[n];
    HashSet<String> hs = new HashSet<String>();
    for(int i = 0; i < n; i++) {
      w[i] = sc.next();
      hs.add(w[i]);
    }
    String ans = "Yes";
    if(hs.size() != n) ans = "No";
    for(int i = 1; i < n; i++) {
      char s = w[i - 1].charAt(w[i - 1].length() - 1);
      char t = w[i].charAt(0);
      if(s != t) ans = "No";
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 22996
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

using namespace std;
using P = pair<int, int>;
using T = tuple<long, long, long>;

long long MOD = 1000000007;
long long dp[100005][4];

int D[30][30];
int c[500][500];
int change[3][30];

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

	for (int i = 0; i < C; ++i) {
		for (int j = 0; j < C; ++j) {
			cin >> D[i][j];
		}
	}

	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 30; ++j) {
			change[i][j] = 0;
		}
	}
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			cin >> c[i][j];
			change[((i + 1) + (j + 1)) % 3][c[i][j] - 1]++;
		}
	}

	int ans = 250000 * 1000 + 5;
	for (int i = 0; i < C; ++i) {
		for (int j = 0; j < C; ++j) {
			if (i == j)continue;
			for (int k = 0; k < C; ++k) {
				if (k == i || k == j)continue;
				int temp = 0;
				for (int m = 0; m < C; ++m) {
					temp += D[m][i] * change[0][m];
					temp += D[m][j] * change[1][m];
					temp += D[m][k] * change[2][m];
				}
				ans = min(temp, ans);
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 1280
function myout(text){console.log(text);}//standard output
function Main(input) {
	//input = parseInt(input);
	//input = input.trim().split(" ");
	//input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  myout(input.lastIndexOf("Z") - input.indexOf("A") + 1);
}

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


Measured memory_bytes: 7372
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int res = Integer.MAX_VALUE;

        for(int i = 0; i <= 100000; i++) {
            res = Math.min(res, (i * C * 2) + (Math.max(0, X - i) * A) + (Math.max(0, Y - i) * B));
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 35936
#include <algorithm>  // sort, 二分探索(lower_bound)など
#include <cmath>      // pow, logなど
#include <complex>    // 複素数
#include <deque>      // 両端アクセスのキュー
#include <iostream>   // 入出力
#include <iterator>
#include <map>
#include <numeric>  // iota(整数列の生成), gcd, lcm
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>  // 順序保持しないmap
#include <unordered_set>  // 順序保持しないset
#include <utility>        // pair
#include <vector>

#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPR(i, a, b) for (int i = (a); i >= (b); i--)
#define ALL(container) (container).begin(), (container).end()
#define MAX(x) *max_element(ALL(x))  // 最大値を求める
#define MIN(x) *min_element(ALL(x))  // 最小値を求める

using namespace std;
typedef long long ll;

constexpr int INF = 1e9;
constexpr int MOD = 1000000007;

int main() {
  string S, T;
  cin >> S >> T;
  T.pop_back();
  if (S == T) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include <limits.h>


int parent(int i){
	return i / 2;
}

int left(int i){
	return 2 * i;
}

int right(int i){
	return 2 * i + 1;
}

int main(){
	int A[251];
	int n,i;
	
	for (i = 0; i < 250; i++){
		A[i]= INT_MAX;
	}

	scanf("%d",&n);
	for (i = 1; i <= n; i++){
		scanf("%d",&A[i]);
	}
	for (i = 1; i <= n; i++){
		printf("node %d: key = %d, ",i,A[i]);
		if (parent(i) > 0){
			printf("parent key = %d, ",A[parent(i)]);
		}
		if (left(i) < 250 && A[left(i)] != INT_MAX){
			printf("left key = %d, ",A[left(i)]);
			if (right(i)<250 && A[right(i)] != INT_MAX){
				printf("right key = %d, ",A[right(i)]);
			}
		}
		printf("\n");
	}

	return 0;
}

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

int main()
{
    string sa, sb, sc;
    cin >> sa;
    cin >> sb;
    cin >> sc;
    int peo = 0;
    int n = sa.size() + sb.size() + sc.size();
    string ans;
    rep(i, n) {
        int npeo = 0;
        if(peo == 0 && sa == "") {
            ans = "A";
            break;
        }
        if(peo == 1 && sb == "") {
            ans = "B";
            break;
        }
        if(peo == 2 && sc == "") {
            ans = "C";
            break;
        }
        if(peo == 0) {
            if(sa[0] == 'a') npeo = 0;
            if(sa[0] == 'b') npeo = 1;
            if(sa[0] == 'c') npeo = 2;
            sa.erase(0, 1);
        }
        if(peo == 1) {
            if(sb[0] == 'a') npeo = 0;
            if(sb[0] == 'b') npeo = 1;
            if(sb[0] == 'c') npeo = 2;
            sb.erase(0, 1);
        }
        if(peo == 2) {
            if(sc[0] == 'a') npeo = 0;
            if(sc[0] == 'b') npeo = 1;
            if(sc[0] == 'c') npeo = 2;
            sc.erase(0, 1);
        }
        peo = npeo;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
/*
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};
*/
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

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


ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

/*
//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}
*/
ll N, M;
vector<ll> A;

int main(){
  cin >> N >> M;
  A.resize(N);
  rep(i, N) cin >> A[i];
  ll ans = 0;
  priority_queue<double> pq;
  rep(i, N){
    pq.push(A[i]);
  }
  rep(i, M){
    double tmp = pq.top();
    pq.pop();
    pq.push(tmp/2);
  }
  rep(i, N){
    ans += ll(pq.top());
    pq.pop();
  }
  cout << ans << endl;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n, m;
  cin >> n >> m;
  if (n*m == 1) cout << 1 << endl;
  else if (n==1 || m==1) cout << max(n, m)-2 << endl;
  else cout << (n-2)*(m-2) << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val s = readLine()!!
    val t = readLine()!!
    val positions = ((s.length - t.length) downTo 0).filter { p -> (0 until t.length).all { s[it + p] == '?' || s[it + p] == t[it] }}
        .map { p -> s.substring(0, p) + t + s.substring(p + t.length) }
        .sorted()
    if (positions.isEmpty()) {
        println("UNRESTORABLE")
        return
    }
    println(positions.first().replace('?', 'a'))
}


Measured memory_bytes: 34144
#include <stdio.h>
#include <bits/stdc++.h>
#include <iostream>

using namespace std;

int main()
{
  long long int a, b, k;
  scanf("%lld %lld %lld", &a, &b, &k);

  if (a >= k)
   printf("%lld %lld\n", a-k, b);
  else if(a+b >= k)
   cout << "0 " << b-(k-a) << endl;
  else
   printf("0 0\n");
 
     


  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int n, i, min, max, cnt;
		long sum = 0;
		ArrayList<Integer> I = new ArrayList<Integer>();
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		for(cnt = 0; cnt < n; cnt++){
			i = sc.nextInt();
			I.add(new Integer(i));
		}
		max = I.get(new Integer(0));
		min = I.get(new Integer(0));
		for(cnt = 0; cnt < n; cnt++){
			if(min > I.get(new Integer(cnt))){
				min = I.get(new Integer(cnt));
			}else if(max < I.get(new Integer(cnt))){
				max = I.get(new Integer(cnt));
			}
			sum += I.get(new Integer(cnt));
		}
		System.out.println(min + " " + max + " " + sum);
	}
}

Measured memory_bytes: 43760
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>

using namespace std;

typedef long long ll;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep1(i,n) for(int i=1; i<=(int)(n); i++)
#define all(c) c.begin(),c.end()
#define psb push_back
#define ppb pop_back

const int INF = 1001001001;

int main() {
    ll A;
    long double B;

    cin >> A >> B;

    ll B100 = B*100+0.001;

    cout << A * B100 / 100 << endl;
}


Measured memory_bytes: 3720
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int n;
V<string> s;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    s.resize(n);
    for (int i = 0; i < n; i++) cin >> s[i];

    map<string, int> sc;
    for (int i = 0; i < n; i++) sc[s[i]]++;
    V< P<int, string> > ans;
    for (P<string, int> ssc: sc) {
        ans.emplace_back(ssc.second, ssc.first);
    }

    sort(ALL(ans), [&](P<int, string> i, P<int, string> j) {
        if (i.first == j.first) return i.second < j.second;
        else return i.first > j.first;
    });

    int maxi = ans[0].first;
    for (int i = 0; i < ans.size(); i++) {
        if (ans[i].first == maxi) cout << ans[i].second << '\n';
        else break;
    }
    return 0;
}


Measured memory_bytes: 29296