akhauriyash/Code-Regression huggingface dataset:
N=int(input())
S=input()
cur=0
lis=["" for i in range(N)]
lis[cur]=S[0]
for c in S[1:]:
	ss=lis[cur]
	if c==".":
		lis[cur]=ss+"."
	else:
		if ss[-1]=="#":
			lis[cur]=ss+"#"
		else:
			cur+=1
			lis[cur]="#"
def counting(sss):
	curb=sss.find("#")
	curw=sss.rfind(".")
	return tuple([sss[:curw+1].count("#"),sss[curb:].count(".")])

c=0
lasc=0
kugi=[]
for l in lis:
	if l=="":
		break
	else:
		ka=counting(l)
		c+=ka[0]
		kugi.append(ka)
lasc=c
for w,b in kugi[::-1]:
	c=c-w+b
	if c<lasc:
		lasc=c
print(lasc)


Measured memory_bytes: 18664
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
s = input()

slis = list(s)
slis = slis[:-1]

ans = len(s)

while len(slis) > 0:
    if len(slis)%2 == 1:
        slis = slis[:-1]
        continue
    else:
        slicenum = len(slis)//2
        if slis[:slicenum] == slis[slicenum:]:
            ans = len(slis)
            break
        else:
            slis =slis[:-1]
            continue
    
print(ans)
# print("{:.10f}".format(ans))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <numeric>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int a,b,c,x;
    cin >> a >> b >> c;
    if(a==b) x=c;
    else if(b==c) x=a;
    else x=b;
    cout << x << endl;
}


Measured memory_bytes: 256
s = input()
a_idx = None
for i, c in enumerate(list(s)):
    if c == 'A':
        a_idx = i
        break
z_idx = None
for i, c in enumerate(reversed(list(s))):
    if c == 'Z':
        z_idx = len(s) -i
        break
print(len(s[a_idx:z_idx]))

Measured memory_bytes: 10484
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

    ll n; cin >>n;
    vector<ll> nump(n+10, 0);

    for (ll j = 2; j <= n; j++) {
        ll m = j;
        for (ll i = 2; i*i <= j; i++) {
            while (m % i == 0) {
                nump[i] += 1;
                m /= i;
            }
        }
        if (m != 1) {
            nump[m] += 1;
        }
    }

    ll ans = 1;
    for (ll i = 0; i < n+10; i++) {
        if (nump[i]) {
             ans *= (nump[i]+1);
        }
        ans %= MODLL; 
    }

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




Measured memory_bytes: 256
from heapq import heappush, heappop,heapify
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
x = []
s = 0
s += a[0]
heappush(x,-a[1])
heappush(x,-a[1])
for i in range(2,n):
  y = heappop(x)
  s -= y
  heappush(x,-a[i])
  heappush(x,-a[i])
print(s)
          

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

using namespace std;

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string a;
		cin >> a;
		if (a.substr(0, 2) == ">'") {
			int counter = 0;
			bool hantei = false;
			int i;
			for (i = 2; i < a.size(); i++) {
				if (a[i] == '=') {
					counter++;
				} else if (a[i] == '#' && counter > 0) {
					hantei = true;
					break;
				} else {
					hantei = false;
					break;
				}
			}
			if (hantei) {
				int j;
				for (j = i+1; j < a.size(); j++) {
					if (a[j] == '=') {
						counter--;
					} else if (a[j] == '~') {
						hantei = true;
						break;
					} else {
						hantei = false;
						break;
					}
				}
				if (hantei) {
					if (counter == 0 && j == a.size()-1) {
						cout << 'A' << endl;
					} else {
						cout << "NA" << endl;
					}
				} else {
					cout << "NA" << endl;
				}
			} else {
				cout << "NA" << endl;
			}
		} else if (a.substr(0, 2) == ">^") {
			int i;
			bool hantei = false;
			for (i = 2; i < a.size()-1; i += 2) {
				if (a.substr(i, 2) == "Q=") {
					hantei = true;
				} else if (a.substr(i, 2) == "~~" && i == a.size()-2 && hantei) {
					hantei = true;
					break;
				} else {
					hantei = false;
					break;
				}
			}
			if (hantei) {
				cout << 'B' << endl;
			} else {
				cout << "NA" << endl;
			}
		}else {
			cout << "NA" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1216
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int l = sc.nextInt();
    int r = sc.nextInt();
    int d = sc.nextInt();
    int count = 0;
    for (int i = l; i < r+1; i++) {
      if (i % d == 0) count++;
    }
    System.out.println(count);
  }
}


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

#define ll long long

using namespace std;

