akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main() {
    int a_num, b_num, m;
    cin >> a_num >> b_num >> m;

    vector<int> a(a_num), b(b_num);
    int a_min = 1e5 + 1;
    int b_min = 1e5 + 1;
    for(int i = 0; i < a_num; i++) {
        cin >> a[i];
        if(a_min > a[i]) a_min = a[i];
    }
    for(int i = 0; i < b_num; i++) {
        cin >> b[i];
        if(b_min > b[i]) b_min = b[i];
    }

    int ans = a_min + b_min;
    for(int i = 0; i < m; i++) {
        int x, y, c;
        cin >> x >> y >> c;
        x--; y--;
        if(ans > a[x] + b[y] - c) ans = a[x] + b[y] - c;
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000
typedef long long ll;
const ll INF = (1LL<<60);
ll mod = 1e9+7;
struct edge{ ll to,cost; };

int N,M;
int S,T;
vector<edge> G[MAX];

ll sd[MAX];
ll td[MAX];
ll sp[MAX];
ll tp[MAX];

void dijkstra(int S,ll sd[MAX],ll sp[MAX]){
  for(int i=0;i<MAX;i++){
    sd[i]=INF;
    sp[i]=0;
  }
  sd[S]=0;
  sp[S]=1;
  typedef pair<ll,ll> P;
  priority_queue< P , vector<P> , greater<P> > Q;
  Q.push( P(0,S) );
  while(!Q.empty()){
    P p=Q.top();
    Q.pop();
    ll pos=p.second;
    ll cost=p.first;
    if( cost > sd[pos])continue;
    
    for(int i=0;i<(int)G[pos].size();i++){
      edge e=G[pos][i];
      if( sd[e.to] > cost+e.cost ){
        sd[e.to]=cost+e.cost;
        sp[e.to]=sp[pos];
        Q.push( P(sd[e.to], e.to) );
      }else if(sd[e.to]==cost+e.cost){
        sp[e.to]+=sp[pos];
        sp[e.to]%=mod;
      }
    }
  }
}

int main(){
  cin>>N>>M;
  cin>>S>>T;
  S--;
  T--;
  
  for(int i=0;i<M;i++){
    ll a,b,c;
    cin>>a>>b>>c;
    a--;
    b--;
    G[a].push_back( (edge){b,c} );
    G[b].push_back( (edge){a,c} );
  }
  
  dijkstra(S,sd,sp);
  dijkstra(T,td,tp);

  ll dist = sd[T];
  ll total = (sp[T]*tp[S])%mod;
  //  cout<<dist<<' '<<total<<endl;
  
  //  cout<<total<<endl;
  
  for(int from=0;from<N;from++){
    for(int j=0;j<(int)G[from].size();j++){
      ll to=G[from][j].to;
      ll cost=G[from][j].cost;
      if( sd[from] + td[to] + cost != dist )continue;
      if( sd[from]*2 >= dist || td[to]*2 >= dist)continue;
      ll tmp = (sp[from]*tp[to])%mod;
      tmp = (tmp*sp[from])%mod;
      tmp = (tmp*tp[to])%mod;
      
      total += (mod-tmp);
      total %= mod;      
    }
  }
  
  for(int v=0;v<N;v++){
    if(sd[v]!=td[v])continue;
    if(sd[v]+td[v]!=dist)continue;
    
    ll tmp = (sp[v]*tp[v])%mod;
    tmp = (tmp*tp[v])%mod;
    tmp = (tmp*sp[v])%mod;
    
    total += (mod-tmp);
    total %= mod;
  }

  cout<<total<<endl;
  return 0;
}


Measured memory_bytes: 18772
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n, k;
    cin >> n >> k;
    ll m = n * (n + 1) / 2;
    vl a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i < n; ++i) {
        a[i] += a[i - 1];
    }
    ll ret = 0;
    vl b;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            ll sum = a[j];
            if (i)
                sum -= a[i - 1];
            b.push_back(sum);
        }
    }
    vector<bool> use(m, true);
    for (int i = 50; i >= 0; --i) {
        ll bit  = 1LL << i;
        int cnt = 0;
        for (int j = 0; j < m; ++j) {
            if (use[j] && (bit & b[j]))
                cnt++;
        }
        if (cnt >= k)
            ret += bit;
        else
            continue;
        for (int j = 0; j < m; ++j) {
            if (!(bit & b[j]))
                use[j] = false;
        }
    }
    cout << ret << "\n";
    return 0;
}

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

	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String[] cmd=br.readLine().split(" ");
		int n=Integer.valueOf(cmd[0]);
		long k=Long.valueOf(cmd[1]);
		cmd=br.readLine().split(" ");
		int[] arr=new int[n+1];
		for(int i=1;i<=n;i++)
		{
			arr[i]=Integer.valueOf(cmd[i-1]);
		}
		int start=1;
		int[] bool=new int[n+1];
		long moves=0;
		int b=0;
		int ans=0;
		while(bool[start]==0)
		{
			bool[start]=1;
			moves++;
			start=arr[start];
			if(moves==k)
			{
				b=1;
				ans=start;
				break;
			}
		}
		if(b==1)
			System.out.println(ans);
		else
		{
			b=0;
			bool=new int[n+1];
			int c=0;
			while(bool[start]==0)
			{
				bool[start]=1;
				moves++;
				c++;
				start=arr[start];
				if(moves==k)
				{
					b=1;
					ans=start;
					break;
				}
			}
			if(b==1)
				System.out.println(ans);
			else
			{
				long rem=k-moves;
				rem=rem%c;
				while(rem!=0)
				{
					rem--;
					start=arr[start];
				}
				System.out.println(start);
			}
		}
	}

}


