akhauriyash/Code-Regression huggingface dataset:
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
int main() {
	int a, b, c; cin >> a >> b >> c;
	cout << min(c, b / a);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    if(a>b){
        cout<<"a > b"<<endl;
    }else if(a<b){
        cout<<"a < b"<<endl;
    }else{
        cout<<"a == b"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3096
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<fstream>
using namespace std;
int main(){
	int n,a[4];
	cin>>n;
	for(int i=0;i<4;i++){
		a[i]=n%10;
		n/=10;
	}
	int b=0;
	if(a[0]==a[1]&&a[1]==a[2]) b=1;
	if(a[1]==a[2]&&a[2]==a[3]) b=1;
	if(b) printf("Yes");
	else printf("No");
	return 0;
} 

Measured memory_bytes: 256
unittest
{
	assert( [ "2 3", "10 1", "1", "15 1", "2", "30 2", "1 2" ].solve == 25 );
	assert( [ "12 1", "100000 1", "2" ].solve == -1 );
	assert( [ "4 6", "67786 3", "1 3 4", "3497 1", "2", "44908 3", "2 3 4", "2156 3", "2 3 4", "26230 1", "2", "86918 1", "3" ].solve == 69942 );
}



import std.algorithm;
import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = 0L;
	auto m = 0L;
	input.front.formattedRead!"%s %s"( n, m );
	auto as = new long[ m ];
	auto ss = new long[ m ];
	foreach( ref a, ref s; lockstep( as, ss ) )
	{
		input.popFront;
		a = input.front.split.to!( long[] )[ 0 ];
		input.popFront;
		foreach( c; input.front.split.to!( long[] ) )
		{
			s |= 1L << ( c - 1 );
		}
	}
	
	// dp[ 開けられる宝箱のbit集合 ] = 合計費用
	auto dp = new long[ 1L << n ];
	dp[ 1 .. $ ] = long.max;
	foreach( i; 0L .. dp.length.signed )
	{
		foreach( a, s; lockstep( as, ss ) )
		{
			if( dp[ i ] < long.max ) dp[ i | s ] = min( dp[ i | s ], dp[ i ] + a );
		}
	}
	return ( dp[ $ - 1 ] == long.max ) ? -1 : dp[ $ - 1 ];
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	string s;
	int k;
	cin >> k >> s;
	if (s.size() <= k)cout << s << endl;
	else {
		rep(i, k)cout << s[i];
		cout << "..." << endl;
	}
}

Measured memory_bytes: 3640
from collections import deque
s = input()
d = deque(s)
q = int(input())
flag = 0
for i in range(q):
    tfc = input().split()
    if tfc[0] == '1':
        if flag == 0:
            flag = 1
        else:
            flag = 0
    else:
        if flag == 0:
            if int(tfc[1]) == 1:
                d.appendleft(tfc[2])
#                 print('appendleft:', d)
            else:
                d.append(tfc[2])
#                 print('append:', d)
        else:
            if int(tfc[1]) == 1:
                d.append(tfc[2])
#                 print('append:', d)
            else:
                d.appendleft(tfc[2])
#                 print('appendleft:', d)
if flag == 0:
    print(''.join(d))
else:
    print(''.join(reversed(d)))

Measured memory_bytes: 8564
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <stack>
#include <queue>
#include <functional>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

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

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

	int size = s.size();
	rep(i, size)
		cout << (char)((s[i] - 'A' + n) % 26 + 'A');

	return 0;
}

Measured memory_bytes: 256
using System;