const int maxn = 1e5+50;

int main()
{
    ll ans = 0;
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    if (2*c < a + b)
    {
        int tmp = min(x, y);
        ans += tmp * c * 2;
        x -= tmp;
        y -= tmp;
    }
    else
    {
        ans += x*a + y*b;
        x = y = 0;
    }
    ans += x * min(2*c, a);
    ans += y * min(2*c, b);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std;
typedef long long LL;
const int maxn = 1e6 + 5;
LL a[maxn];
int n;

void Find(int n)
{
	a[0] = 2, a[1] = 1;
	for(int i = 2; i <= n; i ++) a[i] = a[i-1] + a[i-2];
	cout<< a[n] <<endl;
}

int main()
{
	cin>>n;
	Find(n);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,K;
    string S;
    cin >>K>>S;
    N = S.size();
    if(K>=N){
        cout<<S<<endl;
    }else{
        rep(i,K){
            cout<<S[i];
        }
        cout<<"..."<<endl;
    }




    return 0;
    

}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int A, B, X;
    cin >> A >> B >> X;
    if (X - A < B && A <= X)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}


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

int main() {
	int pas[3];
	int jui[2];
	for (int i = 0; i < 3; i++) {
		cin >> pas[i];
	}
	for (int i = 0; i < 2; i++) {
		cin >> jui[i];
	}
	sort(pas, pas + 3);
	sort(jui, jui + 2);

	int a = pas[0] + jui[0] - 50;
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 3140
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
//#define iinf (3000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int main(){
	std::ios::sync_with_stdio(false);
	int n,c,i,C=0,c1,s,t,j,maxx=-100;
	cin>>n>>c;
	vector <vii >se(31);
	vii v;
	rep(i,n){
		cin>>s>>t>>c1;
		c1--;
		se[c1].pb(mp(s,t));
	}
	//return 0;
	rep(i,c){
		sort(all(se[i]));
		if(se[i].empty())
			continue;
		if(se[i].size()>0){
			v.pb(mp(se[i][0].ff,1));
		}
		
		rep(j,se[i].size()-1){
			if(se[i][j].ss!=se[i][j+1].ff){
				v.pb(mp(se[i][j].ss,2));
				v.pb(mp(se[i][j+1].ff,1));
				
			}
		}
		v.pb(mp(se[i][j].ss,2));
	}
	sort(all(v));
	rep(i,v.size()){
		if(v[i].ss==1){
			C++;
		}
		else{
			C--;
		}
		maxx=max(maxx,C);
	}
	cout<<maxx<<endl;

} 


Measured memory_bytes: 3572
from collections import deque
import bisect

def main():
    N = int(input())
    l = deque([])

    for i in range(N):
        a = int(input())
        if len(l) == 0 or a <= l[0]:
            l.appendleft(a)
        else:
            ind = bisect.bisect_left(l, a)
            l[ind-1] = a

    print(len(l))

if __name__ == "__main__":
    main()


Measured memory_bytes: 47192
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var di = new Dictionary<String, int>(){
			{"SUN",7},
			{"MON",6},
			{"TUE",5},
			{"WED",4},
			{"THU",3},
			{"FRI",2},
			{"SAT",1},	
		};
		Console.WriteLine(di[S]);
		
		
		
		
	}
	String S;
	public Sol(){
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 11220
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
using namespace std;

static int64_t get_diff(int64_t H, int64_t W)
{
	int64_t res = numeric_limits<int64_t>::max();
	for (int64_t h = 1; h < H; h++) {
		int64_t a_space = h * W;

		int64_t b_h = (H - h) / 2;
		int64_t b_space_1 = b_h * W;
		int64_t c_space_1 = (H - h - b_h) * W;
		int64_t _max, _min;
		if (b_space_1 > 0 && c_space_1 > 0) {
			_max = max(max(a_space, b_space_1), c_space_1);
			_min = min(min(a_space, b_space_1), c_space_1);
			res = min(res, _max - _min);
		}

		int64_t b_w = W / 2;
		int64_t b_space_2 = (H - h) * b_w;
		int64_t c_space_2 = (H - h) * (W - b_w);
		_max = max(max(a_space, b_space_2), c_space_2);
		_min = min(min(a_space, b_space_2), c_space_2);
		res = min(res, _max - _min);
	}
	return res;
}

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

	cout << min(get_diff(H, W), get_diff(W, H)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll MAXN = 50;
ll n,m;
ll cnt[MAXN];
/********** Good Luck :) **********/
int main()
{
    IOS();
    cin >> n >> m;
    REP (i,n) {
        ll k;
        cin >> k;
        ll l;
        REP (i,k) {
            cin >> l;
            cnt[l]++;
        }
    }

    ll ans = 0;
    REP1 (i,m) {
        if (cnt[i] == n) {
            ans++;
        }
    }

    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 = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		int costLeft = 0;
		int costRight = 0;
		while (sc.hasNextInt()) {
			int i = sc.nextInt();
			if (i > X) {
				costRight++;
			}
			if (i < X) {
				costLeft++;
			}
		}
		
		System.out.println(Integer.min(costLeft, costRight));
	}
}

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

int main() {
	int n;
		int count=0;
	cin>>n;
	if(n>81){
	    cout<<"No"<<endl;
	}
	else if(n<1){
	    cout<<"No"<<endl;
	}

	else {
	    for(int i=1;i<=9;i++){
	        if(n%i==0){
	            if(n/i<=9&n/i>=1){
	                cout<<"Yes";
	                count=1;
	                break;
	            }
	        }
	       }
	       if(count==0)
	       cout<<"No";
	    
	}
	return 0;
}

Measured memory_bytes: 3580
/* Simplicity and Goodness */

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B)
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;


