akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;


signed main()
{
	int A, B, C;
	cin >> A >> B >> C;
	if (A == B) cout << C << endl;
	if (B == C) cout << A << endl;
	if (A == C) cout << B << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <fstream>
#include <cassert>
using namespace std;

//common

typedef int  i32;
typedef long long i64,ll;
typedef long double ld;

#define BR "\n"
#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,r) for(int i=(int)l;i<(int)(r);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

//config
//#define NDEBUG
//#define INF 1<<30
//#define EPS 1e-8
//const ll MOD =100000007;

//debug
#ifdef NDEBUG
#define DUMP(x)
#define DUMPLN(x)
#define DEBUG(x)
#define DEBUGLN(x)
#define LINE()
#define LINELN()
#define CHECK(exp,act)
#define STOP(e)
#else
#define DUMP(x)  cerr << #x << " = " << (x)
#define DUMPLN(x)  DUMP(x) <<endl
#define DEBUG(x) DUMP(x) << LINE() << " " << __FILE__
#define DEBUGLN(x) DEBUG(x)<<endl
#define LINE()    cerr<< " (L" << __LINE__ << ")"
#define LINELN()    LINE()<<endl
#define CHECK(exp,act)  if(exp!=act){DUMPLN(exp);DEBUGLN(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}

template<class T> inline string toString(const vector<vector<T> >& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

string BITtoString(int bit){
    stringstream ss;
    while(bit!=0){ss<<(bit%2);bit/=2;}
    string res=ss.str();reverse(ALL(res));
    return res;
}

template<typename T> inline T pmod(T v,T MOD){
	return (v%MOD+MOD)%MOD;
}
#define nextInt(n) scanf("%d",&n)
#define defInt(n) int n;nextInt(n)
#define nextLong(n) scanf("%lld",&n)
#define defLong(n) ll n;nextLong(n)
#define nextDouble(n) scanf("%lf",&n)

class Main{
public:

    int N;
    bool input(){
        //   ifstream cin("in");
        //  ofstream cout( "out" );
        nextInt(N);
        return true;
    }

    bool isC(int n){
        string s;
        stringstream ss; ss<< n; ss >> s;
        REP(i,s.size())if(s[i]!=s[s.size()-1-i])return false;
        return true;
    }

    void run(){
        input();
        int NP=N,NN=N;
        while(!isC(NP))NP--;
        while(!isC(NN))NN++;

        if(abs(N-NP)<=abs(NN-N))cout <<NP<<endl;
        else cout <<NN <<endl;
    }
};

int main(){
	//cout <<fixed<<setprecision(3);	
	//ios::sync_with_stdio(false);
	Main().run();
	return 0;
}

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

int main(){
  int N;cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N-1;i++)cin>>v[i];
  int ans=v[0]+v[N-2];
  for(int i=0;i<N-1;i++){
    if(v[i]<=v[i+1])ans+=v[i];
    else ans+=v[i+1];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define For(i,a,b) for (int i=a;i<=b;i++)
#define Rep(i,a,b) for (int i=b;i>=a;i--)
using namespace std;
ll ans,n;
ll a[110];
ll lzq;
inline ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
ll gcd(ll x,ll y)
{
	if(y==0)return x;
	return gcd(y,x%y);
}
int main()
{
	n=read();
	For(i,1,n)a[i]=read();
	ans=1;
	For(i,1,n)
		For(j,i+1,n)
		{
			lzq=gcd(a[i],a[j]);
			if(lzq==1)continue;
			For(k,j+1,n)
				a[k]/=gcd(a[k],lzq);
			a[i]/=lzq;
			a[j]/=lzq;
			ans*=lzq;
		}
	For(i,1,n)ans*=a[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b, c;
  cin >> a >> b >> c;
  transform(a.begin(), a.end(), a.begin(), ::toupper);
  transform(b.begin(), b.end(), b.begin(), ::toupper);
  transform(c.begin(), c.end(), c.begin(), ::toupper);
  cout << a[0] << b[0] << c[0] << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC114A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());

            if (x == 3 || x == 5 || x == 7) 
            Console.WriteLine("YES");
            else
            Console.WriteLine("NO");

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<algorithm>
using namespace std;

int main() {
	vector<int>a(10);
	for (int b = 0; b < 10; b++)cin >> a[b];
	sort(a.begin(), a.end());
	printf("%d\n%d\n%d\n", a[9], a[8], a[7]);
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f

const int MOD = 1e9+7;
const int N = 200000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;
struct Edge
{
    int x,y;
    int dis;
    Edge(){}
    Edge(int x,int y,int dis):x(x),y(y),dis(dis) {}
    bool operator <(const Edge &rhs)const
    {
        return dis<rhs.dis;
    }
} edge[N];
int tot;
struct Node
{
    int x,y;
} node[N];
int fa[N];
bool cmpX(int a,int b)
{
    return node[a].x<node[b].x;
}
bool cmpY(int a,int b)
{
    return node[a].y<node[b].y;
}
int Find(int x)
{
    if(fa[x]!=x)
        return fa[x]=Find(fa[x]);
    return x;
}
int n;
int Kruskal()
{
    for(int i=1; i<=n; i++)
        fa[i]=i;
    int mst=0;
    sort(edge+1,edge+1+tot);
    for(int i=1; i<=tot; i++)
    {
        int x=Find(edge[i].x);
        int y=Find(edge[i].y);
        if(x!=y)
        {
            mst+=edge[i].dis;
            fa[x]=y;
        }
    }
    return mst;
}
int main()
{
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d%d",&node[i].x,&node[i].y);
    for(int i=1; i<=n; i++)
        fa[i]=i;
    sort(fa+1,fa+1+n,cmpX);
    for(int i=1; i<n; i++)
    {
        int x=fa[i];
        int y=fa[i+1];
        int dis=node[y].x-node[x].x;
        edge[++tot]=Edge(x,y,dis);
    }
    for(int i=1; i<=n; i++)
        fa[i]=i;
    sort(fa+1,fa+1+n,cmpY);
    for(int i=1; i<n; i++)
    {
        int x=fa[i];
        int y=fa[i+1];
        int dis=node[y].y-node[x].y;
        edge[++tot]=Edge(x,y,dis);
    }
    int mst=Kruskal();
    printf("%d\n",mst);
    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

bool possible(ll A, ll B, ll K) {
  if (K <= 1000) {
    vector<ll> a, b;
    for (int i = 1; (int)a.size() < K; i++) {
      if (i != A) a.push_back(i);
    }
    for (int i = 1; (int)b.size() < K; i++) {
      if (i != B) b.push_back(i);
    }
    REP(i, K) {
      if (a[i] * b[K-i-1] >= A*B) return false;
    }
    return true;
  } else {
    for (ll i = K/2 - 400; i <= K/2 + 400; i++) {
      ll Ai = i + (i >= A ? 1 : 0);
      ll Bi = K + 1 - i + 1;
      if (Bi <= B) Bi--;
      if (Ai*Bi >= A*B) return false;
    }
    return true;
  }
}

ll solve(ll A, ll B) {
  ll lo = 0;
  ll hi = A + B + 10;
  while (hi - lo > 1) {
    ll mid = (hi + lo) / 2;
    if (possible(A, B, mid)) lo = mid; else hi = mid;
  }
  return lo;
}


int main2() {
  int Q = nextInt();
  REP(_, Q) {
    ll A = nextInt();
    ll B = nextInt();
    // if (A == B) {
      // cout << 2*A - 2 << endl;
    // } else {
      if (A > B) swap(A, B);
      cout << solve(A, B) << endl;
    // }
  }
  return 0;
}

int main() {
#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main()
{
    string S;
    cin >> S;
    string ans = "Good";
    for(int i = 0; i < S.length()-1; i++){
      if(S[i] == S[i+1]){
        ans = "Bad";
      }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def bubbleSort(A):
  global N
  for i in range(N):
    for j in  range(N-1,i,-1):
      jn = int(A[j][1:])
      jm =  int(A[j-1][1:])
      if jn < jm:
        x = A[j]
        A[j] = A[j-1]
        A[j-1] = x

def selectionSort(A):
  global N
  for i in range(N):
    minj = i
    for j in range(i,N):
      jn = int(A[j][1:])
      jm =  int(A[minj][1:])
      if jn < jm:
        minj = j
    if minj != i :
      x = A[minj]
      A[minj] = A[i]
      A[i] = x

def stableDict(A):
  S = dict()
  for e in A:
    i = e[1:]
    if i in S:
      S[i] = e + S[i]
    else:
      S[i] = e
  return S

def ckStable(org,dst):
  dictOrg = stableDict(org)
  dictDst = stableDict(dst)
  stableFlg = True
  for a in dictOrg.keys():
    if dictOrg[a] != dictDst[a]:
      stableFlg = False
  if stableFlg :
    print("Stable")
  else:
    print("Not stable")

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

A1 = list(A)
A2 = list(A)

bubbleSort(A1)
print(" ".join(A1))
ckStable(A,A1)
  
selectionSort(A2)
print(" ".join(A2))
ckStable(A,A2)


Measured memory_bytes: 5608
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main(){
    input!{
        n:i64,
        m:i64,
        abn:[(i64,i64);n], 
    } //A円　b本
    let mut abn:Vec<(i64,i64)> = abn;
    abn.sort_by_key(|&(k,v)| k);
    let mut m = m;
    let mut ans = 0;
    for (cost,amount) in abn {
        if m < amount {
            ans += cost * m;
            break;
        } else {
            ans += cost * amount;
        }
        m -= amount;
    }
    println!("{}",ans);
}

Measured memory_bytes: 6396
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string instr;

    cin >> instr;
    while(!cin.eof()) {
        int joi=0,ioi=0;
        for(int i=0; i<(int)instr.size()-2;++i) {
            if(instr.substr(i,3)=="JOI") ++joi;
            if(instr.substr(i,3)=="IOI") ++ioi;
        }
        cout << joi << endl;
        cout << ioi << endl;
        cin >> instr;
    }

    return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 1; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define int long long
//#define _GLIBCXX_DEBUG

signed main() {
  int N; cin >> N;
  
  int a = 0;
  rep(i, sqrt(N) + 1) {
    int b = N/i;
    if(i*b == N) {
      a = b;
    }
  }
  int ans = 0;
  while(a/pow(10,ans) >= 10) ans++;
  cout << ans+1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;

int H;
int W;
ll MOD = 1000000007;

int main(void){
    // Your code here!
    cin >> H >> W;
    int a[H][W];
    ll D[H+1][W+1];
    
    for(int i = 0; i <= H; i++) for(int j = 0; j <= W; j++) D[i][j] = 0;
    
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            char sign;
            cin >> sign;
            if(sign=='.') a[i][j] = 0;
            else a[i][j] = 1;
        }
    }
    
    D[0][0] = 1;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
           if(i == 0 && j == 0) continue;
           
           if(a[i][j] == 1) D[i][j] = 0;
           else {
               if(i - 1 >= 0) D[i][j] += D[i-1][j];
               if(j - 1 >= 0) D[i][j] += D[i][j-1];
               D[i][j] = D[i][j] % MOD;
           }
        }
    }
    cout << D[H-1][W-1] << endl;
}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using lli = long long int;
lli dp[1000005][2] = {};
// iまで見て1つ払ってる
void solve(string N)
{
  int n = N.size();
  dp[n - 1][0] = N[n - 1] - '0';
  dp[n - 1][1] = 10 - (N[n - 1] - '0');

  for (int i = n - 2; i >= 0; i--)
  {
    int c = N[i] - '0';
    dp[i][0] = min(dp[i + 1][0] + c, dp[i + 1][1] + c + 1);
    dp[i][1] = min(dp[i + 1][0] + 10 - c, dp[i + 1][1] + 9 - c);
  }
  cout << min(dp[0][0], 1 + dp[0][1]) << endl;
}

int main()
{
  string S;
  cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 17924
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)




int main() {
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	char tmp = '\0';
	rep(i, n) {
		if (tmp != s[i]) {
			tmp = s[i];
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
int N;
long long X[4001];
int dp[4001][4001], pre[4001][4001];

inline long long key(int i, int j) { return X[j] - X[i]; }
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) cin >> X[i+1];
  for (int i=0; i<N; i++) X[i+1] += X[i];

  rep(i, N+1) rep(j, N+1) dp[i][j] = -INF, pre[i][j] = -1;
  for (int i=1; i<=N; i++) dp[0][i] = 1, pre[0][i] = 0;
  rep(i, N+1) {
    vector<pair<long long, P> > left, right;
    for (int j=0; j<i; j++)    left.pb(make_pair(key(j, i), P(dp[j][i], j)));
    for (int j=i+1; j<=N; j++) right.pb(make_pair(key(i, j), P(dp[i][j], j)));
    sort(all(left));
    sort(all(right));
    int head = 0;
    P m = P(-INF, -1);
    for (auto p : right) {
      while (head < left.size() && left[head]._1 < p._1) m = max(m, left[head++]._2);
      if (m._1 != -INF) {
        int j = p._2._2;
        assert(dp[i][j] < m._1+1);
        dp[i][j] = m._1+1, pre[i][j] = m._2;
      }
    }
  }

  P m = P(-INF, -1);
  rep(i, N+1) m = max(m, P(dp[i][N], i));
  int m2 = m._2, m1 = m._1;
  vector<int> ans;
  int left = m2, right = N;
  while (left != 0) {
    ans.pb(left);
    int k = left;
    left = pre[left][right];
    right = k;
  }
  reverse(all(ans));
  assert(ans.size() == m1-1);
  cout << m1 << "\n";
  for (int x : ans) cout <<x << " "; cout << "\n";
  return 0;
}

Measured memory_bytes: 128396
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int MX=500005;

struct qry{
    ll order;
    int l,r,i;
    bool operator < (const qry &a) const{
        return order<a.order;
    }
} qr[MX];
int a[MX],fr[MX],ans[MX];

inline ll hilbert(int x,int y)
{
    static const ll co[8][4]={
        {0,3,1,2},{3,0,2,1},{1,2,0,3},{2,1,3,0},
        {0,1,3,2},{3,2,0,1},{1,0,2,3},{2,3,1,0}
    };
    static const int rot[8][4]={
        {4,7,0,0},{5,6,1,1},{2,2,5,6},{3,3,4,7},
        {0,4,3,4},{1,5,2,5},{6,1,6,2},{7,0,7,3}
    };
    static const int pos[2][2]={{3,1},{2,0}};
    ll o=0;
    int k=20,r=0;
    while(k){
        ll d=1ll<<(k-1);
        ll pw=1ll<<(k+k-2);
        int p=pos[x<d][y<d];
        o+=co[r][p]*pw,r=rot[r][p];
        x-=(x<d)?0:d,y-=(y<d)?0:d,k--;
    }
    return o;
}

int main(){
    int n,q,x,y,l,r;
    scanf("%d %d",&n,&q);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    for(int i=0;i<q;i++){
        scanf("%d %d",&l,&r);
        qr[i].l=l-1,qr[i].r=r-1;
        qr[i].i=i,qr[i].order=hilbert(l-1,r-1);
    }
    sort(qr,qr+q);
    x=y=0,fr[a[0]]=1;
    int s=1;
    for(int i=0;i<q;i++){
        l=qr[i].l,r=qr[i].r;
        while(x<l){
            fr[a[x]]--;
            if(fr[a[x]]==0) s--;
            x++;
        }
        while(x>l){
            x--;
            fr[a[x]]++;
            if(fr[a[x]]==1) s++;
        }
        while(y<r){
            y++;
            fr[a[y]]++;
            if(fr[a[y]]==1) s++;
        }
        while(y>r){
            fr[a[y]]--;
            if(fr[a[y]]==0) s--;
            y--;
        }
        ans[qr[i].i]=s;
    }
    for(int i=0;i<q;i++) printf("%d\n",ans[i]);
    return 0;
}

Measured memory_bytes: 21344
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>

using namespace std;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

ll N;
vector<pdd> A;

ld calc(vector<ll> V) {
	ld sum = 0;
	for (ll n = 1; n < N; n++) {
		ld dd = (A[n].first - A[n - 1].first) * (A[n].first - A[n - 1].first) + (A[n].second - A[n - 1].second) * (A[n].second - A[n - 1].second);
		sum += sqrtl(dd);
	}
	return sum;
}

int main() {
	cin >> N;
	A.resize(N);
	for (ll n = 0; n < N; n++) {
		cin >> A[n].first >> A[n].second;
	}
	vector<ll> V(N);
	for (ll n = 0; n < N; n++)V[n] = n;
	ld sum = 0;
	do {
		for (ll n = 1; n < N; n++) {
			ld dd = (A[V[n]].first - A[V[n - 1]].first) * (A[V[n]].first - A[V[n - 1]].first) + (A[V[n]].second - A[V[n - 1]].second) * (A[V[n]].second - A[V[n - 1]].second);
			sum += sqrtl(dd);
		}
	} while (next_permutation(V.begin(), V.end()));
	ll st = 1;
	for (ll n = 2; n <= N; n++)st *= n;
	cout << setprecision(16) << sum / st << endl;
	return 0;
}

Measured memory_bytes: 256
let [|a;b|] = stdin.ReadLine().Split() |> Array.map int

let f x = [1..x] |> List.map (fun y -> 10.0 ** (float (y - 1)) |> int) |> List.sum

if (a >= b) then (b * (f a)) else (a * (f b))
|>stdout.WriteLine

Measured memory_bytes: 11348
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    string s; cin >> s;
    if (s == "ABC")
        cout << "ARC\n";
    else
        cout << "ABC\n";

}

Measured memory_bytes: 3608
from collections import deque
n=int(input())
E=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  a=a-1
  b=b-1
  E[a].append(b)
  E[b].append(a)
D=deque([0])
V=[0]*n
V[0]=1
A=[0]*n
k=1
while len(D)>0:
  x=D[0]
  D.popleft()
  for i in range(len(E[x])):
    if V[E[x][i]]==0:
      V[E[x][i]]=1
      D.append(E[x][i])
      A[E[x][i]]=A[x]^1
f=0
if n-sum(A)>sum(A):
  f=1
g=max(n-sum(A),sum(A))
a=(n+2)//3
b=n//3
if g>a+b:
  Ans=[0]*n
  s=1
  t=2
  u=3
  if f==0:
    for i in range(n):
      if A[i]==0:
        Ans[i]=u
        u=u+3
      else:
        if s<=n:
          Ans[i]=s
          s=s+3
        elif t<=n:
          Ans[i]=t
          t=t+3
        else:
          Ans[i]=u
          u=u+3
  else:
    for i in range(n):
      if A[i]==1:
        Ans[i]=u
        u=u+3
      else:
        if s<=n:
          Ans[i]=s
          s=s+3
        elif t<=n:
          Ans[i]=t
          t=t+3
        else:
          Ans[i]=u
          u=u+3
else:
  Ans=[0]*n
  s=1
  t=2
  u=3
  if f==1:
    for i in range(n):
      if A[i]==0 and s<=n:
        Ans[i]=s
        s=s+3
      elif A[i]==0 and s>n:
        Ans[i]=u
        u=u+3
      elif A[i]==1 and t<=n:
        Ans[i]=t
        t=t+3
      else:
        Ans[i]=u
        u=u+3
  else:
    for i in range(n):
      if A[i]==1 and s<=n:
        Ans[i]=s
        s=s+3
      elif A[i]==1 and s>n:
        Ans[i]=u
        u=u+3
      elif A[i]==0 and t<=n:
        Ans[i]=t
        t=t+3
      else:
        Ans[i]=u
        u=u+3
print(*Ans)


Measured memory_bytes: 57400
#include<stdio.h>
#define MAX 20

int A[MAX],n;

bool check(int i,int m){
	if (m == 0)return 1;
	if (i >= n)return 0;
	int res = check(i + 1, m) || check(i + 1, m - A[i]);
	return res;
}

int main(){
	int q, m;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &A[i]);
	}
	scanf("%d", &q);
	for (int i = 0; i < q; i++){
		scanf("%d", &m);
		if (check(0,m)){
			printf("yes\n");
		}
		else{
			printf("no\n");
		}
	}
}

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

int gcd(int a, int b) {
    return (a == 0) ? b : gcd(b % a, a);
}

int main() {
    int N;
    std::cin >> N;
    std::vector<int> A(N + 1);
    for (int i = 1; i <= N; ++i) {
        std::cin >> A[i];
    }

    std::vector<int> L(N + 1);
    std::vector<int> R(N + 1);
    L[0] = 0;
    R[N] = 0;
    for (int i = 1; i < N; ++i) {
        L[i] = gcd(L[i - 1], A[i]);
        R[N - i] = gcd(R[N - i + 1], A[N - i + 1]);
    }

    int ans = 0;
    for (int i = 1; i <= N; ++i) {
        int M = gcd(L[i - 1], R[i]);
        ans = std::max(ans, M);
    }

    std::cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define pb push_back
int main(){
    int n;
    cin >> n;
    int ans = INT_MAX;
    rep(i,n+1){
        int itemp = i;
        int j = n - i;
        int cc = 0;
        while(itemp>0){
            cc += itemp % 6;
            itemp /= 6;
        }
        while(j>0){
            cc += j % 9;
            j /= 9;
        }
        ans = min(ans, cc);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	static int n, m;
	static int[] dx = {0,0,-1,1}, dy = {-1,1,0,0};
	static boolean[][] map, check;

	public static int dfs (int y, int x, int step) {
		int ret = step;
		for (int i = 0; i < 4; i++) {
			int nextX = x + dx[i];
			int nextY = y + dy[i];
			if (0 <= nextX && nextX < m &&
				0 <= nextY && nextY < n &&
				map[nextY][nextX] &&
				!check[nextY][nextX]) {

				check[nextY][nextX] = true;
				ret = Math.max(dfs(nextY,nextX,step + 1),ret);
				check[nextY][nextX] = false;
			}
		}
		return ret;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int ans = 0;
			m = sc.nextInt();
			n = sc.nextInt();
			sc.nextLine();
			if (m == 0 && n == 0) break;
			map = new boolean[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++)
					map[i][j] = sc.nextInt() == 1;
			}
			int step = 1;
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					if (map[i][j]) {
						check = new boolean[n][m];
						check[i][j] = true;
						ans = Math.max(dfs(i,j,step),ans);
					}
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define int long long 
using namespace std;
int32_t main()
{
  int n,l;
  cin>>n>>l;
  int a[l];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  while(1)
  {
    int k=n,f=1;
    while(k>0)
    {
      int r=k%10;
      for(int i=0;i<l;i++)
      {
        if(r==a[i])
        {
          f=0;
          break;
          
        }
      }
      if(f==0)
      {
        break;
      }
      k/=10;
    }
    if(f==1)
    {
      cout<<n;
      break;
    }
    n++;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,SM{};
    cin>>n;
    vector<pair<int,int>> a,b;
    fr(i,n){
        string s;
        cin>>s;
        int mn{},sm{};
        for(auto&c:s){
            if(c=='(') ++sm;
            else --sm;
            chmin(mn,sm);
        }
        if(sm>=0) a.emplace_back(-mn,sm);
        else b.emplace_back(sm-mn,-sm);
        SM+=sm;
    }
    if(SM) return puts("No"),0;
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    int tmp{};
    for(auto&[A,B]:a){
        if(A>tmp) return puts("No"),0;
        tmp+=B;
    }
    tmp=0;
    for(auto&[A,B]:b){
        if(A>tmp) return puts("No"),0;
        tmp+=B;
    }
    puts("Yes");
}


Measured memory_bytes: 11280
#include <bits/stdc++.h>
using namespace std;
#define maxn 1000000
#define int long long
#define INF 99999999999LL
int n, a[maxn], f[maxn], last[maxn];
int tot, ans = -INF, ans1, op[maxn];
int mark[maxn], nxt[maxn];

int read()
{
	int x = 0, k = 1;
	char c; c = getchar();
	while(c < '0' || c > '9') { if(c == '-') k = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * k;
}

signed main()
{
	n = read();
	for(int i = 1; i <= n; i ++) a[i] = read();
	for(int i = 1; i <= n; i ++)
	{
		f[i] = a[i], last[i] = 0;
		for(int j = 1; j < i; j ++)
		{
			if((i - j) & 1) continue;
			if(f[j] + a[i] > f[i]) f[i] = f[j] + a[i], last[i] = j;
		}
		if(f[i] > ans) ans = f[i], ans1 = i;
	}
	printf("%lld\n", ans);
	for(int i = ans1, l = 0; i; l = i, i = last[i]) mark[i] = 1, nxt[i] = l;
	for(int i = 1; i <= n; i ++)
		if(mark[i]) break;
		else op[++ tot] = 1;
	for(int i = tot + 1; i <= n; i = nxt[i])
	{
		if(!nxt[i])
		{
			for(int j = n - i + 1; j >= 2; j --) op[++ tot] = j;
			break;
		}
		int K = (nxt[i] - i + 1) / 2 + 1;
		for(int j = K; j >= 2; j --) op[++ tot] = j;
	}
	printf("%lld\n", tot);
	for(int i = 1; i <= tot; i ++) printf("%lld\n", op[i]);
	return 0;
}

Measured memory_bytes: 10496
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
int n,a[100010];
int main(){
    scanf("%d",&n);
    for (int i=1; i<=n; i++)
        scanf("%d",&a[i]);
    sort(a+1,a+n+1,greater<int>());
    for (int i=1; i<=n; i++)
        if (i+1>a[i+1]){
        	int ans=0;
            for (int j=i+1; a[j]==i; j++)
                ans^=1;
            ans|=(a[i]-i)&1;
            if (ans) puts("First");
                else puts("Second");
            return 0;
		}
}

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

int main(void){
  int H, W;
  cin >> H >> W;
  char A[H][W];
  int d[H][W];
  const int INF = 1e9;
  for(int i=0; i<H; i++) for(int j=0; j<W; j++) d[i][j] = INF;
  queue<pair<int, int> > que;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> A[i][j];
      if(A[i][j] == '#') {
        d[i][j] = 0;
        que.push(make_pair(i, j));
      }
    }
  }
  
  while(que.size()){
    auto q = que.front(); que.pop();
    int y = q.first;
    int x = q.second;
    if(x-1 >= 0 && d[y][x-1] == INF) {
      d[y][x-1] = d[y][x] + 1;
      que.push(make_pair(y, x-1));
    }
    if(x+1 <= W-1 && d[y][x+1] == INF) {
      d[y][x+1] = d[y][x] + 1;
      que.push(make_pair(y, x+1));
    }
    if(y-1 >= 0 && d[y-1][x] == INF) {
      d[y-1][x] = d[y][x] + 1;
      que.push(make_pair(y-1, x));
    }
    if(y+1 <= H-1 && d[y+1][x] == INF) {
      d[y+1][x] = d[y][x] + 1;
      que.push(make_pair(y+1, x));      
    }
  }
  
  int ans = 0;
  for(int i=0; i<H; i++) for(int j=0; j<W; j++) ans = max(ans, d[i][j]);
  
/*
  for(int i=0; i<H; i++) {
    for(int j=0; j<W; j++) {
      cout << d[i][j];
    }
    cout << endl;
  }
*/  
  cout << ans << endl;
  return 0;  
}

Measured memory_bytes: 13328
n,x,m=map(int,input().split())
l=[x]
n-=1
f=-1
while(n>0):
    x=x*x
    x%=m
    if x in l:
        for i in range(len(l)):
            if x==l[i]:
                f=i
                s=l[i:].copy()
                break
    if f!=-1:
        break
    l.append(x)
    n-=1

if n==0:
    print(sum(l))
else:
    ans=sum(l)
    l=s.copy()
    ans+=sum(l)*(n//len(l))
    c=n%len(l)
    f=0
    while(c!=0):
        ans+=l[f]
        c-=1
        f+=1
    print(ans)







Measured memory_bytes: 69796
#include <iostream>
#include <vector> //for vector
#include <algorithm> //for sort
using namespace std;

struct City {
  int num;
  int P;
  string S;

  bool operator<(const City& right) const {
    return S == right.S ? P < right.P : S < right.S;
  }
};


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

  int P;
  string S;

  vector<City> v(N);
  for (int i = 0; i < N; i++) {
    v[i].num = i + 1;
    cin >> S >> P;
    v[i].P = -P;
    v[i].S = S;
  }

  sort(v.begin(), v.end());
  for (int i = 0; i < N; i++) {
    cout << v[i].num << endl;
  }

  return 0;
}

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

static const int INF = 1e9+7;

int main(){
    int N,K;
    cin>>N>>K;
    vector<int> h(N);
    vector<int> dp(100000+10,INF);
    for(int i=0; i<N; i++) cin>>h[i];

    dp[0] = 0;

    for(int i=0; i<N; i++){
        for(int j=1; j<=K; j++){
            dp[i+j] = min(dp[i]+abs(h[i]-h[i+j]),dp[i+j]);
        }
    }

    cout<<dp[N-1]<<endl;

    return 0;
}

Measured memory_bytes: 1024
//coins(probablity)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <bool> vb;
typedef vector <double> vf;////////////////////////////////////////////////////////////////////////////
typedef vector <ll> vll;
typedef vector <vector <int>> vvi;
typedef vector <vector <long long>> vvll;
typedef vector <vf> vvf;
typedef vector <long long> vll;
typedef pair <int, int> pii;
typedef pair<ll , ll> pll;
typedef vector <pair <int, int>> vpii;


int main()
{
    int n; cin >> n;
    vf prob(n);
    for(int i = 0; i < n; i++)
        cin >> prob[i];
    
    vvf state(n + 1, vf(n + 1, 0));
    state[0][0] = 1;
    for(int i = 0; i < n+1; i++)
        for(int j = 1; j < n + 1; j++)
        {
            state[i][j] = state[i][j-1] * (1 - prob[j-1]) + ((i - 1 >=0) ? (state[i-1][j-1]*prob[j-1]) : 0);
        }
    
    double res = 0.0;
    for(int i = n/2 + 1; i < n+1; ++i)
    {
        res += state[i][n]; 
    }
    std::cout << std::fixed;
    std::cout << std::setprecision(11);
    cout << res << endl;
}

Measured memory_bytes: 70656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			String N = in.next();
			int total = 0;
			for(int i = 0; i < N.length(); i++) {
				total += Integer.parseInt("" + N.charAt(i));
			}
			if(Integer.parseInt(N) % total == 0) {
				out.println("Yes");
			} else {
				out.println("No");
			}
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}


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

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

  int a;
  string s;
  cin >> a >> s;
  if(a >= 3200) {
    cout << s << '\n';
    return 0;
  }
  cout << "red" << '\n';
  return 0;
}


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

const int N = 2e5+10;

char s[N];

int main() {
	scanf("%s", s);
	int n = strlen(s);
	for (int i = 0; i < n; ++i) {
		if (s[i] == '?') s[i] = 'D';
	}
	printf("%s", s);
}


Measured memory_bytes: 4016
//#define DEBUGGING  // Enables DEBUG macro.
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifndef DEBUGGING
#define DEBUG(...)
#else
template <typename T>
void _debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void _debug(T value, Ts... args) {
  std::cerr << value << ", ";
  _debug(args...);
}
#define DEBUG(...)                     \
  do {                                 \
    cerr << " (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ": ";      \
    _debug(__VA_ARGS__);               \
    cerr << endl;                      \
  } while (0)
#endif

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<i64> A(N);
  for (auto& x : A) cin >> x;
  vector<pair<i64, int>> p(N);
  REP(i, N) p[i] = make_pair(A[i], i);
  sort(p.begin(), p.end());
  i64 low = p[0].first;
  int lowi = 0;
  i64 ans = p[Q - 1].first - low;
  DEBUG(low, p[Q - 1].first, ans);

  vector<i64> taken, buf;
  taken.reserve(N);
  buf.reserve(N);
  for (;;) {
    while (lowi < N && p[lowi].first == low) {
      int j = p[lowi].second;
      A[j] = 0;
      lowi++;
    }
    // cerr << "########" << endl;
    // DEBUG(lowi, low);
    // REP(i, N) cerr << " " << A[i];
    // cerr << endl;
    if (lowi == N) break;
    low = p[lowi].first;
    taken.clear();
    for (int start = 0; start + K - 1 < N; ++start) {
      if (A[start] == 0) {
        continue;
      }
      bool failed = false;
      buf.clear();
      REP(i, K) {
        if (A[start + i] == 0) {
          failed = true;
          start = start + i;
          break;
        }
        buf.push_back(A[start + i]);
      }
      if (failed) {
        continue;
      }
      int take_cnt = 1;
      start += K;
      for (; start < N; ++start) {
        if (A[start] == 0) {
          break;
        }
        buf.push_back(A[start]);
        take_cnt++;
      }
      partial_sort(buf.begin(), buf.begin() + take_cnt, buf.end());
      REP(i, take_cnt) { taken.push_back(buf[i]); }
    }
    if (taken.size() < (size_t)Q) continue;
    sort(taken.begin(), taken.end());
    if (taken.front() != low) continue;
    // cerr << "----" << endl;
    // for (auto x : taken) {
    //   cerr << " " << x;
    // }
    // cerr << endl;

    ans = min(ans, taken[Q - 1] - low);
    DEBUG(low, taken[Q - 1], ans);
  }

  cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE
//ABC, task a, 2020/04/12
//ms, ac
/*
*/

int main(void){
  int N;
  int64_t ans = 0;

  cin >>N;

  for(int i=1;i<=N;i++){
    if(i%3 != 0 && i%5 !=0){ans += i;}
  }

  cout <<ans <<endl;
  return 0;
}


Measured memory_bytes: 3676
package main

import "fmt"

func max(a int, b int) int {
	if a >= b {
		return a
	}
	return b
}

func main() {
	var n int
	fmt.Scan(&n)

	h := make([][]int, n)

	for i := 0; i < n; i++ {
		h[i] = make([]int, 3)
		for j := 0; j < 3; j++ {
			fmt.Scan(&h[i][j])
		}
	}

	dp := make([][]int, n)
	dp[0] = make([]int, 3)
	dp[0][0] = h[0][0]
	dp[0][1] = h[0][1]
	dp[0][2] = h[0][2]
	for i := 1; i < n; i++ {
		dp[i] = make([]int, 3)
		for j := 0; j < 3; j++ {
			for k := 0; k < 3; k++ {
				if j != k {
					dp[i][k] = max(dp[i][k], dp[i-1][j]+h[i][k])
				}
			}
		}
	}
	fmt.Println(max(max(dp[n-1][0], dp[n-1][1]), dp[n-1][2]))
}


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

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


priority_queue<ll>A;
REP(i, N){
  int x;
  cin >> x;
  A.push(x);
}

int tmp;
REP(i, M){
  tmp = A.top();
  A.pop();
  tmp /= 2;
  A.push(tmp);
}
ll sum = 0;

REP(i, N){
    sum += A.top();
    A.pop();
}

print(sum);

}


Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int main()
{
  int n;
  int a[101][101];
  int dp[101][101];
  cin >> n;
  REP(i, 2)
    REP(k, n) {
      cin >> a[i][k];
      dp[i][k] = -1;
    }
  dp[0][0] = a[0][0];
  REP(i, 2) {
    REP(k, n) {
      dp[i + 1][k] = max(dp[i + 1][k], dp[i][k] + a[i + 1][k]);
      dp[i][k + 1] = max(dp[i][k + 1], dp[i][k] + a[i][k + 1]);
    }
  }
  // REP(i, 2) {
  //   REP(k, n) {
  //     cout << dp[i][k] << " ";
  //   }
  //   cout << endl;
  // }
  cout << dp[1][n - 1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pll, pii> P;
const ll INF = 1ll<<30;
const ll longINF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N;
int B[100], ans[100];

int main() {
	cin >> N;
	REP(i, N - 1) scanf("%d", B + i);
	
	ans[0] = B[0];
	ans[N - 1] = B[N - 2];
	REP(i, N - 2) ans[i + 1] = min(B[i], B[i + 1]);
	
	int anss = 0;
	REP(i, N) anss += ans[i];
	cout << anss << endl;
	return 0;
}


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

int main() {
  int N, M, a;
  cin >> N >> M;
  
  for (int i=0; i<M; i++){
    cin >> a;
    N -= a;
  }

  if (N < 0){
    cout << "-1" << endl;
  }
  else{
    cout << N << endl;
  }
}


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextLong();
        }
        long ans = a[0];
        for (int i = 1; i < a.length; i++) {
            ans = gcd(ans, a[i]);
        }
        System.out.println(ans);
    }

    public static final long gcd(long a, long b) {
        if( b == 0 ) return a;
        return gcd(b, a % b);
    }
}

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

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

  int n;
  cin >> n;

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

  vector<vector<int>> dp(n + 1, vector<int>(3, 0));
  int A = 0;
  int B = 1;
  int C = 2;

  for (int i = 0; i <= n; i++) {
    if (i == 0) continue;

    dp[i][A] = a[i - 1] + max(dp[i - 1][B], dp[i - 1][C]);
    dp[i][B] = b[i - 1] + max(dp[i - 1][A], dp[i - 1][C]);
    dp[i][C] = c[i - 1] + max(dp[i - 1][A], dp[i - 1][B]);
  }

  cout << max(dp[n][A], max(dp[n][B], dp[n][C])) << endl;

  return 0;
}

Measured memory_bytes: 6912
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<ctime>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

#define N 101
const double eps = 1e-8;
//n matrix size  a00+x0+...=c0
//k current step
//mat Matrix
bool select_pivot(int n,int k,double mat[N][N],int num[N]){
  int s=k,t=k;//selected pivot
  double val=fabs(mat[k][k]);
  REP(i,k+1,n){
    REP(j,k+1,n){
      if (fabs(mat[i][j]) >val){
	val=fabs(mat[i][j]);
	s=i;
	t=j;
      }
    }
  }

  if ( val<eps)return false;//cannot solve this linear equations.
  
  rep(i,n)swap(mat[i][k],mat[i][t]);

  swap(num[k],num[t]);
  
  REP(i,k,n+1){
    swap(mat[k][i],mat[s][i]);
  }
  
  return true;//no problem for this pivot;
}

//n matrix size  x0,x1,...xn-1 =constant
//row n,column n+1
bool gauss(int n,double mat[N][N],double ret[N]){
  int num[N];
  //step 0
  rep(i,N)num[i]=i;

  //step1
  rep(k,n){
    if ( select_pivot(n,k,mat,num)==false)return false;
    REP(i,k+1,n+1)mat[k][i]/=mat[k][k];//devided by m[k][k];
    mat[k][k]=1;//for looking the equation
    REP(i,k+1,n){//ツ妥」ツ禿シ
      REP(j,k+1,n+1)mat[i][j]+=-mat[i][k]*mat[k][j];
      mat[i][k]=0;//For looking the equation
    }
  }
  
  //step2 
  for(int i=n-1;i>=0;i--){//solve ith row
    REP(j,i+1,n){
      mat[i][n]-=mat[i][j]*mat[j][n];
    }
  }

  //step3
  rep(i,n){
    ret[num[i]]=mat[i][n];
  }
  return true;
}

#define INF ( 1 << 25)

main(){
  int n,s,d;
  int adj[N][N];
  int cost[N][N];
  bool sign[N];
  double mat[N][N];
  double ans[N];
  while(cin>>n>>s>>d && n){
    s--;d--;
    rep(i,n)cin>>sign[i];
    rep(i,n){
      rep(j,n){
	cin>>adj[i][j];
	cost[i][j]=adj[i][j]==0?INF:adj[i][j];
	mat[i][j]=0;
      }
      mat[i][n]=0;
      cost[i][i]=0;
    }
    
    rep(k,n)rep(i,n)rep(j,n)cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);

    rep(i,n){
      int cnt=0;
      if ( i == d){mat[i][i]=1;mat[i][n]=0;continue;}
      if (sign[i]==true){
	
	rep(j,n)
	  if ( adj[i][j] !=0 && cost[i][d]==adj[i][j]+cost[j][d])
	    mat[i][n]+=adj[i][j],mat[i][j]=-1,cnt++;
      }else {
	rep(j,n)
	  if (adj[i][j] != 0 )mat[i][n]+=adj[i][j],mat[i][j]=-1,cnt++;
      }
      mat[i][i]=cnt;
    }
       
    if (false == gauss(n,mat,ans)){puts("No Solution");return true;continue;}

    printf("%.14lf\n",ans[s]);
  }

  return false;
}


/*main for verify
main(){
  srand(time(NULL));
  int n =10;
  double ans[n];
  double ans2[n];
  double mat[N][N];
  rep(i,n)ans[i]=(double)(RAND_MAX-rand())/(double)RAND_MAX;
  
  rep(i,n){
    double sum =0;
    rep(j,n){
      double tmp =(double)(RAND_MAX- rand())/(double)RAND_MAX;
      mat[i][j]=tmp;
      sum+=tmp*ans[j];
    }
    mat[i][n]=sum;
  }

  if (  gauss(n, mat,ans2) == false){puts("Cannot solve");return false;}
  
  int cnt=0;
  
  rep(i,n){
    cout <<i << " " << ans[i] << " " << mat[i][n]<<" " 
	 << fabs(ans[i]-mat[i][n]) << endl;
    if ( fabs(ans[i]-mat[i][n])>eps)cnt++;
  }
  

   
  rep(i,n){
    cout << i <<" " << ans[i] << " " << ans2[i] << " " 
	 << fabs(ans[i]-ans2[i])<<endl;
  }
  
  cout << "number of WA is " << cnt << endl;
}
*/

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//template end

template<unsigned mod>struct mint {
   static int get_mod(){return mod;}
   int val;
   int inv() const{
      int tmp,a=val,b=mod,x=1,y=0;
      while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
      if(x<0)x+=mod; return x;
   }
   mint():val(0){}
   mint(ll x):val(x>=0?x%mod:mod+(x%mod)){}
   mint pow(ll t){mint res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;}return res;}
   mint& operator+=(const mint& x){if((val+=x.val)>=mod)val-=mod;return *this;}
   mint& operator-=(const mint& x){if((val+=mod-x.val)>=mod)val-=mod; return *this;}
   mint& operator*=(const mint& x){val=(ll)val*x.val%mod; return *this;}
   mint& operator/=(const mint& x){val=(ll)val*x.inv()%mod; return *this;}
   mint operator+(const mint& x)const{return mint(*this)+=x;}
   mint operator-(const mint& x)const{return mint(*this)-=x;}
   mint operator*(const mint& x)const{return mint(*this)*=x;}
   mint operator/(const mint& x)const{return mint(*this)/=x;}
   bool operator==(const mint& x)const{return val==x.val;}
   bool operator!=(const mint& x)const{return val!=x.val;}
};
using Mint=mint<1000000007>;
struct factorial {
   vector<Mint> Fact, Finv;
public:
   factorial(int maxx){
      Fact.resize(maxx+1),Finv.resize(maxx+1); Fact[0]=Mint(1); rep(i,0,maxx)Fact[i+1]=Fact[i]*(i+1);
      Finv[maxx]=Mint(1)/Fact[maxx]; rrep(i,maxx,0)Finv[i-1]=Finv[i]*i;
   }
   Mint fact(int n,bool inv=0){if(inv)return Finv[n];else return Fact[n];}
   Mint nPr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[n-r];}
   Mint nCr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[r]*Finv[n-r];}
};

factorial fac(20100000);

int main(){
   int h,w,k; scanf("%d%d%d",&h,&w,&k);
   Mint res=fac.nCr(h+w-2,h-1)*k*(k+1)*(k-1)/3+fac.nCr(h+w,h)*k*(k+3)/2;
   res*=fac.fact(h)*fac.fact(w)*fac.fact(h+w-k,1);
   printf("%d\n",res.val);
   return 0;
}

Measured memory_bytes: 157312
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(c-a)<=d || (abs(b-a)<=d) && (abs(c-b)<=d)){
    cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256