akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

int getLargestRectangle(int size, vi hist) {
	stack<pii> S;
	int maxv = 0;
	hist.push_back(0);

	REP(i, size+1) {
		pii rect;
		rect.first = hist[i];
		rect.second = i;
		if(S.empty()) {
			S.push(rect);
		} else {
			if(S.top().first < rect.first) {
				S.push(rect);
			} else if(S.top().first > rect.first) {
				int target = i;
				while(!S.empty() && S.top().first >= rect.first) {
					pii pre = S.top();
					S.pop();
					int area = pre.first * (i-pre.second);
					maxv = max(maxv, area);
					target = pre.second;
				}
				rect.second = target;
				S.push(rect);
			}
		}
	}

	return maxv;
}

int main() {
	int H, W;
	while(cin >> H >> W, H) {
		vs field(H);
		REP(i, H) {
			cin >> field[i];
		}

		vvi hist(H, vi(W, 0));
		REP(i, H) {
			REP(j, W) {
				if(i == 0) {
					if(field[i][j] == '.') {
						hist[i][j] = 1;
					}
				} else {
					if(field[i][j] == '*') {
						hist[i][j] = 0;
					} else {
						hist[i][j] = hist[i-1][j]+1;
					}
				}
			}
		}

		int ans = 0;
		REP(i, H) {
			ans = max(ans, getLargestRectangle(W, hist[i]));
		}

		cout << ans << endl;
	}
}

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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int N;
VI a;
std::map<int, int> map;
int main() {
    std::cin >> N;
    a.resize(N);
    REP(i, N) {
        std::cin >> a[i];
        if(map.count(a[i]) == 0) {
            map[a[i]] = 1;
        } else{
            map[a[i]] = map[a[i]] + 1;
        }
    }

    long ans = 0;
    for(auto p: map) {
        if(p.first == p.second) continue;
        else if(p.first > p.second) ans += p.second;
        else {
            ans += p.second - p.first;
        }
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define INF 1000000000
#define M 1000000007ll
#define UQ(x) (x).resize(distance((x).begin(),unique(all((x)))))
int n,a[205];
int main() {
	scanf("%d",&n);
	for (int i=0;i<2*n;i++) scanf("%d",&a[i]);
	int ans=0;
	sort(a,a+2*n);
	for (int i=0;i<2*n;i+=2) ans+=a[i];
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
S=str(input())
if S[-1]=="2" or S[-1]=="4" or S[-1]=="5" or S[-1]=="7" or S[-1]=="9":
  print("hon")
elif S[-1]=="0" or S[-1]=="1" or S[-1]=="6" or S[-1]=="8":
  print("pon")
else:
  print("bon")



Measured memory_bytes: 9116
#include <iostream>

using namespace std;

int main(){
	int A_fix, B_fix;
	int A, B;
	cin >> A_fix >> B_fix;

	A = A_fix;
	B = B_fix;
	int div = 0;
	int g_num = 0;
	long long int L_num = 0;
	int a, b;

	while(1){
		if(A_fix>B_fix){
			div = A_fix - B_fix;
			if((B_fix >= div) && (B_fix % div == 0)){
				g_num = div;
				break;
			}
			A_fix = div;
		}else if(A_fix == B_fix){
			g_num = A_fix;
			break;
		}else{
		div = B_fix - A_fix;
		if((A_fix >= div) && (A_fix % div == 0)){
			g_num = div;
			break;
		}
		B_fix = div;
	}
}

	a = A / g_num;
	b = B / g_num;

	L_num = (long long int)a * b * g_num;

	cout << L_num << endl;
	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h,w,n,x=0;
    cin>>h>>w>>n;

    if(w>h)
    {
        //cout<<"1"<<endl;
        for(int i=1;i<=1000000;i++)
        {
            if(i*w>=n)
            {
                x=i;
                break;
            }
        }
        cout<<x<<endl;
    }
    else
    {
        //cout<<2<<endl;
        for(int i=1;i<=1000000;i++)
        {
            if(i*h>=n)
            {
                x=i;
                break;
            }
        }
        cout<<x<<endl;
    }



    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>
#include<map>
using namespace std;
typedef pair<int,int> P;
typedef struct{
	int next;
	int cost[2];
}edge;

int n,m;
vector<edge> mapp[111];
int bfs(int now,int goal,int k);

int main(){
	while(1){
		cin >> n >> m;
		if(n == 0 && m == 0) break;
		for(int i=0;i<m+1;i++){
			mapp[i].clear();
		}
		for(int i=0;i<n;i++){
			int a,b,cost,tim;
			cin >> a >> b >> cost >> tim;
			edge x;
			x.next = a; x.cost[0] = cost; x.cost[1] = tim;
			mapp[b].push_back(x);
			x.next = b; x.cost[0] = cost; x.cost[1] = tim;
			mapp[a].push_back(x);
		}
		int k;
		cin >> k;
		int ans;
		for(int i=0;i<k;i++){
			int p,q,r;
			cin >> p >> q >> r;
			if(r == 0) ans = bfs(p,q,r);
			else if(r == 1) ans = bfs(p,q,r);
			cout << ans << endl;
		}
	}
}

int bfs(int now,int goal,int k){
	vector<int> min_cost;
	min_cost.resize(m+1,-1);
	priority_queue<P, vector<P>,greater<P> > que;
	que.push(P(0,now));
	min_cost[now] = 0;
	while(!que.empty()){
		P p = que.top(); que.pop();
		int no = p.second;
		int co = p.first;
		if(no == goal) return co;
		if(co > min_cost[no]) continue;
		int len=mapp[no].size();
		for(int i=0;i<len;i++){
			edge x = mapp[no][i];
			if(min_cost[x.next] == -1 || co+x.cost[k]<min_cost[x.next]){
				min_cost[x.next] = co + x.cost[k];
				que.push(P(co+x.cost[k],x.next));
			}
		}
	}
	return min_cost[goal];
}

Measured memory_bytes: 1308
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int N;
double L,s[87000],t[87000],u[87000];

int main(){
	while(cin>>N>>L&&N){
		t[0]=u[N+1]=0,s[N+1]=t[N+1]=86400;
		rep(i,N)cin>>s[i+1]>>t[i+1]>>u[i+1];
		double lo=0,hi=1e6;
		rep(h,120){
			double mi=(lo+hi)/2,l=L;
			int ok=1;
			rep2(i,1,N+2){
				l=min(L,l+mi*(s[i]-t[i-1]));
				l=min(L,l+(mi-u[i])*(t[i]-s[i]));
				if(l<=0){ok=0;break;}
			}
			double x=l;
			if(ok)rep2(i,1,N+2){
				l=min(L,l+mi*(s[i]-t[i-1]));
				l=min(L,l+(mi-u[i])*(t[i]-s[i]));
				if(l<=0){ok=0;break;}
			}
			ok&&l>=x?hi=mi:lo=mi;
		}
		printf("%.7f\n",(lo+hi)/2);
	}
}

Measured memory_bytes: 3004
#include<stdio.h>

int main(){
  int i, n, Fibo[44];

  scanf("%d", &n);
  for(i = 0; i <= n; i++){
    Fibo[0] = 1;
    Fibo[1] = 1;
    if(i > 1){
      Fibo[i] = Fibo[i - 1] + Fibo[i - 2];
    }
  }

  printf("%d\n", Fibo[n]);

  return 0;

}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define fi first
#define se second
#define endl '\n'
#define int int64_t
#define double long double
// mt19937 rnd(time(0));
// const double TIME_LIMIT = 1.8;
// Heuristic TL: clock() < TIME_LIMIT * CLOCKS_PER_SEC
const int MAXN = 1000001;
const int INF = numeric_limits<int>::max() >> 3;
const int MOD = (int)998244353;

signed main(){
	ios_base::sync_with_stdio(0); 
	cin.tie(0); 
	cout.tie(0); 
	// freopen("FDT.txt","r",stdin);
	int s, w;
	cin >> s >> w;
	cout << (w >= s ? "unsafe": "safe");
}

Measured memory_bytes: 3652
N,K = map(int,input().split(' '))
S = input()




happies = 0
happy_max = N-1

for i in range(N-1):
    if (S[i] == 'R') & (S[i+1] == 'R'):
        happies +=1
    if (S[-i-1] == 'L') & (S[-i-2] == 'L'):
        happies +=1
print(min(happies+2*K,happy_max))

Measured memory_bytes: 3316
import numpy as np

H,W = map(int,input().split())
A = []
for i in range(H):
	A.append([0 if s == "#" else H+W for s in input()])

A = np.array(A)
for x in range(W - 1):
	A[:,x+1] = np.minimum(A[:, x]+1,A[:, x+1])
for x in range(W - 1, 0 , -1):
	A[:,x-1] = np.minimum(A[:, x-1],A[:, x]+1)
for y in range(H -1):
	A[y+1,:] = np.minimum(A[y, :]+1,A[y+1, :])
for y in range(H -1, 0, -1):
	A[y-1,:] = np.minimum(A[y-1, :],A[y, :]+1)

print(np.max(A))

Measured memory_bytes: 60408
s = gets.to_s.chomp.bytes

l = 0
r = s.size - 1

ans = 0
while l < r
  
  if s[l] == s[r]
    l += 1
    r -= 1
  else
    if s[l] == 120
      l += 1
    elsif s[r] == 120
      r -= 1
    else
      puts "-1"
      exit
    end
    ans += 1
  end
end

puts ans

Measured memory_bytes: 2812
#include<stdio.h>
#define N 1000

int main(){
  int i, j, k, n, key, line=1;
  int A[N];
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  for(i=1;i<=n;i++){
    for(j=0;j<n;j++){
      //if(j == line){
	
      //}
      if(j!=0){
	printf(" ");
      }
      printf("%d", A[j]);
      
    }
    
    printf("\n");
    

    key = A[i];
    k = i-1;
    while(k >=0 && A[k] > key){
      A[k+1] = A[k];
      k--;
    }
    A[k+1] = key;
    //line++;
  }


  return 0;
}




Measured memory_bytes: 2088
#include <bits/stdc++.h>
using namespace std;
signed main(){
  	bool c_moon=true;
	long long x,ans;
  	cin>>x;
		
  	ans=x;
  	while(c_moon){
      c_moon=false;
		for(int i=2;i*i<=ans;i++){
			if(ans%i == 0)
              c_moon=true;
        }
      if(c_moon)
        ans++;
    }
  	cout<<ans<<endl;
    return(0); 
}

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


int main(){
    int N, K;
    cin >> N >> K;
    int R, S, P;
    cin >> R >> S >> P;
    string T;
    cin >> T;

    int total = 0;
    for(int i = 0; i < N; i++){
        if(T[i] == 'r') total += P;
        if(T[i] == 's') total += R;
        if(T[i] == 'p') total += S;
    }

    for(int i = 0; i < K; i++){
        char before = 'x';
        int cnt = 1;
        for(int j = 0; j < (N+K-1)/ K; j++){
            if(j*K+i >= N) continue;
//            cout << ":" << j * K + i << endl;
            char now = T[j*K+i];
            if(before == now){
                cnt++;
            }else{
                // 精算処理
                int kake = cnt / 2;
                if(before == 'r') total -= P * kake;
                if(before == 'p') total -= S * kake;
                if(before == 's') total -= R * kake;

                // 初期化処理
                before = now;
                cnt = 1;
            }
        }
        // 精算処理
        int kake = cnt / 2;
        if(before == 'r') total -= P * kake;
        if(before == 'p') total -= S * kake;
        if(before == 's') total -= R * kake;

    }
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

class Solver {
    public void Solve() {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        double ar = Math.sqrt(a * 1.0);
        double br = Math.sqrt(b * 1.0);
        double cr = Math.sqrt(c * 1.0);
        // if (ar + br < cr) {
        // System.out.println("Yes");
        // } else {
        // System.out.println("No");
        // }
        long aa = a;
        long bb = b;
        long cc = c;
        long ab = aa * bb;
        if (cc - aa - bb <= 0) {
            System.out.println("No");
            return;
        }
        if (4 * ab < (cc - aa - bb) * (cc - aa - bb)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    Scanner sc;

    Solver(Scanner in) {
        this.sc = in;
    }
}

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


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

int main()
{
  int N = 0;
  std::cin >> N;
  std::vector<int> L(N);
  auto * const l = &L[0];
  for (int i = 0; i < N; ++i)
    std::cin >> l[i];
  std::sort(l, l + N);
  long long counter = 0;
  for (int i = 0, _i = N - 2; i < _i; ++i)
  {
    for (int j = i + 1, _j = N - 1; j < _j; ++j)
    {
      for (int k = j + 1; k < N; ++k)
      {
        if (l[i] + l[j] <= l[k])
          break;
        if (
          (l[i] < l[j] + l[k])
          && (l[j] < l[k] + l[i])
        )
          ++counter;
      }
    }
  }
  std::cout << counter;
  return 0;
}


Measured memory_bytes: 384
n = int(input())
a = [0] * n
for i in range(n):
  act = list(map(int, input().split()))
  a[i] = act
  
memo = [0] * n
memo[n - 1] = a [n - 1]
for i in range(n - 2, -1, -1):
  memo[i] = [0] * 3
  memo[i][0] = a[i][0] + max(memo[i+1][1], memo[i+1][2])
  memo[i][1] = a[i][1] + max(memo[i+1][0], memo[i+1][2])
  memo[i][2] = a[i][2] + max(memo[i+1][0], memo[i+1][1])
  
print(max(memo[i]))

Measured memory_bytes: 47220
import java.util.Scanner;
import java.util.ArrayList;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
     ArrayList <Integer> li = new ArrayList <Integer>();
    for(int i=0; i<n; i++){
      int a = sc.nextInt();
      li.add(a);
    }
    int bigger = li.get(0);
    for(int i=1;i<n;i++){
      int a = Math.max(bigger,li.get(i));
      bigger = a;
    }
    int maxNumber=0;
    int m=0;
    for(int i=0;i<n;i++){
      if(li.get(i)==bigger){
        maxNumber++;
        m = i;
      }
    }
    if(maxNumber>1){
      for(int i=0;i<n;i++){
        System.out.println(bigger);
      }
    }else if(m==0&&n==2){
          System.out.println(li.get(1));
          System.out.println(bigger);
    }else if(m==0){
          int semiMax = li.get(1);
          for(int i=2;i<n;i++){
            int a = Math.max(semiMax,li.get(i));
            semiMax = a;
          }
        System.out.println(semiMax);
        for(int i=1;i<n;i++){
          System.out.println(bigger);
        }     
    }else{
        int semiMax = li.get(0); 
        for(int i=1;i<n;i++){
          if(i==m){
            continue;
          }else{
            int a = Math.max(semiMax,li.get(i));
            semiMax = a;
          }
        }
        for(int i=0;i<n;i++){
          if(i==m){
            System.out.println(semiMax);
          }else{
            System.out.println(bigger);
          }
        }
    }
  }
}


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

int main(void){
	int H,N;
	cin >> H >> N;
	int sum = 0;
	string s;
	while(getline(cin, s, ' ')){
		sum += stoi(s);
	}
	if(sum >= H){
		cout << "Yes";
	}else{
		cout << "No";
	}
}


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

int main() {
    string S;
    cin >> S;
    int N=S.size();
    int ans1=0;
    for (int i=0; i<N; i++) {
        char a;
        if(i%2==0){
            a='0';
        }
        else{
            a='1';
        }
        //cout << S[i] << a << endl;
        if (S[i]!=a) {
            ans1++;
        }
    }
    //cout << ans1 << endl;
    
    int ans2=N-ans1;
    if (ans1<ans2) {
        cout << ans1 << endl;
    }
    else{
        cout << ans2 << endl;
    }
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
//回答が整数の場合
int ans=1000000000;
//整数値の入力
int n,k;
cin >> n >>k;
//行列の入力
int table[n]={};
for (int i = 0; i < n; ++i) {
    cin >> table[i];
}

sort(table, table + n);
for (int i = 0; i < n-k+1; ++i) {
    if(ans>table[i+k-1]-table[i]){ans=table[i+k-1]-table[i];}
}


//回答
cout << ans << endl;
return 0;
}

Measured memory_bytes: 640
N, M, Q = map(int, input().split())

train = [[0 for j1 in range(N)] for i1 in range(N)]
st = [[0 for j2 in range(N+1)] for i2 in range(N)]
s = [[0 for j3 in range(N+1)] for i3 in range(N)]


def main():
    for i in range(M):
        l, r = map(int, input().split())
        train[l-1][r-1] += 1

    for i in range(N):
        for j in range(N):
            st[i][j+1] = st[i][j] + train[i][j]

    for i in range(N+1):
        s[N-1][i] = st[N-1][i]
    for i in range(N-2, -1, -1):
        for j in range(N+1):
            s[i][j] = s[i+1][j] + st[i][j]


    for i in range(Q):
        p, q = map(int, input().split())
        print(s[p-1][q])


if __name__ == '__main__':
    main()


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

#define int long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (int)(1000000007)
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 9999999999999999
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 1000005
#define mxnn 2000005
int mat[17][17];
int dp[1<<17];
int pre[1<<17];
int32_t main(){
sp;
int n;
cin >>n;
dp[0] = 0;
for(int i = 0;i<n;i++) for(int j = 0;j<n;j++) cin >>mat[i][j];
for(int i = 0;i<(1<<n);i++){
    vector<int>v;
    for(int j = 0;j<n;j++){
        if(i&(1<<j)) v.pb(j);
    }
    int sum = 0;
    for(int j = 0;j<v.size();j++) for(int k = j+1;k<v.size();k++) sum += mat[v[j]][v[k]];
    dp[i] = sum;
}
for(int mask = 1;mask<(1<<n);mask++){
    for(int i = mask;i>0;i=((i-1)&mask)){
        int a = mask^i;
        dp[mask] = max(dp[mask],dp[i] + dp[a]);
    }
}
cout<<dp[(1<<n)-1];
return 0;
}


Measured memory_bytes: 768
<?php
$input = trim(fgets(STDIN));
list($w,$h,$x,$y,$r)= explode(" ", $input);
if(($x - $r) >= 0 && ($x + $r) <= $w && ($y - $r) >= 0 && ($y + $r) <= $h){
    echo "Yes\n";
}else{
    echo "No\n";
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int a, b, x;
    cin >> a >> b >> x;
    if (a <= x && x <= a + b) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#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) )
typedef long long ll;
using namespace std;

ll calc(const ll &x, ll wj, ll wt, ll ej, ll et) {
    ll D[2][2];
    D[0][0] = wj; D[0][1] = ej; D[1][0] = wt; D[1][1] = et;
    ll ret = LINF*3;
    REP(i,2) {
        REP(j,2) {
            REP(k,2) {
                if (i == k) continue;
                REP(l,2) {
                    ll f = D[i][j];
                    ll la = D[k][l];
                    ret = min(abs(x-f)+abs(f-la), ret);
                }
            }
        }
    }
    return ret;
}

int main(int argc, char const *argv[]) {
    int a, b, q;
    cin >> a >> b >> q;
    vector<ll> s(a); vector<ll> t(b); vector<ll> X(q);
    REP(i,a) cin >> s[i];
    REP(i,b) cin >> t[i];
    REP(i,q) cin >> X[i];
    REP(i,q) {
        ll x = X[i];
        auto Wj = lower_bound(s.begin(), s.end(), x);
        auto Ej = upper_bound(s.begin(), s.end(), x);
        auto Wt = lower_bound(t.begin(), t.end(), x);
        auto Et = upper_bound(t.begin(), t.end(), x);
        ll wj, ej, wt, et;
        if (Wj == s.begin()) wj = LINF;
        else {
            --Wj;
            wj = *Wj;
        }
        if (Wt == t.begin()) wt = LINF;
        else {
            --Wt;
            wt = *Wt;
        }
        if (Ej == s.end()) ej = LINF;
        else ej = *Ej;
        if (Et == t.end()) et = LINF;
        else et = *Et;
        //printf("x = %lld: Wj = %lld Ej = %lld, Wt = %lld Et = %lld\n", x, wj, ej, wt, et);
        ll ans = calc(x, wj, wt, ej, et);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3712
class Solver
  def initialize
    while data = gets
      @data = data.chomp.split(' ').map(&:to_i)
      @length = @data.shift
      @data.unshift(0)
      @graph = Array.new(@data.size).map{Array.new(@data.size, 0)}
      @dp = Array.new(1 << @data.size).map{Array.new(@data.size, -1)}
      create_graph
      answer = 9999

      answer = solver( 0, 0 )

      @graph.each do |graph|
        #p graph
      end
      puts (answer <= @length)? "OK" : "NA"
    end
  end

  def create_graph
    0.upto(@data.size-1) do |id|
      0.upto(@data.size-1) do |id2|
        if id == 0
          @graph[id][id2] = @data[id2]
        elsif id != id2
          if id2 == 0
            @graph[id][0] = @data[id]
          else
            @graph[id][id2] = calc_dist(id, id2)
          end
        end
      end
    end
  end

  def calc_dist(id1, id2)
    r1 = @data[id1]
    r2 = @data[id2]
    a = r1 + r2
    b = r1 - r2
    dist = Math.sqrt(a**2 - b**2)
  end

  def solver( s, v )
    return @dp[s][v] if @dp[s][v] >= 0

    return 0 if s == (1 << @data.size) - 1 && v == 0

    res = 9999
    0.upto(@data.size-1) do |id|
      if !((s >> id) & 1 == 1)
        res = [ res, solver( s | (1 << id), id) + @graph[v][id]].min
      end
    end
    @dp[s][v] = res
  end
end

s = Solver.new

Measured memory_bytes: 8432
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

int main(void) {
	int A, B;
	cin >> A >> B;

	if (A%3 == 0 or B%3 == 0 or (A+B)%3 == 0) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}

	return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int n;
    cin >> n;
    if (n < 2) cout << 1 << endl;
    else if (n < 4) cout << 2 << endl;
    else if (n < 8) cout << 4 << endl;
    else if (n < 16) cout << 8 << endl;
    else if (n < 32) cout << 16 << endl;
    else if (n < 64) cout << 32 << endl;
    else cout << 64 << endl;
    return 0;
}

Measured memory_bytes: 256
//A - Number of Multiples
//Hiia
#include <stdio.h>
#include <stdlib.h>//rannsuu, zettaichi(absolute)
#include <time.h>
//srand((unsigned int) time(0));
#include <math.h>//koudona keisann
#include <string.h>//hairetsu
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
typedef long long ll;
//#define N 998244353
#define pi 3.1415926535897932384626433832

int gcd(int m,int n){if((0==m)||(0==n))return 0;while(m!=n)if(m>n)m=m-n;else n=n-m;return m;}
int lcm(int m,int n){if((0==m)||(0==n))return 0;return(m*n/gcd(m, n));}
int fact(int x){if(x==1) return(x);else return(x*fact(x-1));}//Kaijou x!
int ruijou(int base,int exponent){int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

long long int llgcd(long long int m,long long int n){if((0==m)||(0==n))return 0;while(m!=n)if(m>n)m=m-n;else n=n-m;return m;}
long long int lllcm(long long int m,long long int n){if((0==m)||(0==n))return 0;return(m*n/llgcd(m, n));}
long long int llfact(long long int x){if(x==1) return(x);else return(x*llfact(x-1));}//Kaijou
int llruijou(long long int base,long long int exponent){long long int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

int main()
{
  int a,b,d;
  scanf("%d %d %d", &a,&b,&d);
  if(a%d==0){
    printf("%d\n", b/d-a/d+1);
  }
  else{
    printf("%d\n", b/d-a/d);
  }
  return 0;
}


Measured memory_bytes: 1720
#include <algorithm>
#include <iostream>
#define N 8
using namespace std;
int h,w,c,p[N][N],d[N][N],t[N][N],change[5],ans;
bool visited[N][N];
void func(int);
void func2(int,int);

int main(){
  while(1){
    cin>>h>>w>>c;
    if(!h&&!w&&!c) break;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++) cin>>p[i][j];
    ans=0;
    change[4]=c;
    func(0);
    cout<<ans<<endl;
  }
  return 0;
}

void func(int x){
  if(x==4){
    int flag=0;
    for(int i=0;i<4;i++)
      if(change[i]==change[i+1]) flag=1;
    if(!flag){
      for(int i=0;i<h;i++)
	for(int j=0;j<w;j++) d[i][j]=p[i][j];
      for(int i=0;i<5;i++){
	for(int j=0;j<h;j++)
	  for(int k=0;k<w;k++) visited[j][k]=false,t[j][k]=0;
	func2(0,0);
	for(int j=0;j<h;j++)
	  for(int k=0;k<w;k++)
	    if(t[j][k]) d[j][k]=change[i];
      }
      for(int i=0;i<h;i++)
	for(int j=0;j<w;j++) visited[i][j]=false,t[i][j]=0;
      func2(0,0);
      int cnt=0;
      for(int i=0;i<h;i++)
	for(int j=0;j<w;j++)
	  if(t[i][j]) cnt++;
      ans=max(ans,cnt);
    }
    return;
  }
  for(int i=1;i<=6;i++) change[x]=i,func(x+1);
}

void func2(int y,int x){
  int dx[4]={0,1,0,-1};
  int dy[4]={-1,0,1,0};
  visited[y][x]=true;
  t[y][x]=1;
  for(int i=0;i<4;i++){
    int ny=y+dy[i],nx=x+dx[i];
    if(ny<0||nx<0||h<=ny||w<=nx||d[y][x]!=d[ny][nx]) continue;
    if(visited[ny][nx]) continue;
    func2(ny,nx);
  }
}

Measured memory_bytes: 1164
package main

import "fmt"

func main() {
	var S, T string
	fmt.Scan(&S)
	fmt.Scan(&T)
	ok := false
	if S == T {
		ok = true
	} else {
		for i := 1; i < len(S); i++ {
			s := make([]rune, 0)
			s = []rune(S[i:len(S)])
			s = []rune(append(s, []rune(S[0:i])...))
			if string(s) == T {
				ok = true
				break
			}
		}
	}
	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

int main(){
	int n,m;
	cin >> n>>m;
	int S = m;
	int ti,to;
	for(int i = 0; i < n; i++){
		cin >> ti>>to;
		m = m+ti-to;
		S = max(m,S);
		if(m< 0){
			S = 0;break;
		}
	}
	cout << S << endl;
	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 


string w[110];

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

  for (int i=0; i< n; ++i) {
    cin >> w[i];
  }
//bool値をだして、w[i]の中の末尾と頭を比較
  bool ans =true;
  for (int i=0; i< n-1;++i) {
    if (w[i][w[i].size()-1] != w[i+1][0]){
      ans = false;

    }
  }

  for (int i=0;i<n;i++) {
    for (int j=0;j<i;j++) {
      if(w[i] == w[j]) {
        ans = false;
      }
    }
  }

  if (ans) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

long long gcd(long long a,long long b)
{
	if (b) return gcd(b,a%b);
	else return a;
}
int main()
{
	long long n,x,m,i,c;
	cin>>n;
	m=1;
	for (i=0;i<n;i++)
	{
		cin>>x;
		if (m>x) c=gcd(m,x);
		else c=gcd(x,m);
		m=m/c*x;
	}
	cout<<m<<endl; 
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int H,W,K,ans;string s[6];
int main(){
	cin>>H>>W>>K;
	for(int i=0;i<H;i++)
		cin>>s[i];
	for(int i=0;i<(1<<(H+W));i++){
		int cnt=0;
		for(int j=0;j<H;j++)
			for(int k=0;k<W;k++)
				if(s[j][k]=='#')
					if(((i&(1<<(k+H)))==0)&&((i&(1<<j))==0))
						cnt++;
		if(cnt==K)ans++;
	}cout<<ans;
} 

Measured memory_bytes: 3628
using System;

public class AtCoder{
	public static void Main(){
		string[] s;
		s = Console.ReadLine().Trim().Split(' ');
		
		int a,b;
		a = int.Parse(s[0]);
		b = int.Parse(s[1]);
		
		Console.WriteLine(a+b/2);
	}
}

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

int main() {
  int H, W;
  cin>>H>>W;
  
  vector<bool> row(H, false);
  vector<bool> col(W, false);
  
  vector<string> a(H);
  
  for(int i=0;i<H;i++){
    cin >> a[i];
  }
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(a[i][j]=='#'){
        row[i]=true;
        col[j]=true;
      }
    }
  }
  
  for(int i=0;i<H;i++){
    if(row[i]){
      for(int j=0;j<W;j++){
        if(col[j]){
          cout<<a[i][j];
        }
      }
      cout<<endl;
    }
  }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
#define pint pair<int,int>
#define vi(v) rep(i,v.size())cin >> v[i]
#define vc(v) rep(i,v.size())cout << v[i] << endl
#define ni(n) cin >> n
#define nc(n) cout << n << endl
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
int solve(){
  int a,b,c;
  cin >> a >> b >> c;
  swap(a,b);
  swap(a,c);
  cout << a << " " << b << " " << c << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;

struct Edge{int to,from,cost;};

#ifdef DEBUG
#define debug cout
#else
stringstream __ss__;
#define debug __ss__
#endif

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) debug << *i << " "; debug << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;i--)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repnd(i,m,n) for(int i=(n)-1;i>=(m);i--)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;i--)
#define repn0(i,m,n) for(i=(m);i<=(n);++i)
#define repnd0(i,m,n) for(i=(n)-1;i>=(m);i--)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define SS stringstream
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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



int main() {
	double d;
	IL{
		cin>>d;
		if(d==0)break;
		int b;
		int pib;
		repn0(b,1,10000000){
			pib=(int)(PI*b);
			if(PI-(double)pib/b<=d)break;
			if((double)(pib+1)/b-PI<=d)break;
		}
		if(PI-(double)pib/b<=d){
			if((double)(pib+1)/b-PI<=d){
				if(PI-(double)pib/b<(double)(pib+1)/b-PI){
					cout<<pib<<"/"<<b<<endl;
				}else{
					cout<<pib+1<<"/"<<b<<endl;
				}
			}else{
				cout<<pib<<"/"<<b<<endl;
			}
		}else{
			cout<<pib+1<<"/"<<b<<endl;
		}
	}
	return 0;
}

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int main(){
    ll n, k;
    cin >> n >> k;
    vector<pair<ll, ll>> x(n);
    for(int i = 0; i < n; i++){
        ll a, b;
        cin >> a >> b;
        x[i] = make_pair(a, b);
    }
    sort(begin(x), end(x));
    ll ans, c = 0;
    for(int i = 0; i < n; i++){
        c += x[i].second;
        if(c >= k){
            ans = x[i].first;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
n = int(input())
l =  list(map(int,input().split()))
result = 0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[i] != l[j] and l[i] != l[k] and l[j] != l[k] and l[k]<l[i]+l[j] and l[i]<l[k]+l[j] and l[j]<l[i]+l[k]:
                result += 1
print(result)

Measured memory_bytes: 9044
package main

import (
	"fmt"
)

func main() {
	var n, m, x int
	fmt.Scanf("%d %d %d", &n, &m, &x)
	c := make([]int, n)
	a := make([][]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &c[i])
		a[i] = make([]int, m)
		for j := 0; j < m; j++ {
			fmt.Scanf("%d", &a[i][j])
		}
	}
	answer := minCost(n, m, x, a, c)
	fmt.Println(answer)
}

func minCost(n, m, x int, a [][]int, c []int) int {
	minCost := 12000000
	for bits := 0; bits < (1 << n); bits++ {
		choice := []int{}
		for i := 0; i < n; i++ {
			if (bits & (1 << i)) > 0 {
				choice = append(choice, i)
			}
		}
		if achievable(a, x, choice) {
			cost := calcCost(c, choice)
			if cost < minCost {
				minCost = cost
			}
		}
	}
	if minCost != 12000000 {
		return minCost
	}
	return -1
}

func achievable(a [][]int, x int, choice []int) bool {
	levels := make([]int, len(a[0]))
	for i := 0; i < len(choice); i++ {
		for i, v := range a[choice[i]] {
			levels[i] += v
		}
	}
	for _, v := range levels {
		if v < x {
			return false
		}
	}
	return true
}

func calcCost(c []int, choice []int) int {
	cost := 0
	for _, v := range choice {
		cost += c[v]
	}
	return cost
}


Measured memory_bytes: 2708
#include <cstdio>
#include <algorithm>
const int M = 3e5 + 10;
int n, m, a[M], as[M], b[M];
struct L{int l, r;
	inline int len()const {return r - l + 1;}
	bool operator<(const L& b)const {return len() < b.len();}
}st[M];
inline int lowbit(int x){ return x&-x;}
inline void add(int p, int v) {
	while (p < M) a[p] += v, p += lowbit(p);
}
inline int pre(int p) {
	int s = 0;
	while (p) s += a[p], p -= lowbit(p);
	return s;
}
inline void modi(int l, int r) {
	add(l, 1), add(r + 1, -1);
}
int main() {
//	freopen("input", "r", stdin);
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)
		scanf("%d%d", &st[i].l, &st[i].r);
	std::sort(st + 1, st + 1 + n);
	for (int i = 1; i <= n; i++) b[0]++, b[st[i].len() + 1]--;
//	for (int i = 1; i <= m; i++) b[i] += b[i - 1], as[i] = b[i];
	for (int i = 1, p = 1; i <= m; i++) {
		while (p <= n && st[p].len() < i) modi(st[p].l, st[p].r), p++;	
		for (int j = i; j <= m; j += i) as[i] += pre(j);
	}
	for (int i = 1; i <= m; i++) {
		b[i] += b[i - 1];
		printf("%d\n", as[i] + b[i]);
	}
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
  cin>>n;
  int a[n];
  priority_queue<int>q;
  for(int i=0;i<n;i++)
  {cin>>a[i];
   q.push(a[i]);
  }
for(int i=0;i<n;i++)
{
 if(a[i]==q.top())
 {
 q.pop();
   cout<<q.top()<<endl;
   q.push(a[i]);
 }
  else
    cout<<q.top()<<endl;
}
}

Measured memory_bytes: 3316
#include<iostream>
#include<queue>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  priority_queue<int>pq;
  for(int i=0;i<n;i++){
    int cost;
    cin>>cost;
    pq.push(cost);
  }
  
  for(int i=0;i<m;i++){
    int max_cost=pq.top();pq.pop();
    pq.push(max_cost/2);
  }
  
  long long sum=0;
  while(!pq.empty()){
    sum+=pq.top();pq.pop();
  }

  cout<<sum<<endl;
  return(0);
}


Measured memory_bytes: 892
use proconio::input;
use std::collections::VecDeque;
use proconio::marker::Chars;

fn main() {
    input! {
        h: usize,
        w: usize,
        c: (usize, usize),
        d: (usize, usize),
        hw: [Chars; h],
    }

    let mut q: VecDeque<(usize, usize)> = VecDeque::new();
    let mut map = vec![vec![1000000 ; w]; h];
    q.push_front((c.0, c.1));
    map[c.0 - 1][c.1 - 1] = 0;

    let di = [-1, 0, 1, 0];
    let dj = [0, -1, 0, 1];

    while q.len() > 0 {
        let target = q.pop_front().expect("ERROR");
        let d = map[target.0 - 1][target.1 - 1];
        for v in 0..4 {
            let ni = target.0 as i32 - 1 + di[v];
            let nj = target.1 as i32 - 1 + dj[v];
            if ni < 0 || ni >= h as i32 || nj < 0 || nj >= w as i32 { continue; }
            if hw[ni as usize][nj as usize] == '#' { continue; }
            if map[ni as usize][nj as usize] <= d { continue; }
            map[ni as usize][nj as usize] = d;
            q.push_front((ni as usize + 1, nj as usize + 1));
        }
        for ei in -2..=2 {
            for ej in -2..=2 {
                let ni = target.0 as i32 - 1 + ei;
                let nj = target.1 as i32 - 1 + ej;
                if ni < 0 || ni >= h as i32 || nj < 0 || nj >= w as i32 { continue; }
                if hw[ni as usize][nj as usize] == '#' { continue; }
                if map[ni as usize][nj as usize] <= d + 1 { continue; }
                map[ni as usize][nj as usize] = d + 1;
                q.push_back((ni as usize + 1, nj as usize + 1));
            }
        }
    }
    if map[d.0 - 1][d.1 - 1] == 1000000 {
        println!("-1");
    } else {
        println!("{}", map[d.0 - 1][d.1 - 1]);
    }
}


Measured memory_bytes: 11248
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)1e5
#define mod (ll)(1e9+7)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int check(string s){
	string x=s;reverse(all(x));
	return (x==s);
}
int main(){
	string s,x;ll i,n;cin>>s;n=s.size();
	for(i=0;i<(n-1)/2;i++) x.pb(s[i]);
	if(check(s)&&check(x)) cout<<"Yes\n"; else cout<<"No\n";
}



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

int main(){
	int n;	cin>>n;
	int a[n];	for(int i=0;i<n;i++)cin>>a[i];
	int max=0,second=0,maxpos=0;
	for(int i=0;i<n;i++){
		if(max<a[i]){
			max=a[i];
			maxpos=i;
		}
	}
	for(int i=0;i<n;i++){
		if(i==maxpos)continue;
		if(second<a[i])second=a[i];
	}

	for(int i=0;i<n;i++){
		if(i==maxpos)cout<<second<<endl;
		else cout<<max<<endl;
	}


	return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) ((x).begin()), ((x).end())

#define READ(x) (cin >> (x))
#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))
#define WRITE_YESNO(x) (WRITE_N((x) ? "Yes" : "No"))

#define PRECISE_COUT std::cout << std::setprecision(15) << std::fixed

bool xor_logic(bool x, bool y) { return (x && y) || (!x && !y); }

ll solve(vector<ll> &A) {
  ll highest = 0;
  ll sum = 0;

  for (auto &&x : A) {
    if (x < highest) {
      sum += (highest - x);
    } else {
      highest = x;
    }
  }

  return sum;
}

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N;
  cin >> N;

  std::vector<ll> A(N, 0);
  for (size_t i = 0; i < N; i++) {
    cin >> A[i];
  }

  // main procedure
  ll ans = solve(A);

  // output
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4700
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x): x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

template<class Iterator>
auto runLengthEncoding(Iterator begin, Iterator end) { // {{{
    using value_type = typename iterator_traits<Iterator>::value_type;

    vector<pair<value_type, int>> res;
    res.reserve(distance(begin, end));
    int cnt = 1;

    Iterator prevBegin;
    for (prevBegin = begin++;  begin != end;  prevBegin = begin++) {
        if (*prevBegin == *begin) {
            ++cnt;
        } else {
            res.emplace_back(*prevBegin, cnt);
            cnt = 1;
        }
    }
    res.emplace_back(*prevBegin, cnt);

    return res;
} // }}}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    var(int, N);
    vector<int> a(N); read(a);

    const auto ps = runLengthEncoding(all(a));

    i64 ans = 0;
    for (const auto &e : ps) {
        ans += e.second / 2;
    }

    print(ans);

    return 0;
}


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

const int dh[] = {1, 0, -1, 0}, dw[] = {0, 1, 0, -1};

int main(){
  int H, W;
  cin >> H >> W;

  vector<string> A(H);
  for(int h = 0; h < H; h++){
    cin >> A[h];
  }

  vector<vector<int>> dist(H, vector<int>(W, 1000000));
  set<pair<int, pair<int, int>>> q;
  for(int h = 0; h < H; h++){
    for(int w = 0; w < W; w++){
      if(A[h][w] == '#'){
	q.insert(make_pair(0, make_pair(h, w)));
	dist[h][w] = 0;
      }
    }
  }
  while(!q.empty()){
    auto top = q.begin();
    q.erase(top);

    int dist_now = top->first;
    int h, w;
    tie(h, w) = top->second;
    // cout << dist_now << ' ' << h << ' ' << w << endl;

    for(int i = 0; i < 4; i++){
      int h_next = h + dh[i], w_next = w + dw[i];
      if(h_next < 0 || h_next >= H || w_next < 0 || w_next >= W){
	continue;
      }
      if(dist[h_next][w_next] > dist_now + 1){
	q.insert(make_pair(dist_now + 1, make_pair(h_next, w_next)));
	dist[h_next][w_next] = dist_now + 1;
      }
    }
  }

  int ans = 0;
  for(int h = 0; h < H; h++){
    for(int w = 0; w < W; w++){
      // cout << dist[h][w] << ' ';
      ans = max(ans, dist[h][w]);
    }
    // cout << endl;
  }

  cout << ans << endl;
}


Measured memory_bytes: 52608
#include "bits/stdc++.h"

using namespace std;

int main() {
	int N,R;
	cin >> N >>R;
	if (N >= 10) {
		cout << R << endl;
	}
	else {
		cout << R + 100 * (10 - N) << endl;
	}

	return 0;
}

Measured memory_bytes: 3576