void solve()
{
    int n;
    scn(n);

    map<string, int> fa;

    fa["AC"] = fa["TLE"] = fa["WA"] = fa["RE"] = 0;

    rep(i, 0, n) {
        string here;
        cin >> here;
        fa[here] ++;
    }

    cout << "AC x " << fa["AC"] << '\n';
    cout << "WA x " << fa["WA"] << '\n';
    cout << "TLE x " << fa["TLE"] << '\n';
    cout << "RE x " << fa["RE"] << '\n';
}

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

Measured memory_bytes: 3704
#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>;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main(){
    fastio;
    ll h, n;
    cin >> h >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n) h -= a[i];
    if(h<=0){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }
    #ifdef TIMER_
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}

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

#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define FORV(a, A) for (auto &a : A)

using namespace std;

using ll = long long;

void Main()
{
   int x, D, r;
   cin >> r >> D >> x;
   for (int i = 0; i < 10; i++)
   {
      x = r * x - D;
      cout << x << endl;
   }
}

int main()
{
   std::cin.tie(nullptr);
   std::ios_base::sync_with_stdio(false);
   std::cout << std::fixed << std::setprecision(15);
   Main();
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define MOD 1e9+7;
using namespace std;
using ll = long long;

int main() {
	int c[3][3];
	rep(i,3) rep(j,3) cin >> c[i][j];
	int sa[3][4];
	//
	rep(i,3) {
		sa[i][0] = c[i][0] - c[i][1];
		sa[i][1] = c[i][1] - c[i][2];
		sa[i][2] = c[0][i] - c[1][i];
		sa[i][3] = c[1][i] - c[1][i];
	}

	if (sa[0][0] == sa[1][0] && sa[1][0] == sa[2][0]) {
		if (sa[0][1] == sa[1][1] && sa[1][1] == sa[2][1]) {
			if (sa[0][2] == sa[1][2] && sa[1][2] == sa[2][2]) {
				if (sa[0][3] == sa[1][3] && sa[1][3] == sa[2][3]) {
					cout << "Yes";
					return 0;
				}
			}
		}
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 3644
program kadai
implicit none
integer  ::  N,K
integer,allocatable  ::  h(:)
integer  ::  ans,i

read(*,*) N,K
allocate(h(N))
read(*,*) h

ans=0
do i=1,N
    if (h(i)>K-1) then
        ans=ans+1
    end if
end do
write(*,*) ans
stop
contains
end program kadai

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  string S; cin >> S;
  int K; cin >> K;
  int L = S.size();

  REP(i, L) {
    if (i == L-1) {
      S[i] = (S[i] - 'a' + (K % 26)) % 26 + 'a';
    } else if (S[i] != 'a' and 26 - (S[i] - 'a') <= K) {
      K -= 26 - (S[i] - 'a');
      S[i] = 'a';
    }
    assert(K >= 0);
  }

  cout << S << endl;

  return 0;
}


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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

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

    
    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

   
    bool can = true;
    for (int i = 0; i < S.size();) {
        bool can2 = false; 
        for (int j = 0; j < 4; ++j) {
            string d = divide[j];
            if (S.substr(i, d.size()) == d) { 
                can2 = true;
                i += d.size(); 
            }
        }
        if (!can2) { 
            can = false;
            break;
        }
    }

    can ? cout << "YES" << endl : cout << "NO" << endl;
    
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define NL << endl
using namespace std;
using ll = long long;
int INFINT = 1 << 30;
ll INFLL = 1LL << 60;
int gcd(int a, int b) {return b ? gcd(b, a%b) : a;}

int main() {

	int n;

	cin >> n;

	string ans;
	if (n == 0) {
		cout << "0" NL;
		return 0;
	}
	while (n != 0) {
		if (n % 2 != 0) {
			n -= 1;
			ans = "1" + ans;
		}
		else {
			ans = "0" + ans;
		}
		n /= -2;
	}

	cout << ans NL;

	return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int ans = 0;

		if (a==b && b==c) {
			System.out.println(0);
			System.exit(0);
		}
		if (a>b) {int i = a; a = b; b = i;}
		if (b>c) {
			if (a>c) {int i=a; a=c; c=b; b=i;}
			else {int i=b; b=c; c=i;}
		}
		//a<=b<=c

		if (b<c) {
			ans += (c-b);
		}

		if ((b-a)%2==1) {
			ans++;
			b++;
			c++;
		}

		ans += (b-a)/2;

		System.out.println(ans);
	}

}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#include<queue>
#include<functional>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 11234567890123456789
using namespace std;

void dfs(ll depth,ll index, vl &nextButton, vb &pushButton){
	if (index == 1){
		cout << depth << endl;
		exit(0);
	}if (pushButton[index]) return;
	pushButton[index] = true;
	dfs(depth + 1, nextButton[index], nextButton, pushButton);
}

int main(){
	ll n; cin >> n;
	vl nextButton(n); rep(i, n) cin >> nextButton[i];
	rep(i, n) nextButton[i]--;
	vb pushButton(n, false);
	dfs(0, 0, nextButton, pushButton);
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll ;
int main()
{
	ios::sync_with_stdio(false);
	long long N;
	cin>>N;
	ll t=sqrt(N);
	while(t*t!=N)
	{
		N=N-1;
		t=sqrt(N);
	}
	cout<<N<<endl;
	return 0;
}

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

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

template <class Head>
void dbgLog(Head&& head) {
  cerr << head << endl;
}

template <class Head, class... Tail>
void dbgLog(Head&& head, Tail&&... tail)
{
  cerr << head << " ";
  dbgLog(forward<Tail>(tail)...);
}

#if DEBUG
  #define DLOG(...)        dbgLog(__VA_ARGS__)
  #define DFMT(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DFMT(...)
  #define DCALL(func, ...)
#endif

// operator<< definitions for some classes

template <typename T1, typename T2>
ostream& operator<< (ostream& os, const pair<T1,T2>& p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}

template <typename T>
ostream& operator<< (ostream& os, const vector<T>& v) {
  os << '[';
  for (auto it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  os << ']';

  return os;
}

template <typename T, typename T2, typename T3>
ostream& operator<< (ostream& os, const priority_queue<T, T2, T3>& orig) {
  priority_queue<T, T2, T3> pq(orig);
  bool first = true;
  os << '[';
  while (!pq.empty()) {
    T x = pq.top(); pq.pop();
    if (!first) os << ", ";
    os << x;
    first = false;
  }
  return os << ']';
}

struct MyException : exception {};

int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N, M; cin >> N >> M;
  vector<ll> L(M), R(M), C(M);
  for (int i = 0; i < M; i++) {
    cin >> L.at(i) >> R.at(i) >> C.at(i);
  }
  vector<ll> ordL(M);
  iota(ordL.begin(), ordL.end(), 0);
  sort(ordL.begin(), ordL.end(),
       [&](int p, int q) { return L.at(p) < L.at(q); }
       );

  try {

    map<int, ll> theM;
    theM[1] = 0;
    for (int i = 0; i < M; i++) {
      int j = ordL.at(i);
      auto it = theM.lower_bound(L.at(j));
      if (it == theM.end()) throw MyException();
      ll val = it->second;
      ll newVal = val + C.at(j);
      bool early = false;
      for ( ; it != theM.end(); ) {
	if (R.at(j) <= it->first) {
	  if (newVal < it->second) theM[R.at(j)] = newVal;
	  early = true;
	  break;
	}else {
	  if (newVal < it->second) it = theM.erase(it);
	  else it++;
	}
      }
      if (!early) {
	theM[R.at(j)] = newVal;
      }
    }
    auto it = theM.lower_bound(N);
    if (it == theM.end()) throw MyException();
    cout << it->second << endl;
  }catch(const MyException& e) {
    cout << "-1\n";
  }  
  return 0;

}



Measured memory_bytes: 9472
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
using P=pair<int,int>;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  for(ll i=1; i<=3500; i++) {
    for(ll j=1; j<=3500; j++) {
      ll x=N*i*j,y=4*i*j-N*i-N*j;
      if(x>0&&y>0&&x%y==0) {
        cout << i << " " << j << " " << x/y << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;int f,j;char s[1<<20];int dfs() {
vector<int>nxt;int i=0,k=0;char T;while (f<=j) {
T=s[f];if (T>='0' && T<='9') k=k*10+T-48,f++;else if (T=='[') f++,i++,nxt.push_back(dfs());
else if (T==']') {f++;if (nxt.empty()) return (k+1)>>1;for (k=0,sort(nxt.begin(),nxt.end()),i=(i-1)>>1;i>=0;k+=nxt[i--]);return k;}}}
int main() {int q;scanf("%d",&q);while (q--) {scanf("%s",&s),j=strlen(s),s[j]=']',f=0,printf("%d\n",dfs());}return 0;}

Measured memory_bytes: 1100
N = int(input())
p = [11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381]

p = list(map(str, p[:N]))
print(" ".join(p))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n;
vector<vector<int>> M(100, vector<int>(100));
vector<int> C(100);
vector<int> D(100);


void bfs(int v) {
  C.at(v) = GRAY;
  D.at(v) = 0;
  queue<int> Q;
  Q.push(v);

  while (Q.size() > 0) {
    int u = Q.front(); Q.pop();
    C.at(u) = BLACK;
    rep(i, n) {
      if (M.at(u).at(i) == 1 && C.at(i) == WHITE){
        Q.push(i);
        C.at(i) = GRAY;
        D.at(i) = D.at(u)+1;
      } 
    }
  }
}

int main() {
  cin >> n;
  rep(i, n) {
    int id, k; cin >> id >> k;
    rep(j, k) {
      int v; cin >> v;
      M.at(i).at(v-1) = 1;
    }
  }
  rep(i, n)D.at(i) = -1;
  bfs(0);
  rep(i,n) cout << i+1 << " " << D.at(i) << endl;
}



Measured memory_bytes: 3216
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int n,k,d,e,m;
    m=0;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++){
        a[i]=0;}
    for(int i=0;i<k;i++){
        cin>>d;
        for(int j=0;j<d;j++){
            cin>>e;
            a[e-1]=1;}}
    for(int i=0;i<n;i++){
        if(a[i]==0) m++;}
    cout<<m;
























    return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


int compare_int(const void *a, const void *b)
{
//    return *(int*)a - *(int*)b;
    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

long long  factorial(long long n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}

int min(int a, int b) {
    if (a > b)
        return b;
    else
        return a;
}

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}



//int ()
/*
int triangle(int a, int b, int c){
  if(a<b+c){
    if(b<c+a){
      if(c<a+b){
        printf("1\n");
        return 1;
      }
    }
  }
  printf("1\n");
  return 0;
}
*/

int main()
{
//  int  a ,b, c, d, e, X, Y ,r;
  long long  a, b, c, d, e, X, Y;
  //  double  c;
 long long  A[200003]={};
//  int  A[100003]={};
  int  B[100003]={};
  int  C[100003][100001]={};

  int  flg=0;

//  char s[101][101]={};
  char s[100001]={};
  char t[100001]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p,q;
//  int flag=0;
//  int tmp=0;
//  char tmp[101]={};
//  long long min=10000000000;
//  long long min=100000001;
  int min =100000001;
  int len=0;
  int l=0;
//  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  int ans_ac=0;
  int ans_wa=0;
  int max=0;
  long long sum=0;
  int addr=0;
  int ptn=0;
  int  tmp=0;
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
  scanf("%lld%lld", &a, &b);

  for(i=0;i<a;i++){
    scanf("%lld", &A[i]);
  }
    qsort(A, a, sizeof(long long), compare_int);
  for(i=a-1;0<=i;i--){
    if(b>0){
      b--;
    }
    else sum=sum+A[i];
//    printf("%lld\n", A[i]);
  }
  printf("%lld\n", sum);
  
return 0;
}


Measured memory_bytes: 3324
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;

/**
 * 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;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long n = in.nextLong();

            ArrayList<Long> a = new ArrayList<>();
            ArrayList<Long> b = new ArrayList<>();
            ArrayList<Long> c = new ArrayList<>();

            ArrayList<Long> d = new ArrayList<>();
            ArrayList<Long> e = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                a.add(in.nextLong());
            }
            for (int i = 0; i < n; i++) {
                b.add(in.nextLong());
            }
            for (int i = 0; i < n; i++) {
                c.add(in.nextLong());
            }

            Collections.sort(a);
            Collections.sort(b);
            Collections.sort(c);

            long ans = 0;
            for (int i = 0; i < n; i++) {
                long lowerResult = ~Collections.binarySearch(a, b.get(i), (x, y) -> x.compareTo(y) >= 0 ? 1 : -1);
                long upperResult = ~Collections.binarySearch(c, b.get(i), (x, y) -> x.compareTo(y) > 0 ? 1 : -1);
                ans += lowerResult * (n - upperResult);
            }

            out.print(ans);
        }

    }
}



Measured memory_bytes: 101872
#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;
string to_str(ll x){string res; while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return res;}
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

double dist(int x1,int y1,int x2,int y2){
    return pow((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2),0.5);
}

int main(){
    int n; scanf("%d",&n);
    vector<int> x(n),y(n);
    rep(i,0,n)scanf("%d%d",&x[i],&y[i]);
    vector<int> ord(n); iota(ALL(ord),0);
    double ans=0;
    do{
        double sub=0;
        rep(i,0,n-1)sub+=dist(x[ord[i]],y[ord[i]],x[ord[i+1]],y[ord[i+1]]);
        ans+=sub;
    }while(next_permutation(ALL(ord)));
    rep(i,1,n+1)ans/=i;
    printf("%.12f\n",ans);
    return 0;
}

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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(12);
    }
} fast;

/* template */
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;
}

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) (x).erase(unique(all(x)), (x).end())
#define int long long

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;

/* main */
signed main(void)
{
    int n, l;
    cin >> n >> l;
    vector<string> v(n);
    rep(i, n)
    {
        cin >> v[i];
    }
    sort(all(v));
    rep(i, n)
    {
        cout << v[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c,k;
  cin>>a>>b>>c>>k;
  while(a>=b && k)
  {
   b=b*2;
    k--;
  }
  while(b>=c && k)
  {
    c=c*2;
    k--;

    
  }
  if(a<b && b<c)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  
}

Measured memory_bytes: 3632
import std.stdio;
import std.c.stdio;
import std.uni;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    string X;
    bool input() {
        X = readln.chomp;
        return X != ".";
    }
    void solve() {
        struct Parser {
            int index;
            char Letter() {
                //writeln("Letter");
                int C = 0;
                while (X[index] == '+' || X[index] == '-') {
                    C += (X[index] == '+' ? 1 : -1);
                    index++;
                }
                assert(X[index].isUpper || X[index] == '?');
                if (X[index] == '?') {
                    index++;
                    return 'A';
                } else {
                    char c = (X[index] - 'A' + 26 * 5 + C) % 26 + 'A';
                    index++;
                    return c;
                }
            }
            bool tryLetter() {
                return (X[index] == '+' || X[index] == '-' || X[index].isUpper || X[index] == '?');
            }
            string String() {
                //writeln("String");
                if (tryLetter) return [Letter()];
                assert(X[index] == '[');
                index++;
                char[] Ret = Cipher.dup;
                Ret.reverse;
                assert(X[index] == ']');
                index++;
                return cast(string)Ret;
            }
            string Cipher() {
                //writeln("Cipher");
                string Ret;
                while (index < X.length && X[index] != ']') {
                    Ret ~= String;
                }
                return Ret;
            }
        }
        Parser(0).Cipher.writeln;
    }
    while (input) solve;
}

Measured memory_bytes: 1056
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
const int maxn =1000;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b>=c)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

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

typedef vector<int> vi;

int v, d;
const int N = 1001;
int p[N];
int r[N];
int f[N];

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

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if(x == y) return;

	if(r[x] < r[y]) {
		p[x] = y;
	} else {
		p[y] = x;
		if(r[x] == r[y]) r[x]++;
	}
}

void uft() {
	repa(i,1,v) {
		p[i] = i;
		r[i] = 0;
	}

	repa(i,1,v) {
		repa(j,i,v) {
			if(abs(f[i] - f[j]) < d) unite(i, j);
		}
	}

	int ans = 0;
	vector<int> memo(v+1, 0);
	repa(i,1,v) {
		int root = find(i);
		if(memo[root] == 0) {
			memo[root] = 1;
			ans++;
		}
	}
	cout << ans << endl;
}

void dfs(int n, int g, vi& groups) {
	queue<int> que;
	que.push(n);

	while(!que.empty()) {
		int p = que.front();
		que.pop();

		if(groups[p] != 0) continue;

		groups[p] = g;
		repa(i,n+1,v) {
			if(groups[i] == 0 && abs(f[p] - f[i]) < d) {
				que.push(i);
			}
		}
	}
}

void solve() {
	int g = 1;
	vi groups(v+1, 0);
	repa(i,1,v) {
		if(groups[i] == 0) {
			dfs(i, g, groups);
			g++;
		}
	}
	cout << (g-1) << endl;
}

int main() {
	fill(f, f+N, 0);
	f[0] = 1;
	f[1] = 2;
	repa(i,2,N-1) {
		f[i] = (f[i-1] + f[i-2]) % N;
	}

	long t, elapsed;
	while(cin>>v>>d) {
		//t = clock();
		//uft();
		//elapsed = clock() - t;
		//cout << "Time = " <<  elapsed / 1000.0 << endl;

		//t = clock();
		solve();
		//elapsed = clock() - t;
		//cout << "Time = " <<  elapsed / 1000.0 << endl;
	}
}

Measured memory_bytes: 1436
#include <stdio.h>

void maxHeapify(int *, int);
void buildMaxheap(int*);

int n, a[500000];

int main(){

  int i;

  scanf("%d", &n);
  for(i=1; i<=n; i++){
    scanf("%d", &a[i]);
  }

  buildMaxheap(a);

  for(i=1; i<=n; i++){
    printf(" %d", a[i]);
  }
  printf("\n");
  return 0;
  
}

void buildMaxheap(int *a){
  int i;

  for(i=n/2; i>=1; i--){
    maxHeapify(a, i);
  }
}
void maxHeapify(int *a, int i){ //error

  int left =(i*2);
  int right=(i*2+1);
  int largest, temp;
  
  //左の子、自分、右の子でMAXを選ぶ

  if(left<=n && a[i]< a[left]){ //左の子存在、左の子より小さい
    largest=left; //あくまで節点の場所
  }else largest=i;

  if(right<=n && a[largest]<a[right]){

    largest=right;
  }

  if(largest != i){

    temp=a[largest];

    a[largest]=a[i];
    a[i]=temp;

    maxHeapify(a, largest);
  }
}



Measured memory_bytes: 3724
import java.io.*;
import java.util.*;

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

        // 空白で分割してaとbを定義

        int a = scanner.nextInt();

        int b = scanner.nextInt();

    		System.out.println(a * b + " " + 2 * (a + b));
	}
}


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

