akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef		 long long int    ll;
typedef		 long double   ld;
typedef		vector<ll>      vll;
#define     fi              first
#define     print(v)        for(ll i:v) cout<<i<<ss
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
const double eps = 1e-8;


int main()
{
    
    string s1,t;
    cin>>s1>>t;
    cout<<t+s1<<nn;





}


/* Final check before submit :

1. array size or integer overflow,like uninitialised 0 index.

2. Think twice,code once.check all possible counter test case.

3. Be careful about corner case! n=1?k=1? something about 0?

4. avoid stupid mistake!complexity(t/m)?precision error?submit same code twice?

5. if got WA than remember that you are missing something common.
   *** Be confident!!! who knows? may be your one step back to AC ***
4. minus mod ans=(ans-k+mod)%mod;

*/






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

#define rep(i,b) for(long long i = 0; i < (b); i++)
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
using ll = long long;

ll lcm(ll a,ll b){
	
	return (a*b)/(__gcd(a,b));
}
void solve() 
{
int n;
cin>>n;
if(n>=30){
	cout<<"Yes";
	return ;
}
cout<<"No";
}



int  main(){

		solve();
		cout<<endl;

}
	

	

	

	

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

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

  int N;
  cin >> N;
  vector<int> A;
  for (int i = 0; i < N; i++) {
    int buf;
    cin >> buf;
    A.push_back(buf);
  }
  for (int i = 0; i < N; i++) {
    A[i] -= i + 1;
  }
  sort(A.begin(), A.end());
  int b = A[N/2];
  long long int sadness = 0;
  for (int i = 0; i < N; i++) {
    sadness += abs(A[i] - b);
  }
  cout << sadness << endl;
  return 0;
}


Measured memory_bytes: 1400
#include <stdio.h>
#define max 25
#define null -1
typedef struct
{
	int p,l,r;	
}Node;
Node T[max];

void preorder(int root)
{
	if(root==null)
		return;		
		printf(" %d",root);
		preorder(T[root].l);
		preorder(T[root].r);		
}

void inorder(int root)
{
	if(root==null)
		return;					
		inorder(T[root].l);
		printf(" %d",root);
		inorder(T[root].r);
}

void postorder(int root)
{
	if(root==null)
		return;				
		postorder(T[root].l);
		postorder(T[root].r);
		printf(" %d",root);
}

int main(int argc, char *argv[])
{
	int i,n,node,left,right,root;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	T[i].p=null;
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&node,&left,&right);
		T[node].l=left;
		T[node].r=right;
		if(left!=null)
		T[left].p=node;
		if(right!=null)
		T[right].p=node;
	}
	for(i=0;i<n;i++)
	if(T[i].p==null)
	{
	root=i;	
	break;
	}
	printf("Preorder\n");
	preorder(root);
	printf("\nInorder\n");
	inorder(root);
	printf("\nPostorder\n");
	postorder(root);
	printf("\n");
	return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;

int main() {
  int w, a, b;
  cin >> w >> a >> b;
  if ((a + w >= b && a + w <= b + w) || (b >= a && b <= a + w))
    cout << 0 << endl;
  else
    cout << min(abs(b - (a + w)), abs(a - (b + w))) << endl;
}


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