Measured memory_bytes: 61200
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <cstdio>
#include <math.h>
#include <utility>
#include <list>
#include <functional>
using namespace std;

#define ll long long
#define vecint vector<int>
#define Pii pair<int, int>

#define REP(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define print(a) cout << a << endl

#define MOD 1000000007
#define NIL -1

int main(){
  string S;
  list<int> st;

  cin>>S;
  rep(i,S.size()){
    switch(S[i]){
      case '0':st.push_back(0);break;
      case '1':st.push_back(1);break;
      case 'B':
      if(st.size()==0) break;
      st.pop_back();break;
    }
  }
  list<int>::iterator itr;
  for(itr=st.begin();itr!=st.end();itr++){
    cout<<*itr;
  }
  cout<<endl;
  return 0;
}


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

int main(){
    int a, b , c;
    cin >> a >> b >> c;
    int ans = 0,i;
    for(i=0;i<c;i++){
    if(b >= a){
        b = b-a;
        ans ++;
    }
    else{
        cout << ans;
        return 0;
    }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
ls = [list(map(int,input().split())) for i in range(m)]
city = [0 for i in range(n)]
for i in range(m):
  city[ls[i][0]-1] += 1
  city[ls[i][1]-1] += 1
for i in range(n):
  print(city[i])

Measured memory_bytes: 3060
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++)
    cin >> p[i];
  long long ans = 0;
  sort(p.begin(), p.end());
  for (int i = 0; i < n - 1; i++)
    ans += p[i];
  ans += p[n - 1] / 2;
  cout << ans << endl;
  return 0;
}


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

#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main()
{
    fast_io;
    int x;
    cin >> x;
    int yen500 = 0, yen5 =0;
    yen500 = x / 500;
    x -= (yen500 * 500);
    yen5 = x / 5;
    int ans = (yen500 * 1000 )+( yen5 * 5);
    cout << ans << "\n";
}


Measured memory_bytes: 3572
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

LL gcd(LL a, LL b){
    LL tmp; 
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    tmp = a%b;
    while(tmp!=0){
        a = b;
        b = tmp;
        tmp = a%b;
    }

    return b;
}

int main() {
    int n;
    vector<LL> a;
    LL tmp_a;
    LL ans=0;
    LL tmp_ans;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> tmp_a;
        a.push_back(tmp_a);
    }

    vector<LL> l(n+2,0);
    vector<LL> r(n+2,0);

    for(int i=1; i<=n; i++){
        if(i==1){
            l[i]=a[i-1];
        }else{
            l[i]=gcd(l[i-1],a[i-1]);
        }
        //cout << i << " " << l[i-1] << " " << a[i-1] << " " << l[i] << endl;
    }

    for(int i=n; i>=1; i--){
        if(i==n){
            r[i]=a[i-1];
        }else{
            r[i]=gcd(r[i+1],a[i-1]);
        }
        //cout << i << " " << r[i+1] << " " << a[i-1] << " " << r[i] << endl;
    }

    for(int i=1; i<=n; i++){
        if(i==1){
            tmp_ans=r[2];
        }else if(i==n){
            tmp_ans=l[n-1];
        }else{
            tmp_ans=gcd(l[i-1],r[i+1]);
        }
        if(tmp_ans>ans){
            ans=tmp_ans;
        }
    }

    cout << ans << endl;

    return 0;
}


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

int N;
int K;
const long long INF = 1LL << 60;
int main() {
    cin >> N;
    cin >> K;
    int h[N];
    for (int i = 0; i < N; ++i) cin >> h[i];
    sort(h, h + N);
    long long res = INF;
    for (int i = 0; i <= N-K; ++i) res = res < abs(h[i]-h[i+K-1]) ? res : abs(h[i]-h[i+K-1]);
    cout << res << endl;
}

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