int ab(int a)
{
	if(a<0) return -a;
	return a;
}

int main()
{
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n,v=1,mv=0,tmp,x;
	cin >> n;
	for(int i=1;i<=n;i++)
	{
		cin >> tmp;
		if(ab(tmp)>mv) mv=ab(tmp),v=i,x=(tmp<0) ? 1 : 0;
	}
	cout << 2*n-2 << "\n";
	for(int i=1;i<=n;i++)
		if(i!=v) cout << v << " " << i << "\n";
	if(x)
		for(int i=n;i>1;i--)
			cout << i << " " << i-1 << "\n";
	else 
		for(int i=1;i<n;i++)
			cout << i << " " << i+1 << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(ll i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD=1e9+7;
int main()
{
    ll a,b,c;
    bool x=0;
    cin>>a>>b>>c;
    if(a==b&&b!=c) x=1;
    if(a==c&&a!=b) x=1;
    if(b==c&&a!=b) x=1;
    if(x) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
using namespace std;
int main()
{
    fastio;
    long long n,i,sum=0,temp=0;
    cin>>n;
    long long a[3*n];
    for(i=0;i<3*n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+3*n);
    for(i=3*n-2; ;i=i-2)
    {
        if(temp==n)
        {
            break;
        }
        sum=sum+a[i];
        temp++;
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 6008
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    int h[n];
    for(int i=0;i<n;i++)
        scanf("%d",&h[i]);
    sort(h,h+n);
    long long x=0;
    for(int i=0;i<n-k;i++)
        x+=h[i];
    printf("%lld\n",x);
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int(i)=int (a);i<=int (b);i++)
#define ff(i,a,b) for(int(i)=int (a);i<int (b);i++)
#define F(i,a,b) for(int(i)=int (a);i>=int (b);i--)
#define foreach(i,x) for(typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define vt vector
#define ll long long
#define lower(p,x) lower_bound(all(p),x)
#define upper(p,x) upper_bound(all(p),x)
#define ms(a,x) memset(a,x,sizeof a)
#define minn(a,b,c,d) min(a,min(b,min(c,d))) 
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
const double pi=acos(-1.0);//NOTE:PI
const double eps=1e-5;
const int INF=1e9,mod=1e9+7,N=1e6+6;
ll a[N];
ll dp[55][55][2500];
ll n,k;
ll back(ll pos,ll take,ll sum){
	if(pos==n) {
		if(static_cast<double>(sum)/static_cast<double>(take)==k) return 1;
		return 0;	
	}
	if(dp[pos][take][sum]!=-1) return dp[pos][take][sum];
	return dp[pos][take][sum]=back(pos+1,take+1,sum+a[pos])+back(pos+1,take,sum);

}
int main(){
	cin>>n>>k;ms(dp,-1);
	ff(i,0,n) cin>>a[i];
	cout<<back(0,0,0);
}


Measured memory_bytes: 59648
//
//  main.cpp
//  Exercise
//
//

#include <algorithm>
#include <iostream>
#include <limits>
#include <math.h>
#include <tuple>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include "string.h"
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <array>
#include <set>

using namespace std;

using int_t = long long;

vector<int> par;
vector<int> rnk;

void init(int n) {
    par = vector<int>(n);
    rnk = vector<int>(n);
    for (int i = 0; i < n; i++) {
        par[i] = i;
        rnk[i] = 0;
    }
}

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

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    
    if (rnk[x] < rnk[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (rnk[x] == rnk[y]) rnk[x]++;
    }
}

bool same(int x, int y) {
    return find(x) == find(y);
}

int main() {
    int N, M;
    scanf("%d %d", &N, &M);
    
    vector<int> ps;
    ps.reserve(N);
    for (int i = 0; i < N; i++) {
        int p;
        scanf("%d", &p);
        ps.push_back(p);
    }
    
    init(N);
    for (int i = 0; i < M; i++) {
        int xi, yi;
        scanf("%d %d", &xi, &yi);
        unite(xi-1, yi-1);
    }
    
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (same(i, ps[i]-1)) {
            cnt++;
        }
    }
    
    printf("%d", cnt);
    
    printf("\n");
    return 0;
}





Measured memory_bytes: 1408
#include <stdio.h>

int min(int p,int q);
int left_check(int na,int nh);
int right_check(int na,int nh);
void init();
int check(int na,int nh);

int map[100][1000];
int n,m,a;

int main(void){
	int h,p,q;
	int i,j;
	
	while(1){
		init();
		scanf("%d %d %d",&n,&m,&a);

		if( n == 0 && m == 0 && a == 0){
			break;
			return 0;
		}

		
		
		for(i = 0;i < m;i++){
			scanf("%d %d %d",&h,&p,&q);
			j = min(p,q);
			map[j][h] = 1;
		}	
		check(a,1000);
	}


	return 0;
}

int min(int p,int q){
	if(p < q)
		return p;
	else
		return q;
}

void init(){
	int i,j;
	for(i = 0;i < 100;i++){
		for(j = 0;j < 1000;j++){
		map[i][j] = 0;
		}
	}
	n = 0;
	m = 0;
	a = 0;
}

int check(int na,int nh){
	
	if( nh == 0){
		printf("%d\n",na);
		return 0;
	}
	
	if( left_check(na,nh) ){
		check( (na-1), (nh-1));
	}else if( right_check(na,nh) ){
		check( (na+1), (nh-1));
	}else{
		check(na,(nh-1));
	}
	
}

int left_check(int na,int nh){
	if(na == 1){
		return 0;	
	}else{
		if(map[na-1][nh] == 1){
			return 1;
		}else{
			return 0;
		}
		
	}
	
}

int right_check(int na,int nh){
	if(na == n){
		return 0;
	}else{
		if(map[na][nh] == 1){
			return 1;
		}else{
			return 0;
		}	
	
	}
	
}

Measured memory_bytes: 988
#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>


typedef long double ld;
typedef long long ll;

using namespace std;

int main() {
	vector<int> a;
	for (int i = 0; i < 4; i++) {
		int t;
		cin >> t;
		a.push_back(t);
	}
	sort(a.begin(), a.end());
	if (a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 3572
#include <iostream>

using namespace std;

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

    if(inN <= 9)
    {
        cout << inN << endl;
    }
    else if(inN <= 99)
    {
        cout << "9" << endl;
    }
    else if(inN <= 999)
    {
        cout << 9 + inN - 99 << endl;
    }
    else if(inN <= 9999)
    {
        cout << 9 + 900 << endl;
    }
    else if(inN <= 99999)
    {
        cout << 9 + 900 + inN - 9999 << endl;
    }
    else if(inN <= 999999)
    {
        cout << 9 + 900 + 90000 << endl;
    }

    return 0;
}

Measured memory_bytes: 764