namespace Solution
{
    class Program
    {
        static void Main(string[] args)
        {
          String s = Console.ReadLine();
          String res = "Good";
          Char prev = ' ';
          foreach (Char c in s) 
          {
            if (prev == c)
            {
              res = "Bad";
              break;
            }
            prev = c;
          }
          Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
#include <cstdlib>
#define INT_MAX 2147483647
#define INT_MIN -2147483646
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;

int h;
vector<int> A(500010);

void maxheapify(int a) {
	if (a > h / 2) return;
	int p = A[a], l = A[a * 2], r = A[a * 2 + 1];
	int m = a;
	if (p < l&&r < l) m = a * 2;
	else if (p < r&&l < r) m = a * 2 + 1;
	if (m != a) {
		int pass = A[m];
		A[m] = p;
		A[a] = pass;
		maxheapify(m);
	}
}

int main() {
	cin >> h;
	Loop1(i, h) {
		cin >> A[i];
	}
	A[h + 1] = INT_MIN;
	Loopr1(i, h / 2) {
		maxheapify(i);
	}
	Loop1(i, h) {
		cout << " " << A[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 4480
#include <stdio.h>

void insert(int [], int);
void printout(int [], int);


int main(){
  int N,i,j;
  int A[100];

  scanf("%d\n",&N);
  for(i=0;i<N;i++)scanf("%d",&A[i]);

  printout(A, N);
  insert(A, N);
  
  return 0;
}

void insert(int A[], int N){
  int i,j,v=0;

  for(i=1;i<N;i++){
    v = A[i];
    j = i-1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    printout(A, N);
  }
}

void printout(int A[],int N){
  int i;

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



Measured memory_bytes: 2104
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
using namespace std;

map < string, int > m;

int main(){

  string s;
  int lenmax = 0;
  int nummax = 0;
  string tmp = "";
  string anslen,ansnum;

  getline(cin, s);

  for(int i=0;i<=s.size();i++){
    if(s[i] == ' ' || s[i] == '\0'){
      m[tmp]++;

      if(tmp.size() > lenmax){
	anslen = tmp;
	lenmax = tmp.size();
      }

      if(m[tmp] > nummax){
	ansnum = tmp;
	nummax = m[tmp];
      }

      i++;
      tmp = "";
    }
    
    tmp += s[i];
  }

  cout << ansnum << " " << anslen << endl;
}

Measured memory_bytes: 1188
const t={input:require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/),n:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.n())}return a}else{const a=t.input[0];t.input.shift();return Number(a)}},s:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.s())}return a}else{const a=t.input[0];t.input.shift();return String(a)}},c:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.c())}return a}else{let a=t.input[0].split('');const b=a[0];a.shift();if(a.length>0){t.input[0]=a.join('')}else{t.input.shift()}return String(b)}},o:(...arg)=>{console.log(...arg)},abs:(a)=>{return Math.abs(a)},min:(...a)=>{return Math.min(...a)},max:(...a)=>{return Math.max(...a)},floor:(a)=>{return Math.floor(a)},asc:(ar:number[])=>{return ar.sort((a,b)=>{return a-b})},desc:(ar:number[])=>{return ar.sort((a,b)=>{return b-a})},sw:(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]}};
const main=()=>{
  let n=t.n()
  let sa=[],na=[]
  for(let i=0;i<n;i++){
    sa[i]=t.s()
    na[i]=t.n()
  }
  for(let i=0;i<n;i++){
    let st=sa[0],nt=na[0],ti=0
    for(let j=1;j<sa.length;j++){
      if(st >= sa[j]){
        if(st==sa[j]){
          if(nt<na[j]){
            st=sa[j]
            nt=na[j]
            ti=j
          }
        }else{
          st=sa[j]
          nt=na[j]
          ti=j
        }
      }
    }
    t.o(ti+1)
    sa[ti]='zzzzzzzzzzz'
  }
  
}
main()

Measured memory_bytes: 7800
#include <iostream>
using namespace std;
int main()
{
  int x,y,z,i;
  for (i = 0; i < 3001; i++) {
    cin >> x >> y;
    if(x==0 && y==0)break;
    if(x>y){
      z=x;
      x=y;
      y=z;
    }
    else{}
    cout <<x <<" "<< y <<'\n';
    /* code */
  }
  return 0;
}

Measured memory_bytes: 3000
h,w=map(int,input().split())
ans=[["."]*(w+2)]
for i in range(h):
  temp=list(map(str,input()))
  temp.insert(0,".")
  temp.append(".")
  ans.append(temp)
ans.append(["."]*(w+2))
for i in range(1,h+1):
  for j in range(1,w+1):
    if ans[i][j]==".":
      temp=0
      for k in range(3):
        for l in range(3):
          if ans[i-1+k][j-1+l]=="#":
            temp=temp+1
      ans[i][j]=str(temp)
for i in range(1,h+1):
  del ans[i][0]
  del ans[i][w]
  print("".join(ans[i]))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define mod 1000000007
#define pb push_back  
#define endl "\n"
#define fi first
#define se second 
#define ll long long
#define inf 9000000000000000000
#define PI 3.14159265359

int power(int a,int b,int m=mod)
{
     if(b==0)	return 1;
     if(b==1)	return a;
	 int res=power(a,b/2,m);
	 res=(res*res)%m;
     if(b&1)	res=(res*a)%m;
     return res;
}
int modinv(int a,int m=mod){ return power(a,m-2,m);}
int add(int a,int b,int m=mod){	int c=(a%m+b%m);	if(c>=m)	c-=m;	return c;}
int sub(int a,int b,int m=mod){	int c=(a%m-b%m);	if(c<0)		c+=m;	return c;}
int mul(int a,int b,int m=mod){	return (a*b)%m;}


int32_t main()
{
   IOS
    
   int s,total,j;
   cin>>s;
   
   int dp[2001]={0};
   
   dp[0] = 1;
   dp[1] = 0;
   dp[2] = 0;
   
   
   for(total=3;total<=s;total++)
   {
     for(j=3;j<=total;j++)
     {
     	dp[total] = add(dp[total],dp[total - j]);
     }
   }
   cout<<dp[s]<<endl;
}

Measured memory_bytes: 3668
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;

signed main() {
	int N;
	cin >> N;
	int i = 1;
	int cnt = 0;
	int power = 1;
	while (cnt != N) {
		power *= i;
		power %= MOD;
		i++;
		cnt++;
	}
	cout << power;
}

