akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#define bufsize 1<<22
char ibuf[bufsize];
char *ptr=ibuf;

int read()
{
    int i=0;
    while(*ptr>='0')
    {
        i=i*10+*ptr-'0';
        ++ptr;
    }
    ++ptr;
    return i;
}

int h,w;
#define obs(i,j) ptr[i*(w+1)+j]=='@'

main()
{
    fread(ibuf,1,bufsize,stdin);

    h=read(),w=read();
    int k=read(),sx=read()-1,sy=read()-1,tx=read()-1,ty=read()-1;

    struct po {int x,y;};
    struct po qu[1<<20];
    struct po *beg=qu,*end=qu+1;
    beg->x=sx,beg->y=sy;
    unsigned int dist[1<<20];
    memset(dist,-1,sizeof(dist));
    dist[sx*w+sy]=0;
    while(beg!=end)
    {
        int x=beg->x,y=beg->y;
        unsigned int d=dist[x*w+y];
        ++beg;
        for(int i=1,a=x,b=y,z=a*w+y; i<=k; i++)
        {
            a++,z+=w;
            if(a==h||obs(a,b)||dist[z]<=d) break;
            if(a==tx && b==ty)
            {
                printf("%u\n",d+1);
                return 0;
            }
            if(dist[z]!=d+1)
            {
                end->x=a,end->y=b;
                dist[z]=d+1;
                ++end;
            }
        }
        for(int i=1,a=x,b=y,z=a*w+y; i<=k; i++)
        {
            b++,z++;
            if(b==w||obs(a,b)||dist[z]<=d) break;
            if(a==tx && b==ty)
            {
                printf("%u\n",d+1);
                return 0;
            }
            if(dist[z]!=d+1)
            {
                end->x=a,end->y=b;
                dist[z]=d+1;
                ++end;
            }
        }
        for(int i=1,a=x,b=y,z=a*w+y; i<=k; i++)
        {
            a--,z-=w;
            if(a<0||obs(a,b)||dist[z]<=d) break;
            if(a==tx && b==ty)
            {
                printf("%u\n",d+1);
                return 0;
            }
            if(dist[z]!=d+1)
            {
                end->x=a,end->y=b;
                dist[z]=d+1;
                ++end;
            }
        }
        for(int i=1,a=x,b=y,z=a*w+y; i<=k; i++)
        {
            b--,z--;
            if(b<0||obs(a,b)||dist[z]<=d) break;
            if(a==tx && b==ty)
            {
                printf("%u\n",d+1);
                return 0;
            }
            if(dist[z]!=d+1)
            {
                end->x=a,end->y=b;
                dist[z]=d+1;
                ++end;
            }
        }
    }
    puts("-1");
}


Measured memory_bytes: 11304
# -*- coding: utf-8 -*-
s = list(input())
k = int(input())

part = [[]]

for i in range(len(s)):
    for j in range(1,k+1):
        if i + j > len(s):
            break
        part.append(s[i:i+j])
del part[0]

part.sort()

delete = []

for i in range(1,len(part)):
    if part[i-1] == part[i]:
        delete.append(i)

diff = 0
for i in range(len(delete)):
    del part[delete[i] - diff]
    diff += 1

print("".join(part[k-1]))


Measured memory_bytes: 6632
using System;
using System.Linq;

namespace agc007_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int count = 0;
            for (int i = 0; i < x[0]; i++)
            {
                string s = Console.ReadLine();
                for (int j = 0; j < x[1]; j++)
                {
                    if (s[j] == '#')
                    {
                        count++;
                    }
                }
            }
            Console.WriteLine(count == x[0] + x[1] - 1 ? "Possible" : "Impossible");
        }
    }
}

Measured memory_bytes: 13396
s = input()
mx = 0
cnt = 0
f = True
for i in range(len(s)):
    if f:
        if s[i] == "R": cnt += 1
        else:
            f = False
            mx = max(mx, cnt)
    else:
        if s[i] == "R":
            f = True
            cnt = 1
print(max(mx,cnt))

Measured memory_bytes: 9016
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  int t = a+b;
  if(k <= a) {
    cout << k << "\n";
  } else if(k <= t) {
    cout << a << "\n";
  }
  else {
    cout << a-(k-t);
  }
}

Measured memory_bytes: 3600
#include <cstdio>

int n,m;
int edges[100010],next[200020],to[200020];
bool visited[100010];
int stack[100010],stack_top;

inline void edge_add(int u,int v)
{
    static int count = 1;

    to[count] = v;
    next[count] = edges[u];
    edges[u] = count++;
}

void dfs(int x)
{
    int e;

    stack[stack_top++] = x;
    visited[x] = true;
    for(e = edges[x];e;e = next[e])
        if(!visited[to[e]])
            return dfs(to[e]);
}