namespace ABC098A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b,max,x;
            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);

            max = a + b;
            if (max < a - b) max = a - b;
            if (max < a * b) max = a * b;

            Console.WriteLine(max);

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n, num, comm;
    vector<int> V;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> comm;
        if (comm == 0) {
            cin >> num;
            V.push_back(num);
        } else if (comm == 1) {
            cin >> num;
            cout << V[num] << endl;
        }
        else {
            V.pop_back();
        }
    }
    return 0;
}


Measured memory_bytes: 3848
((input: string): void => {
    const hoge = input.trim().split(/\n/).map(Number)
    const fuga = hoge.slice(-2)[0] - hoge[0];
    console.log(fuga > hoge.slice(-1)[0] ? ':(' : 'Yay!');
})(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdlib>
using namespace std;

int main() {
	vector<int> a;
	int x;
	while (cin >> x) {
		a.push_back(x);
	}
	sort(a.begin(), a.end());
	cout << a[0] + a[1] + (a[2]*10)<< endl;
	return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n, a, b;
  cin>>n>>a>>b;
  int mn = max(0, a+b-n);
  int mx = min(a, b);
  cout << mx << ' ' << mn << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	for (int i = 0; i < 10000; ++i)
	{
		vector<int> vec(10000);
		cin >> vec.at(i);
		if(vec.at(i)==0){
			break;
		}
		else{
			cout << "Case " << i+1 << ": " << vec.at(i) << endl;
		}
	}
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define FAST_INPUT ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long

using namespace std;

void solve() {
    int x;
    cin >> x;
    x-=400;
    cout << (8-x/200) << endl;
}

int main() {
    FAST_INPUT;

    solve();

    return 0;
}


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

bool compare_inverse(pair<int, int> a, pair<int, int> b) {
        return a.first > b.first;
}

int main(){
  int n,m;
  cin >> n >> m;
  vector<pair<int,int>>num(n+m);
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
    num[i] = make_pair(a[i],1);
  }
  int b[m],c[m];
  for(int i=0;i<m;i++){
    cin >> b[i] >> c[i];
    num[i+n] = make_pair(c[i],b[i]);
  }
  sort(num.begin(),num.end(),compare_inverse);
  ll ans=0;
  int k=0;
  for(int i=0;i<n;i++){
    if(num[k].second!=1){
      ans += num[k].first;
      num[k].second += -1;
    }else{
      ans += num[k].first;
      k += 1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 2944
#include <stdio.h>

int main() {
	int a, n, nn[4], find, x;

	scanf("%d", &n);

	for (a = 3; a >= 0; a--) {
		nn[a] = n % 10;
		n = n / 10;
	}

	find = nn[0];
	x = 0;
	for (a = 0; a < 3; a++) {
		if (nn[a] == find) x++;
	}
	if (x >= 3) {
		printf("Yes\n");
		return 0;
	}

	find = nn[1];
	x = 0;
	for (a = 1; a < 4; a++) {
		if (nn[a] == find) x++;
	}
	if (x >= 3) {
		printf("Yes\n");
		return 0;
	}
	
	printf("No\n");

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main()
{
    string a, b, c;
    cin >> a >> b >> c;

    putchar(toupper(a[0]));
    putchar(toupper(b[0]));
    putchar(toupper(c[0]));
    return 0;
}

Measured memory_bytes: 256
module Main where

import Control.Applicative
import Numeric
import Data.Char

main :: IO ()
main = loop

loop :: IO()
loop = do
  { [n] <- getIntegers
  ; if n == 0 then return ()
    else do
      {  print (sum (map digitToInt (show n)))
       ; loop
       ;
       }
  }

-- main = do
--  { [x] <- getInts
--  ; loop x
--  ; 
--    }

-- loop :: Int -> IO [Int]
-- loop 0 = return []
-- loop x = do
--   { x <- getInts
  
    
--
getIntegers :: IO [Integer]
getIntegers = map read . words <$> getLine

getInts :: IO[Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

getDoubles :: IO [Double]
getDoubles = map read . words <$> getLine

putDoubles :: [Double] -> IO ()
putDoubles = putStrLn . unwords . map showDouble

showDouble :: Double -> String
showDouble d = showFFloat Nothing d ""




Measured memory_bytes: 4524
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String[] arr = br.readLine().split(" ");
        int A = Integer.parseInt(arr[0]);
        int B = Integer.parseInt(arr[1]);
        int C = Integer.parseInt(arr[2]);
        int ans = 0;
        if (A > B) {
            ans = 0;
        } else if (B / A > C) {
            ans = C;
        } else {
            ans = B / A;
        }
        out.println(ans);
        out.close();
    }
}


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

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

#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)

class CModuloSummation {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n; in >> n;
		int res = 0, x;
		f(i, n) in >> x, res += x;
		res -= n;
		out << res;
	}
};


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	CModuloSummation solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NEAL_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif


int main() {
    ios::sync_with_stdio(false);
#ifndef NEAL_DEBUG
    cin.tie(nullptr);
#endif

    int N;
    cin >> N;
    set<string> items;

    while (N-- > 0) {
        string str;
        cin >> str;
        items.insert(str);
    }

    cout << items.size() << '\n';

}


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

using namespace std;
using ll = long long;

using ll = long long;

const int mod = 1e9 + 7;

void add_self(int&a, int b) {
    a += b;
    if(a >= mod) {
        a -= mod;
    }
}
int mul(int a, int b) {
    return (ll) a * b % mod;
}

int n;

struct M {
    vector<vector<int>> t;
    M() {
        t.resize(n, vector<int>(n));
    }
    M operator* (const M& b) const {
        M c = M();
        for(int i = 0; i < n; ++i) {
            for(int j = 0; j < n; ++j) {
                for(int k = 0; k < n; ++k) {
                    add_self(c.t[i][k], mul(t[i][j], b.t[j][k]));
                }
            }
        }
        return c;
    }
};

signed main() {
    ll k;
    scanf("%d%lld", &n, &k);
    vector<vector<int>> can(n, vector<int>(n));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            scanf("%d", &can[i][j]);
        }
    }
    M answer = M();
    for (int i = 0; i < n; i++) {
        answer.t[i][i] = 1;
    }
    M m = M();
    m.t = can;
    while (k) {
        if (k % 2) {
            answer = answer * m;
        }
        m = m * m;
        k /= 2;
    }
    int total = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            add_self(total, answer.t[i][j]);
        }
    }
    printf("%d\n", total);
    return 0;
    vector<int> dp(n, 1);
    // dp[i] - the number of ways we got to vertex 'i' so far
    for (ll step = 0; step < k; step++) {
        vector<int> new_dp(n);
        for (int a = 0; a < n; a++) {
            for (int b = 0; b < n; b++) {
                if (can[a][b]) {
                    add_self(new_dp[b], dp[a]);
                }
            }
        }
        dp = new_dp;
    }
    return false;
}

Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <vector>
#include <algorithm>
using namespace std;
long n, A[20] = {};

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	long m, i, j, k;
	cin >> n;
	for (i = 0; i < n; ++i)
		cin >> A[i];

	vector<long> vN;
	vN.reserve(40000);
	for (i = 0; i < n; ++i){
		vN.push_back(A[i]);
		int s = vN.size();
		for (j = 0; j < s - 1; ++j){
			long k = vN[j] + A[i];
			if( k <= 2000 ) 
				vN.push_back(k);
		}
	}
	sort(vN.begin(), vN.end());
	cin >> m;
	for (i = 0; i < m; ++i){
		cin >> k;
		cout << (binary_search(vN.begin(), vN.end(), k) ? "yes\n" : "no\n");
	}

	return 0;
}