Measured memory_bytes: 256
#include<iostream>
#define l int64_t
#define c continue;
#define o(a) cout<<a<<" ";
#define r(i,x,y) for(l i=x;i<y;i++){
using namespace std;
int main(){l m=1e9+7,a=93,x,y,z,w,o,p,v[a]={1},t[a][a][2],b;v[1]=1;r(i,2,a)v[i]=v[i-1]+v[i-2];}r(i,2,a)r(j,1,i)b=v[i+1];if(j<2){t[i][0][0]=v[i],t[i][0][1]=b,t[i][j][0]=b,t[i][j][1]=2*b-v[i];c}t[i][j][0]=t[i-1][j-1][1],t[i][j][1]=t[i-1][j-1][1]+t[i-1][j-1][0];}}cin>>b;while(b--){cin>>x>>y;if(x>y)swap(x,y);if(y<2){o(1)o(1)c}r(i,0,a)if(v[i]>x||v[i+1]>y){z=i-1,o(z)break;}}if(z<2){o(x*y%m)c}w=0;r(j,0,z)o=t[z][j][0],p=t[z][j][1];if(o>x||p>y)c w+=(y-p)/o+1;if(x>=p)w+=(x-p)/o+1;}o(w%m)}}

Measured memory_bytes: 4476
#include <bits/stdc++.h>
using namespace std;
const double eps=1e-2;
const int MAXN = 55;
typedef long long LL;
LL a[MAXN], b[MAXN];