int main(void)
{
    int i;
    int u,v;

    //freopen("x.in","r",stdin);

    scanf("%d %d",&n,&m);
    for(i = 0;i < m;++i)
        scanf("%d %d",&u,&v),edge_add(u,v),edge_add(v,u);

    dfs(1);
    stack[stack_top++] = -1;
    dfs(1);

    printf("%d\n",stack_top - 2);
    while(stack[--stack_top] > 0)
        printf("%d ",stack[stack_top]);
    stack_top = 0;
    while(stack[++stack_top] > 0)
        printf("%d ",stack[stack_top]);
    puts("");

    return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
 
using namespace std;
 
auto main() -> int
{
  int HP, waza; cin >> HP >> waza;
  vector<int> Damage(waza);
  
  REP(i, waza)
  	cin >> Damage[i];
  
  sort(ALL(Damage), greater<int>());
  
  REP(i, waza)
  {
  	HP -= Damage[i];
  }
  
  if(HP <= 0)
  	cout << "Yes" << endl;
    
  else
  	cout << "No" << endl;

}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		String s = scan.next();
		long n = Long.valueOf(s);
		
		System.out.println(dfs(n,1,0));
	}
	
	
	static long dfs(long n, int m, long sum) {//mは何桁目まで調べたか
		if(NumberOfDigit(n) == m) {
			return sum + n;
		}
		
		sum = dfs(n,m+1,sum);
		
		sum = (int)Math.pow(2, NumberOfDigit(n)-m-1) * (n%(int)Math.pow(10,m)) + dfs(n/(int)Math.pow(10,m),1,sum);
		
		return sum;
	}
	
	static int NumberOfDigit(long num) {
		int i = 0;
		while(num != 0) {
			num /= 10;
			i++;
		}
		return i;
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}

#define LB(v, x) (lower_bound(ALL(v), x) - v.begin())
#define UB(v, x) (upper_bound(ALL(v), x) - v.begin())

auto fl = [](auto a, auto b) { assert(b != 0); return a / b - (a % b != 0 && ((a >= 0) != (b >= 0)) ? 1 : 0); };
auto ce = [](auto a, auto b) { assert(b != 0); return a / b + (a % b != 0 && ((a >= 0) == (b >= 0)) ? 1 : 0); };
auto mo = [](auto a, auto b) { assert(b != 0); a %= b; if(a < 0) { a += abs(b); } return a; };

int main() {
	IN(LL, n, k);
	vector<LL> a(n);
	cin >> a;
	sort(ALL(a));
	
	auto f = [&](LL x) {
		LL c = 0;
		inc(i, n) {
			if(a[i] * a[i] <= x) { c--; }
			
			if(a[i] == 0) { c += (0 <= x ? n : 0); }
			if(a[i] >  0) { c +=     UB(a, fl(x, a[i])); }
			if(a[i] <  0) { c += n - LB(a, ce(x, a[i])); }
		}
		return c / 2;
	};
	
	/*
	auto g = [&](LL x) {
		LL c = 0;
		inc(i, n) {
		inc(j, n) {
			if(a[i] * a[j] <= x) { c++; }
		}
		}
		return c;
	};
	*/
	
	LL INF = 2e18, L = -INF, H = +INF;
	until(H - L == 1) {
		LL M = (H + L) / 2;
		(f(M) < k ? L : H) = M;
	}
	OUT(H);
}


Measured memory_bytes: 1792
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
#define fir first
#define sec second
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, s, k, sum, ans;
struct Edge { Pll to; LL cost; };
vector<Edge>vec[100][100];
char a[1000][1000];
LL d[100][100];
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
void DIUX() {
	rep(i,100)
		rep(j,100)
		d[i][j] = INF;
	d[0][0] = 1;
	priority_queue<Ppll, vector<Ppll>, greater<Ppll>> pq;
	pq.push(Ppll(d[0][0], Pll(0, 0))); // (cost,頂点番号) 
	while (!pq.empty()) {
		Ppll pp;
		pp = pq.top();
		LL cos = pp.first; Pll vv = pp.second;
		pq.pop();
		if (d[vv.fir][vv.sec] < pp.first)continue;
		for (int i = 0; i < vec[vv.fir][vv.sec].size(); i++) {
			Pll pos = vec[vv.fir][vv.sec][i].to;
			if (vec[vv.fir][vv.sec][i].cost + d[vv.fir][vv.sec] < d[pos.fir][pos.sec]) {
				d[pos.fir][pos.sec] = vec[vv.fir][vv.sec][i].cost + d[vv.fir][vv.sec];
				pq.push(make_pair(d[pos.fir][pos.sec], vec[vv.fir][vv.sec][i].to));
			}
		}
	}
}
int main() {
	cin >> n >> m;
	rep(i, n)
		rep(j, m) {
		cin >> a[i][j];
		if (a[i][j] == '.') {
			ans++;
			if(i>0)
				if (a[i - 1][j] == '.') {
					vec[i][j].push_back(Edge{ Pll(i - 1,j),1 });
					vec[i-1][j].push_back(Edge{ Pll(i,j),1 });
			}
			if (j>0)
				if (a[i][j-1] == '.') {
					vec[i][j].push_back(Edge{ Pll(i,j-1),1 });
					vec[i][j-1].push_back(Edge{ Pll(i,j),1 });
				}
		}

	}
	DIUX();
	LL A = d[n-1][m-1];
	cout << (A != INF ? ans - A : -1) << endl;
	return 0;
}

Measured memory_bytes: 896
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