Measured memory_bytes: 12116
x,n=map(int,input().split())
if n==0:
  print(x)
else:
  a=list(map(int,input().split()))
  flag=0
  i=0
  while flag==0:
    continueflag=0
    for j in range(n):
      if a[j]==x-i:
        continueflag=1
        break
    if continueflag==0:
      print(x-i)
      break
      
    continueflag=0
    for j in range(n):
      if a[j]==x+i:
        continueflag=1
        break
    if continueflag==0:
      print(x+i)
      break
    i=i+1


Measured memory_bytes: 9204
#for _ in range(int(input())):
a,b,c=map(int,input().split())
k=int(input())
f=0
if a<b<c:
  print('Yes')
  f=1
t=0
while(b<=a):
  b*=2
  t+=1
while(c<=b):
  c*=2
  t+=1
if t<=k and f==0:
  print('Yes')
  f=1
if f==0:print('No')

Measured memory_bytes: 61712
#include <stdio.h>
int main(){
    char x[1001];
    int temp,now;
    for(int i=0;i<1001;i++)
        x[i]='\0';
    while(1){
        scanf("%s",x);
        if(x[0]=='0')return 0;
        temp=now=0;
        while(x[now]!='\0'){
            temp+=x[now]-'0';
            now++;
        }
        for(int i=0;i<now;i++)
            x[i]='\0';
        printf("%d\n",temp);
    }
}

Measured memory_bytes: 2740
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }




void solve() {
    int n; string s;
    cin >> n >> s;
    
    int cnt = 0;
    rep(i, n) {
        if (s.substr(i, 3) == "ABC") cnt++;
    }
    cout << cnt << endl;
}



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T;
    // cin >> T;
    T = 1;
    
    while (T--) {
        solve();
    }
}