int main() {
int N;
cin >> N;
long long int A[N+1], B[N], cnt =0, a;


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

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

for (int i = 0; i < N; ++i)
{
	a = B[i] - A[i];
	if(a < 0){cnt = cnt + B[i]; continue;}
	else cnt = cnt + A[i];
	B[i] = B[i] - A[i];
	a = B[i] - A[i+1];
	if(a < 0){cnt = cnt + B[i];A[i+1] = A[i+1] - B[i];}
	else{cnt = cnt + A[i+1];A[i+1] = 0;}
}

cout << cnt << endl;

return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define testing 0
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<endl
#define dbv(v) cerr << #v << ":"; for (auto i : v) cerr << i << ' '; cerr << endl
#define dbvp(v) cerr << #v << ":"; for (auto i : v) cerr << "{"  << i.f << ',' << i.s << "} "; cerr << endl
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define inf (int)1e9+500
#define oo (ll)1e18
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "hi\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
inline string lts(ll a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}
inline ll stl(string a){
  char x[100]; ll res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}
string cts(char x) {string s(1,x); return s;}
const int MOD = 1e9 + 7;
template <typename T> void maxself(T& a, T b) {
	a = max(a, b);
}
template <typename T> void minself(T& a, T b) {
	a = min(a, b);
}
#define MAXN (int)2e5+5
#if !testing
#define cerr if(0)cout
#endif
pi A[MAXN];
struct node {
	ll s,e,m,val;
	ll add;
	node *l, *r;
	node (int _s, int _e) {
		s = _s, e = _e;
		m = (s+e)/2;
		add = 0;
		if (s!=e) {
			l = new node(s,m);
			r = new node(m+1,e);
			val=max(l->val,r->val);
		} else {
			val = A[s].s;
		}
	}
	ll value() {
		val+=add;
		if(s!=e) {
			l->add+=add,r->add+=add;
		}
		add=0;
		return val;
	}
	void update(int qs, int qe, int nval) {
		value();
		if (qs==s&&qe==e) {
			add+=nval;
			return;
		}
		if (qe<=m) l->update(qs,qe,nval);
		else if (qs>m) r->update(qs,qe,nval);
		else l->update(qs,m,nval),r->update(m+1,qe,nval);
		val = max(l->value(),r->value());
	}
	ll get(int x) {
		value();
		if(s==e) return val;
		if (x<=m) return l->get(x);
		else return r->get(x);
	}
	
}*seg;
			


int32_t main() {
	IAMSPEED
	// set testing to 0 when submitting to judge
	ll n,d,a; cin>>n>>d>>a;
	FOR(i,0,n-1) cin>>A[i].f>>A[i].s;
	sort(A,A+n);
	seg = new node(0,n-1);
	ll ans = 0;
	FOR(i,0,n-1) {
		db(i);
		if(seg->get(i)>0) {
			ll v = seg->get(i);
			int idx = prev(upper_bound(A,A+n,pi(2*d+A[i].f,oo)))-A;
			int bombs = (a+v-1)/a;
			ans+=bombs;
			db2(i,idx);
			seg->update(i,idx,-(bombs*a));
		}
		
	}
	cout << ans;
}


Measured memory_bytes: 28416
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

def table(n:int, p=10**9+7):
    global fact, factinv, inv
    fact = [1, 1]
    factinv = [1, 1]
    inv = [0, 1]
    for i in range(2, n+1):
        #fact.append((fact[-1] * i) % p)
        inv.append((-inv[p % i] * (p // i)) % p)
        #factinv.append((factinv[-1] * inv[-1]) % p)

m, a, b = mi()

P = 10**9+7
N = 2*(10**5)
table(N)

mca = bunshi= 1
for i in range(1, a+1):
    #mca *= (m-i+1) * inv[i]
    mca *= (m-i+1)
    bunshi *= i 
    mca %= P
    bunshi %= P
mcb = mca
mca = mca * pow(bunshi, P-2, P)
mca %= P

for i in range(a+1, b+1):
    #mcb *= (m-i+1) * inv[i]
    mcb *= (m-i+1)
    bunshi *= i 
    mcb %= P
    bunshi %= P
mcb = mcb * pow(bunshi, P-2, P)
mcb %= P

print((pow(2, m, P)-1-mca-mcb) % P)

Measured memory_bytes: 11052
import java.util.*;
import java.io.*;
 
public class Main {
    static boolean[][] used;
    static int[] ans;
    public static void main(String[] args) throws Exception {
        long mod = (long)Math.pow(10,9)+7;
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        char[] s = sc.next().toCharArray();
        String ans = "";
        for(char c : s){
            if(c == 'B'){
                if(ans.isEmpty()){
                    continue;
                }
                ans = ans.substring(0,ans.length()-1);
            }else{
                ans += c;
            }
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

Measured memory_bytes: 22996
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll A,B,C,D,E,F,G,H,K,L,M,N,P,Q,R,W,X,Y,Z;
string S,T;

int main(){
  cin >> S;
  T=S;
  reverse(ALL(T));
  if(T!=S){
    cNo;
    return 0;
  }
  rep(i,S.size()/2){
    if(S[i]!=T[i+(S.size()+1)/2]){
      cNo;
      return 0;
    }
  }
  rep(i,S.size()/2){
    if(T[i]!=S[i+(S.size()+1)/2]){
      cNo;
      return 0;
    }
  }
  cYes;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int n, m, a[100010];
int main () {
	int t = 0;
	scanf ("%d%d", &n, &m);
	for (int i = 1; i <= m; i++) {
		scanf ("%d", &a[i]);
		if (a[i] & 1) t++;
	}
	if (t > 2) { printf ("Impossible\n"); return 0; };
	for (int i = 1; i <= m; i++) if (a[i] & 1) {
		if (t == 2) swap (a[i], a[1]);
		else swap (a[i], a[m]);
		t--;
	}
	for (int i = 1; i <= m; i++) printf ("%d%c", a[i], " \n"[i == m]);
	if (m == 1) {
		if (a[1] == 1) printf ("1\n1\n");
		else printf ("2\n%d 1\n", a[1] - 1);
	} else if (m == 2) {
		if (a[1] == 1) {
			if (a[2] == 1) printf ("1\n2\n");
			else printf ("2\n2 %d\n", a[2] - 1);
		} else printf ("2\n%d %d\n", a[1] - 1, a[2] + 1);
	} else {
		if (a[1] == 1) {
			printf ("%d\n", m - 1);
			for (int i = 2; i < m; i++) printf ("%d ", a[i]);
			printf ("%d\n", a[m] + 1);
		} else {
			printf ("%d\n", m);
			printf ("%d ", a[1] - 1);
			for (int i = 2; i < m; i++) printf ("%d ", a[i]);
			printf ("%d\n", a[m] + 1);
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int func_f(int n){return n%2==0?n/2:3*n+1;}

int main(void){
	int S, count = 1, a;
	scanf("%d",&S);
	int num[1000001]={0};
	num[S] = 1;
	a = S;
	while(1){
		count++;
		a = func_f(a);
		num[a]++;
		if(num[a] == 2)break;
	}
	printf("%d",count);
	return 0;
}

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void dfs(int v, int tot, vi &ans, vi &cnt, const vii &g, vb &seen) {
  seen[v] = true;
  ans[v] = cnt[v] + tot;
  for(int nv : g[v]) {
    if(seen[nv]) continue;
    dfs(nv, ans[v], ans, cnt, g, seen);
  }
}

int main(){
  int n, q;
  cin >> n >> q;
  vii g(n);
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vi cnt(n);
  rep(i,q) {
    int p, x;
    cin >> p >> x;
    p--;
    cnt[p] += x;
  }
  vb seen(n);
  vi ans(n);
  dfs(0, 0, ans, cnt, g, seen);
  rep(i,n) cout << ans[i] << ' ';
}

Measured memory_bytes: 30592
def frame(h,w):
    for height in range(h):
        for width in range(w):
            if 0 < height < h-1 and 0 < width < w-1:
                print('.',end='')
            else:
                print('#',end='')
        print()
    print()

hws = []
while True:
    hw = list(map(int,input().split()[:2]))
    if hw[0] == hw[1] == 0:
        break
    hws.append(hw)

for hw in hws:
    frame(hw[0],hw[1])


Measured memory_bytes: 7004
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define sz(s) ((int) ((s).size()))
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif

typedef long long ll;
typedef long double ld;

const int inf = (int) 1e9 + 100;
const ld eps = 1e-11;
const ld pi = acos(-1.0L);

mt19937 mrand(random_device{} ());
int rnd(int x) {
  return mrand() % x;
}

const int maxn = 2e5 + 100;

ld harm[maxn];

void precalc() {
  harm[0] = 0;
  for (int i = 1; i < maxn; i++) {
    harm[i] = harm[i - 1] + (ld) 1 / i;
  }
}

int n;
int d, x;

bool read() {
  if (scanf("%d%d%d", &n, &d, &x) < 3) {
    return false;
  }
  return true;
}

void solve() {
  ld res = 0;
  for (int it = 0; it < 2; it++) {
    ld cur = d;
    for (int i = 0; i < n; i++) {
      res += cur * harm[n - i] / 2;
      cur += 2 * x;
    }
    d = d + x * (2 * n - 1);
    x = -x;
  }
  printf("%.18f\n", (double) res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen("text.in", "r", stdin));
  assert(freopen("text.out", "w", stdout));
#endif

  while (true) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time: %.18f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
static double q, h, s, d, n;
double f(double cost, double size) {
    return cost / size;
}
int main(void) {
    long sum = 0;
    scanf("%lf%lf%lf%lf%lf", &q, &h, &s, &d, &n);
    if (f(s, 1) <= f(d, 2))
        d = 2 * s;
    if (f(h, 0.5) <= f(s, 1))
        s = 2 * h;
    if (f(h, 0.5) <= f(d, 2))
        d = 4 * h;
    if (f(q, 0.25) <= f(h, 0.5))
        h = 2 * q;
    if (f(q, 0.25) <= f(s, 1))
        s = 4 * q;
    if (f(q, 0.25) <= f(d, 2))
        d = 8 * q;
    while (n >= 2) {
        sum += (long)d;
        n -= 2;
    }
    while (n >= 1) {
        sum += (long)s;
        n -= 1;
    }
    while (n >= 0.5) {
        sum += h;
        n -= 0.5;
    }
    while (n >= 0.25) {
        sum += q;
        n -= 0.25;
    }
    printf("%ld\n", sum);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define nes ios_base :: sync_with_stdio(0); cin.tie(0);
using namespace std;
int main(){
	nes;
	string s;
	cin>>s;
	int count=0;
	for(auto i : s) count+=(i-'0');
	if(count%9==0) cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 3752
class Watch:
    def __init__(self, S):
        h = S / 3600 
        m = S % (60 * 60) / 60
        s = S - h * 3600 - m * 60
        print "%(h)d:%(m)d:%(s)d" % {'h':h, 'm':m, 's':s}

if __name__ == "__main__":
    S = int(raw_input())
    w = Watch(S)

Measured memory_bytes: 6436
#include <stdio.h>
#include <math.h>
 
int main()
{
  double x1,y1,x2,y2;
  scanf("%lf",&x1);
  scanf("%lf",&y1);
  scanf("%lf",&x2);
  scanf("%lf",&y2);
  printf("%lf\n",sqrt(pow(x2-x1,2)+pow(y2-y1,2)));
  return 0;
}


Measured memory_bytes: 2112
#include<iostream>
#include<algorithm>
#include<cstdio>

using namespace std;
int main()
{
  int N,D,X,A[101],i,j,res=0;
  scanf("%d",&N);
  scanf("%d %d",&D,&X);
  for(i=1;i<=N;i++)
    scanf("%d",&A[i]);
  for(j=1;j<=N;j++)
    for(i=0;i*A[j]+1<=D;i++)
      res++;
  printf("%d\n",res+X);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define INF 1000000000
int n,m;
int d[80][150][10];
int r[150][1000];
int f[150][10];
int c[150];
int i,j,k,l;
int t;
int a,b;

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

int main(){
	while(1){
		scanf("%d %d",&n,&m);
		if(n==0&&m==0)return 0;
		for(i=0;i<n;i++)c[i]=0;
		for(i=0;i<n;i++){
			scanf("%d",&t);
			for(j=0;j<t;j++){
				scanf("%d %d",&a,&b);
				r[i][a-1]=b;
				f[i][c[i]++]=a-1;
			}
		}
		for(k=0;k<=m;k++)for(i=0;i<n;i++)for(j=0;j<c[i];j++){
			d[k][i][j]=INF;
		}
		for(i=0;i<c[0];i++){
			d[m][0][i]=0;
		}
		if(m>=1)for(j=0;j<c[1];j++){
			d[m-1][1][j]=0;
		}
		for(i=1;i<n;i++){
			if(i>1){
				for(j=0;j<=m-1;j++){
					for(k=0;k<c[i];k++){
						for(l=0;l<c[i-2];l++){
							d[j][i][k]=min(d[j][i][k],d[j+1][i-2][l]+abs(f[i][k]-f[i-2][l])*(r[i][f[i][k]]+r[i-2][f[i-2][l]]));
						}
					}
				}
			}
			for(j=0;j<=m;j++){
				for(k=0;k<c[i];k++){
					for(l=0;l<c[i-1];l++){
						d[j][i][k]=min(d[j][i][k],d[j][i-1][l]+abs(f[i][k]-f[i-1][l])*(r[i][f[i][k]]+r[i-1][f[i-1][l]]));
					}
				}
			}
		}
		int ans=INF;
		for(i=0;i<=m;i++)for(j=0;j<c[n-1];j++){
			ans=min(ans,d[i][n-1][j]);
		}
		for(i=1;i<=m;i++)for(j=0;j<c[n-2];j++){
			ans=min(ans,d[i][n-2][j]);
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 2068
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
	let s: String = read();
    
    if s == "AAA" || s == "BBB" {
    	println!("No");
    } else {
    	println!("Yes");
    }
}


Measured memory_bytes: 4352
import java.util.Scanner;
import java.util.Arrays;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] nums = new int[3];
    nums[0] = sc.nextInt();
    nums[1] = sc.nextInt();
    nums[2] = sc.nextInt();
    Arrays.sort(nums);
    System.out.println(nums[2] * 10 + nums[1] + nums[0]);
  }
}

Measured memory_bytes: 22996
N,M = map(int,input().split())
A = [0]*(N+1)
mod = 10**8

for i in range(M):
    p,S = input().split()
    p = int(p)
    if S == 'AC':
        if A[p]//mod==0:
            A[p] += mod
    else:
        if A[p]//mod==0:
            A[p] += 1
            
AC = sum(A)//mod
WA = 0
for i in A:
    if i//mod!=0:
        WA += i%mod
print(AC,WA)

Measured memory_bytes: 45016
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
    cin>>N;
    vec L(N);
    ll sum = 0;
    rep(i,N){
        cin>>L.at(i);
        sum += L.at(i);
    }
    rep(i,N){
        if(L.at(i) >= sum - L.at(i)){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <string>
#include <vector>

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

    int counter = 0;
    int box = 0;
    for(int i = 0; i < n; i++){
        if(a[box] == 2){
            std::cout << i+1;
            return 0;
        }
        else{
            box = a[box] - 1;
        }
    }
    std::cout << -1;
    return 0;
}



Measured memory_bytes: 888
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int w;
		while ((w = in.nextInt()) >= 0) {
			System.out.println(4280 - price(w));
		}
		in.close();
	}

	private static int price(int w) {
		if (w <= 10) {
			return 1150;
		}
		if (w <= 20) {
			return 1150 + 125 * (w - 10);
		}
		if (w <= 30) {
			return 2400 + 140 * (w - 20);
		}
		return 3800 + 160 * (w - 30);
	}

}

Measured memory_bytes: 16776
#include <stdio.h>

int main(void)
{
  int n;
  int debt = 100000;
  int i;

  scanf("%d", &n);
  for (i =0; i < n; i++) {
    debt *= 1.05;
    if (debt % 1000 != 0) {
      debt -= (debt % 1000);
      debt += 1000;
    }
  }
  printf("%d\n", debt);

  return 0;
}

Measured memory_bytes: 592
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long N = scan.nextInt();
        long P = scan.nextInt();
        long Q = scan.nextInt();
        long C[] = new long[(int)N];
        long ans = 0;
        for(int i = 0; i < N; i++){
            long num = scan.nextInt();
            C[i] = (Q - i) * P - num;
            ans += num;
        }
        Arrays.sort(C);
        long S = ans;
        for(int i = 0; i < N; i++){
            S += C[(int)N - i - 1];
            S += i * P * 2;
            ans = Math.max(ans, S);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 175596
let () =
    let maxk k = if k < 3 then 0 else (k - 2) * (k - 1) / 2 in
    let main () =
        let n, k = Scanf.sscanf (read_line ()) "%d %d" (fun n k -> n, k) in
        if k > maxk n then Printf.printf "-1\n" else
            if n = 2 then Printf.printf "1\n1 2\n" else (
                let m1 = n - 1 in
                let m2 = maxk n - k in
                Printf.printf "%d\n" (m1 + m2);
                for i = 1 to m1 do
                    Printf.printf "%d %d\n" i n
                done;
                let rec loop i j rest =
                    if rest > 0 then (
                        Printf.printf "%d %d\n" i j;
                        if j + 1 < n then loop i (j + 1) (rest - 1) else
                            loop (i + 1) (i + 2) (rest - 1)
                    )
                in
                loop 1 2 m2
            )
    in
    main ()

Measured memory_bytes: 4096
#include <stdio.h>
#define MAX 100000

int partition(int *,int,int);

int main()
{
  int i,a[MAX],n,x,k;

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

  k = partition(a,1,n);

  for(i=1 ; i<=n ; i++)
  {
    if(i!=k && i!=n)printf("%d ",a[i]);
    else if (i==k)printf("[%d] ",a[i]);
    else if(i== n) printf("%d",a[i]);
  }
  printf("\n");

  return 0;
}

int partition(int *A,int p,int r)
{
  int j,n,m,x,i;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++)
  {
    if(A[j]<=x)
    {
      i=i+1;
      n=A[i];
      A[i]=A[j];
      A[j]=n;
    }
  }
  m=A[i+1];
  A[i+1]=A[r];
  A[r]=m;
  return i+1;
}



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

namespace ATCode1a
{
    class Program
    {
        static void Main(string[] args)
        {
            string b = Console.ReadLine();

            if (b == "A")
            {
                Console.WriteLine("T");
            }
            if (b == "T")
            {
                Console.WriteLine("A");
            }
            if (b == "C")
            {
                Console.WriteLine("G");
            }
            if (b == "G")
            {
                Console.WriteLine("C");
            }
            else
            {
            }
        }
    }
}

Measured memory_bytes: 13140
#C - Poll
N = int(input())
S = [input() for _ in range(N)]
S_set = list(sorted(set(S)))

counter = {}
for k in S_set:
    counter[k] = 0
for i in S:
    counter[i] += 1
    
maxim = max(counter.values())
ans = [i for i in S if counter[i] == maxim]
ans = list(sorted(set(ans))) 

for j in ans:
    print(j)

Measured memory_bytes: 51320
import heapq

k = int(input())

que = []
for i in range(1, 10):
    heapq.heappush(que, i)

ans = -1
for _ in range(k):
    ans = que[0]
    n = ans
    heapq.heappop(que)

    last = n % 10
    if last == 0:
        heapq.heappush(que, n * 10)
        heapq.heappush(que, n * 10 + 1)
    elif last == 9:
        heapq.heappush(que, n * 10 + 8)
        heapq.heappush(que, n * 10 + 9)
    else:
        heapq.heappush(que, n * 10 + last - 1)
        heapq.heappush(que, n * 10 + last)
        heapq.heappush(que, n * 10 + last + 1)

print(ans)


Measured memory_bytes: 11788
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(int X = 0; X < N; X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())

using namespace std;

int main(){

    ll n,m;

    cin >> n >> m;

    if(n != 1 && m != 1){

        cout << max((ll)0, n - 2) * max((ll)0, m - 2) << endl;
    }else if(n == 1 && m == 1){
        cout << 1 << endl;
    }else{
        cout << n * m - 2 << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
//#include <cmath>
//#include <cstdlib>
using namespace std;


int main(){
	/*input*/
	int n;
	cin >> n;

	/*calc*/
    int ans = 0;
    int h =  n / 100;
    int ans_tmp1 = h*100 + h*10 + h;
    int ans_tmp2 = (h+1)*100 + (h+1)*10 + (h+1);

    if(n <= ans_tmp1) ans = ans_tmp1;
    else ans= ans_tmp2;

    /*output*/
	cout<< ans <<endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# input
K, X = map(int, input().split())

# solve & output
if K > 1:
    for i in range(X - K + 1, X + K):
        if i == X + K - 1:
            print(i)
        else:
            print(i, end=' ')
else:
    print(X)


Measured memory_bytes: 3060
#include <iostream>
#include<vector>
using namespace std;
int main() {
	int N, M;
	
	cin >> N >> M;
	
	int judge[30] = {};
	for (int i = 0; i < N; i++) {
		int K;
		cin >> K;
		for (int L = 0; L < K; L++) {
			int A;
			cin >> A;
			judge[A-1]++;
		}

	}
	int cnt = 0;
	for (int i = 0; i < M; i++)
	{
		if (judge[i] == N) {
			cnt++;
		}
	}
	cout << cnt << endl;
	
	return 0;
}


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

int dp[100010], n, h[100010];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &h[i]);
	dp[1] = 0, dp[2] = abs(h[2] - h[1]);
	for (int i = 3; i <= n; i++)
		dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
	printf("%d\n", dp[n]);
	return 0;
}

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

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class AKthTerm {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      vector<int> vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
      int k; cin >> k;
      cout << vec[k-1] << endl;
    }
};

signed main() {
  AKthTerm solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define st first
#define nd second
#define turbo ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define vi vector<int>
#define vvi vector<vi>
#define qi queue<int>
#define ld long double

using namespace std;

/*---------------------------------------------------------///CODE///---------------------------------------------------------*/

int dp[100][2];
int dp2[100][2];

void clear_dp()
{
    for(int i = 0; i < 100; i++)
        for(int j = 0; j < 2; j ++)
            dp2[i][j] = 0;

}
void add_dp()
{
    for(int i = 0; i < 100; i++)
        for(int j = 0; j < 2; j++) 
            dp[i][j] = dp2[i][j];
    clear_dp();
}
const int MOD = 1e9 + 7;

int main()
{
    turbo

    dp[0][0] = 1;

    string K; cin >> K;
    int d; cin >> d;

    for(int i = 0; i < K.size(); i++)
    {
        for(int j = 0; j < d; j++)
        {
            for(int k = K[i] - '0' + 1; k <= 9; k++)
                (dp2[(j + k) % d][1] += dp[j][1]) %= MOD;

            for(int k = 0; k < K[i] - '0'; k++)
            {
                (dp2[(j + k) % d][1] += (dp[j][0] + dp[j][1])) %= MOD;
            }
            (dp2[(j + K[i] - '0') % d][0] += dp[j][0]) %= MOD;
            (dp2[(j + K[i] - '0') % d][1] += dp[j][1]) %= MOD;
        }
        add_dp();
    }

    cout << (dp[0][0] + dp[0][1] - 1 + MOD)% MOD;
    return 0;
}

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

int main() {
    int c1,c2,c3; cin >> c1 >> c2 >> c3;
    if(c1==c2 && c2==c3) cout << 1 << endl;
    else if(c1==c2 || c2==c3 || c1==c3) cout << 2 << endl;
    else cout << 3 << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
 int a, b, c, N, i;
 cin >> N;

 for(i = 0;i < N;i++){
  cin >> a >> b >> c;
  if(a*a + b*b == c*c || a*a + c*c == b*b || b*b + c*c == a*a){
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
 }

 return 0; 
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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; }
const int INF=1001001001;

int main() {
  int64_t X;
  cin>>X;
  int64_t A,B;
  for(int i=-200;i<=200;i++){
   for(int j=-200;j<=200;j++){
     if(pow(i,5)-pow(j,5)==X){cout<<i<<" "<<j<<endl;return 0;}
   }
  }
  return 0;
}

Measured memory_bytes: 4012
#include<stdio.h>
#include<math.h>

int main()
{
		int d;
		int r;
		double f;
		int a = 0;
		int b = 0;

		scanf("%d %d",&a,&b);

		d = a / b;
		r = a % b;
		f = (double)a / b;
		printf("%d %d %f",d,r,f);
		return 0;
}


Measured memory_bytes: 2104
from collections import deque
n = int(input())
k = 0
data = [[] for _ in range(n)]
ans_index = []

for i in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    data[a].append(b)
    ans_index.append(b)

q = deque([0])
color = [0] * n
while q:
    cur = q.popleft()
    c = 1
    for x in data[cur]:
        if c == color[cur]:
            c += 1
    
        color[x] = c
        c += 1
        q.append(x)

print(max(color))
for i in ans_index:
    print(color[i])


Measured memory_bytes: 91404
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int n, pos;
vector<int> pre, in, post;

void rec(int l, int r){
  if(l >= r) return;
  int root = pre.at(pos++);
  int m = distance(in.begin(), find(all(in), root));
  rec(l, m);
  rec(m+1, r);
  post.push_back(root);
}

void solve(){
  pos = 0;
  rec(0, pre.size());
  rep(i, n) {
      if(i != 0) cout << " ";
      cout << post.at(i);
  }
  cout << endl;
}

int main() {
  int k;
  cin >> n;
  rep(i, n) {
      cin >> k;    
      pre.push_back(k);
  }
  rep(i, n) {
      cin >> k;
      in.push_back(k);
  }
  solve();
}


Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k,t=0;
	cin>>n>>k;
	int a[n];
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]>=k) t++;
	}
	cout<<t;
}

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

typedef long double ld;									// XD
#define int long long
#define PB push_back
#define all(x) (x).begin(),(x).end()
#define ii pair <int,int>
#define mii map <int,int>
#define vi vector<int>
#define vii vector< ii >
#define F first
#define S second
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a; i>=b; --i)
#define sz(x) (int)((x).size())
#define mem(a,x) memset(a,x,sizeof(a))
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
inline void io(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int mod = 1e9 + 7;
const int inf = 3e16;
const int maxn = 1e5+5;

void solve(){
	int d, t, s; cin>>d>>t>>s;
	if(s*t >= d) cout<<"Yes";
	else cout<<"No";
}
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0); //io();
    //cout<<setprecision(12);
    int tc=1;// cin>>tc;
    while(tc--){
        solve();cout<<'\n';
    }
    return 0;
}


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

// main
int main(){
    string date; cin >> date;

    if(date == "SUN"){
        cout << 7 << endl;
    }else if (date == "MON")
    {
        cout << 6 << endl;
    }else if (date == "TUE")
    {
        cout << 5 << endl;
    }else if (date == "WED")
    {
        cout << 4 << endl;
    }else if (date == "THU")
    {
        cout << 3 << endl;
    }else if (date == "FRI")
    {
        cout << 2 << endl;
    }else if (date == "SAT")
    {
        cout << 1 << endl;
    }else{
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int a, b, c; scanf("%d%d%d", &a, &b, &c);
	
	if(a == b and b == c) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x = 0;
  int N;
  string S;
  cin >> N >> S;
  int num[110] = {0};
  for (int i = 0; i < N; i++) {
    if (S[i] == 'I') x++;
    else x--;
    num[i + 1] = x;
  }
  sort(num, num + N + 1, greater<int>());
  cout << num[0] << endl;
}

Measured memory_bytes: 256
import sys
from heapq import heapify, heappop, heappush
from collections import defaultdict


def main():
    finput=lambda :sys.stdin.readline().strip()
    n,a,b=map(int,finput().split())
    h=[int(finput()) for _ in range(n)]
    gs=lambda a,b:a//b+(a%b>0)
    def enough(t):
        s=sum([gs(max(x-t*b,0),a-b) for x in h])
        if s<=t:
            return True
        else:
            return False
    l=max(h)//b+1
    t=0
    while l>0:
        t=t+l//2
        if enough(t):
            t=t-l//2
            l=l//2
        else:
            t+=1
            l=l-l//2
    print(t)

if __name__=='__main__':
    main()



Measured memory_bytes: 16976
class MaxHeap
  def initialize
    @heap = [nil]
    @size = 0
  end
  
  def insert(key)
    @heap << key
    @size += 1
    up_heap(@size / 2)
  end
  
  def up_heap(i)
    return if i.zero?
    l, r = i * 2, i * 2 + 1
    largest = (l <= @size and @heap[l] > @heap[i]) ? l : i
    largest = r if r <= @size and @heap[r] > @heap[largest]
    unless largest == i
      @heap[i], @heap[largest] = @heap[largest], @heap[i]
      up_heap(i / 2)
    end
  end
   
  def remove_root
    a = @heap[1]
    b = @heap.pop
    @size -= 1
    return b if @heap.size == 1
    @heap[1] = b
    down_heap(1)
    a
  end
   
  def down_heap(i)
    return if i > @size
    l, r = i * 2, i * 2 + 1
    largest = (l <= @size and @heap[l] > @heap[i]) ? l : i
    largest = r if r <= @size and @heap[r] > @heap[largest]
    unless largest == i
      @heap[i], @heap[largest] = @heap[largest], @heap[i]
      down_heap(largest)
    end
  end
  
  def size
    @heap.size - 1
  end
end


n, m = gets.split.map(&:to_i)
given = Hash.new {|h, v| h[v] = []}
n.times.each do
  a, b = gets.split.map(&:to_i)
  given[a] << b
end

mh = MaxHeap.new
sum = 0

(1..m).each do |left_day|
  given[left_day].each {|reward| mh.insert(reward)}
  sum += mh.remove_root unless mh.size.zero?
end
puts sum

Measured memory_bytes: 15100
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main () {
   
    
    int w, a, b;
    scanf("%d%d%d", &w, &a, &b);
    
    if (b >= a && b <= w + a) {
        printf("0");
        return 0;
    }
    if (b + w >= a && b + w <= w + a) {
        printf("0");
        return 0;
    }
    
    int result = abs (b - a);
    if (abs(b - a - w) < result)
        result = abs(b - a - w);
    if (abs(b + w - a) < result)
        result = abs (b + w - a);
    printf("%d", result);
}






Measured memory_bytes: 128
S = input()

KEYENCE = 'keyence'
patterns = []
for i in range(len(KEYENCE)):
    patterns.append((KEYENCE[:i:], KEYENCE[i::]))

for stt, end in patterns:
    if S.startswith(stt) and S.endswith(end):
        print('YES')
        break
else:
    print('NO')

Measured memory_bytes: 3060
let s, q = Scanf.scanf " %s %d" @@ fun a b -> a, b
let r, fs, bs = ref 0, ref [], ref []
let g s = String.(init (length s) @@ fun i -> s.[length s - i - 1])
let _ = Scanf.(for _ = 1 to q do scanf " %d" @@ fun t -> if t = 1 then r := !r lxor 1 else scanf " %d %s" @@ fun f c -> if !r = f - 1 then fs := c :: !fs else bs := c :: !bs done); List.(if !r = 0 then bs := rev !bs else fs := rev !fs); let f, b = String.(concat "" !fs, concat "" !bs) in print_endline @@ if !r = 0 then f ^ s ^ b else b ^ g s ^ f

Measured memory_bytes: 13568
import java.util.*;
import java.io.*;
import java.math.*;
 
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    
    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // for(int i=0; i<n; i++) {a[i]=sc.nextInt();}
        int n=sc.nextInt();
        int k=sc.nextInt();
        int id=0,ans=1;
        
        for(int i=0; i<n; i++) {int x=sc.nextInt(); if(x==1){id=i;} }
        
        if(n>k){
            k--;
            ans=(n-1)/k;
            if((n-1)%k!=0)ans++;
        }

        out.println(ans);
        out.flush();
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
     
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }
     
    static boolean bit(long x,int k){
        // weather k-th bit (from right) be one or zero
        return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
    }    
}

class P implements Comparable<P>{
    long x;
    double d;
    P(long x, double d) {
        this.x=x;
        this.d=d;
    } 
      
    public int compareTo(P p){
        return (d - p.d)>0?1:-1;//des
    } 
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}

Measured memory_bytes: 32168
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define ch_edge(CH,i) CH[i],CH[(i+1)%CH.size()]

typedef complex<double> Point;
typedef vector<Point> VP;
#define X real()
#define Y imag()

double cross(Point a, Point b) {
  return a.X*b.Y - a.Y*b.X;
}

int main(void){
	int n;
	cin>>n;
	VP p(n);
	rep(i,n){
		double x,y;
		cin>>x>>y;
		p[i] = {x,y};
	}

	double s=0;
	rep(i,n) s+=cross(ch_edge(p,i));
	printf("%.1f\n",s/2.0);
    return 0;
}

Measured memory_bytes: 3292
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main() {
	char str[1200];
	int i, l;
	fgets(str, 1200, stdin);
	l = strlen(str);
	for (i = 0; i < l; ++i)
	{
		if (isupper(str[i])) str[i] = tolower(str[i]);
		else if (islower(str[i])) str[i] = toupper(str[i]);
	}
	printf("%s", str);
	return 0;
}


Measured memory_bytes: 2148
package main

import (
	"fmt"
	"math"
)

func main() {

	var P, Q, R int
	fmt.Scanf("%d %d %d", &P, &Q, &R)

	fmt.Println(math.Min(math.Min(float64(P)+float64(Q), float64(R)+float64(Q)), float64(P)+float64(R)))
}


Measured memory_bytes: 1840
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i = 0; i <= VMAX; i++)
    C[i] = 0;
  for(i = 0; i < n; i++)
    {
      scanf("%hu",&A[i + 1]);
      C[A[i+1]]++;

    }

  for(i = 1; i <= VMAX; i++)
    C[i] = C[i] + C[i - 1];
  for(j = 1; j <= n; j++)
    {
      B[C[A[j]]] = A[j];
      C[A[j]]--;
    }

  for(i = 1; i <= n; i++)
    {
      if(i > 1) printf(" ");
      printf("%d",B[i]);
    }
  printf("\n");

  return 0;
}





Measured memory_bytes: 9596
#include<bits/stdc++.h>
#define mod 1000000007
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
char S[300010];
int f[300010][3][4][2];
void add(int&a,int b){a=a+b>=mod?a+b-mod:a+b;}
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	scanf("%s",S+1);int n=strlen(S+1);
	if(n==1){printf("%d\n",S[1]!='0');return 0;}
	if(S[1]!='1')f[1][1][0][0]=1;
	if(S[1]!='0')f[1][2][1][1]=1;
	S[n+1]='1';
	for(int i=1;i<=n;++i)
		for(int j=0;j<3;++j)
			for(int k=0;k<4;++k)
				for(int l=0;l<2;++l)
					if(f[i][j][k][l]){
						if(S[i+1]!='1')add(f[i+1][j+1&1][k][l],f[i][j][k][l]);
						if(S[i+1]!='0'){
							int nk=k;
							if(j==2)
								if(l&&k==1)nk|=2;
								else if(!l)nk|=1;
							add(f[i+1][2][nk][l^(j!=1)],f[i][j][k][l]);
						}
					}
	int ans=0;
	for(int i=0;i<=2;++i)add(ans,f[n+1][i][3][0]),add(ans,f[n+1][i][3][1]);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 28672
#include <cstdio>

int main() {
	int a, b, c, d;
	scanf("%d%d%d%d", &c, &d, &a, &b);
	printf("%d %d %d %d", a + (d - b), b + (a - c), c + (d - b), d + (a - c));
	return 0;
}


Measured memory_bytes: 1712
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main(input) {
  input = myconv(input,5);
  input.shift();
  var umu = [];
  var count = {};
  var output = 0;
  for(var i = 0; i < input.length; i++){
    if(count[input[i]] == null){
       umu.push(input[i]);
      count[input[i]] = 1;
    }else{
      count[input[i]]++;
    }
  }
  
  for(var i = 0; i < umu.length; i++){
    if(count[umu[i]] % 2 == 1){
       output++;
    }
  }
  myout(output);
}

Main(myin());


Measured memory_bytes: 35936