int main()
{
    int n; LL x; cin>>n>>x;
    a[0]=1,b[0]=1;
    for(int i=1; i<=n; i++) {
        a[i]=a[i-1]*2+3;
        b[i]=b[i-1]*2+1;
    }
    LL sum = 0, ans = 0;
    for(int i=n; i>=0; i--) {
        if(x==a[i]/2) {
            ans+=b[i]/2;
            break;
        }
        if(x > a[i]/2) {
            ans+=(b[i-1]+1);
            x-=(a[i]/2+1);
        }
        else {
            x--;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

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

    queue<pair<char,int>> q;

    int count=0; 
    for(int i=0;i<s.length();i++)
    {
        if(s[i]==s[i+1])
        {
            count++; 
        }
        else
        {
            q.push(make_pair(s[i],count+1)); 
            count=0; 
        }
    }

    /*
    while(!q.empty())
    {
        cout<<q.front().first<< " "<<q.front().second<<endl; 
        q.pop(); 
    }
    */

    vector<int> v; 
    int i=0; 
    pair<char,int> f; 
    char prev; 
    while(!q.empty())
    {
        f = q.front();
        q.pop(); 
        if(i==0)
        {
            if(f.first=='<')
            {
                int k=0;
                while(f.second-- >0)
                {
                    v.push_back(k); 
                    k++; 
                }
            }
            else
            {
                int k=f.second;
                while(f.second-- >0)
                {
                    v.push_back(k); 
                    k-- ; 
                }
            }
            i++; 
            prev=f.first; 
        }
        else
        {
            if(prev=='<')
            {
                int k = max(v[v.size()-1]+1,f.second); 
                v.push_back(k);
                //f.second--; 
                while(--f.second >0)
                {
                   v.push_back(f.second);  
                }
                prev='>'; 
            }
            else
            {
                int k= min(v[v.size()-1]-1,0);
                v.push_back(k); 
                //f.second--; 
                k++; 
                while(--f.second>0)
                {
                    v.push_back(k);
                    k++; 
                }
                prev='<'; 
            }
        }
        /*
        for(int i=0;i<v.size();i++)
        {
            cout<< v[i]<<" ";
        }
        cout<<endl; 
        */

    }
    if(prev=='<')
    {
        v.push_back(v[v.size()-1]+1); 
    }
    else
    {
        v.push_back(v[v.size()-1]-1); 
    }
    long sum=0; 
    for(int i=0;i<v.size();i++)
    {
        //cout<< v[i]<<" ";
        sum+=v[i]; 
    }
    //cout<<endl; 
    cout<<sum<<endl; 
    

    return 0; 
}



Measured memory_bytes: 5116
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());
  if (!a[0]) {
      cout << 0 << endl;
      return 0;
  }

  ll ans = 1;
  rep(i,n) {
      if (ans == -1) continue;
      else if (ans > 1000000000000000000 / a[i]) ans = -1;
      else ans *= a[i];
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 4056
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a, b, c;
int32_t main(){_

   cin>>a>>b>>c;

   if(a > b)swap(a, b);

   if(c >= a and c <= b){
      cout<<"Yes";
   }
   else{
      cout<<"No";
   }

   return 0;
}

// Common sense: do smth instead of nothing
// Even a single second counts...
// If other's can do it, even I can do it. It wouldn't be that tough. Let me give it a try.
// Mistakes made in past
// -Ques. ask for max-min => think binary_search, DP, greedy
// -not reading question properly / skipping to read & understand all samples properly & wasting time in wrong direction.
// -Using wrong indexing in nested loops something like a[i], when it is supposed to be a[j](WA)
// -value of const int N is not correct (WA/RTE).
// -Did you memset dp to -1 ?
// -check for small edges cases and work on small test cases manually if WA
// -not deallocating memory to pointers can lead to MLE. Use delete :))
// -not reading problem statements of harder problems E,..., thinking it couldn't be solved, but it isn't the case.
// -Avoid using #define int long long as much as possible when it's dp problem and requires high memory say, O(N^2, N=5000) (MLE)
// -Check Bitwise Operator Precedence 
// -Use pragmas to optimize (by constant factor) when necessary..
// -Think before coding & starting to debug. Have patience to look inside code and actually see how it works

Measured memory_bytes: 384
#include <cstdio>
#include <string>
#include <iostream>
#include <math.h>
#include <map>
#include <vector>

using namespace std;
#define ASCII 48

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

	int L, R;
	int Lmax = 0, Rmin = n;
	for (int i = 0; i < m; i++) {
		cin >> L >> R;
		if (L > Lmax)Lmax = L;
		if (R < Rmin)Rmin = R;
	}

	int ans = Rmin - Lmax + 1;
	if (ans < 0)ans = 0;
	cout << ans << endl;
}


Measured memory_bytes: 256
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline-------------------------------------------
    N,M =map(int,input().split())
    A = list(map(int,input().split()))
    heap = []
    for i in range(N):
        heappush(heap,-A[i])
    for i in range(M):
        p = -heappop(heap)//2
        heappush(heap,-p)
    print(-sum(heap))
    
if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 16896
from heapq import heapify, heappush, heappop

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapify(a)
for i in range(m):
    max = heappop(a)
    heappush(a, -((-max)//2))
print(sum(a)*(-1))


Measured memory_bytes: 14180
import java.util.*;
import java.awt.geom.*;
public class Main {

	class Point extends Point2D.Double implements Comparable<Point2D.Double>{
		Point(double x, double y){
			super(x,y);
		}
		@Override
		public int compareTo(Point2D.Double o) {
			if(super.x < o.x) return -1;
			if(super.x > o.x) return 1;
			if(super.y < o.y) return -1;
			if(super.y > o.y) return 1;
			return 0;
		}
	}

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			Point []  plist = new Point[n];
			for(int i = 0; i < n; i++){
				String [] a = sc.next().split(",");
				double x = Double.parseDouble(a[0]);
				double y = Double.parseDouble(a[1]);
				plist[i] = new Point(x, y);
			}
			Arrays.sort(plist);
			
			ArrayList<Point2D> res = convexHull(plist);
			System.out.println(n - res.size());
		}
	}

	private ArrayList<Point2D> convexHull(Point2D [] plist) {
		int n = plist.length;
		int k = 0;
		Point2D [] qs = new Point2D[n * 2];
		
		for(int i = 0; i < n; i++){
			while(k > 1 && cross(sub(qs[k-1], qs[k-2]), (sub(plist[i],qs[k-1]))) <= 0){
				k--;
			}
			qs[k++] = plist[i];
		}
		
		for(int i = n - 2, t = k; i >= 0; i--){
			while(k > t && cross(sub(qs[k-1],qs[k-2]), (sub(plist[i],qs[k-1]))) <= 0){
				k--;
			}
			qs[k++] = plist[i];
		}
		ArrayList<Point2D> res = new ArrayList<Point2D>();
		for(int i = 0; i < k - 1;i++){
			res.add(qs[i]);
		}
		
		return res;
	}

	private double cross(Point2D p1, Point2D p2) {
		double res = p1.getX() * p2.getY() - p1.getY() * p2.getX();
		return res;
	}

	private Point2D sub(Point2D p1, Point2D p2) {
		double x = p1.getX() - p2.getX();
		double y = p1.getY() - p2.getY();
		return new Point2D.Double(x, y);
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 12000
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  4 22:42:24 2019

@author: yuta
"""

A,B,C = list(map(int,input().split()))
def main(a,b,c):
    d = int(b/a)
    if d >= c:
        e = c
    else:
        e = d
    print(e)
main(A,B,C)

Measured memory_bytes: 2940
import sys
import itertools

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


mod = 10 ** 9 + 7


def main():

    H, W, K = in_nn()

    if W == 1:
        print(1)
        exit()

    comb_t = itertools.product(range(2), repeat=W - 1)
    comb = [[0 for _ in range(3)] for _ in range(W)]

    for c in comb_t:

        f = True
        for i in range(W - 2):
            if c[i] == c[i + 1] == 1:
                f = False
                break

        if f:
            for i in range(W):

                if i - 1 >= 0 and c[i - 1] == 1:
                    comb[i][0] += 1
                elif i < W - 1 and c[i] == 1:
                    comb[i][2] += 1
                else:
                    comb[i][1] += 1

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

    for y in range(H):
        for x in range(W):

            now = dp[y][x]
            dp[y + 1][x] += now * comb[x][1]
            dp[y + 1][x] %= mod
            if 0 <= x - 1 < W:
                dp[y + 1][x - 1] += now * comb[x][0]
                dp[y + 1][x - 1] %= mod
            if 0 <= x + 1 < W:
                dp[y + 1][x + 1] += now * comb[x][2]
                dp[y + 1][x + 1] %= mod

    print(dp[H][K - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 9412
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#define rep(i, n) for(ll i=0; i<n; i++)
using namespace std;
typedef long long ll;

const ll INF = ll(1e18)+1;

int main(){
    int n,k; cin>>n>>k;
    int a[n];
    rep(i, n) cin >> a[i];
    for(int i=k; i<n; i++){
        if(a[i] > a[i-k]) cout << "Yes"<< endl;
        else cout <<"No"<<endl;
    }
}

Measured memory_bytes: 4408
//long time no ac
#include<bits/stdc++.h>
using namespace std;


#define     SPEED     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	ll          long long int
#define 	pb          push_back
#define 	pii         pair<int,int>
#define 	vi          vector<int>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	hell        1000000007
#define 	rep(i,n)    for(i=0;i<n;i++)
#define 	repe(i,a,b) for(i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search
#define 	mp          make_pair

ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2);
	if(b%2==0)
		return((c%hell)*(c%hell))%hell;
	return ((((c%hell)*(c%hell))%hell)*(a%hell))%hell;
}

ll dp[100005],a[100105],n,k;

ll f(ll x)
{
	if(x==n-1)
		return 0;
	if(x>=n)
		return hell;
	if(dp[x]==-1)
	{
		ll i;
		dp[x]=f(x+1)+abs(a[x]-a[x+1]);
		repe(i,1,k+1)
		{
			dp[x]=min(f(x+i)+abs(a[x]-a[x+i]), dp[x]);
		}
	}
	return dp[x];
}


int main()
{
	SPEED;
	ll t,c=0,i,j,m,cs=0;
	t=1;

	//cin>>t;
	string s;
	while(t--)
	{
		cin>>n>>k;
		// n=s.length();
		rep(i,n)
		{
			cin>>a[i];
			dp[i]=-1;
		}
		c=f(0);
		cout<<c;
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 4992
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define uint unsigned int
#define MOD 1000000007
#define MAXN 200005
#define MAXH 4
#define MAXM 100
#define INF 1LL << 60
#define ll long long
#define ull unsigned long long
#define RNG mt19937
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
int cur[17];

bool ask(int l){
	printf("? ");
	cd(i,l,0)printf("%d",cur[i]);
	printf("\n");
	fflush(stdout);
	char c;
	scanf(" %c",&c);
	return c == 'Y';
}

int main(){
	// find len	
	int len = -1;
	fu(i,1,10){
		cur[i-1] = 1;
		if(!ask(i)){len = i-1;cur[i-1] = 0;break;}
		cur[i-1] = 0;
	}
	//whatis(len);
	if(len == -1){// power of ten
		int ans = -1;
		fu(i,1,10){
			cur[i-1] = 9;
			if(ask(i)){ans = i;break;}
		}
		printf("! ");
		printf("1");
		cu(i,0,ans-1)printf("0");
		printf("\n");
		fflush(stdout);
	}
	else{
		cd(i,17,17-len){
			int l = 1, r = 9;	
			int best = 0, m = 0;
			while(l <= r){
				m = l + (r-l)/2;	
				cur[i] = m;	
				if(!ask(17)){best = m;l = m + 1;}
				else r = m - 1;
			}
			cur[i] = best;
			cd(j,i,0)cur[j] = 9;
			bool res = ask(17);
			cd(j,i,0)cur[j] = 0;
			if(!res){
				cur[i] = best + 1;
				break;
			}
		}
		printf("! ");
		cd(i,17,17-len){
			printf("%d",cur[i]);
		}
		printf("\n");
		fflush(stdout);
	}
}


Measured memory_bytes: 684
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
 
  if ((N/1000 == (N-(N-N%10)%100)%1000/100 && (N-(N-N%10)%100)%1000/10 == (N-N%10)%100) || ((N-(N-N%10)%100)%1000/10 == (N-N%10)%100 && (N-N%10)%100/10 == N%10)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" <<endl;
  }
 
}

Measured memory_bytes: 256
def f(m, r):
    connmap = [[] for _ in range(m + 1)]
    for _ in range(r):
        a, b = map(int, input().split())
        connmap[a].append(b)
        connmap[b].append(a)
    group = [0] * (m + 1)
    num = 0
    for i in range(1, m + 1):
        if group[i] > 0:
            continue
        num += 1
        group[i] = num
        for j in connmap[i]:
            group[j] = num
        bfs = connmap[i]
        while len(bfs) > 0:
            tmp = []
            for j in bfs:
                for k in connmap[j]:
                    if group[k] > 0:
                        continue
                    group[k] = num
                    tmp.append(k)
            bfs = tmp
    return group

n, k, l = map(int, input().split())

road = f(n, k)
rail = f(n, l)

count = {}

for i in range(1, n + 1):
    key = '{0} {1}'.format(road[i], rail[i])
    if key in count:
        count[key] += 1
    else:
        count[key] = 1
    
for i in range(1, n + 1):
    key = '{0} {1}'.format(road[i], rail[i])
    print(count[key], end=' ' if i < n else '')
print()



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

int main()
{
	ll n;
	cin >> n;
	ll cnt[5]={};
	while(n--)
	{
		string x;
		cin >> x;
		if(x[0]=='M')cnt[0]++;
		else if(x[0]=='R')cnt[1]++;
		else if(x[0]=='A')cnt[2]++;
		else if(x[0]=='C')cnt[3]++;
		else if(x[0]=='H')cnt[4]++;
	}
	ll ans = 0;
	for(ll i = 0;i<5;i++)
	{
		for(ll j = i+1;j<5;j++)
		{
			for(ll k = j+1;k<5;k++)
			{
				ans += cnt[i]*cnt[j]*cnt[k];
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int a, b, c; cin >> a >> b >> c;
	int k; cin >> k;
	rep(i, k)
	{
		if (a >= b)b *= 2;
		else c *= 2;
	}
	if (a < b&&b < c)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3632
import java.util.*;

@SuppressWarnings("unchecked")
public class Main {
	// public static void printArray(int[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static<T> void printArrayT(T[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	public static String joinInt(int[] a, String separator) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < a.length; i++) {
			if (i > 0) {
				sb.append(separator);
			}
			sb.append(a[i]);
		}
		return sb.toString();		
	}

	static int[] nextIntArray(Scanner sc, int N) {
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = sc.nextInt();
		}
		return arr;
	}

	static long MOD = 1000000007;

	// static long dp(int x, int y) {
	// 	long[] table = new long[x + 1];
	// 	Arrays.fill(table, 1);
	// 	for (int i = 0; i < y; i++) {
	// 		for (int j = 1; j <= x; j++) {
	// 			table[j] += table[j-1];
	// 			table[j] %= MOD;
	// 		}
	// 	}
	// 	return table[x];
	// }

	static long rev(long val) {
		return pow(val, MOD - 2);
	}

	static long pow(long x, long n) {
		long ans = 1;
		while(n != 0){
			if((n & 1) == 1) ans = ans*x % MOD;
			x = x*x % MOD;
			n = n >> 1;
		}
		return ans;
	}

	static long bang(int n) {
		long ans = 1;
		for (long i = 2; i <= n; i++) {
			ans *= i;
			ans %= MOD;
		}
		return ans;
	}

	static long combi(int x, int y) {
		// System.out.println("combi");
		long ans = bang(x + y);
		// System.out.println("*" + ans);
		ans *= rev(bang(x));
		ans %= MOD;
		ans *= rev(bang(y));
		ans %= MOD;
		
		return ans;
	}

	static long solve(int X, int Y) {
		if (X > 2*Y) return 0;
		if (Y > 2*X) return 0;

		int x = 0;
		int y = 0;
		if (Y > X) {
			int n = Y-X;
			y += n;
			X -= n;
			Y -= 2 * n;
		}
		if (X > Y) {
			int n = X - Y;
			x += n;
			X -= 2 * n;
			Y -= n;
		}
		if (X % 3 != 0) return 0;
		int n = X / 3;
		x += n;
		y += n;

		// System.out.println(x + ", " + y);
		return combi(x, y);
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		System.out.println(solve(X, Y));
	}
}


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

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) return 0;
    int t[n], h[n];
    for (int i = 0; i < n; i++) {
      cin >> t[i];
    }
    sort(t, t + n);
    
    int temp = 1;
    int pt;
    int ph = 0;
    while (ph < n) {
      bool flag = false;
      for (int i = 0; i < n; i++) {
	if (t[i] == temp) {
	  flag = true;
	  break;
	}
      }
      if (flag == false) {
	h[ph++] = temp;
      }
      temp++;
    }
    
    int current = 0;
    int turn = 0;
    int subt = 0;
    int subh = 0;
    while (subt < n && subh < n) {
      if (turn == 0) {
	bool flag = false;
	for (int i = 0; i < n; i++) {
	  if (t[i] > current) {
	    current = t[i];
	    t[i] = 0;
	    subt++;
	    flag = true;
	    break;
	  }
	}
	
	if (flag == false) {
	  current = 0;
	}
	turn = 1;
      } else {
	bool flag = false;
	for (int i = 0; i < n; i++) {
	  if (h[i] > current) {
	    current = h[i];
	    h[i] = 0;
	    subh++;
	    flag = true;
	    break;
	  }
	}
	
	if (flag == false) {
	  current = 0;
	}
	turn = 0;
      }
    }
    
    cout << n - subh << endl;
    cout << n - subt << endl;
  }
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n),b(n-1);
    rep(i,n-1) cin >> b[i];
    
    a[0] = b[0];
    a[1] = b[0];
    a[n-1] = b[n-2];
    for (int i = 1; i < n-1; i++) {
        a[i] = min(b[i], b[i-1]);
        a[i+1] = b[i];
    }

    int ans = 0;
    rep(i,n) ans += a[i];

    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using pci = pair<char, int>;
using vpci = vector<pci>;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(size_t i=0;i<(b);i++)
#define rREP(i,b) for(int i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define Foreach(item,collection) for(auto item:collection)
#define mod(i) ((i) % (ll)(1e9 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9 + 5))))
#define Yes out("Yes")
#define No out("No")
#define NO out("NO")
#define YES out("YES")
#define INF 1e10;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define IfOut(condition,text) if((condition)){out(text);return 0;}
#define IfeOut(condition,itext,etext) if(condition){out(itext);return 0;}else{out(etext);return 0;}
#define Select(collection,condition,result) Foreach(i,collection){result+=condition;}
#define GetAuto(_N,vect) {cin>>_N;vect.resize(_N);REP(i,_N){cin>>vect[i];}}
#define beginend(vec) (vec).begin(),(vec).end()
#define pb(item) push_back(item)
#define removeAll(vec,deleg) auto itr=remove_if(beginend(vec),deleg);vec.erase(itr,vec.end());
void removeAt(string& s, int index) { s.erase(index, 1); }
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
ll manhattanDistance(ll x1, ll y1, ll x2, ll y2) { return (abs(x2 - x1) + abs(y2 - y1)); }
vector<ll> sieveOfEratosthenes(int max) { ll prime; double sqrtmax = sqrt(max); vector<ll> primeVec, searchVec; FOR(i, 2, max + 1) searchVec.push_back(i); do { prime = searchVec[0]; primeVec.push_back(prime); auto itr = remove_if(beginend(searchVec), [=](ll x)->bool {return x%prime == 0; }); searchVec.erase(itr, searchVec.end()); } while (prime < sqrtmax); primeVec.reserve(primeVec.size() + searchVec.size()); primeVec.insert(primeVec.end(), beginend(searchVec)); return primeVec; }
bool isPrime(ll x) { if (x == 2) return true; if (x < 2 || x % 2 == 0) return false; ll i = 3; while (i <= sqrt(x)) { if (x%i == 0) return false; i += 2; }return true; }
vector<ll> rangePrimes(int start, int cnt) {
	vl rt;
	int n = start+1;
	if (n <= 1) n = 2;
	if (n == 2) {
		rt.pb(2); n++;
	}
	if (n % 2 == 0) n++;
	while (cnt) {
		if (isPrime(n)) {
			rt.pb(n); cnt--;
		}
		n += 2;
	}
	return rt;
}


int N, P;

int main() {
	while (cin>>N>>P,(N!=-1||P!=-1))
	{
		auto box = rangePrimes(N, P);
		int cnt = 0;
		bool f = true;
		
		vl sss;
		int bsize = box.size();
		FOR(i, 0, bsize) {
			FOR(x, i, bsize) {
				sss.pb(box[i] + box[x]);
			}
		}
		sort(beginend(sss));

		out(sss[P-1]);
	}

	return 0;
}

Measured memory_bytes: 3244
#include <iostream>
#include <cmath>
#include <vector>
#include <string>

#define NUM 753

using namespace std;

int diff = NUM;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);//高速化、endlは使わない

  string S;
  cin >> S;

  int length = S.length();

  for(int i = 0; i < (length-2); ++i){
    string buff = S.substr(i,3);

    diff = min(diff, abs(NUM - stoi(buff)));
  }

  cout << diff << endl;
}


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


int main(void) {
    int n, q, a, t, tmp1, tmp2;
    
    cin >> n >> q;
    fenwick_tree<long long> tree(n);
    for (int i = 0; i < n; ++i) {
        cin >> a;
        tree.add(i, a);
    }

    for (int i = 0; i < q; ++i) {
        cin >> t >> tmp1 >> tmp2;
        switch (t) {
            case 0:
                tree.add(tmp1, tmp2);
                break;
            case 1:
                cout << tree.sum(tmp1, tmp2) << endl;
                break;
            default:
                ;
        }
    }

    return 0;
}


Measured memory_bytes: 8236
#include<bits/stdc++.h>
using namespace std;
const double eps=1e-16;
int main(){
	int n,t,A;
	cin>>n>>t>>A;
	int h[100005];
	double T[100005];
	int ans=1;
	for(int i=1;i<=n;i++){
		cin>>h[i];
		T[i]=t-h[i]*0.006;
		if(fabs(T[i]-A)<fabs(T[ans]-A)){
			ans=i;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <queue>
#include <tuple>
#include <regex>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cstring>
#include <climits>

#define RREP(i,a,b) for(int i=a;i<b;++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define INVREP(i,a,b) for(int i=a;i>=b;--i)
#define MOD 1000000007ll
#define BIT(i) (1ll<<i)
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }//aに更新したいものを
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

//繰り返し2乗
ll modpow(ll N, ll P, ll M=MOD) {if (P == 0) return 1;if (P % 2 == 0) {ll t = modpow(N, P / 2, M);return t * t % M;}return (N * modpow(N, P - 1, M))%M;}
//階乗
pair<vector<ll>, vector<ll>> fact(ll n) {vector<ll>f(n, 1);RREP(i, 2, n) f[i] = (f[i - 1]*i) % MOD;vector<ll>invf(n, 1);invf[n - 1] = modpow(f[n - 1],MOD-2,MOD);INVREP(i, n - 1, 2) invf[i - 1] = (invf[i]*i) % MOD;return pair<vector<ll>, vector<ll> >(f,invf);}
ll modmult(ll a, ll b, ll M = MOD) { return (a*b) % M; }
ll modadd(ll a, ll b, ll M = MOD) { return (a + b) % M; }
ll comb(pair<vector<ll>, vector<ll>>p, int n, int r) {return modmult(modmult(p.first[n], p.second[r]), p.second[n - r]); }
/*
    auto a = fact(200009);
    cout << comb(a,15,5) << endl;
*/

int main()
{
    /* collection
    ll n;
    cin >> n;
    vector<ll> A;
    REP(i, n) cin >> A[i];
    vector<pair<ll, ll>> AB;
    REP(i, n) {cin >> AB[i].first;cin >> AB[i].second;}
    
    sort(ALL(vec),greater<int>());

    map<ll, ll> mp;
    map<ll, ll, greater<ll>> mp;
    REP(i, 100) mp[i] = i * 10;
    cout << mp.lower_bound(50)->second << endl;
    cout << mp.upper_bound(50)->second << endl;
    cout << next(mp.upper_bound(50))->second << endl;
    cout << prev(mp.upper_bound(50))->second << endl;
    */
    int n,k;
    cin>>n>>k;
    vector<int> a(n+2,0);
    REP(i, n) cin >> a[i+1];
    
    REP(i,k){
//        強制離脱
        if(a[0]==n && a[n+1]==-n){
            break;
        }
        vector<int> b(n+2,0);
//        累積和作成
        RREP(j,1,n+1){
            auto p=a[j];
            auto l=max(0,j-p);
            auto r=min(n+1,j+p+1);
            //cout<<l<<" "<<r<<endl;
            b[l]+=1;
            b[r]-=1;
        }
        //RREP(k,1,n+1)cout<<b[k];
        //cout<<endl;
        a=b;
        RREP(j,1,n+1) a[j]+=a[j-1];
        //RREP(k,1,n+1)cout<<a[k];
        //cout<<endl;
    }
//    anser
        vector<int> b(n+2,0);
        RREP(j,1,n+1){
            cout<<a[j];
            if(j==n){
                cout<<endl;
            }
            else{
                cout<<" ";
            }
        }
    
    
}


Measured memory_bytes: 4576
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
#define VI vector<int>
#define VL vector<LL>
#define VII vector< vector<int> >
#define VLL vector< vector<LL> >
#define VS  vector<string>
#define VSS vector< vector<string> >
#define PII pair<int,int>
#define PIS pair<int,string>
#define PSI pair<string,int>
#define PLL pair<LL,LL>
const LL MOD = 1000000007;
const LL INF = 1e16;
LL facctorialMethod(int k);
int main(){
    LL n,n_len_2,n2_start;
    string s;
    cin >> n;
    cin >> s;
    n_len_2 = n / 2;
    n2_start = n / 2 + n%2;
    if(n%2 == 1) {
        cout << "No" << endl;  
        return 0;      
    }
    if(s.substr(0,n_len_2) == s.substr(n2_start,n_len_2)) {
//        cout << "s.substr(0,n_len_2-1) :" << s.substr(0,n_len_2) << endl;
//        cout << "s.substr(n2_start,n_len_2-1) :" << s.substr(n2_start,n_len_2) << endl;
//        cout << "1-1 :" << s.substr(0,1) << endl;
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    return 0;
}

LL facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i){
        sum *= i;
    }
    return sum;
}


Measured memory_bytes: 3632
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int L;
    cin >> L;

    int n = 0;
    int c = 1;
    while(c * 2 <= L) {
        c *= 2;
        n++;
    }

    n += 1;

    vector<int> v(n - 1, -1);
    int cnt = 0;
    int cc = 1 << (n - 2);
    REP(i, n - 1) {
        if (L - cc >= c) {
            v[i] = L - cc;
            L -= cc;
            cnt++;
        }

        cc >>= 1;
    }

    cout << n << " " << 2 * (n - 1) + cnt << endl;

    reverse(ALL(v));
    REP(i, n - 1) {
        cout << i + 1 << " " << i + 2 << " " << 0 << endl;
        cout << i + 1 << " " << i + 2 << " " << (1 << i) << endl;

        if (v[i] > 0) cout << i + 1 << " " << n << " " << v[i] << endl;
    }
    
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
typedef pair<ll, ll> P;
const ll INF = 1e18;
 
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
	ll int n,i;
	cin >> n;
	ll int x[n], l[n];
	for(i=0;i<n;i++)
	{
		cin >> x[i] >> l[i];
	}
 
	vector<P> v;
	for(i=0;i<n;i++)
	{
		v.push_back(P(x[i]+l[i], x[i]-l[i]));
	}
	sort(v.begin(), v.end());
 
	ll int ans = 0;
	ll int at = -INF;
	for(i=0;i<n;i++)
	{
		ll int left = v[i].second;
		ll int right = v[i].first;
		if(left >= at)
		{
			ans++;
			at=right;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3956