Measured memory_bytes: 256
object Main {
  
  def main(args: Array[String]) = {
    
    val input: String = readLine()
    val list: Array[Int] = input.split(" ").map((a: String) => a.toInt)
    
    for (i <- 0 to list.length - 2) {
      for (j <- 1 to list.length - 1) {
        if (list(i) > list(j)) {
          val tmp = list(i)
          list(i) = list(j)
          list(j) = tmp
        }
      }
    }
    
    println(list.mkString(" "))
  }
  
  //def readLine(): String = {"3 8 1"}
}



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

const int MX = 26;
int f[MX];

int main() {
	string S;
	int n, ans = 0;
	cin >> S;
	n = S.size();
	for(int i = 0; i < n; i++) {
		f[S[i] - 'a']++;
	}
	
	bool ok = true;
	for(int i = 0; i < MX; i++) {
		ok &= (f[i] % 2 == 0);
	}

	ok ? cout << "Yes\n" : cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

int binpow(int a, int b) {
    if (b == 0)
        return 1;
    int res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}

ll gcd(ll a,ll b)
{
    if (b==0) return a;
    return gcd(b,a%b);
}
string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a,b;
    cin>>a>>b;
    if (a<10&&b<10)
    {
        cout<<a*b;
    }
    else
    {
        cout<<-1;
    }
    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 max = sc.nextInt();
		int min = max;
		
		for (int i = 1; i < n; i++) {
			int a = sc.nextInt();
			if (a > max)			max = a;
			else if (a < min)		min = a;
		}
		
		System.out.println(Math.abs(max - min));
	}
}

Measured memory_bytes: 21844
using System;
class ProgramD
    {
        static void Main(string[] args)
        {
            
            //入力
            string[] a = Console.ReadLine().Split(' ');
            long n = long.Parse(a[0]);
            long x = long.Parse(a[1]);
            long y = long.Parse(a[2]);
            long[] ans = new long[n];
 
            for(long i = 1;i <= n;i++)
                for(long j = i+1;j <= n;j++)
                {
                    if(j <= x)
                    {
                        ans[j - i]++;
                        continue;
                    }
 
                    if(y <= i)
                    {
                        ans[j - i]++;
                        continue;
                    }
 
                    
                    ans[Math.Min(j - i, Math.Abs(y - j)+ Math.Abs(x - i) + 1)]++;
 
                }
 
            for(long i = 1;i <= n - 1;i++)
                Console.WriteLine(ans[i]);
 
            
        }
 
 
    }

Measured memory_bytes: 13244
// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//


#include<bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define int long long int
#define ld long double
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define r0 return 0;
#define tc int t;cin>>t;while(t--)
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define md 998244353
#define inf 1000000000000000 //1e15
#define gcd __gcd
#define lcm(a,b) ((a)*(b))/gcd(a,b)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
int min(int a,int b){
    return (a<b)?a:b;
}
int max(int a,int b){
    return (a>b)?a:b;
}
int fp(int a,int b){
    if(b==0) return 1;
    int x=fp(a,b/2);
    x=(x*x)%mod;
    if(b&1) x=(x*a)%mod;
    return x;
}
int factorial(int n)
{
    int fact=1;
    for(int i=2;i<=n;i++)
    fact=fact*i;
    
    return fact;
}
int ncr(int n,int r)
{
    return factorial(n)/(factorial(r)*factorial(n-r));
}
int binomialCoeff(int n,int k)
{
    int dp[k+1];
    memset(dp,0,sizeof(dp));
    dp[0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=min(i,k);j>0;j--)
        dp[j]=(dp[j]+dp[j-1])%mod;
    }
    return dp[k]%mod;
    
}
void c_p_c()
{
    crap;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
signed main()
{
    c_p_c();
    int n;
    cin>>n;
    
    cout<<(fp(10,n)%mod-(2*fp(9,n))%mod+fp(8,n)%mod+mod)%mod<<endl;
    
    
    
    //cout<<( (10^n)%mod- (2*(9^n) )%mod+((8^n))%mod +mod)%mod<<endl;
}

Measured memory_bytes: 3628
#ifdef DBG1
  #define LOCAL
#endif

#ifdef LOCAL
  #define _GLIBCXX_DEBUG
#endif

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#ifdef DBG1
    #define dbg(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dbg(...)
#endif

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;

bool check(const char *s, int A, int B) {
  assert(A < B);
  for (int i = A; i < B; ++i) {
    if (s[i] == '#' && s[i + 1] == '#') {
      return false;
    }
  }
  return true;
}

bool check2(const char *s, int A, int B) {
  assert(A < B);
  for (int i = A; i <= B; ++i) {
    if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
      return true;
    }
  }
  return false;
}

