akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7ffffffe
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double dl;
using namespace std;

int n,m;
vpi v;
priority_queue<int,vector<int>,less<int>> pq;
int main(){
	cin>>n>>m;
	rep(i,n){
		int a,b;
		cin>>a>>b;
		a--;
		v.pb(mp(a,b));
	}
	stable_sort(all(v));
	int cur=0,ans=0;
	rep(i,m){
		for(int j=cur;j<n;j++){
			int a=v[j].fi,b=v[j].sc;
			if(a<=i){
				pq.push(b);
			}else break;
			cur++;
		}
		if(sz(pq)){
			int t=pq.top();
			ans+=t;
			pq.pop();
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1908
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
 
// ------------------------------------------------------------------------------------------------

const ll MOD = 998244353;
ll n, ans;
vll x, y, idx, idx2, t;

ll query(ll l, ll r, ll v, ll tl, ll tr) {
    if (l > r) {
        return 0;
    }
    if (l == tl && r == tr) {
        return t[v];
    }
    ll tm = (tl + tr) / 2;
    return query(l, min(r, tm), v * 2, tl, tm) + query(max(l, tm + 1), r, v * 2 + 1, tm + 1, tr);
}

void update(ll pos, ll v, ll tl, ll tr) {
    t[v]++;
    if (tl != tr) {
        ll tm = (tl + tr) / 2;
        if (pos <= tm) {
            update(pos, 2 * v, tl, tm);
        } else {
            update(pos, 2 * v + 1, tm + 1, tr);
        }
    }
}

ll bin_exp(ll b, ll e, ll mod = MOD) {
    ll ret = 1;
    while (e > 0) {
        if (e & 1) {
            (ret *= b) %= MOD;
        }
        (b *= b) %= MOD;
        e >>= 1;
    }
    return ret;
}

int main() {
    fast_io; cout_precision;
    cin >> n;
    x.resize(n); y.resize(n);
    idx.resize(n); idx2.resize(n);
    for (ll i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        idx[i] = i; idx2[i] = i;
    }
    sort(idx.begin(), idx.end(), [&](const ll &l, const ll &r) {
        if (y[l] != y[r]) {
            return y[l] < y[r];
        } else {
            return l < r;
        }
    });
    for (ll i = 0; i < n; i++) {
        idx2[idx[i]] = i;
    }
    sort(idx.begin(), idx.end(), [&](const ll &l, const ll &r) {
        if (x[l] != x[r]) {
            return x[l] < x[r];
        } else {
            return y[l] < y[r];
        }
    });
    t.resize(3 * n);
    ans = 0;
    for (ll i = 0, q1, q2, q3, q4; i < n; i++) {
        q3 = query(0, idx2[idx[i]], 1, 0, n - 1);
        q2 = i - q3;
        q4 = idx2[idx[i]] - q3;
        q1 = n - i - 1 - q4;
        (ans += bin_exp(2, n)) %= MOD;
        (ans -= bin_exp(2, q1 + q2)) %= MOD;
        (ans -= bin_exp(2, q2 + q3)) %= MOD;
        (ans -= bin_exp(2, q3 + q4)) %= MOD;
        (ans -= bin_exp(2, q4 + q1)) %= MOD;
        (ans += bin_exp(2, q1)) %= MOD;
        (ans += bin_exp(2, q2)) %= MOD;
        (ans += bin_exp(2, q3)) %= MOD;
        (ans += bin_exp(2, q4)) %= MOD;
        (ans -= 1) %= MOD;
        update(idx2[idx[i]], 1, 0, n - 1);
    }
    cout << (ans + MOD) % MOD << endl;
}

Measured memory_bytes: 11264
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define   pr pair<int,int>
using namespace std::chrono;
const int N = 1e6 , M=N,inf=(int)1e9;
const ll mod=1e9+7;
int fastAbs(int n) { return (n ^ (n >> 31)) - (n >> 31); }
ll multiply(ll a, ll b){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
int ans ;
void read (vector< int > & a){
    for( int i = 0 ; i < a.size() ; i++)    cin>>a[i];
}
map< pair<int,int> , int > mp;
const int dx[4] = {1,0,0,-1};
const int dy[4] = {0,-1,1,0};
void solve(){
   int n , m ;
   cin >> n >> m ;
   vector< pair < ll , ll > > a(n);
   for( int i = 0 ; i < n ; i++){
        cin >> a[i].ff >> a[i].ss;
   }
   sort(st(a));
   ll ans = 0 ;
   for( int i = 0 ; i  < n ; i++){
        if(m>=a[i].ss){
            ans+=(a[i].ss*a[i].ff);
            m-=a[i].ss;
        }
        else{
            ans+=m*a[i].ff;
            break;
        }
   }
   cout << ans ;

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q=1;
    //cin >> q;
    while(q--)
        solve();
}
/*
    update - o(1) - log time
*/


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

using namespace std;

int main(int argc, char *argv[]) {
	int N;

	vector<int> A;
	vector<int> B;
	vector<int> C;

	cin >> N;

	for (int i = 0; i < N; i++) {
		int n;
		cin >> n;
		A.push_back(n);
	}

	for (int i = 0; i < N; i++) {
		int n;
		cin >> n;
		B.push_back(n);
	}

	for (int i = 0; i < N; i++) {
		int n;
		cin >> n;
		C.push_back(n);
	}

	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());

	long long ans = 0;
	for (int i = 0; i < B.size(); i++) {
		long long a = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
		long long c = C.end() - upper_bound(C.begin(), C.end(), B[i]);
		ans += a * c;
	}

	cout << ans << endl;

	return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int dp[1001][1001];

int main()
{
    int n;
    char c;
    while (cin >> n, n)
    {
        rep(i, n)
        {
            rep(j, n)
            {
                cin >> c;
                dp[i][j] = (c == '*' ? 0 : 1);
            }
        }

        int maxv = 0;
        for (int i = 1; i < n; i++)
        {
            for (int j = 1; j < n; j++)
            {
                if (dp[i][j] == 0)
                    continue;
                dp[i][j] = min({dp[i][j - 1], dp[i - 1][j - 1], dp[i - 1][j]}) + 1;
                maxv = max(maxv, dp[i][j]);
            }
        }
        OP(maxv);
    }

    return 0;
}


Measured memory_bytes: 6908
N, Y = map(int, input().split())

l = (-1, -1, -1)

for i in range(N + 1):
    for j in range(N + 1):
        if 10000 * i + 5000 * j + 1000 * (N - (i + j)) == Y and N - (i + j) >= 0:
            l = (i, j, N - (i + j))
            break

print(l[0], l[1], l[2])

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

int main() {
  int n,k,x,ans=0;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    /* code */
    cin >> x;
    ans += min(x,k-x)*2;
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 256
from functools import reduce
l = [int(input()) for _ in range(5)]
r = min([10 if i % 10 == 0 else i % 10 for i in l])
m = [i if i % 10 == 0 else i // 10 * 10 + 10 for i in l]
print(reduce(lambda a, b: a + b, m) + r - 10)

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

fn read<T: FromStr> () -> T {
    let stdin = std::io::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 N: usize = read();
    let mut vec: Vec<usize> = (0..N).map(|_| read::<usize>()).collect();
    vec.sort();
    let mut value: f64 = vec[0] as f64;
    for i in 1..N {
        value = (value + vec[i] as f64)/2_f64;
    }
    println!("{}",value);
}



Measured memory_bytes: 4352
#
# abc048 a
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """AtCoder Beginner Contest"""
        output = """ABC"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """AtCoder Snuke Contest"""
        output = """ASC"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """AtCoder X Contest"""
        output = """AXC"""
        self.assertIO(input, output)


def resolve():
    S = list(input().split())

    print("A"+S[1][0]+"C")


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16228
N=int(input())
P=list(map(int,input().split()))
Q=[i for i in range(1,N+1)]
c=0
if P==Q:
   print("YES")
else:
   for j in range(0,N):
       if P[j]!=Q[j]:
           c +=1
   if c==2:
       print("YES")
   else:
       print("NO")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}
 
void solve()
{
    int n;
    cin>>n;
    int a[n];
    int ze = 0;
    for (int i = 0; i < n;i++){
        cin >> a[i];
        if(a[i]==0){
            ze++;
        }
    }
    if(ze){
        cout << 0 << endl;
        return;
    }
    int ans = 1;
    int z = 1e18;
    for (int i = 0; i < n;i++){
        if(z/ans<a[i]){
            cout << -1;
            return;
        }
        ans *= a[i];
    }
    cout << ans << endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1;
    // cin >> tc;
    while (tc--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 4324
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main{
	static final int module = (int) 1e9 + 7;
	static int w, h;
	static StringBuilder[] graph;
	static int[][] memo;

	public static int dp(int i, int j) {
		if (i == h - 1 && j == w - 1)
			return 1;
		if (i >= h || j >= w || graph[i].charAt(j)=='#')
			return 0;
		if (memo[i][j] != -1)
			return memo[i][j];
		return memo[i][j] = (dp(i+1,j)+dp(i,j+1)) % module;

	}

	public static void main(String[] args) throws IOException {

		PrintWriter pw = new PrintWriter(System.out);
		Scanner sc = new Scanner(System.in);
		h = sc.nextInt();
		w = sc.nextInt();
		graph = new StringBuilder[h];
		memo = new int[h][w];
		for (int i = 0; i < h; i++) {
			graph[i] = new StringBuilder(sc.nextLine());
			Arrays.fill(memo[i], -1);
		}
		pw.print(dp(0,0));
		pw.close();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}


Measured memory_bytes: 42368
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    x=int(input())
    for a in range(-118,120):
        for diff in range(1,238):
            if a**5-(a-diff)**5>10**9:
                break
            if a**5-(a-diff)**5==x:
                print(a,a-diff)
                sys.exit()

if __name__=='__main__':
    main()

Measured memory_bytes: 64152
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
#include <map>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> p(n+10);
    rep(i,n){
        cin >> p[i];
    }
    int res = 0;
    for(int i = 1; i < n-1; i++){
        if(p[i-1] < p[i]){
            if(p[i] < p[i+1]){
                res++;
            }
        }
        else{
            if(p[i] > p[i+1]){
                res++;
            }
        }
    }
    cout << res;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int helper(long long int dp[][3001],int A[],int i,int j){
    if(i>j){
        return 0;
    }
    if(i==j){
        return A[i];
    }
    if(dp[i][j]!=-1){
        return dp[i][j];
    }
    return dp[i][j] = max(A[i]+min(helper(dp,A,i+1,j-1),helper(dp,A,i+2,j)),A[j]+min(helper(dp,A,i+1,j-1),helper(dp,A,i,j-2)));
    
}

int main() {
        int n;
        cin>>n;
        int A[n];
    	long long int total = 0;
        for(int i=0;i<n;i++){
            cin>>A[i];
            total+=A[i];
        }
        long long int dp[3001][3001];
        memset(dp,-1,sizeof(dp));
        long long int X =helper(dp,A,0,n-1);
    	long long int Y  = total-X;
    	cout<<X-Y<<endl;
	//code
	return 0;
}

Measured memory_bytes: 70784
import java.util.*;
public class Main {
static int a[]=new int [1100];
  public static void main(String args[])
  {
	  Scanner input=new Scanner(System.in);
	  int n,m;
	  n=input.nextInt();m=input.nextInt();
	  int sum=0;
	  for(int i=1;i<=n;i++)
	  {
		  a[i]=input.nextInt();sum+=a[i];}
	  int limt=sum/(4*m);
	  if(sum%(4*m)>0)limt++;
	  int cnt=0;
	 for(int i=1;i<=n;i++)
	 {
		 if(a[i]>=limt)cnt++;
	 }
	  if(cnt>=m)System.out.println("Yes");
	  else
		  System.out.println("No");
  }
}

Measured memory_bytes: 22484
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <queue>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

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

  vector<int> V;

  for (int i = 0; i < N; ++i) {
    int v;
    cin >> v;
    V.push_back(v);
  }

  vector<int> nums = V;

  for (int i = 0; i < N; ++i) {
    nums.push_back(V[i]);
  }

  int ans = 0;

  for (int deleteCount = 0; K - deleteCount >= 0; ++deleteCount) {
    int pickCount = min(N, K - deleteCount);

    if (pickCount < deleteCount) continue;
    // fprintf(stderr, "PC: %d, DC: %d\n", pickCount, deleteCount);

    int from = max(0, N - pickCount);

    for (int i = from; i <= N; ++i) {
      priority_queue <int, vector<int>, greater<int>> pque;

      int sum = 0;

      for (int j = i; j < i + pickCount; ++j) {
        sum += nums[j];
        pque.push(nums[j]);
      }

      for (int k = 0; k < deleteCount && !pque.empty(); ++k) {
        if (pque.top() >= 0) break;

        sum -= pque.top();
        pque.pop();
      }

      ans = max(ans, sum);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const ll MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;


bool useinit = false;
ll combMax = 4000;
vector<vector<ll> > comb(combMax + 2, vector<ll> (combMax + 2));
void init(){
    comb[0][0] = 1;
    for(ll i = 0; i <= combMax; i++){
        for(ll j = 0; j <= i; j++){
            comb[i + 1][j] += comb[i][j];
            comb[i + 1][j + 1] += comb[i][j];
            comb[i + 1][j] %= MOD;
            comb[i + 1][j + 1] %= MOD;
        }
    }
}
ll nCk(ll n,ll k){
    if(!useinit){
        init();
        useinit = true;
    }
    return comb[n][k];
}

int main(void){

    ll n,k;
    cin>>n>>k;
    for(ll i=1;i<=k;i++){
        cout<<nCk(n-k+1,i)%MOD*nCk(k-1,i-1)%MOD<<endl;
    }
}

Measured memory_bytes: 125568
def main():
  N,M=map(int,input().split())
  S=input()

  c,l=N,[]
  while c>0:
    for i in range(M,0,-1):
      if i<=c and S[c-i]=='0':
        l+=[i]
        c-=i
        break
    else:
      l=[-1]
      break
  print(*l[::-1])

main()


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

int main() {
  int x,y;
  while (1) {

    cin >> x >> y;
    if ((x == 0)&&(y == 0)) {
      /* code */
      break;

    }
    if (x >= y) {
      cout << y<< " "<< x << '\n';
      /* code */
    }else{
      cout << x<< " "<<y << '\n';
    }
  }

  return 0;
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define ll long long
#define dd double
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod (ll)(998244353)
#define sz(a) (ll)a.size()
#define all(a) a.begin(),a.end()
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=a-1;i>=b;i--)
#define tc(t) ll t;cin >>t;while(t--)
#define pb emplace_back
#define ee emplace
#define rr return 0
#define mp make_pair
#define pr  pair <ll,ll>
#define ff first
#define ss second
#define pie 3.1415926535
#define inf LLONG_MAX
ll mult(ll a, ll b, ll p = mod) {return ((a % p) * (b % p)) % p;}
ll add(ll a, ll b, ll p = mod) {return (a % p + b % p) % p;}
ll fpow(ll x, ll y)
{
	ll res = 1;
	x = x % mod;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1LL)
			res = (res * x) % mod;
		y = y >> 1LL;
		x = (x * x) % mod;
	}
	return res;
}
ll inv(ll a, ll p = mod) {return fpow(a, p - 2);}
bool sa(const pair<ll, ll> &a, const pair<ll, ll> &b) {return (a.second < b.second);}
bool fd(const pair<ll, ll> &a, const pair<ll, ll> &b) {return (a.first > b.first);}
bool sd(const pair<ll, ll> &a, const pair<ll, ll> &b) {return (a.second > b.second);}
ll dx[4] = {0, 0, 1, -1};
ll dy[4] = {1, -1, 0, 0};
bool valid(ll x, ll y, ll n, ll m) {
	if (x < 0 || y < 0) {
		return false;
	}
	else if (x >= n || y >= m) {
		return false;
	}
	else
		return true;
}
#define MAXN 1000001
ll spf[MAXN];
void sieve()
{
	spf[1] = 1;
	for (ll i = 2; i < MAXN; i++)

		// marking smallest prime factor for every
		// number to be itself.
		spf[i] = i;

	// separately marking spf for every even
	// number as 2
	for (ll i = 4; i < MAXN; i += 2)
		spf[i] = 2;

	for (ll i = 3; i * i < MAXN; i++)
	{
		// checking if i is prime
		if (spf[i] == i)
		{
			// marking SPF for all numbers divisible by i
			for (ll j = i * i; j < MAXN; j += i)

				// marking spf[j] if it is not
				// previously marked
				if (spf[j] == j)
					spf[j] = i;
		}
	}
}


double dp[301][301][301];
double solve(int x, int y, int z, int n) {
	if (x < 0 || y < 0 || z < 0)
		return 0;
	if (x == 0 && y == 0 and z == 0)
		return 0;
	if (dp[x][y][z] > -.9)
		return dp[x][y][z];
	double ans = n + x * solve(x - 1, y, z, n) + y * solve(x + 1, y - 1, z, n) + z * solve(x, y + 1, z - 1, n);
	return dp[x][y][x] = (double)ans / (double) (x + y + z);
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	string s1;
	string s2;
	cin >> s1 >> s2;
	for (int i = 0; i < min(s2.length(),s1.length()); i++) {
		if (s1[i] != s2[i]) {
			cout << "No"; return 0;
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 3648
n = int(input())
s = input()
l = 0
r = n - 1
ans = 0

while l < r:
    while l < r and s[l] == 'R':
        l += 1
    while l < r and s[r] == 'W':
        r -= 1
    if l >= r:
        break
    ans += 1
    l += 1
    r -= 1

print(ans)

Measured memory_bytes: 9332
#include<iostream>
#include <string>
#include<algorithm>
#include <set>
#include <cmath>
using namespace std;
typedef long long lint;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep0(i,n) rep(i,0,n)

int main(void) {
	ios::sync_with_stdio(false);
	int N, i, j;
	string S;
	cin >> N;
	cin >> S;
	if (N % 2 == 1) {
		cout << "No";
	}
	else {
		N = N / 2;
		j = 0;
		for (i = 0; i < N; i++) {
			if (S[i] == S[N + i]) j++;
		}
		if (j == N) cout << "Yes";
		else cout << "No";
	}
	return 0;
}
//
////sort Ｎ個の配列a
//sort(a, a + N); //昇順
//sort(a, a + N, greater<int>()); //降順
//
////最大公約数（ユークリッドの互除法利用）
//int gcd(int a, int b) {
//	if (a == 0) return b;
//	if (b == 0) return a;
//	int m = max(a, b);
//	int n = min(a, b);
//	if (m%n == 0) return n;
//	else return gcd(n, m%n);
//
//}
//
////最小公倍数
//int lca(int a, int b) {
//	if (a == 0) return 0;
//	if (b == 0) return 0;
//	return a * b / gcm(a, b);
//}
//
////n^k(整数)
//int pow_int(int n, int k) {
//	int re = 1;
//	for (int i = 0; i < k; i++) re *= n;
//	return re;
//}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rgi register int
#define ll long long
class fastin{
	private: int _ch,_f;
	public: inline fastin& operator>>(char&c) {c=getchar(); return *this;}
		template<typename _Tp> inline fastin& operator>>(_Tp&_x){
		_x=0; while(!isdigit(_ch)) _f|=(_ch==45),_ch=getchar();
		while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),_ch=getchar();
		_f&&(_x=-_x,_f=0); return *this;}
	fastin() {_ch=_f=0;}
}fin;
class fastout{
#define endl '\n'
	private: int _num[32],_head;
	public: inline fastout& operator<<(char c) {putchar(c); return *this;}
		template<typename _Tp> inline fastout& operator<<(_Tp _x){
		_Tp _k; if(_x==0) {putchar('0'); return *this;} if(_x<0) putchar('-'),_x=-_x;
		while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
		while(_head>0) putchar(_num[_head]),--_head; return *this;}
	fastout() {_head=0;}
}fout;
// ----------------------------
#define int ll
// using namespace std;
const int maxn=3004;
const int mod=998244353,inf=1000000007;

// int cnt[maxn];
ll a[maxn];
ll f[maxn][maxn];
signed main()
{
	ll n,s;
	fin>>n>>s;
	for(rgi i=1;i<=n;++i) fin>>a[i];
	f[0][0]=1;
	for(rgi i=0;i<=n;++i)
		for(rgi j=0;j<=s;++j)
		{
			// fout<<i<<' '<<j<<' '<<f[i][j]<<endl;
			(f[i+1][j]+=f[i][j]*2LL)%=mod;
			if(j+a[i+1]<=s) (f[i+1][j+a[i+1]]+=f[i][j])%=mod;
		}
	fout<<f[n][s];
	return 0;
}
// ----------------------------
// by imzzy


Measured memory_bytes: 74036
/* 
Hey there stalker....
 
█▀▀▄░░░░░░░░░░░▄▀▀█
░█░░░▀▄░▄▄▄▄▄░▄▀░░░█
░░▀▄░░░▀░░░░░▀░░░▄▀
░░░░▌░▄▄░░░▄▄░▐▀▀
░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█ 
░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
░░░█░░░░░░░░░░░▄▀▄░▀▄
░░░█░░░░░░░░░▄▀█░░█░░█
░░░█░░░░░░░░░░░█▄█░░▄▀
░░░█░░░░░░░░░░░████▀
░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀
 
Like what you see?
*/
#include <bits/stdc++.h>
using namespace std;
 
#define fastIO ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define endl '\n'
#define lli long long int
#define ld long double
#define p_b push_back
#define m_p make_pair
#define fs first
#define sc second
#define all(x) x.begin(),x.end()
#define fr(i,a,n) for(lli i=a; i<n; i++)
#define rep(i,a,n) for(lli i=a; i>=n; i--)
const lli mod = 1e9 + 7;
/*****************************************************/
lli n,w,wt[105],v[105],i,j,dp[105][100005];
lli F(lli idx,lli ww)
{
    if(idx==0 || ww<=0)
        return 0;
    if(wt[idx]>ww)
    {
        lli r1;
        if(dp[idx-1][ww]!=-1)
            r1=dp[idx-1][ww];
        else
        {
            r1=F(idx-1,ww);
            dp[idx-1][ww]=r1;
        }
        return r1;
    }
    else
    {
        lli r1,r2;
        if(dp[idx-1][ww-wt[idx]]!=-1)
            r1=dp[idx-1][ww-wt[idx]];
        else
        {
            r1=F(idx-1,ww-wt[idx]);
            dp[idx-1][ww-wt[idx]]=r1;
        }
        r1+=v[idx];
        if(dp[idx-1][ww]!=-1)
            r2=dp[idx-1][ww];
        else
        {
            r2=F(idx-1,ww);
            dp[idx-1][ww]=r2;
        }
        return max(r1,r2);
    }
}
int main()
{
    fastIO
    cin>>n>>w;
    for(i=1;i<=n;i++)
        cin>>wt[i]>>v[i];
    for(i=0;i<105;i++)
    {
        for(j=0;j<100005;j++)
            dp[i][j]=-1;
    }
    cout<<F(n,w);
    //cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

Measured memory_bytes: 82304
#include<cstdio>

#define int long long

using namespace std;

inline int read()
{
	int x=0;int f=1;
	int c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		x=(x<<1)+(x<<3)+(c^48);
		c=getchar();
	}
	return x*f;
} 

int n;
int k;
int ans;

signed main()
{
	n=read();k=read();
	for(int i=0;i<n;i++)
	{
		int temp=read();
		if(temp>=k)ans++;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String str = "";
        int countAB = 0;
        int FinishedA = 0;
        int startB = 0;
        int startBFinishA = 0;

        for (int i = 0; i < N; i++) {
            str = sc.next();

            countAB += count(str);

            if (str.charAt(0) == 'B' && str.charAt(str.length() - 1) == 'A') {
                startBFinishA++;
            } else if (str.charAt(0) == 'B') {
                startB++;
            } else if (str.charAt(str.length() - 1) == 'A') {
                FinishedA++;
            }
        }

        if (startB > 0 && FinishedA > 0) {
            countAB += (startB >= FinishedA ? FinishedA : startB);
            countAB += startBFinishA;
        } else if (startB == 0 && FinishedA == 0) {
            countAB += (startBFinishA > 0 ? startBFinishA - 1 : startBFinishA);
        } else {
            countAB += (startBFinishA > 0 ? startBFinishA : 0);
        }
        System.out.println(countAB);
    }

    public static int count(String str) {
        int count = 0;
        for (int index = 0; (index = str.indexOf("AB", index)) != -1; index++) {
            count++;
        }
        return count;
    }
}


Measured memory_bytes: 32004
a,b=map(int,input().split())
s=input()
n=len(s)
l=list("0123456789")

f=0
for i in range(a):
    if s[i] in l:
        f+=1
    
if s[a]=="-":
    
    f+=1

for i in range(b):
    if s[-1-i] in l:
        f+=1
    
print("Yes" if f==n else "No")

    


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

int main() {
	int n, m, p, x[101],k=0, ans[101];

	while (true) {
		int sum = 0;
		cin >> n >> m >> p;

		if (n == 0) {
			if (m == 0) {
				if (p == 0) {
					break;
				}
			}
		}

		for (int i = 1; i <= n; i++) {
			cin >> x[i];
			sum = sum + x[i];
		}
		sum = sum*(100-p);
		

		if (x[m] != 0) {
			sum = (int)sum / x[m];
			ans[k] = sum;
			k++;
		}

		else {
			ans[k] = 0;
			k++;
		}

	}
	for (int i = 0; i < k; i++)
		cout << ans[i] << endl;
}

Measured memory_bytes: 3076
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

bool func(int x,int y){
    if(y%2!=0)return false;
    return 4*x-y>=0 && y-2*x>=0;
}
int main(){
    int x=in(),y=in();
    string ans=func(x,y)?"Yes":"No";
    cout<<ans<<endl;
}

Measured memory_bytes: 3676
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long x = in.nextLong();
		long cur = 100; 
		int year = 0;
		while(cur < x) {
			year += 1;
			cur += (cur * (0.01));
		}
		System.out.println(year);
	}
} 


Measured memory_bytes: 35816
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int N, M;

LL fact(int n) {
    if (n == 0) return 1;
    return n * fact(n - 1) % MOD;
}

int main(void) {
    cin >> N >> M;
    if (abs(N - M) >= 2) {
        cout << 0 << endl;
        return 0;
    }
        cout << (fact(N) * fact(M) % MOD) * (1 + (N == M)) % MOD << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>
 
int main(void)
{
  int i, j, k, tmp = 0;
  
  scanf("%d %d %d", &i, &j, &k);
  
  tmp = i;
  i = j;
  j = tmp;
  tmp = i;
  i = k;
  k = tmp;
  
  
  
  
  printf("%d %d %d\n", i, j, k);
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  if (N % 10 == 9) {
    N = N - N % 10 + 1;
  } else {
    N = N - N % 10 + 9;
  }
  
  if (N % 100 / 10 == 9) {
    N = N - N % 100 + 10 + N % 10;
  } else {
    N = N - N % 100 + 90 + N % 10;
  }
  
  if (N / 100 == 9) {
    N = 100 + N % 100;
  } else {
    N = 900 + N % 100;
  }
  
  cout << N << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

int main() {
    ll n;
    string s;
    cin >> n;
    cin >> s;
    ll le = 0, lw = 0;
    ll re = 0, rw = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'E') re++;
        else rw++;
    }
    ll min = n;

    for (int i = 0; i < n; i++) {
        if (s[i] == 'E') {
            re--;
        } else {
            rw--;
        }
        if (lw + re < min) min = lw + re;
        if (s[i] == 'E') {
            le++;
        } else {
            lw++;
        }
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 900
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;
int main ()
{
 char x,y;
	const char A=10,B=11,C=12,D=13,E=14,F=15;
	while(~scanf(" %c %c",&x,&y));{
	if (x<y)
		printf("<\n");
	else if (x>y)
			printf(">\n");
		 else if (x==y)
				printf("=\n");
	}
}


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

int main() {
  
  int N,M;
  
  cin >> N;
  cin >> M;
  
  string res;
  
  if ( N == M){
    res = "Yes"; 
  }
  else{
    res = "No";
  }
  
  
  cout << res << endl;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;

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

    ll  N,M;
    cin >> N >> M;

    ans += N * (N-1) / 2;
    ans += M * (M-1) / 2;

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


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

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

array<string, 3> buttons = {
	"ABC",
	"DEF",
	"GHI",
};

bool neigh(char c, char t) {
	int x = (c - 'A') % 3;
	int y = (c - 'A') / 3;
	for (int i = 0; i < 4; i++) {
		int nx = x + dx[i];
		int ny = y + dy[i];
		if (0 <= nx && nx < 3 && 0 <= ny && ny < 3) {
			if (buttons[ny][nx] == t) return true;
		}
	}
	return false;
}

bool solve(const string& s) {
	char c;
	for (auto it = s.begin(); it != s.end(); ++it) {
		if (it != s.begin() && !neigh(c, *it)) {
			return false;
		}
		c = *it;
	}
	return true;
}

int main() {
	string s;
	while (cin >> s) {
		if (solve(s)) {
			cout << s << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long a[1001],b[1001],c[1001];
long long x,y,z,k;
vector<long long> v;
vector<long long> ans;

long long FUN2(long long l)
{
    int nr=0, lastj = z;
    for(int i=0;i<v.size();i++)
    {
        for(int j=lastj;j > 0;j--, lastj--)
        {
            if(v[i]+c[j]<l)
                break;
        }
        nr+=z-lastj;
    }
    return nr;
}

long long cautbin()
{
    long long l=1,r=30000000000;
    long long mid;
    while(l!=r)
    {
        mid=(l+r+1)/2;
        if(FUN2(mid)<k)
            r=mid-1;
        else l=mid;
    }
    return l;
}

void afisare(long long l=cautbin())
{
    for(int i=0;i<v.size();i++)
    {
        for(int j=z;j>=1;j--)
        {
            if(v[i]+c[j]>l)
                ans.push_back(v[i]+c[j]);
            else break;
        }
    }
    while(ans.size()<k)
    {
        ans.push_back(l);
    }
    sort(ans.begin(),ans.end(),greater<long long>());
    for(auto i:ans)
        cout<<i<<"\n";
}

int main()
{
    cin>>x>>y>>z>>k;
    for(int i=1;i<=x;i++)
        cin>>a[i];
    for(int i=1;i<=y;i++)
        cin>>b[i];
    for(int i=1;i<=z;i++)
        cin>>c[i];

    sort(c+1,c+1+z);

    for(int i=1;i<=x;i++)
    {
        for(int j=1;j<=y;j++)
        {
            v.push_back(a[i]+b[j]);
        }
    }
    sort(v.begin(),v.end());
    afisare();
    return 0;

}


Measured memory_bytes: 10476
#include <vector>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int ll;

#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)

int bs(vector<int> v, int minIdx, int maxIdx, int value) {
    if (value >= v[minIdx]) {
        return minIdx;
    }
    if (value <= v[maxIdx]) {
        return maxIdx + 1;
    }
    
    if (maxIdx - minIdx <= 1) {
        return maxIdx;
    }

    int midIdx = (maxIdx + minIdx) / 2;
    if (value < v[midIdx]) {
        return bs(v, midIdx, maxIdx, value);
    } else {
        return bs(v, minIdx, midIdx, value);
    }
}

int main(int argc, const char * argv[]) {
    int N, M;
    cin >> N >> M;
    vector< vector<int> > days = vector< vector<int> >( M + 1, vector<int>() );
    vector<int> maxes = vector<int>();
    vector<int> maxIndice = vector<int>();
    maxes.push_back(0);
    maxIndice.push_back(-1);
    
    for (int i = 0; i < N; i++) {
        int A, B;
        cin >> A >> B;
        if(M >= A) {
            days[A].push_back(B);
        }
    }
    
    for (int i = 0; i < M; i++) {
        days[i+1].push_back(0);
        sort(days[i+1].begin(), days[i+1].end(), greater<int>());
    }
    
    ll sum = 0;
    for (int i = 1; i <= M; i++) {
        if (days[i][0] > 0) {
            int day_i_insertTo = bs(maxes, 0, (int)maxes.size() - 1, days[i][0]);
            maxes.insert(maxes.begin() + day_i_insertTo, days[i][0]);
            maxIndice.insert(maxIndice.begin() + day_i_insertTo, i);
        }
        
        if (maxes[0] != 0) {
            int maxIndex = maxIndice[0];
            sum += days[maxIndex][0];
            days[maxIndex].erase(days[maxIndex].begin());
            maxes.erase(maxes.begin());
            maxIndice.erase(maxIndice.begin());
            if (days[maxIndex][0] > 0) {
                int day_i_insertTo = bs(maxes, 0, (int)maxes.size() - 1, days[maxIndex][0]);
                maxes.insert(maxes.begin() + day_i_insertTo, days[maxIndex][0]);
                maxIndice.insert(maxIndice.begin() + day_i_insertTo, maxIndex);
            }
        }
    }
    
    cout << sum;
    
    return 0;
}


Measured memory_bytes: 6272
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

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;
}

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */
int x[10][10];

int main() {

    string s;
    cin >> s;
    if(s == "Sunny"){
        cout << "Cloudy" << endl;
    }
    else if(s == "Cloudy") {
        cout << "Rainy" << endl;
    } else{
        cout << "Sunny" << endl;
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; cin >> N;
  	multiset<int> act;
  	int t;
  	for(int i = 0; i < N; i ++){
      	cin >> t;
        if(!act.size() || *act.begin()>=t)act.insert(t);
      	else{
        	auto p = act.lower_bound(t); p --;
          	act.erase(p);
          	act.insert(t);
        }
   	}
  	cout << act.size() << endl;
}

Measured memory_bytes: 4992
a = input()
if a=='SUN':
    print(7)
elif a=='MON':
    print(6)
elif a=='TUE':
    print(5)
elif a=='WED':
    print(4)
elif a=='THU':
    print(3)
elif a=='FRI':
    print(2)
else:
    print(1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define INF (1<<28)
#define DEKAI 1000000007
#define FDST int hogehogehoge;cin>>hogehogehoge;
#define int long long
vector<int> tree[100010],rvtree[100010];
int ans[100010];
signed main(){
	int n,m;
	cin>>n>>m;
	int a,b;
	lp(i,n-1+m){
		cin>>a>>b;
		tree[a].push_back(b);
		rvtree[b].push_back(a);
	}
	int nekko;
	lp(i,n){
		if(rvtree[i+1].size()==0){
			nekko=i+1;
			break;
		}
	}
	queue<int> q;
	q.push(nekko);
	ans[nekko]=0;
	int now;
	int scnt[100010];
	lp(i,n){
		scnt[i+1]=rvtree[i+1].size();
	}
	while(!q.empty()){
		now=q.front();
		q.pop();
		lp(i,tree[now].size()){
			if(scnt[tree[now][i]]>1){
				scnt[tree[now][i]]--;
				continue;
			}
			q.push(tree[now][i]);
			ans[tree[now][i]]=now;
		}
		//cout<<"a"<<endl;
	}
	lp(i,n){
		cout<<ans[i+1]<<endl;
	}
	return 0;
}



Measured memory_bytes: 15360
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int num=2019;
int main(){
    ll l,r;
    cin >> l >> r;
    ll mn=num+1;
    for(ll i=l; i<=min(l+2020,r)-1; i++){
        for(int j=i+1; j<=min(l+2020,r); j++){
            if(mn>(i*j%num))mn=(i*j)%num;          
        }
    }
    cout << mn << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define MAX 10000
#define nil -1
#define vmax 10000
#define sentinel 2000000000
constexpr long long int inf = 1000000000000;
constexpr long long int rinf = -(INT64_MAX);
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

int main() {
    string s;
    cin>>s;
    vector<char> a;
    int b=s.size();
    for(int i=0;i<b;i+=2){
        a.push_back(s[i]);
    }
    int c=a.size();
    for(int i=0;i<c;i++){
        cout<<a[i];
    }
    cout<<endl;
}


Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC110.A
{
    class Program
    {
        static void Main()
        {
            var inputs = Console.ReadLine().Split(' ')
                .Select(elem => int.Parse(elem))
                .OrderByDescending(elem => elem)
                .ToArray();

            Console.WriteLine(inputs[0] * 10 + inputs[1] + inputs[2]);
        }
    }
    class Scanner
    {
        string[] s;
        long i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public int Nextint()
        {
            return int.Parse(Next());
        }
        public int[] Arrayint(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Nextint() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }

        public double[] ArrayDouble(long N, double add = 0)
        {
            double[] Array = new double[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }

        public decimal NextDecimal()
        {
            return decimal.Parse(Next());
        }

        public decimal[] ArrayDecimal(long N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDecimal();
            }
            return Array;
        }
    }
}

Measured memory_bytes: 13396