int main(){
    int x=in(), n=in();
    vec a(n);
    int ans=-1;
    int tmp=1000;
    rep(i,n)a[i]=in();
    for(int i=-10;i<=110;i++){
        bool flag=true;
        REP(e,a)if(e==i){
            flag=false;
            continue;
        }
        if(!flag)continue;
        if(abs(i-x)<tmp){
            ans=i;
            tmp=abs(i-x);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3692
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n , T =f()

    minc = 10000
    for i in range(n):
        c,t = f()
        if t<= T:
            minc = min(minc, c)
    
    if minc == 10000:
        print('TLE')
    else:
        print(minc)

solve()

Measured memory_bytes: 3060
N = gets.to_i
h_list = gets.split.take(N).map(&:to_i)
count = (1..(N - 1)).count do |i|
  n = h_list[i]
  (0...i).all? do |j|
    m = h_list[j]
    m <= n
  end
end
ans = 1 + count
puts ans


Measured memory_bytes: 1916
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <iomanip>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    static const double pi = 2.0 * asin(1.0);

    double a,b,h,m;
    cin >> a >> b >> h >> m;

    double m_ = m;

    m /= 5.0;

    h += (m_/60.0);

    double angle = max(m,h) - min(m,h);

    //cout << h << endl;

    if(angle >6){
        double a = 12.0+min(m,h);
        angle = a - max(m,h);
    }

    angle *= 30.0;
    //cout << "angle " << angle << endl;

    double ans = (a*a) + (b*b) - (2.0*a*b*cos(pi*angle/180.0));

    double ans_ = sqrt(ans);

    //cout << ans_ << endl;

    cout << fixed << setprecision(15) << ans_ << endl;




    return 0;
}

Measured memory_bytes: 4144
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 55
#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};


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

    int N;
    ll K;
    cin>>N>>K;
    vector<int> A(N);
    for(int i=0;i<N;i++) cin>>A[i];
    vector<int> C[210000];
    for(int i=0;i<N;i++){
        C[A[i]].push_back(i);
    }
    for(int i=1;i<=200000;i++){
        if(!C[i].empty()) C[i].push_back(C[i][0]);
    }
    int next[210000];
    for(int i=1;i<=200000;i++){
        for(int j=0;j<(int)C[i].size()-1;j++){
            next[C[i][j]]=C[i][j+1];
        }
    }
    int now=-1,count=0;
    while(now!=N-1){
        now++;
        int nex=next[now];
        if(nex<=now) count++;
        now=nex;
    }
    count++;
    K%=count;
    if(K==0){
        cout<<endl;
        return 0;
    }
    now=-1;
    while(K>1){
        now++;
        int nex=next[now];
        if(nex<=now) K--;
        now=nex;
    }
    now++;
    vector<int> flag(210000,-1);
    vector<int> ans;
    for(int i=now;i<N;i++){
        if( flag[A[i]]==-1 ){
            ans.push_back(A[i]);
            flag[A[i]]=ans.size()-1;
        }else{
            int x=flag[A[i]];
            for(int j=ans.size()-1;j>=x;j--){
                if(j==flag[ans[j]]){
                    flag[ans[j]]=-1;
                }
                ans.erase(ans.begin()+j);
            }
        }

    }
    for(int i=0;i<(int)ans.size();i++){
        if(i) cout<<" ";
        cout<<ans[i];
    }
    cout<<endl;

}

Measured memory_bytes: 15992
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

ll mod = 1e9 + 7;

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

  ll a, b, c;
  cin >> a >> b >> c;
  ll ans = a * b / 2;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
int main() {
	
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int N[4] = {0};
	scanf("%d %d %d", &N[0], &N[1], &N[2]);
	std::sort(N, N + 3);

	printf("%d", N[0] * N[1] / 2);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define maxn 100005
using namespace std;
int dp[maxn], h[maxn];
int main(){
	ios::sync_with_stdio ( false );
	cin.tie(0);
	int n;
	cin >> n;
	for ( int i=0; i<n; ++i ) cin >> h[i];
	dp[0] = 0, dp[1] = abs(h[1]-h[0]);
	for ( int i=2; i<n; ++i )
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
	cout << dp[n-1] << '\n';
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int N,M;
int A,B,C,D;
int sum, ans;
string S;

int main() {
	cin >> S;
	if (S == "ABC") {
		cout << "ARC" << endl;
	}
	else if (S == "ARC") {
		cout << "ABC" << endl;
	}

	return 0;
}

Measured memory_bytes: 3592
#include <string>
#include <iostream>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);

long long mod = 1e9 + 7;
using namespace std;
int main() {
    fastIO;
    int N;
    cin >> N;
    int a[N];
    long long sum = 0;
    for (int i = 0; i<N; i++){
        cin >> a[i];
        sum +=a[i];
        sum %= mod;
    }
    long ans = 0;
    for (int i = 0; i < N; i++)
    {
        sum -= a[i];
        if (sum < 0) sum += mod;
        ans += a[i] * sum;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4388
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int n;
cin >>n;
int a;
cin >>a;
int b;
cin >>b;
int c;
cin >>c;
int d[n];
int e;
e=0;
while(e<n){
cin>>d[e];
e=e+1;}
sort(d,d+n);
int f;
f=c/a;
int g;
e=n-1;
while(e>=0){
c=c+d[e];
a=a+b;
g=c/a;
if(g<f){break;}
if(g>f){f=g;}
e=e-1;}
cout <<f<<endl;}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

int main(){

  ll a,b;cin>>a>>b;
  if(a<b)out("a < b");
  else if(a>b)out("a > b");
  else out("a == b");


  return 0;
}



Measured memory_bytes: 3016
n = int(input())
a = list(map(int, input().split()))
nep = 0
par = 0
cet = 0
for x in a:
    if x % 2 != 0:
        nep += 1
    elif x % 4 != 0:
        par += 1
    else:
        cet += 1

last = 0
for i in range(n):
    if last == 0:
        if nep:
            nep -= 1
            last = 1
        elif par:
            par -= 1
            last = 2
        else:
            cet -= 1
            last = 0
        continue
    if last == 2:
        if par:
            par -= 1
            last = 2
        elif cet:
            cet -= 1
            last = 0
        else:
            print('No')
            exit(0)
        continue 
    if cet:
        cet -= 1
        last = 0
    else:
        print('No')
        exit(0)
print('Yes')


Measured memory_bytes: 14480
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Throwable {
		BufferedReader vd = new BufferedReader(new InputStreamReader(System.in));
		String[] s = vd.readLine().split(" ");
		int a = Integer.parseInt(s[0]);
		int b = Integer.parseInt(s[1]);
		int c = Integer.parseInt(s[2]);
		int k = Integer.parseInt(vd.readLine());
		int sum=0;
		if((a>=b)&&(a>=c)) {
			sum = (int) (a*Math.pow(2, k) + b + c);
		}else if((b>a)&&(b>=c)) {
			sum = (int) (b*Math.pow(2, k) + a + c);
		}else if((c>a)&&(c>b)) {
			sum = (int) (c*Math.pow(2, k) + a + b);
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, M, Q; cin  >> N >> M >> Q;
    int CS[550][550] = {0};
    for(int i=0; i<M; ++i){
        int l, r;
        cin >> l >> r;
        CS[l][r]++;
    }
    for(int i=0; i<=N; ++i){
        for(int j=0; j<N; ++j){
            CS[i][j+1] += CS[i][j];
        }
    }
    for(int j=0; j<=N; ++j){
        for(int i=0; i<=N; ++i){
            CS[i+1][j] += CS[i][j];
        }
    }
    for(int i=0; i<Q; i++){
        int p, q; cin >> p >> q;
        cout << CS[q][q] + CS[p-1][p-1] - CS[q][p-1] - CS[p-1][q] << endl;
    }
    return 0;
}

Measured memory_bytes: 2048
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int l, r, d;
    cin>>l>>r>>d;
    int ans=0;
    for(int i=l; i<=r; i++){
        if(i%d==0) ans++;
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);


int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N; cin>>N;
    vector<ll> A(N+1);
    rep1(i,N) cin>>A[i];
    map<ll,ll> X;
    map<ll,ll> Y;
    rep1(i,N){
        X[i+A[i]]++;
        Y[i-A[i]]++;
    }
    ll ans=0;
    for(auto x:X){
        ans+=x.b*Y[x.a];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 39032
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
using ll = long long;
int main() {
  ll N, ans{};
  cin >> N;
  map<string,int> m;
  string S;
  while (cin >> S) {
    sort(begin(S),end(S));
    ans += m[S]++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 11136
#include <stdio.h>
int i,N[7],n,a,b;
int t[7][7]={
{0,0,0,0,0,0,0},
{0,0,3,5,2,4,0},
{0,4,0,1,6,0,3},
{0,2,6,0,0,1,5},
{0,5,1,0,0,6,2},
{0,3,0,6,1,0,4},
{0,0,4,2,5,3,0}
};
int hantei(int p){
    int i;
    for(i=1;i<7;i++){
        if(p==N[i]){
            return i;
        }
    }
    return 0;
}
int main(void){
    for(i=1;i<7;scanf("%d",&N[i++]));
    for(scanf("%d",&n);n--;){
        scanf("%d%d",&a,&b);
        printf("%d\n",N[t[hantei(a)][hantei(b)]]);
    }
}

Measured memory_bytes: 1852
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A=0,B=0,N=0;
  cin >> N;
  vector<int> cards(N);
  
  for(int n=0;n<N;n++){
    cin >> cards.at(n);
  }
 sort(cards.begin(),cards.end());
  reverse(cards.begin(),cards.end());
  
    
    for(int n=0;n<N;n++){
    if( n % 2 == 0) {
      A+=cards.at(n);
    }
      else if( n % 2 !=0)  B+=cards.at(n);
  }
  cout << A-B << endl;
}

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

using ll = long long;
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');

void solve(std::string A, std::string B) {
  if (A.size() > B.size()) {
    cout << "GREATER" << endl;
  }else if(A.size() < B.size()){
    cout << "LESS" << endl;
  } else {

  cout << (A > B ? "GREATER" : A < B ?"LESS":"EQUAL") << endl;
  }
}

int main() {
    std::string A;
    std::cin >> A;
    std::string B;
    std::cin >> B;
    solve(A, B);
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int dis[7][7], cost[7][7];

void init() {
  dis[0][1] = 6; dis[0][2] = 13, dis[0][3] = 18, dis[0][4] = 23, dis[0][5] = 43, dis[0][6] = 58;
  dis[1][2] = 7, dis[1][3] = 12, dis[1][4] = 17, dis[1][5] = 37, dis[1][6] = 52;
  dis[2][3] = 5, dis[2][4] = 10, dis[2][5] = 30, dis[2][6] = 45;
  dis[3][4] = 5, dis[3][5] = 25, dis[3][6] = 40;
  dis[4][5] = 20, dis[4][6] = 35;
  dis[5][6] = 15;
  cost[0][1] = 300, cost[0][2] = 500, cost[0][3] = 600, cost[0][4] = 700, cost[0][5] = 1350, cost[0][6] = 1650;
  cost[1][2] = 350, cost[1][3] = 450, cost[1][4] = 600, cost[1][5] = 1150, cost[1][6] = 1500;
  cost[2][3] = 250, cost[2][4] = 400, cost[2][5] = 1000, cost[2][6] = 1350;
  cost[3][4] = 250, cost[3][5] = 850, cost[3][6] = 1300;
  cost[4][5] = 600, cost[4][6] = 1150;
  cost[5][6] = 500;
}

bool in_range(int h, int m) {
  if (h < 17 || h > 19) return false;
  if (h == 17 && m < 30) return false;
  if (h == 19 && m > 30) return false;
  return true;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  init();
  int d, a;
  while (cin >> d, d) {
    int hd, md, ha, ma;
    cin >> hd >> md >> a >> ha >> ma;
    d--, a--;
    if (d > a) swap(d, a);
    bool ok = (dis[d][a] <= 40);
    ok &= (in_range(hd, md) || in_range(ha, ma));
    cout << (ok ? (cost[d][a] / 2 + 50 - 1) / 50 * 50 : cost[d][a]) << endl;
  }

  return 0;
}


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

string str[3];

inline int solve( int p ) {
    if( str[p].empty() == true )
        return p;
    
    char ch = str[p].back();
    str[p].pop_back();
    
    return solve( (int) (ch - 'a') );
}

int main( void ) {
    
    for( int i = 0; i <= 2; i ++ ) {
        cin >> str[i];
        reverse( str[i].begin(), str[i].end() );
    }
    
    cout << (char) ( solve( 0 ) + 'A' );
    
    return 0;
}

Measured memory_bytes: 256
int main(void)
{
  int k,x,min,max;
  
  scanf("%d%d", &k, &x);
  min = x-(abs(k-1));
  max = x+(abs(k-1));
  
  for(int i=min; i<=max; i++)
  {
    printf("%d ", i);
  }
  
  return(0);
}


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

using namespace std;

int dp[3][100010];

int main(){

	int n;

	cin >> n;

	int a[100010],b[100010],c[100010];
		

	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i] >> c[i];
	}

	dp[0][0] = a[0];
	dp[1][0] = b[0];
	dp[2][0] = c[0];


	for(int i=1;i<n;i++){

		dp[0][i] = a[i] + max(dp[1][i-1],dp[2][i-1]);
		dp[1][i] = b[i] + max(dp[0][i-1],dp[2][i-1]);
		dp[2][i] = c[i] + max(dp[1][i-1],dp[0][i-1]);	

	}

	cout << max(dp[0][n-1], max(dp[1][n-1],dp[2][n-1])) << endl;


	
	return 0;

}

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

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

  int a[n];
  for( int i=0; i<n ; i++){
    cin >> a[i];
  }

  for( int i=n-1; i>=0; i--){
    if ( i!=n-1 )cout << ' ';
    cout << a[i];
  }
  cout << endl;
}


Measured memory_bytes: 3092
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    s = list(input())
    ans = 0
    f = defaultdict(lambda : [])
    for i in range(n):
        f[s[i]].append(i)
    for t in range(1000):
        k = list(str(t))
        k = ["0"]*(3-len(k))+k
        j = -1
        for i in range(3):
            x = bisect.bisect_right(f[k[i]],j)
            if x >= len(f[k[i]]):
                break
            j = f[k[i]][x]
        else:
            ans += 1
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 44012
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main() 
{
	int A, B;
	cin >> A >> B;
	int socket = 1, tap = 0;
	while (socket < B) {
		socket += A - 1;
		tap++;
	}
	cout << tap << endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/agc027/tasks/agc027_a
// A - Candy Distribution Again
#include <stdio.h>
#include <stdlib.h>

// 標準入力から改行かスペースまで読み取り、数字として返す
int get_num() {
    // 10文字+区切り文字までしか受け付けられない
    char s[11];
    int i, n;
    // scanf()の直後は改行が入力に残っているので、
    // 最初の改行は読み飛ばす
    do {
        s[0] = getchar();
    } while (s[0] == '\0' || s[0] == '\n');
    for (i = 1; i < sizeof(s); i++) {
        s[i] = getchar();
        if (s[i] == ' ' || s[i] == '\n') {
            s[i] = '\0';
            break;
        }
    }
    sscanf(s, "%d", &n);
    return n;
}

// バブルソート
void sort(int a[], int num) {
    int i, j, b;
    for (i = 0; i < num-1; i++) {
        for (j = 0; j < num-i-1; j++) {
            if (a[j] > a[j+1]) {
                b = a[j];
                a[j] = a[j+1];
                a[j+1] = b;
            }
        }
    }
}

int main(void) {
    int n, x, i;
    int a[100];
    n = get_num();
    x = get_num();
    for (i = 0; i < n; i++) {
        a[i] = get_num();
    }

    sort(a, n);
    
    i = 0;
    while (x - a[i] >= 0) {
        x -= a[i];
        i++;
        if (i == n) {
            if (x > 0) {
                i--;
            }
            break;
        }
    }

    printf("%d\n", i);
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
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; }
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
const int MAX=2e7;
const ll MOD=1e9+7;
const int INF=1<<30;

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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i,N){
    cin >> A[i];
  }
  int maxA=0;
  int GCD=A[0];
  rep(i,N){
    if(A[i]>maxA) maxA=A[i];
    GCD=gcd(GCD,A[i]);
  }
  if(maxA>=K&&(maxA-K)%GCD==0) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	char s[1000], t[1000];
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> s[i];
	}
	for(int i = 1; i <= n; i++) {
		cin >> t[i];
	}
	for(int i = 1; i <= n; i++) {
		cout << s[i] << t[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
 
using namespace std;
  
const double eps=1e-10;
 
const int dy[]={-1,-1,0,1,1, 1, 0,-1};
const int dx[]={ 0, 1,1,1,0,-1,-1,-1};

long solve(string s)
{
	long res=0;

	while(s.size()!=1){
		res++;

		long next=-1,now=atol(s.c_str());

		for(int i=1;i<s.size();i++){
			string s1=s.substr(0,i),s2=s.substr(i);
			if(next==-1 || next<atol(s1.c_str())*atol(s2.c_str())) next=atol(s1.c_str())*atol(s2.c_str());
		}
		if(now==next) return -1;
	
		stringstream ss;
		ss<<next;
		s=ss.str();
	}

	return res;
}

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

	for(int i=0;i<q;i++){
		string s;
		cin>>s;
		cout<<solve(s)<<endl;
	}

	return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0);
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a>=k){
        cout<<k<<"\n";
    }else{
        if(b>=k-a){
            cout<<a<<"\n";
        }else{
            cout<<a-(k-a-b)<<"\n";
        }
    }


return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

int main(){
    ll k, cnt = 0, x = 0;
    string s;
    ll ans;
    cin >> s >> k;
    int n = s.size();
    bool f = false, all = true;
    char c = s[0];
    for(int i = 0; i < n; i++){
        if(c != s[i]) all = false;
    }
    if(all){
        cout << (n*k)/2 << endl;
        return 0;
    }
    while(c == s[x])x++;
    for(int i = 0; i < n-1; i++){
        if(s[i] == s[i+1]){
            if(i == n-2) f = true;
            cnt++;
            i++;
        }
    }
    ans = k * cnt;
    if(!f && s[0] == s[n-1] && x % 2 != 0) ans += k-1;
    cout << ans << endl;
    return 0;
}

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

struct brac{
	int A,B,C;
	int dot;
	brac(int A, int B, int C, int dot):A(A),B(B),C(C),dot(dot){}
	brac(){}
};

int main(){
	while(1){
		int p,q;
		cin >> p >> q;
		if(p==0) break;
		
		vector<brac> info(p+q);
		int a=0, b=0, c=0;
		for(int i=0; i<p+q; i++){
			if(i==p) a=b=c=0;
			info[i] = brac(a,b,c,0);
			string str;
			cin >> str;
			bool indent=true;
			int dot=0;
			for(int j=0; j<(int)str.length(); j++){
				if(indent && str[j]=='.') dot++;
				else indent=false;
				if(str[j]=='(') a++;
				if(str[j]==')') a--;
				if(str[j]=='{') b++;
				if(str[j]=='}') b--;
				if(str[j]=='[') c++;
				if(str[j]==']') c--;
			}
			info[i].dot = dot;
		}
		
		vector<set<int> > ans(q);
		for(int i=1; i<=20; i++){
			for(int j=1; j<=20; j++){
				for(int k=1; k<=20; k++){
					bool correct=true;
					for(int t=0; t<p; t++){
						if(i*info[t].A +j*info[t].B +k*info[t].C != info[t].dot){
							correct = false;
							break;
						}
					}
					if(!correct) continue;
					for(int t=0; t<q; t++){
						ans[t].insert( i*info[p+t].A +j*info[p+t].B +k*info[p+t].C );
					}
				}
			}
		}
		
		for(int i=0; i<q-1; i++){
			if(ans[i].size()==0){
				cerr << "error" << endl;
			}
			if(ans[i].size()!=1){
				cout << -1 << " ";
			}else{
				cout << *(ans[i].begin()) << " ";
			}
		}
		if(ans[q-1].size()!=1){
			cout << -1 << endl;
		}else{
			cout << *(ans[q-1].begin()) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3208
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
using namespace std;
using ll=long long;
//using R=double;

const int INF = 10000000;
typedef pair<int, int> p;

int main(){

    int x1, y1, x2, y2;
    int x3, y3, x4, y4;
    cin >> x1 >> y1 >> x2 >> y2;
    
    int x_dif = x2 - x1;
    int y_dif = y2 - y1;

    y3 = y2 + x_dif;
    x3 = x2 - y_dif;
    y4 = y1 + x_dif;
    x4 = x1 - y_dif;

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

    return 0;

}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] x = new int[n][2];
        for(int i=0; i<n; i++){
            x[i][0] = sc.nextInt();
            x[i][1] = sc.nextInt();
        }
        sc.close();

        if(n == 2){
            System.out.println(0.5);
            System.out.println(0.5);            
            return;
        }

        long[] num = new long[n];
        final int N = 3500000;
        double r = Math.pow(10, 11);

        for(int i=0; i<N; i++){
            double theta = 2.0d * Math.PI * (double)i / (double)N;
            double mx = r * Math.cos(theta);
            double my = r * Math.sin(theta);            
            double min = Math.pow(10, 200);
            int minpos = 0;
            for(int j=0; j<n; j++){
                double len = Math.pow((double)(x[j][0]) - mx, 2) + Math.pow((double)(x[j][1]) - my, 2);
                if(len < min){
                    min = len;
                    minpos = j;
                }
            }
            num[minpos]++;
        }

        for(int i=0; i<n; i++){
            System.out.println((double)(num[i]) / (double)N);
        }
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    REP(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    REP(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

int main()
{
  int N = inputValue();
  int M = inputValue();
  priority_queue<int> que;
  REP(i, N){
    int v;
    cin >> v;
    que.push(v);
  }
  while(M > 0){
    int v = que.top() / 2;
    que.pop();
    que.push(v);
    M--;
  }
  ll ans = 0;
  REP(i, N){
    ll v = que.top();
    ans += v;
    que.pop();
  }
  cout << ans << endl;
}


Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<long long>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;
const int mod = 1e9 + 7;
const int MAX = 200002;
ll fact[MAX], invfact[MAX];

#define MAX_V 1000000

ll C[51][51];
ll mod_pow(ll a, ll n, ll mod) {
	ll res = 1;
	while(n > 0) {
		if(n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}

	return res;
}

ll mod_inverse(ll a, ll m) {
	return mod_pow(a, m - 2, m);
}

ll nCr(ll n, ll r) {
	return fact[n] * invfact[r] % mod * invfact[n - r] % mod;
}

void init() {
	fact[0] = invfact[0] = 1;
	rep(i, 1, MAX) {
		fact[i] = (fact[i - 1] * i) % mod;
		invfact[i] = mod_inverse(fact[i], mod);
	}
}
	
void comb(int N) {
	rep(i, 0, N + 1) rep(j, 0, i + 1) {
		if(j == 0 || i == j) C[i][j] = 1ll;
		else C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
	}
}

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

	//init();

	int N, A, B;
	cin >> N >> A >> B;
	vector<ll> v(N);
	rep(i, 0, N) cin >> v[i];
	comb(N);

	vsort_r(v);

	long double rsl = 0.0;
	rep(i, 0, A) rsl += v[i];
	rsl /= A;

	int X = 0, Y = 0;
	rep(i, 0, N) {
		if(v[i] == v[A - 1]) {
			if(i < A) Y++;
			X++;
		}
	}

	ll count = 0;
	if(Y != A) {
		count = C[X][Y];
		//count = nCr(X, Y);
	} else {
		rep(i, A, B + 1) {
			//count += nCr(X, i);
			count += C[X][i];
		}
	}

	cout.precision(20);
	cout << fixed << rsl << endl;
	cout << count << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>

using namespace std;
typedef long long LL;
const int maxn = 400005;

int n,K;char str[maxn];
bool check(int pos,int rv)
{
	char now=n&1?'A':'B';
	if (rv) now='A'+'B'-now;
	for (int i=pos;i<=n;i++,now='A'+'B'-now)
	if (str[i]!=now) return false;
	for (int i=1;i<pos;i++,now='A'+'B'-now)
	if (str[i]!=now) return false;
	return true;
}
int main()
{
	#ifdef Amberframe
		freopen("agc011d.in","r",stdin);
		freopen("agc011d.out","w",stdout);
	#endif
	scanf("%d %d %s",&n,&K,str+1);int pos=1,rv=0;
	for (int i=1;i<=n*2&&K;i++,K--) {
		if (str[pos]=='A') {
			if (rv) pos=pos%n+1,rv^=1;
			else str[pos]='B';
		} 
		else {
			if (rv) str[pos]='A';
			else pos=pos%n+1,rv^=1;
		}
	}
	while (K&&!check(pos,rv))
	{
		if (str[pos]=='A') {
			if (rv) pos=pos%n+1,rv^=1;
			else str[pos]='B';
		} 
		else {
			if (rv) str[pos]='A';
			else pos=pos%n+1,rv^=1;
		}
		K--;
	}
	if (!K) {
		if (rv) for (int i=1;i<=n;i++) str[i]='A'+'B'-str[i];
		for (int i=pos;i<=n;i++) printf("%c",str[i]);
		for (int i=1;i<pos;i++) printf("%c",str[i]);
	}
	else {
		if (n&1) printf("%c",K&1?'B':'A');
		for (int i=1;i<=n/2;i++) printf("BA");
	}
	return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer token = new StringTokenizer(br.readLine());
		int N = Integer.parseInt(token.nextToken());
		int K = Integer.parseInt(token.nextToken());
		token = new StringTokenizer(br.readLine());
		int[] candles = new int[N];
		for(int i=0;i<N;i++) {
			candles[i] = Integer.parseInt(token.nextToken());
		}
		// 题目测试用例与题目要求不符
		int cnt = Integer.MAX_VALUE;
		int tmp = 0;
		for(int i=0, j=K-1;j<N;i++, j++) {
			cnt = Math.min(cnt, candles[j] - candles[i] + Math.min(Math.abs(candles[i]), Math.abs(candles[j])));
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 35864
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<double,double> Pdouble;

const int INF = 100000000;

const int MAX_N = 20;
const int MAX_M = 20;

char maze[MAX_N][MAX_M + 1];
int N, M;
int sx, sy;
int gx, gy;
int d[MAX_N][MAX_M];

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

void bfs(){
  queue<P> que;
  for(int i=0; i<N; i++){
    for(int j=0; j<M; j++){
      d[i][j] = INF;
    }
  }

  que.push(P(sx, sy));
  d[sx][sy] = 0;

  while(que.size()){
    P p= que.front();
    que.pop();
    /*if(p.first == gx && p.second == gy){
      break;
    }*/

    for(int i = 0; i<4; i++){
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];

      if(0 <= nx && nx < N 
      && 0 <= ny && ny < M
      && maze[nx][ny] != '#'
      && d[nx][ny] == INF){
        que.push(P(nx, ny));
        d[nx][ny] = d[p.first][p.second] + 1;
      }
    }
  }
  return;
}

int main(){
  cin >> N >> M;
  for(int i=0; i<N; i++){
    for(int j=0; j<M; j++){
      cin >> maze[i][j];
    }
  }

  int maxd[MAX_N][MAX_M];
  
  for(int i=0; i<N; i++){
    for(int j=0; j<M; j++){
      if(maze[i][j] != '#'){
        int max = 0;
        sx = i;
        sy = j;
        bfs();
        for(int k=0; k<N; k++){
          for(int m=0; m<M; m++){
            if(max <d[k][m] && d[k][m] != INF){
              max = d[k][m];
            }
          }
        }
        maxd[i][j] = max;
      }else{
        maxd[i][j] = 0;
      }
    }
  }

  int answer = 0;
  for(int i=0; i<N; i++){
    for(int j=0; j<M; j++){
      if(answer < maxd[i][j]){
        answer = maxd[i][j];
      }
    }
  }
  cout << answer << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

long keisan(long x, long y, char z){
	long ans;
	if(z=='+') ans=x+y;
	else if(z=='-') ans=x-y;
	else if(z=='*') ans=x*y;
	else if(z=='/') ans=x/y;
	
	return ans;
}

int main(void){
	long a, b, result;
	char num[10], c;
	
	scanf("%ld", &a);
	scanf(" %c", &c);
	scanf(" %ld", &b);
	
	result = keisan(a,b,c);
	
	while(1){
		scanf(" %c", &c);
		if(c=='=') break;
		scanf(" %ld", &a);
		
		result = keisan(result, a, c);
	}
	printf("%ld\n", result);
	
	return 0;
}

Measured memory_bytes: 596
from collections import deque
import sys
input = sys.stdin.readline


def main():
    N, M, P = map(int, input().split())
    edge = []
    g = [[] for _ in range(N)]
    rg = [[] for _ in range(N)]
    for _ in range(M):
        A, B, C = map(int, input().split())
        A -= 1
        B -= 1
        C -= P
        C = -C
        edge.append((A,B,C))
        g[A].append(B)
        rg[B].append(A)

    # 0 => N-1の間にある閉路を検出したいので
    # 0とN-1からたどりつけない場所は前処理で取り除く
    
    visited1 = set() 
    visited2 = set()
    visited1.add(0)
    visited2.add(N-1)
    Q = deque()
    Q.append(0)
    while Q:
        v = Q.popleft()
        for dest in g[v]:
            if dest in visited1:
                continue
            visited1.add(dest)
            Q.append(dest)
    
    Q.append(N-1)
    while Q:
        v = Q.popleft()
        for dest in rg[v]:
            if dest in visited2:
                continue
            visited2.add(dest)
            Q.append(dest)
    
    OK = visited1 & visited2
    
    flag = True
    d = [float('inf')] * N
    d[0] = 0
    #ベルマンフォード法、N回実行してまだ更新されている場合は負の閉路が存在する
    for _ in range(N):
        flag = False
        for a, b, c in edge:
            if not a in OK:
                continue
            if not b in OK:
                continue
            newD = d[a] + c
            if newD < d[b]:
                d[b] = newD
                flag = True
        if not flag:
            print(max(0,-d[N-1]))
            exit()
    else:
        print(-1)
        exit()


if __name__ == "__main__":
    main()

Measured memory_bytes: 48876