bool solve() {
  int n, A, B, C, D;
  if (scanf("%d%d%d%d%d", &n, &A, &B, &C, &D) != 5) { return false; }

  --A, --B, --C, --D;
  static char s[200100];
  scanf("%s", s);
  printf("%s\n", check(s, A, C) && check(s, B, D) && (C < D || check2(s, B, D)) ? "Yes" : "No");

  return true;
}

int main() {
  while (solve());
  return 0;
}


Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from fractions import Fraction

N, K = map(int, input().split())
if N >= K*2-1:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 65388
S = input()
S = S[::-1]

divide = ["esare","resare","maerd","remaerd"]
hantei = False
i = 0

while i < len(S):
    for j in range(len(divide)):
        if (len(S[j:]) >= len(divide[j])) and (S[i:i+len(divide[j])] == divide[j]):
            i += len(divide[j])
            break
    else:
         break
else:
    hantei = True

if hantei:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int i;
    int a[100];
    for(i=0;i<n;i++){
        cin >> a[i];
    }
    stable_sort(a,a+n);
    reverse(a,a+n);
    int ans=0;
    for(i=0;i<n;i++){
        if(a[i]>=i+1){
            ans=i+1;
        }
    }
    cout << ans << endl;
    return(0);
}


Measured memory_bytes: 3152
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<utility>
#include<functional>
#include<cassert>

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

int main(void) {
	int n,ans=1;
	string s;
	cin >> n >> s;
	for (int i = 0; i < s.size()-1; i++) {
		if (s[i] != s[i + 1])ans++;
	}

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

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n;
  	cin>>n;
  ll b[n-1];
  for(ll i=0;i<n-1;i++)
    cin>>b[i];
  vector<ll> a(n,-1);
  a[0]=b[0];
  a[1]=b[0];
  for(ll i=1;i<n-1;i++)
  {
    if(a[i]>b[i])
      a[i]=b[i];
    a[i+1]=b[i];
  }
  ll sum=0;
  for(ll i=0;i<n;i++)
    sum+=a[i];
 cout<<sum<<endl;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
mai=0
for i in range(n):
    if a[i]<0:
        mai+=1
ans=0
for i in range(n):
    ans+=abs(a[i])
    a[i]=abs(a[i])
if mai%2==0:
    print(ans)
else:
    print(ans-2*abs(min(a)))

Measured memory_bytes: 14412
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
    while (1)
    {
        int n, a[1000];
        double av=0, var=0;
        scanf("%d", &n);
        if (n==0) break;
        for (int i=0; i<n; i++)
        {
            scanf("%d", &a[i]);
            av+=a[i];
        }
        av/=n;
        for (int i=0; i<n; i++) var+=abs(av-a[i])*abs(av-a[i]);
        var/=n;
        printf("%.10f\n", sqrt(var));
    }
    return 0;
}



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

namespace Beg122A
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var atcg = new char[4] { 'A', 'T', 'C', 'G' };
            var start = false;
            var startIndex = 0;
            var ans = 0;
            var finalCharTrue = false;
            for (int i = 0; i<s.Length;i++)
            {
                if(atcg.Contains(s[i]))
                {
                    if(!start)
                    {
                        startIndex = i;
                        start = true;
                    }
                    if(i == s.Length - 1)
                    {
                        finalCharTrue = true;
                    }
                }
                if(start && !atcg.Contains(s[i]))
                {
                    ans = Math.Max(ans, i - startIndex);
                    start = false;
                }
            }
            if(finalCharTrue)
                ans = Math.Max(ans, s.Length - startIndex);
            Console.WriteLine(ans);
        }

    }
}


Measured memory_bytes: 13268
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<algorithm>
using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    map<int, int> A;
    for(int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        A[a] += 1;
    }
    vector<int> numvec;
    for(auto pair : A) {
        numvec.push_back(pair.second);
    }
    sort(numvec.begin(), numvec.end());
    int ret = 0;
    int to_rewrite = numvec.size()-K;
    for(int i = 0; i < to_rewrite; ++i) {
        ret += numvec[i];
    }
    cout << ret << endl;
    return 0;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % 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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

ll dp[100100][2];
const ll MOD = 1e9+7;

vector<int> G[100100];

int N;

ll dfs(int v, int color, int p){

  if(dp[v][color] >= 0) return dp[v][color];
  
  ll ret = 1;

  for(auto nv : G[v]){

    if(nv == p) continue;

    if(color == 0){

      ret = (ret * (dfs(nv, 0, v) + dfs(nv, 1, v)) % MOD) % MOD;

    }else{
      
      ret = (ret * dfs(nv, 0, v)) % MOD;

    }
  }

  return dp[v][color] = ret;

}

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

  cin >> N;

  int x, y;
  rep(i, N-1){
    cin >> x >> y;
    x--;
    y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }

  rep(i, N){
    rep(j, 2){
      dp[i][j] = -1;
    }
  }

  ll ans = (dfs(0, 0, -1) + dfs(0, 1, -1)) % MOD;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 15616
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
#define Endl endl
const int INF=100000000;
int main(){
	string s;
	cin>>s;
	cout<<"ABC"<<s<<endl;
	return 0;
}

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

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

