akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>

using namespace std;

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

const int mod=1e9+7;

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    vector<ll> x(n),d(n);
    for(ll i=0;i<n;i++){
        cin >> x[i];
    }
    d[0]=0;
    for(ll i=1;i<n;i++){
        d[i]=x[i]-x[i-1];
    }
    ll ans=0;
    for(ll i=0;i<n;i++){
        ans+=min(a*d[i],b);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next(), ans = "None";
    if(!S.contains("z")) {
      ans = "z";
    }
    if(!S.contains("y")) {
      ans = "y";
    }
    if(!S.contains("x")) {
      ans = "x";
    }
    if(!S.contains("w")) {
      ans = "w";
    }
    if(!S.contains("v")) {
      ans = "v";
    }
    if(!S.contains("u")) {
      ans = "u";
    }
    if(!S.contains("t")) {
      ans = "t";
    }
    if(!S.contains("s")) {
      ans = "s";
    }
    if(!S.contains("r")) {
      ans = "r";
    }
    if(!S.contains("q")) {
      ans = "q";
    }
    if(!S.contains("p")) {
      ans = "p";
    }
    if(!S.contains("o")) {
      ans = "o";
    }
    if(!S.contains("n")) {
      ans = "n";
    }
    if(!S.contains("m")) {
      ans = "m";
    }
    if(!S.contains("i")) {
      ans = "l";
    }
    if(!S.contains("k")) {
      ans = "k";
    }
    if(!S.contains("j")) {
      ans = "j";
    }
    if(!S.contains("i")) {
      ans = "i";
    }
    if(!S.contains("h")) {
      ans = "h";
    }
    if(!S.contains("g")) {
      ans = "g";
    }
    if(!S.contains("f")) {
      ans = "f";
    }
    if(!S.contains("e")) {
      ans = "e";
    }
    if(!S.contains("d")) {
      ans = "d";
    }
    if(!S.contains("c")) {
      ans = "c";
    }
    if(!S.contains("b")) {
      ans = "b";
    }
    if(!S.contains("a")) {
      ans = "a";
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 38616
N = input()
jewelrys = int(N)
value = input().split()
cost = input().split()
maxsum = 0
i = 0

for i in range(0, jewelrys):
    value[i] = int(value[i])
    cost[i] = int(cost[i])
    if(value[i] > cost[i]):
        maxsum += (value[i] - cost[i])

print(maxsum)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<sstream>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    ll a;
    ll b1,b2;
    cin>>a;
    scanf("%lld.%lld",&b1,&b2);
    ll ans = a * (100 * b1 + b2) / 100;
    cout<<ans<<endl;
}

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

using namespace std;

#define fir first
#define sec second
#define ins insert
#define pb push_back
#define po pop_back
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define YES cout << "Yes" << '\n';
#define NO cout << "No" << '\n';

typedef long long ll;

const ll max_n = 1e6 + 10 , Mod = 1e9 + 7 , inf = 1e18;
ll n , four , m_two , tmp , num;

void read_input(){
        cin >> n;
        for(int i = 0 ; i < n ; i++){
                cin >> num;
                
                if(num % 4 == 2)
                        m_two++;
                
                else if(num % 4 == 0)
                        four++;
        }
}

void solve(){
        tmp = n - m_two - four;

        if(m_two){
                if(four >= tmp)
                        YES
                else
                        NO
        }

        else{
                if(four != 0 && ((four + 1) >= tmp))
                        YES
                else
                        NO
        }
}

void output(){
        //no output
}

int main(){
        IOS;
        read_input();
        solve();
        output();
        return 0;
}

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

int main(){
    ll a,b,m; cin >> a >> b >> m;
    vector<ll> f(a);
    vector<ll> mi(b);
    rep(i,a) cin >> f.at(i);
    rep(i,b) cin >> mi.at(i);
    ll fmin = INF, mmin = INF;
    rep(i,a) fmin = min(fmin,f.at(i));
    rep(i,b) mmin = min(mmin,mi.at(i));
    ll ans = fmin + mmin;
    rep(i,m){
        ll x,y,c; cin >> x >> y >> c;
        x--; y--;
        ans = min(ans,f.at(x)+mi.at(y)-c);
    }
    cout << ans << endl;
} 

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define lli long long int


void solve(){
    int n;
    cin>>n;
    int d[n][2];
    for(int i=0;i<n;i++){
        for(int j=0;j<2;j++){
            cin>>d[i][j];
        }
    }
    int tot=0;
    for(int i=0;i<n;i++){
        if(d[i][0]==d[i][1]){
            tot++;
        }else{
            tot=0;
        }
        if(tot==3){
            cout<<"Yes"<<endl;
            return;
        }
    }
    cout<<"No"<<endl;
}

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





Measured memory_bytes: 3628
#include<stdio.h>
main(){

  int tmp,i,j,tr[10000],ans[10000]={};

  for(i=0;;i++){
    if(scanf("%d",&tr[i]) == EOF){
      break;
    }
  }

  tmp=i;

  for(i=0;i<tmp;i++){
    if(tr[i]==0){
      for(j=i-1;j>=0;j--){
	if(tr[j]!=0){
	  ans[i]=tr[j];
	  tr[j]=0;
	  break;
	}
      }
    }
  }

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

Measured memory_bytes: 652
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;
int main(){

    int N;
    cin >>N;
    
    vector<long long> vec(N);

    REP(i,N) cin >> vec[i];
    
    FOR(i,0,N-1){
        long long n=vec[i];
        long long m=vec[i+1];
        if (n<m) swap(n,m);
        long long l=n%m;
        
        while(l!=0){
            n=m;
            m=l;
            l=n%m;
        }
    
        vec[i+1]=(vec[i]/m)*vec[i+1];
        
    }
    cout << vec[N-1]<<endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    int n;
    cin >> n;
    int height = 0;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        if(height < a) height = a;
        else ans += height - a;
    }
    cout << ans << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3560
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int N, M;
LL a[555], imos[555];
long double dp[555][555];

int main(void)
{
	cin >> N >> M;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		imos[i + 1] = imos[i] + a[i];
	}
	for (int i = 0; i < 555; ++i) {
		for (int j = 0; j < 555; ++j) {
			dp[i][j] = -123456789012345678;
		}
	}
	dp[0][0] = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < M; ++j) {
			for (int k = i + 1; k <= N; ++k) {
				long double width = k - i;
				dp[k][j + 1] = max(dp[k][j + 1], dp[i][j] + (long double)(imos[k] - imos[i]) / width);
			}
		}
	}
	cout.precision(15);
	long double ans = 0.;
	for (int i = 1; i <= M; ++i) {
		ans = max(ans, dp[N][i]);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 8100
#include<cstdio>
#include<map>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(){
	int n;cin>>n;
	int l,r,cnt,ans=0;
	REP(i,n){
		cin>>l>>r;
		cnt=r-l+1;
		ans+=cnt;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
int main(void){
    int w,n,a,b;
    int num[31];
    int i;
    int tmp;
    
    for(i=0; i<=30; i++){
        num[i] = i;
    }
    
    scanf("%d",&w);
    scanf("%d",&n);
    
    for(i=1; i<=n; i++){
        scanf("%d,%d",&a,&b);
        tmp=num[a];
        num[a]=num[b];
        num[b]=tmp;
    }
    
    for(i=1; i<=w; i++){
        printf("%d\n",num[i]);
    }
    
    return 0;
}

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

void change_Small_Word(string &s, int N){
    
    for(int i = 0; i < N; i++){
        bool b = isupper(s[i]);
        if(b){
            s[i] = tolower(s[i]);
        }
    }
    
}


int main(void){
    
    string str, word;
    cin >> str;
    change_Small_Word(str, str.size());
    
    int ans = 0;
    while(true){
        cin >> word;
        if(word == "END_OF_TEXT") { break; }
        change_Small_Word(word, word.size());
        if(str == word){ ans++; }
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{
	int a, b; cin >> a >> b;
	int ans = max(0,a-2*b);
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")  
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl "\n"
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define mem(z,i) memset(z,i,sizeof(z))
#define eps 1e-7
#define I (int)
const int mod=(int)1e9+7;
const long long INF = 1000000000000000000LL;
//const int WASTE=∞;
//#define int long long
int power(int a,int b,int m){
	int i=1;
	while(b){
		if(b%2)
			i=(i*a)%mod;
		b/=2;
		a=(a*a)%mod;
	}
	return i;	
}
const int N=1e5+5;
ll highestPowerof2(ll n) 
{ 
   ll p = (ll)log2(n); 
   return (ll)pow(2, p);  
} 
signed main() {
	ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    ll n;
    cin>>n;
    unsigned  long long ans=0;
    n=highestPowerof2(n);
    while(n){
    	ans+=n;
    	n/=2;
    }
    cout<<ans;
	return 0;
}

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

const long long MOD = 998244353;

long long powp(long long a, long long b, long long p){
	if(b == 0) return 1;
	if(b%2 == 0){
		long long c = powp(a, b/2, p);
		return (c*c)%p;
	}
	else{
		return (a*powp(a, b-1, p))%p;
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	long N;
	cin >> N;
	map<long long, long long> cnt;
	int s; cin >> s;
	if(s != 0){
		cout << 0 << endl;
		return 0;
	}
	for(int i = 1; i < N; i++){
		long long d; cin >> d;
		cnt[d]++;
	}
	long long ans = 1LL;
	long long pre = 1LL;
	bool zero = false;
	int q = 0;
	for(auto p : cnt){
		if(p.first != q+1){
			zero = true;
			break;
		}
		ans *= powp(pre, p.second, MOD);
    	ans %= MOD;
		pre = p.second;
        q++;
	}
	if(zero) cout << 0 << endl;
	else cout << ans << endl;
	return 0;
}


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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;

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

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

int main() {
  ll N,M;
  cin>>N>>M;
  vector<ll> mo(N);
  for(ll i = 0LL; i < N; i++) {
    ll x;
    cin>>x;
    if(i==0LL) mo[i]=x%M;
    else mo[i]=(mo[i-1]+x)%M;
  }
  sort(mo.begin(),mo.end());
  ll ans = 0LL;
  ll k = 0LL;
  for(ll i = 0LL; i < N;i++){
    k++;
    if(i==N-1LL||mo[i]!=mo[i+1LL]){
      if(mo[i]==0LL)ans+=(k+k*(k-1LL)/2LL);
      else ans+=(k*(k-1LL)/2LL);
      k=0LL;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
using ll = long long;
using namespace std;
int main(){
    bool color[8];
    int n,x,cnt=0,ans=0;
    cin >> n;
    for(int i=0;i<8;i++)    color[i]=false;
    for(int i=0;i<n;i++){
        cin >> x;
        if(x>=3200) cnt++;
        else    color[x/400]=true;
    }
    for(int i=0;i<8;i++){
        if(color[i]==true)    ans++;
    }
    cout << max(1,ans) << " " << ans+cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)


template<class T>
void show_1d_vector(const vector<T> &v){
    for(auto v1: v) {
        cout << v1 << " ";
    }
    cout << endl;
}


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> even(n/2);
    vector<int> odd(n/2);
    map<int,int> am;
    map<int,int> evenm;
    map<int,int> oddm;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        am[a[i]]++;
    }

    for(int i = 0; i < n; i++){
        if(i%2==1){
            even[i/2] = a[i];
            evenm[a[i]]++;
        }
        else{
            odd[i/2] = a[i];
            oddm[a[i]]++;
        }
    }
    if(am.size()==1){
        cout << n/2 << endl;
        return 0;
    }

    int evenmax = 0, evenkey = -1;
    for(auto itr = evenm.begin(); itr != evenm.end(); ++itr){
        if(evenmax < itr->second){
            evenmax = itr->second;
            evenkey = itr->first;
        }
    }

    int oddmax = 0, oddkey = -1;
    for(auto itr = oddm.begin(); itr != oddm.end(); ++itr){
        if(oddmax < itr->second){
            oddmax = itr->second;
            oddkey = itr->first;
        }
    }

    int evenmax2, oddmax2;
    if(evenkey == oddkey){
        int forbidden = oddkey;
        oddmax2 = 0;
        for(auto itr = oddm.begin(); itr != oddm.end(); ++itr){
            if(oddmax2 < itr->second && itr->first != forbidden){
                oddmax2 = itr->second;
            }
        }

        forbidden = evenkey;
        evenmax2 = 0;
        for(auto itr = evenm.begin(); itr != evenm.end(); ++itr){
            if(evenmax2 < itr->second && itr->first != forbidden){
                evenmax2 = itr->second;
            }
        }
        if(evenm.size()==1){
            int ans = odd.size() - oddmax2;
            cout << ans << endl;
            return 0;
        }
        if(oddm.size()==1){
            int ans = even.size() - evenmax2;
            cout << ans << endl;
            return 0;
        }

        int ans1 = even.size() - evenmax + odd.size() - oddmax2;
        int ans2 = even.size() - evenmax2 + odd.size() - oddmax;
        cout << min(ans1,ans2) << endl;
        return 0;

    }else{
        int ans = even.size() - evenmax + odd.size() - oddmax;
        cout << ans << endl;
        return 0;
    }



}


Measured memory_bytes: 10368
#include <iostream>
std::string m[12];
void d(int x,int y){
	if(x>0&&m[y][x-1]-48)m[y][x-1]=48,d(x-1,y);
	if(x<11&&m[y][x+1]-48)m[y][x+1]=48,d(x+1,y);
	if(y>0&&m[y-1][x]-48)m[y-1][x]=48,d(x,y-1);
	if(y<11&&m[y+1][x]-48)m[y+1][x]=48,d(x,y+1);
	return ;
}
main(){
	while(1){
		int y=12;
		for(;y;y--)std::cin>>m[y-1];
		if(std::cin.eof())return 0;
		int r = 0;
		for(y=0;y<12;y++)for(int x=0;x<12;x++)if(m[y][x]-48)r++,m[y][x]=48,d(x,y);
		std::cout<<r<<'\n';
	}
}

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

const int N=2e3+10;


const int inf=2e9;
using ll=long long;


int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin.exceptions(cin.failbit);
    int x;
    cin>>x;
    cout<<360/__gcd(x,360);

}

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



void solve(long long N, std::vector<long long> a){
    ll sum=0;
    for(auto &&elm : a) {
        sum ^= elm;
    }
    for(ll i=0; i<N; i++) {
        cout << (a[i]^sum);
        cout << (i==N-1?"\n":" ");
    }
}

signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 4848
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        string s = ReadLine();
        if (s.Distinct().Count() == 2)
            WriteLine("Yes");
        else
            WriteLine("No");
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  string s;cin >> s;
  string target = "keyence";
  if(s==target){
  	cout << "YES" << endl;
  	return 0;
  }
  bool isfound = false;
  for(int i=0;i<7; ++i){
    string sub = s.substr(i,s.size()-7);
    string tmp = s;
    tmp.replace(i,sub.size(), "");
    if(tmp == target){
      isfound = true;
      break;
    }
  }
  if(isfound){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
int n;
ll x[maxn], s[maxn];
ll dp[maxn];
int main(){
//    freopen("e:\\in.txt","r",stdin);
    while(cin>>n){
        for(int i = 0; i < n; i++)cin>>x[i]>>s[i];
        dp[0] = s[0];
        ll ans = dp[0];
        for(int i = 1; i < n; i++){
            dp[i] = max(dp[i - 1] + s[i] - x[i] + x[i - 1], s[i]);
            ans = max(ans, dp[i]);
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 4992
import java.util.Scanner;

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

        long A = sc.nextInt();
        long B = sc.nextInt();

        for(int i = 10; i < 1010; i++) {
            if((int)(i * 0.08) == A && (int)(i*0.1) == B) {
                System.out.println(i);
                return;
            }
        }
        System.out.println("-1");

    }

}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N , l , r , A = 0;
  cin >> N;
 
  for(int i = 0; i < N; i++){
	cin >> l >> r;
    A+=(r-l)+1	;
 }
  
  if ( A < 100000 )
  cout << A;
  
  else 
    cout  << 100000;
	
}

Measured memory_bytes: 256
a = list(map(int, input().split()))
cnt = 0 
a.sort()
if a[2] > a[1]:
        cnt += a[2] - a[1]
        a[1] += cnt 
        a[0] += cnt 
if a[1] > a[0]:
        if (a[1] % 2 == 0) ^ (a[0] % 2 == 0): 
                cnt += (a[1] + 1 - a[0]) // 2 + 1 
        else:
                cnt += (a[1] - a[0]) // 2
print(cnt)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		// スペース区切りの整数の入力
		int m = sc.nextInt();
		int x = sc.nextInt();

		int[] a = new int[n + 1];
		int pn = 0;
		int p0 = 0;
		for (int i = 0; i < m; i++) {
			a[i] = sc.nextInt();
			if (x > a[i]) {
				p0++;
			} else if (x < a[i]) {
				pn++;
			}
		}
		if (pn >= p0) {
			System.out.println(p0);

		} else {
			System.out.println(pn);
		}
	}
}


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

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define scn(var)         cin >> var;
#define pYes()           prt("Yes")
#define pNo()            prt("No")
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

//----------------------------------------------------

int main(){
    ll a, b, c, k, ans = 0;
    cin >> a >> b >> c >> k;
    if(a >= k){
        cout << k << endl;
        return 0;
    }else {
        ans += a;
        ll tmp = k - a;
        if(b >= tmp){
            cout << ans << endl;
        }else{
            ll tmp2 = tmp - b;
            ans -= tmp2;
            cout << ans << endl;
        }
    }


}

Measured memory_bytes: 3624
n = gets.to_i
t1 = 1 #0-9
t2 = 1 #1-8
t3 = 1 #1-9 or 0-8
mod = 10**9 + 7
for i in 0...n
  t1 *= 10
  t2 *= 8
  t3 *= 9
  t1 %= mod
  t2 %= mod
  t3 %= mod
end
ans = t1 - t2 - (t3-t2) * 2

ans %= mod

puts ans

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

int main() {
 int N,K;
  cin>>N>>K;
  vector<int> ten(N);
  for(int i=0;i<N;i++){
    cin>>ten.at(i);
  }
  
  for(int i=K; i<N;i++){
    if(ten.at(i)-ten.at(i-K)>0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }

}

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

int main() {
	long long h;
	cin >> h;
	long long total = 2;
	while (h != 1) {
		h /= 2;
		total *= 2;
	}
	
	cout << total - 1 << '\n';
	
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]

def is_same(si, sj, A, B):
     for i in range(M):
          for j in range(M):
               if A[si+i][sj+j] != B[i][j]:
                    return False
     return True

def main():
     for i in range(N-M+1):
          for j in range(N-M+1):
               if is_same(i,j, A, B):
                    return True
     return False

if main():
     print("Yes")
else:
     print("No")


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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
  ll a, b, c, k, x;
  cin >> a >> b >> c >> k;
  if (k % 2 == 0)
	x = a - b;
  else
	x = b - a;
  cout << x << endl;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	var line = input.split("\n");
	var N = Number(line[0]);
	var X = line[1].split(" ");

	var Y = X.slice().sort(function(a, b){
		return Number(a) - Number(b)
	});

	var median = [Number(Y[(N/2 - 1)]), Number(Y[N/2])];

	for(var i = 0; i < X.length; i++){
		if(median[1] <= Number(X[i])){
			console.log(median[0] + "\n");
		}else{
			console.log(median[1] + "\n");
		}
	}
	return 0;

}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int mod = 1e9 + 7;

ll modinv(ll a, ll m) {
  ll b = m;
  ll u = 1;
  ll v = 0;
  
  while (b > 0) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  
  u %= m;
  if (u < 0) u += m;
  return u;
}

int main() {
  int X, Y;
  cin >> X >> Y;
  
  if (X * 2 - Y < 0 || Y * 2 - X < 0 || (2 * X - Y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  
  ll a = (2 * Y - X) / 3;
  ll b = (2 * X - Y) / 3;
  
  ll ans = 1;
  for (int i = 0; i < a; i++) {
    ans *= a + b - i;
    ans %= mod;
  }
  
  for (int i = 1; i <= a; i++) {
    ans *= modinv(i, mod);
    ans %= mod;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        String[] ary = new String[k];
        for (int i = 0; i < k; i++) {
            String a = sc.next();
            ary[i] = a;
        }
        first : for (int i = n; i < 100000; i++) {
            String nStr = String.valueOf(i);
            for (String str : ary) {
                if (nStr.contains(str)) {
                    continue first;
                }
            }
            System.out.println(i);
            break;
        }
    }
}

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

string s;

int main()
{
	cin >> s;
	cout << s.substr(0, s.size() - 8) << endl;
	return 0;
}

Measured memory_bytes: 256
H,W=gets.chomp.split.map(&:to_i)
s=[]
H.times {s << gets.chomp.split("")}

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

visited = Array.new(H).map{Array.new(W,false)}

queue = []

ans = 0
(0...H).each do |i|
  (0...W).each do |j|
    next if visited[i][j] == true
    b = 0
    w = 0

    queue << [i,j]
    visited[i][j] = true
    b += 1 if s[i][j] == '#'
    w += 1 if s[i][j] == '.'
    while(queue.size > 0) do
#      p queue
      pos = queue.pop
      (0..3).each do |ci|
        ii = pos[0]+di[ci]
        jj = pos[1]+dj[ci]
        next if ii < 0 || ii >= H
        next if jj < 0 || jj >= W
        next if visited[ii][jj]

        if s[pos[0]][pos[1]] != s[ii][jj]
#          printf("%s %s\n", s[pos[0]][pos[1]], s[ii][jj])
          queue << [ii,jj]
          visited[ii][jj] = true
          b += 1 if s[ii][jj] == '#'
          w += 1 if s[ii][jj] == '.'
        end
      end
    end
#    printf("%d %d\n", b, w)
    ans += b * w
  end
end
puts ans

Measured memory_bytes: 20476
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, 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)

using namespace std;

typedef pair<int, int> P;

class BTournament {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    vector<vector<int>> G;

    int dfs(int v) {

        vector<int> d;
        REP(i, G[v].size()) {
            d.push_back(dfs(G[v][i]));
        }
        sort(d.rbegin(), d.rend());

        int res = 0;
        REP(i, d.size()) {
            res = max(res, i + d[i] + 1);
        }
        return res;
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        G.resize(N);

        REP(i, N - 1) {
            int a;
            cin >> a;
            a--;
            G[a].push_back(i + 1);
        }

        int res = dfs(0);
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BTournament solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 13568
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}
ll mod = 1e9 + 7;
ll A0[62];
ll A1[62];
int main() {
	ll N, M, K;
	cin >> N >> M >> K;
	rep(i, N + 1) {
		rep(j, M + 1) {
			if (i * M + j * N -2* i * j == K) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
	int n;
	int m;
	cin >> n;
	for(int i=1;i<=n;i++){
		if(i*(i+1)/2>=n){
			m = i;
			break;
		}
	}
	int x = m*(m+1)/2-n;
	for(int i=1;i<=m;i++){
		if(i!=x){
			cout << i << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import bisect

n = int(input())
A = list(map(int, input().split()))
q = int(input())

for i in range(q):
    query = int(input())
    lower = bisect.bisect_left(A, query)
    upper = bisect.bisect_right(A, query)

    print("{} {}".format(lower, upper))


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


int main(){
  long long A,B,r;
  cin>>A>>B;
  r=A%B;
  
  while(r !=0){
    A=B;
    B=r;
    r=A%B;
  }
  
  long long x=B;
  long long ws=1;
  for(long i=2; i*i<=x; i++){
    if(B%i ==0){
      while(B%i ==0) B=B/i;
      ws++;
    }
  }
  if(B !=1) ws++;
  
  cout<<ws<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int N;	//問題数
    int[] T;	//解答にかかる時間
    int M;	//ドリンクの種類数
    int[] P;	//ドリンクに対応する問題
    int[] X;	//ドリンクを飲んだ時のPの解答にかかる時間
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.N = sc.nextInt();
        T = new int[N];
        for (int i=0; i<N; i++) {
        	T[i] = sc.nextInt();
        }
        this.M = sc.nextInt();
        P = new int[M];
        X = new int[M];
        for (int i=0; i<M; i++) {
        	P[i] = sc.nextInt();
        	X[i] = sc.nextInt();
        }
    }
    
    //解答処理
    private int[] solve() {
    	int sum = 0;	//ドリンクを飲まなかったときの解答時間の総和
    	for (int i=0; i<N; i++) {
    		sum += T[i];
    	}
    	
        int[] total = new int[M];
        for (int i=0; i<M; i++) {
        	total[i] = sum - T[P[i]-1] + X[i];
        }
        
        return total;
    }
    
    //出力
    public void show(int[] answer) {
    	for (int i=0; i<answer.length; i++) {
    		System.out.println(answer[i]);   		
    	}
    }

}


Measured memory_bytes: 36260
#include <stdio.h>

int main(){
    int N, Array[250];
    scanf("%d\n",&N);
    for (int ix = 0 ; ix < N ; ix++){
        if ( ix == N-1) scanf("%d\n",&Array[ix]);
        else scanf("%d ",&Array[ix]);
    }
    for (int ix = 0 ; ix < N ; ix++){
        printf("node %d: key = %d, ",ix+1,Array[ix]);
        if (ix != 0) printf("parent key = %d, ",Array[((ix+1)/2)-1]);
        if (2*(ix+1) <= N) printf("left key = %d, ",Array[2*(ix+1)-1]);
        if (2*(ix+1)+1 <= N) printf("right key = %d, ",Array[2*(ix+1)]);
        printf("\n");
    }
    
    return 0;
}



Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
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;}
#define MOD 1000000007ll // prime
// How to devide :
// ModInt a(6ll);
// ModInt b(2ll);
// a *= b.exp(MOD-2ll);  -> a/=b;  result: a = 3
struct ModInt{
	ll val;
	ModInt():val(0ll){}
	ModInt(ll v):val(((v%MOD)+MOD)%MOD){}
	ModInt exp(ll y)const{
		if(!y)return ModInt(1ll);
		ModInt a = exp(y/2ll);
		a *= a;
		if(y&1)a*=(*this);
		return a;
	}
	bool operator==(const ModInt& x)const{return val==x.val;}
	inline bool operator!=(const ModInt& x)const{return !(*this==x);}
	bool operator<(const ModInt& x)const{return val<x.val;}
	bool operator>(const ModInt& x)const{return val>x.val;}
	inline bool operator>=(const ModInt& x)const{return !(*this<x);}
	inline bool operator<=(const ModInt& x)const{return !(*this>x);}
	ModInt& operator+=(const ModInt& x){if((val+=x.val)>=MOD)val-=MOD;return *this;}
	ModInt& operator-=(const ModInt& x){if((val+=MOD-x.val)>=MOD)val-=MOD;return *this;}
	ModInt& operator*=(const ModInt& x){(val*=x.val)%=MOD;return *this;}
	ModInt operator+(const ModInt& x)const{return ModInt(*this)+=x;}
	ModInt operator-(const ModInt& x)const{return ModInt(*this)-=x;}
	ModInt operator*(const ModInt& x)const{return ModInt(*this)*=x;}
};
istream& operator>>(istream&i,ModInt&x){i>>x.val;return i;}
ostream& operator<<(ostream&o,const ModInt&x){o<<x.val;return o;}
ModInt pow(ModInt a,ll x){
	ModInt res = ModInt(1ll);
	while(x){
		if(x&1)res *= a;
		x >>= 1;
		a = a*a;
	}
	return res;
}
const int SIZE = 200100;
ModInt inv[SIZE+10],fac[SIZE+10],facinv[SIZE+10];
// notice: 0C0 = 1 
ModInt nCr(int n,int r){
	assert(!(n<r));
	assert(!(n<0||r<0));
	return fac[n]*facinv[r]*facinv[n-r];
}
void init(){
	fac[0]=ModInt(1ll);
	for(int i=1;i<=SIZE;i++)fac[i]=fac[i-1]*ModInt(i);
	inv[1]=ModInt(1ll);
	for(int i=2;i<=SIZE;i++)inv[i]=ModInt(0ll)-ModInt(MOD/i)*inv[MOD%i];
	facinv[0]=ModInt(1ll);
	for(int i=1;i<=SIZE;i++)facinv[i]=facinv[i-1]*inv[i];
	return;
}
string L;
ModInt rec(int pos){
	if(pos==L.size()){
		return ModInt(1ll);
	}
	if(L[pos]=='0'){
		return rec(pos+1);
	}else{
		int n = L.size()-pos-1;
		return rec(pos+1)*ModInt(2ll)+pow(ModInt(3ll),n);
	}
}
int main(){
	init();
	cin >> L;
	cout << rec(0) << endl;
    return 0;
}

Measured memory_bytes: 8320
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <utility>
#include <string>
using namespace std;
#define N 200000
#define INF 2000000000

class Queue
{
  private:
    pair<string, int> q[N];
    int head;
    int tail;

  public:
    Queue()
    {
        head = tail = 0;
        for (int i = 0; i < N; i++)
        {
            q[i].first = "";
            q[i].second = INF;
        }
    }
    bool isEmpty()
    {
        if(head==tail)
            return true;
        else
            return false;
    }
    void enqueue(pair<string, int> x)
    {
        q[tail++] = x;
    }
    pair<string, int> dequeue()
    {
        return q[head++];
    }
};

int main(void)
{
    int n, q;
    cin >> n >> q;
    Queue Q;
    string name;
    int time;
    for (int i = 0; i < n; i++)
    {
        cin >> name >> time;
        Q.enqueue(make_pair(name, time));
    }
    
    pair<string, int> p;
    int t = 0;
    while(!Q.isEmpty())
    {
        p = Q.dequeue();
        t += min(q, p.second);
        p.second -= q;
        if(p.second>0)
            Q.enqueue(p);
        else
            cout << p.first << " " << t << "\n";
    }
    return 0;
}



Measured memory_bytes: 8524
#include <stdio.h>

int GCD(int a, int b) {
	int tmp;
	if (b > a) {
		tmp = a;
		a = b;
		b = tmp;
	}

	

	while (b != 0) {
		tmp = a % b;
		a = b;
		b = tmp;
	}

	return a;
}

int LCM(int a, int b, int r) {
	return a / r * b;
}

int main(void) {
	int a, b;
	int tmp;
	while (scanf("%d %d", &a, &b) != EOF) {
		tmp = GCD(a, b);
		printf("%d %d\n", tmp, LCM(a, b, tmp));
	}
	
	return 0;
}

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

int main() {
	int n,max,min;
	long long sum;
	cin >> n;
	for(int i=0; i<n; i++){
		int x;
		cin >> x;
		if(i==0){
			max = x;
			min = x;
			sum = x;
		}else{
			if(x>max) max=x;
			if(x<min) min=x;
			sum+=x;
		}
	}
	cout << min << " " << max << " " << sum <<endl;
	return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=998244353;
const LL LINF=1LL<<60;
const int INF=1<<30;





int main(){
    int H,W,h,w;cin >> H >> W >> h >> w;
    if(H%h==0&&W%w==0){
        puts("No");
        return 0;
    }
    puts("Yes");
    if(W%w==0){
        vector<int> s(H+1,501);
        s[0] = 0;
        for (int i = 0; i <= H; i++) {
            if(i+h<=H) s[i+h] = s[i] - 1;
        }
        for (int i = 1; i <= H; i++) {
            for (int j = 1; j <= W; j++) {
                cout << s[i] - s[i-1] << (j==W?"\n":" ");
            }
        }
    }
    else{
        vector<int> s(W+1,501);
        s[0] = 0;
        for (int i = 0; i <= W; i++) {
            if(i+w<=W) s[i+w] = s[i] - 1;
        }
        for (int i = 1; i <= H; i++) {
            for (int j = 1; j <= W; j++) {
                cout << s[j] - s[j-1] << (j==W?"\n":" ");
            }
        }
    }
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    int tall = a[0];
    rep(i, n){
        if(a[i]<tall){
            ans += tall - a[i];
        }
        tall = max(tall, a[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4052
#include <iostream>

using namespace std;

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

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

  int max = a[0][0] + sum;
  int tmp = max;
  
  for(int i = 1; i<n; i++){
    tmp = tmp + a[0][i] - a[1][i-1];
    if(max < tmp)
      max = tmp;
  }

  cout << max;
  return 0;
}


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

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

  while (t--){
    int maxh=0, minh=0;
    int n, a, b;
    cin >> n >> a;
    for (int i = 1; i < n; i++){
      cin >> b;
      maxh = max(b - a, maxh);
      minh = min(b - a, minh);
      a = b;
    }
    cout << maxh << " " << -minh << endl;
  }
}

Measured memory_bytes: 3076
import heapq

n, m = map(int, input().split())
# pythonのheapqは最小値しか取り出せないので−1をかける
a = list(map(lambda x: -1*int(x), input().split()))
# heapqへ
heapq.heapify(a)
for i in range(m):
    tmp = heapq.heappop(a)
    tmp *= -1
    x = tmp // 2 * -1
    heapq.heappush(a, x)

print(-sum(a))

Measured memory_bytes: 20464
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;

ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
	}
	
	mod& operator=(const ll & tx) {
		x = tx;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return (x + m2.x) % MOD;
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return (x - m2.x + MOD) % MOD;
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return (x * m2.x) % MOD;
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return mod(((*this).x * (*this).inv().x) % MOD);
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}

/* TEMPLATE ENDS HERE */

int main() {
	cout << fixed << setprecision(12);	
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	int ret = 1;
	for (int i = 0; i < n - 1; i++) {
		if (s[i] != s[i + 1]) {
			ret++;
		}
	}
	while (k && (ret > 2)) {
		ret -= 2;
		k--;
	}
	if (k && (ret == 2)) {
		ret--;
	}
	cout << n - ret << endl;
	return 0;
}


Measured memory_bytes: 3732
import sys
# sys.setrecursionlimit(100000)


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


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    A = sorted(input_int_list())
    ans_a = A[-1]
    ans_b = A[0]
    for a in A:
        tmp = a
        if tmp > ans_a - a:
            tmp = ans_a - a
        if tmp > ans_b:
            ans_b = a
    print(ans_a, ans_b)

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 84696
#include<bits/stdc++.h>
using namespace std;
struct line{
	int u,v;
}l[100005];
int b[100005],use[100005];
int n,m,fa[100005];
int x,y,xx;
int fir[100005],nxt[200005],to[200005],cnt,pc[200005];
int deg[100005];
int fi[100005][20];
int k[100005];

int find(int x){
	if(x==fa[x]) return x;
	return fa[x]=find(fa[x]);
}

void kruskal(){
	for(int i=1;i<=m;i++){
		x=find(l[i].u);
		y=find(l[i].v);
		if(x==y) continue;
		if(x<y) fa[y]=x;
		else fa[x]=y;
		to[++cnt]=l[i].v,nxt[cnt]=fir[l[i].u],fir[l[i].u]=cnt,pc[cnt]=i;
		to[++cnt]=l[i].u,nxt[cnt]=fir[l[i].v],fir[l[i].v]=cnt,pc[cnt]=i;
		use[i]=1;
	}
	for(int i=1;i<=m;i++){
		if(use[i]==0) deg[l[i].u]^=1,b[i]=0;
	}
}

void dfs(int x,int f){
	for(int i=fir[x];i;i=nxt[i]){
		if(to[i]==f) continue;
		if(l[pc[i]].v!=to[i]) b[pc[i]]=1;
		else b[pc[i]]=0;
		deg[x]^=1;
		k[to[i]]=pc[i];
		dfs(to[i],x);
	}
}

void Dfs(int x,int f){
	for(int i=fir[x];i;i=nxt[i]){
		if(to[i]==f) continue;
		Dfs(to[i],x);
		if(deg[to[i]]){
			deg[to[i]]^=1;
			deg[x]^=1;
			b[k[to[i]]]^=1;
		}
	}
}

int main(){
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=1;i<=m;i++){
		scanf("%d %d",&l[i].u,&l[i].v);
	}
	kruskal();
	dfs(1,0);
	Dfs(1,0);
	if(deg[1]==1){
		printf("-1\n");
		return 0;
	}
	for(int i=1;i<=m;i++){
		if(b[i]==1) printf("%d %d\n",l[i].v,l[i].u);
		else printf("%d %d\n",l[i].u,l[i].v);
	}
	
	return 0;
}

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

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    int N, M;
    ll K;
    cin >> N >> M >> K;
    vector<ll> A(N), B(M);
    for (int i=0; i<N; ++i) {
        cin >> A[i];
    }
    vector<ll> cb(M+1, 0);
    int mx = 0;
    for (int i=0; i<M; ++i) {
        cin >> B[i];
        cb[i+1] = cb[i] + B[i];
        if (cb[i+1] <= K) mx = i+1;
    }
    cb.push_back(LLONG_MAX);

    ll time = 0;
    for (int i=0; i<N; ++i) {
        time += A[i];
        if (time > K) break;
        int j = upper_bound(cb.begin(), cb.end(), K - time) - cb.begin();
        mx = max(mx, i+j);
    }
    cout << mx << endl;

    return 0;
}

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

int main(){
    string a,b;
    cin>>a>>b;
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    if(a<b){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
}


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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;
//const int MOD = (int) 1e9 + 7;
const int MOD = (int) 998244353;
const int maxn = (int) 2e5 + 20;
const int maxm = (int) 1e6 + 20;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL MOD)
{
    if(n < 0) a = fp(a, MOD - 2, MOD), n = -n;
    LL res = 1; for(; n; n >>= 1, a = a * a % MOD) if(n & 1) res = res * a % MOD; return res;
}

void work()
{
    int x;
    cin >>x;
    int ans = 0;
    ans += 1000 * (x / 500);
    x %= 500;
    ans += 5 * (x / 5);
    cout <<ans <<endl;
}


int main(int argc, char **argv)
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
//    pre();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  int N; cin >> N;
  int cnt = 0;
  for (int i = 1; i <= N; ++i) {
    int keta = log10(i) + 1;
    if (keta % 2  ==  1) ++cnt;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3932
i;main(n){
	char s[20];
	int r = 999;
	gets(s);
	for (;i<9;i++) {
		char t[] = {s[i],s[i+1],s[i+2]};
		n=abs(753-atoi(t));
		r=n<r?n:r;
	}
	printf("%d\n", r);
}

Measured memory_bytes: 128