VLL DP0, DP1;
VVLL childs;
VVLL G;
VLL parents;
ll N, M;

ll dp0(ll n) {
	if (DP0[n] != -1)return DP0[n];
	if (childs[n].size() == 0) {
		DP0[n] = 1;
		return 1;
	}
	DP0[n] = 1;
	for (ll c : childs[n]) {
		DP0[n] *= (dp0(c) + 1);
		DP0[n] %= M;
	}
	return DP0[n];
}

void dp1(ll n) {
	if (n == 0) {
		DP1[n] = 0;
	}
	if (childs[n].size() == 0) {
		return;
	}
	VLL sfront(childs[n].size());
	sfront[0] = DP0[childs[n][0]]+1;
	for (ll c = 1; c < childs[n].size(); c++) {
		sfront[c] = sfront[c-1]*(DP0[childs[n][c]]+1);
		sfront[c] %= M;
	}
 	VLL sback(childs[n].size());
	sback.back() = DP0[childs[n].back()]+1;
	for (ll c = (ll)childs[n].size() - 2; c >= 0; c--) {
		sback[c] = sback[c + 1] * (DP0[childs[n][c]]+1);
		sback[c] %= M;
	}
	for (ll c = 0; c < childs[n].size(); c++) {
		ll ans = 1;
		if (c > 0)ans *= sfront[c - 1];
		if (c < (ll)childs[n].size() - 1) {
			ans = (ans * sback[c + 1]) % M;
		}
		ans = (ans * (DP1[n] + 1)) % M;
		DP1[childs[n][c]] = ans;
		dp1(childs[n][c]);
	}
	return;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cin >> N >> M;
	childs.resize(N);
	G.resize(N);
	for (ll n = 0; n < N - 1; n++) {
		ll x, y;
		cin >> x >> y;
		x--; y--;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	parents.resize(N);
	queue<pll> q;
	q.push(pll(0,-1));
	while (!q.empty()) {
		pll cur = q.front();
		q.pop();
		parents[cur.first] = cur.second;
		for (ll child : G[cur.first]) {
			if (child == cur.second)continue;
			childs[cur.first].push_back(child);
			q.push(pll(child, cur.first));
		}
	}
	DP0.resize(N,-1);
	for (ll n = 0; n < N; n++)dp0(n);
	DP1.resize(N,-1);
	dp1(0);
	for (ll n = 0; n < N; n++) {
		cout << (DP0[n] * (DP1[n]+1)) % M << "\n";
	}
	return 0;
}

Measured memory_bytes: 23296
function main()
  n = parse(readline())
  a = parse.(split(readline()))
  max = 0
  min = 1000000000
  for i in 1:n
    if a[i] <= min
      min = a[i]
    end
    if a[i] >= max
      max = a[i]
    end
  end
  print(max-min)
end

main()

Measured memory_bytes: 119808
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int b=0,c,e=1,f=0,a,k=0,l;
    cin>>a;
    for(int i=a;i>0;i=i/10)
        b++;
    if(b>2)
    for(int k=b;k>1;k=k-2)
        {f=f+9*e;e=e*100;}
    else if(b==1)
        f=a;
    if(b%2!=0 && b>2)
        f=f+(a-e)+1;
    if(b==2)
        f=9;
    cout<<f;
}


Measured memory_bytes: 256
input1 = input()
x = []
y=[]
check=0

for i in input1:
    if i!=" " and check==0:
        x.append(i)
    elif i==" ":
        check=1
    elif i!=" " and check==1:
        check==1
        y.append(i)
xstring=''.join(x)
ystring=''.join(y)

xint=int(xstring)
yint=int(ystring)

if yint==1:
    print(0)
else:
    cnt=0
    while ((xint-1)*(cnt))+xint<yint:
        cnt=cnt+1
    cnt=cnt+1
    print(cnt)
    

    


Measured memory_bytes: 3064
# import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial  # , gcd
from bisect import bisect_left, bisect_right  # bisect_left(list, value)

sys.setrecursionlimit(10 ** 7)
enu = enumerate
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")

X = int(input())
print('Yes') if 30<=X else print('No')

Measured memory_bytes: 65096
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <stack>
using namespace std;
typedef long long LL;
const int N = 1e6+7 , INF = 0x3f3f3f3f , MOD = 1e9+7;
const double PI = acos(0.0) * 2;
template<typename T1>
T1 gcd(T1 a , T1 b){ return b ? gcd(b,a%b) : a;}

int main(){
#ifdef LOCAL
    freopen("E:\\c++\\in.txt", "r", stdin);
//  freopen("E:\\c++\\out.txt","w",stdout);
#endif
    LL n,a,b,c,d;
    scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
    bool f = 0;
    for(int i = 0 ; i <= n ; i++){
        if( (a+i*c-(n-1-i)*d) <= b && b <= (a+i*d-(n-1-i)*c) ){
            f = 1;
            break;
        }
    }
    puts(f ? "YES" : "NO");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>
#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222






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


  vpll v;
  cin >> n >> m;
  rep(i, n) {
    ll a, b;
    cin >> a >> b;
    if (m - a >= 0) v.pb(pll(m - a, b));
  }
  priority_queue<ll, vll, greater<ll>> pq;
  v.pb(pll(inf, 0));
  sort(all(v));
  ll cur = 0;
  rep(i, m) {
    while (v[cur].first <= i) {
      tmp = pq.size();
      if (tmp < i + 1) {
        pq.push(v[cur].second);
      }
      else {
        tmp = pq.top();
        if (tmp < v[cur].second) {
          pq.pop();
          pq.push(v[cur].second);
        }
      }
      cur++;
    }
  }
  while (!pq.empty()) {
    ans += pq.top();
    pq.pop();
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3696
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let ab = read_vec::<u64>();
    let ans = if ab[0] == ab[1]{
        "Draw"
    } else if ab[0] == 1  {
        "Alice"
    } else if ab[1] == 1 {
        "Bob"
    } else if ab[0] < ab[1]{
       "Bob" 
    } else {
        "Alice"
    };
    println!("{}",ans );
}

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

typedef long long ll;

int main(void)
{
	ll n;

	scanf("%lld" ,&n);

    ll t = (ll)log2(n);

    printf("%lld" ,(ll)pow(2.0, t) + (ll)pow(2.0, t) - 1);
    return 0;
}

Measured memory_bytes: 384
import math
def combinations_count(n, r):
    return (math.factorial(n) // (math.factorial(n - r) * math.factorial(r)))

inf = (10 ** 9) + 7
n, k = map(int, input().split())
for i in range(1, k+1):
    if (n - k + 1 >= i):
        print((combinations_count((n - k + 1), i)*combinations_count((k-1), i-1)) %inf)
    else:
        print(0)

Measured memory_bytes: 3316
import java.util.*;
import java.io.*;
import java.math.BigInteger; 

 public class Main{
// taking inputs
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
// ends

//......................................@uthor_Alx..............................................

   public static void main(String[] args) throws  IOException{
	        		  assign();
              int r= int_v(read());
              int[] arr=int_arr();
              int[] f=new int[300000];
              for(int x:arr){f[x]++;}
              for(int i=1;i<=r;i++){
              	out.write(f[i]+"\n");
              }
              out.flush();
	        		 
	}
	       
	          
}

	    

	
  





Measured memory_bytes: 63848
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=(a);i<(b);++i)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}"<<endl;
  return o;
}

//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m; 
  if (u < 0) u += m;
  return u;
}
ll const mod = 1e9+7;

// combination
const int MAX = 510000;
const ll MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  int N;
  string s;
  cin >> N;
  int ac=0,wa=0,tle=0,re=0;
  rep(i,N) {
    cin >> s;
    if (s=="AC") ac++;
    else if (s=="WA") wa++;
    else if (s=="TLE") tle++;
    else re++;
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}

Measured memory_bytes: 3624
x = gets.to_i
r = x % 11

answer = 0

if x < 11
  if x < 7
    answer = 1
  else
    answer = 2
  end
elsif r == 0
  answer = x / 11 * 2
elsif r < 7
  answer = x / 11 * 2 + 1
else
  answer = x / 11 * 2 + 2
end

puts answer

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

int main() {
    // your code goes here
    int n,i,a[200005],ans=0,pb=1;
    bool ok=false;
    cin >> n;
    for(i=1;i<=n;i++){
        cin >> a[i];
        if(a[i]==1) ok=true;
    }
    if(!ok){
        cout << "-1" << endl;
        return 0;
    }
    for(i=1;i<=n;i++){
        if(a[i]!=pb) ans++;
        else pb++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    int X; cin >> X;
    if(X >= 2000) cout << 1 << endl;
    else{
        for(int i=1; i<20; i++){
            if(100*i <= X && X <= 100*i+5*i) {cout << 1 << endl; break;}
            if(i == 19) cout << 0 << endl;
        }
    }

}



Measured memory_bytes: 256