akhauriyash/Code-Regression huggingface dataset:
n,k=map(int,input().split())
li_d=[]
li_A=[]
for i in range(k):
    li_d.append(int(input()))
    li_A.append(input().split())
li=[]
for i in range(k):
    lis=li_A[i]
    li=li+lis
li=list(set(li))
print(n-len(li))

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

int main()
{
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++)
	{
		int t;
		cin >> t;
		v[i] = t;
	}
	bool flag = true;
	int i = 0;
	int ans = 0;
	while (flag)
	{
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--)
		{
			if (v[j] < v[j -1])
			{
				swap(v[j], v[j - 1]);
				flag = 1;
				ans++;
			}
		}
		i++;
	}
	for (int j = 0; j < n; j++)
	{
		cout << v[j];
		if (j != n - 1)
		{
			cout << " ";
		}
		else
		{
			cout << endl;
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3096
import collections

N = int(input())
sequence = list(map(int, input().split()))
CTR = collections.Counter(sequence).most_common()
ans = 0

for i in range(len(CTR)):
    cnt = CTR[i][1]
    obj = int(CTR[i][0])

    if (obj > cnt):
        ans += cnt
    
    else:
        ans += cnt - obj
    
print(ans)

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

int main(){
  int n;
  n = 1;

  while(n!=0){
    cin >> n;
    int s[n];
    for(int i=0;i<n;i++){
      s[i] = 0;
    }

    for(int i=0;i<n;i++){
      cin >> s[i];
    }

    // // s[n]の出力
    // for(int i=0;i<n;i++){
    //   cout << s[i] << " ";
    // }
    // cout << endl;

    double avg = 0;
    for(int i=0;i<n;i++){
      avg += s[i];
    }
    avg /= n;
    // printf("%.8lf", avg);

    double alpha = 0;
    for(int i=0;i<n;i++){
      alpha += pow(s[i] - avg, 2);
    }
    alpha /= n;
    alpha = sqrt(alpha);

    if(n!=0){
      printf("%.8lf\n", alpha);
    }
  }
}



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

int main(int argc, char const *argv[])
{
    string str;
    cin >> str;

    int count1 = 0;
    int count2 = 0;

    for(auto i=0;i<str.length();i++){
        if(i%2==0){
            if(str[i]!='0')
                count1++;
            else
                count2++;
        }
        else{
            if(str[i]!='0')
                count2++;
            else
                count1++;
        }
    }


    cout << min(count1,count2) << endl;
    return 0;
}

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

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

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

#define MAX_V 100000

struct scc {

  int V;
  vector<vector<int>> G, rG;
  vector<int> vs, cmp;
  vector<bool> used;

  scc(int V) : V(V) {
    used.assign(V, false);
    G.resize(V), rG.resize(V);
    cmp.resize(V);
  }

  void add_edge(int from, int to) {
    G[from].push_back(to);
    rG[to].push_back(from);
  }

  void dfs(int v) {
    used[v] = true;
    for (int i = 0; i < (int)G[v].size(); i++) {
      if (!used[G[v][i]]) dfs(G[v][i]);
    }
    vs.push_back(v);
  }

  void rdfs(int v, int k) {
    used[v] = true;
    cmp[v] = k;
    for (int i = 0; i < (int)rG[v].size(); i++) {
      if (!used[rG[v][i]]) rdfs(rG[v][i], k);
    }
  }

  int scc_run() {
    fill(used.begin(), used.end(), false);
    vs.clear();
    for (int v = 0; v < V; v++) if (!used[v]) dfs(v);
    fill(used.begin(), used.end(), false);
    int k = 0;
    for (int i = vs.size() - 1; i >= 0; i--) if (!used[vs[i]]) rdfs(vs[i], k++);
    return k;
  }
};

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

  int V, E; cin >> V >> E;
  scc cc(V);

  REP(_, E) {
    int f, t; cin >> f >> t;
    cc.add_edge(f, t);
  }
  cc.scc_run();
  int Q; cin >> Q;
  REP(_, Q) {
    int x, y; cin >> x >> y;
    cout << (cc.cmp[x] == cc.cmp[y]) << endl;
  }
  return 0;
}

Measured memory_bytes: 4416
#include<bits/stdc++.h> 
using namespace std; 
  
const int MAX = 1000001; 
  
// structure to store queries 
struct Query 
{ 
    int l, r, idx; 
}; 
  
// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 
  
// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 
  
// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
    // initialising bit array 
    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 
  
    // holds the rightmost index of any number 
    // as numbers of a[i] are less than or equal to 10^6 
    int last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit)); 
  
    // answer for each query 
    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 
        // If last visit is not -1 update -1 at the 
        // idx equal to last_visit[arr[i]] 
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 
  
        // Setting last_visit[arr[i]] as i and updating 
        // the bit array accordingly 
        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 
  
        // If i is equal to r of any query  store answer 
        // for that query in ans[] 
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 
  
    // print answer for each query 
    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
} 


// Driver code 
int main() 
{ 
	int n,q,l,r;
	cin>>n>>q;
	int arr[n];
	Query queries[q];

	for(int i=0;i<n;i++)
		cin>>arr[i];

	for(int i=0;i<q;i++)
		cin>>l>>r, queries[i].l=l-1,queries[i].r=r-1,queries[i].idx=i; 

	sort(queries, queries+q, cmp); 
	answeringQueries(arr, n, queries, q); 
	return 0; 
} 


Measured memory_bytes: 19352
/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
// ****  All Required define Pre-Processors and typedef Constants *******/
#define mem(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define fl(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)

#define fi(it, l) for (auto it = l.begin(); it != l.end(); it++)

#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> dmap;
typedef set<int> dset;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
/********** solver function **********/
int solve(int i,int k, vector<int> & v, vector<int> & dp){
    if( i==v.size()-1) return 0;
    if( i>=v.size()) return INT_MAX-1000;
    if( dp[i]!=-1 ) return dp[i];
    int ans=INT_MAX;
    for( int p=i+1;p<=i+k;p++){
        if ( p<v.size()){
            ans=min( ans, abs( v[p]-v[i])+ solve( p,k,v, dp));
        }
    }
	return  dp[i] =ans;
}
/********** Main()  function **********/
int main()
{std::ios::sync_with_stdio(false);
	int n;cin>>n;int k; cin>>k;
    vector<int> dp(n, -1);
    vector<int> v(n);
    for( int i=0; i<n; i++)
    cin>>v[i];
    cout<<solve( 0,k,v, dp)<<endl;
	return 0;
}

Measured memory_bytes: 11492
/// Coded by Dhiman Sarker Bappi (Dhimanda) - RMSTU

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

int main()
{
    string a;
    cin >> a;
    bool ok= false;
    if(a[0]=='7') ok = true;
    if(a[1]=='7') ok = true;
    if(a[2]=='7') ok = true;
    if (ok) cout << "Yes\n" ;
    else  cout << "No\n" ;
    //main();
    return 0;
}


// Contact : chessdhiman@gmail.com


Measured memory_bytes: 3624
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

struct S004 {
  S004() : s(-1), d(-1) {}             
  S004(int s_, int d_) : s(s_), d(d_) {}
  long s, d;
};

template<typename a>
struct S005 {
  typedef a e;
  std::vector<std::vector<a>> xs;
  const std::vector<a>& ys;
  long n;
  S005(const std::vector<a>& ys_, long n_) : ys(ys_), n(n_) {
    xs.resize(n);
    for(a x : ys) {
      a y = x;
      xs[x.s].push_back(y);
    }
  }
  const std::vector<a>& operator [] (long i) const {
    return xs[i];
  }
  long v() const {
    return n;
  }
  const std::vector<a>& es() const {
    return ys;
  }
};


struct Solver {
  long n, m;
  std::vector<std::array<long, 2>> xs;
  Solver() {
    S002 reader;
    reader >= n >= m >m>= xs;
  }
  void solve() {
    std::vector<S004> edges;
    for(std::array<long, 2> e : xs) {
      e[0] -= 1, e[1] -= 1;
      edges.push_back(S004(e[0], e[1]));
      edges.push_back(S004(e[1], e[0]));
    }
    S005<S004> graph(edges, n);
    std::vector<bool> visited(n, false);
    long res = dfs(graph, 0, visited, 0);
    printf("%ld\n", res);
  }
  long dfs(const S005<S004>& graph, long i, std::vector<bool>& visited, long d) {
    if( d == n - 1 ) return 1;
    long res = 0;
    visited[i] = true;
    for(S004 edge : graph[i]) {
      if( visited[edge.d] ) continue;
      res += dfs(graph, edge.d, visited, d + 1);
    }
    visited[i] = false;
    return res;
  }
};
 
int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

Measured memory_bytes: 256
import sys
def input():
	return sys.stdin.readline()[:-1]

n, q = map(int, input().split())
s = input()
Qs = [input().split() for _ in range(q)]

def calc_l(x):
	for i in range(q):
		if Qs[i][0] == s[x]:
			if Qs[i][1] == "L":
				x -= 1
			else:
				x += 1
		if x < 0:
			return True
		if x > n-1:
			return False
	return False

def calc_r(x):
	for i in range(q):
		if Qs[i][0] == s[x]:
			if Qs[i][1] == "L":
				x -= 1
			else:
				x += 1
		if x > n-1:
			return True
		if x < 0:
			return False
	return False

if calc_l(0):
	l_ok = 0
	l_ng = n
	while l_ng - l_ok > 1:
		left = (l_ok + l_ng) // 2
		if calc_l(left):
			l_ok = left
		else:
			l_ng = left
else:
	l_ok = -1

if calc_r(n-1):
	r_ok = n-1
	r_ng = -1
	while r_ok - r_ng > 1:
		right = (r_ok + r_ng) // 2
		if calc_r(right):
			r_ok = right
		else:
			r_ng = right
		#print(r_ok, r_ng)
	if calc_r(r_ng):
		r_ok = r_ng
else:
	r_ok = n

#print(l_ok, r_ok)
print(r_ok - l_ok - 1)

Measured memory_bytes: 84000
#include <algorithm>
#include <array>
#include <assert.h>
#include <bitset>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstring>
#include <functional>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <istream>

#include <map>
#include <math.h>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

namespace asl
{
    class DisjointSet
    {
    public:
        std::vector<int> ds;

        DisjointSet(int n)
        {
            ds = std::vector<int>(n, -1);
        }

        int root(int a)
        {
            return ds[a] < 0 ? a : ds[a] = root(ds[a]);
        }

        bool join(int u, int v)
        {
            u = root(u), v = root(v);

            if (u == v)
                return false;

            if (ds[u] < ds[v])
                std::swap(u, v);

            ds[v] += ds[u];
            ds[u] = v;

            return true;
        }

        bool same(int u, int v)
        {
            return root(u) == root(v);
        }

    };
} 

#include <experimental/optional>

namespace asl
{

    namespace fun
    {
        std::string YES = "YES";
        std::string NO = "NO";

        void set_yn(std::string yes, std::string no)
        {
            YES = yes;
            NO = no;
        }

        void fin(std::string word)
        {
            std::cout << word << std::endl;
            std::exit(0);
        }

        void yes()
        {
            fin(YES);
        }

        void no()
        {
            fin(NO);
        }

    } 

} 

#include <random>

using namespace std;
using namespace asl;

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

    fun::set_yn("Yes", "No");

    int n, q;
    long long m;
    cin >> n >> m >> q;

    DisjointSet ds(n);
    vector<pair<int, int>> edges;

    int cc = n;

    for (int i = 0; i < q; ++i)
    {
        int u, v, c;
        cin >> u >> v >> c;

        if (c == 0)
        {
            if (ds.join(u, v))
                cc--;
        }
        else
            edges.emplace_back(u, v);
    }

    if (m == n - 1)
    {
        if (edges.empty())
            fun::yes();
        else
            fun::no();
    }

    for (auto [u, v] : edges)
    {
        if (ds.same(u, v))
            fun::no();
    }

    long long top = n - cc + 1LL * cc * (cc - 1) / 2;

    if (m <= top)
        fun::yes();
    else
        fun::no();

    return 0;
}




Measured memory_bytes: 4956
a=[]
for c in input().split():
    if c=='+':   a.append(a.pop() + a.pop())
    elif c=='-': a.append(-a.pop() + a.pop())
    elif c=='*': a.append(a.pop() * a.pop())
    else:        a.append(int(c))

print(a.pop())


Measured memory_bytes: 5596
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,a) for(ll i=ll(a-1);i>=0;--i)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll MOD3 = 1e6;
const ll EPS = 1e-10;
int sgn(const double a){
    return (a < -EPS ? -1 : (a > EPS ? +1 : 0));
}
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<long double,long double> point;
typedef complex<long double> Point;
const ll MAX = 1e9;
constexpr ll nx[4] = {-1,0,1,0};
constexpr ll ny[4] = {0,1,0,-1};
ll mod_pow(ll n, ll p, ll m){
    ll ret = 1;
    ll mul = n%m;
    while(p){
        if (p&1) ret = ret*mul%m;
        p >>= 1;
        mul = mul*mul%m;
    }
    return ret;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll ans = mod_pow(10,n,MOD)+MOD-(mod_pow(9,n,MOD)*2%MOD+MOD-mod_pow(8,n,MOD))%MOD;
    PRINT(ans%MOD);
}


Measured memory_bytes: 3648
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      l: usize,
      aa: [usize; l],
    }
    let mut dp = vec![vec![0; 5]; l+1];
    for i in 0..5 { dp[0][i] = 0; }

    for i in 0..l {
        dp[i+1][0] = dp[i][0] + aa[i];

        let even = if aa[i] == 0 { 2 } else { aa[i]%2 };
        let odd = if aa[i]%2 == 1 { 0 } else { 1 };

        dp[i+1][1] = min( dp[i][0], dp[i][1] ) + even;
        dp[i+1][2] = min(dp[i][0], min(dp[i][1], dp[i][2])) + odd;
        dp[i+1][3] = min(dp[i][0], min(dp[i][1], min(dp[i][2], dp[i][3]))) + even;
        dp[i+1][4] = [dp[i][0], dp[i][1],dp[i][2],dp[i][3],dp[i][4]].iter().min().unwrap() + aa[i];
    }
    // debug!(dp);
    let ans = dp[l].iter().min().unwrap();
    println!("{}", ans);
}


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

int main() {
  int A, B;
  cin >> A >> B;
  if (A + B == 3){
    cout << 3 << endl;
  }
  else if (A + B == 4){
    cout << 2 << endl;
  }
  else {
    cout << 1 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main(){
    int N,M;
    cin >> N >> M;
    vector<int> P[100001];
    int A,B;
    rep(i,N){
        cin >> A >> B;
        P[A].emplace_back(B);
    }
    priority_queue<int> que;
    long long res = 0;
    for(int i=1;i<=M;i++){
        for(int p : P[i]) que.push(p);
        if(!que.empty()){
            res += que.top();
            que.pop();
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

ll waru = 998244353;
int main(void){
    ll a; ll b; ll c; ll d;
    cin >> a >> b >> c >> d;
    vector<vector<ll>> dp(c+1, vector<ll>(d+1, 0));
    dp[a][b] = 1;
    for(int i=1; i<c+1; i++){
        for(int j=1; j<d+1; j++){
            dp[i][j] += dp[i-1][j] * j;
            dp[i][j] += dp[i][j-1] * i;

            dp[i][j] -= dp[i-1][j-1] * (i-1) * (j-1);

            dp[i][j] += waru*3000*3000;
            dp[i][j] %= waru;
        }
    }

    cout << dp[c][d] << endl;
    return 0;
}

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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	 int h , a ;
	 cin >> h >> a ;
	 cout << (h + a - 1) / a << endl;
 }


Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <numeric>

using namespace std;

struct edge {
    int to,cost;
    edge(int to, int cost){
        this->to = to;
        this->cost = cost;
    }
};
const int MAX_V = 100000;
vector<edge> G[MAX_V];
int N, M;

bool visited[MAX_V];
int position[MAX_V];

bool dfs(int n, int x){
    visited[n] = true;
    position[n] = x;

    bool isValid = true;
    for (edge e : G[n]){
        if (visited[e.to] && position[e.to] != x + e.cost){
            isValid = false;
        } else if (not(visited[e.to])){
            isValid = dfs(e.to, x + e.cost);
        }
        if (not(isValid)){
            break;
        }
    }
    return isValid;
}

int main()
{
    cin >> N;
    cin >> M;

    for (int i = 0; i < M; i++){
        int left, right, dist;
        cin >> left;
        cin >> right;
        cin >> dist;
        left--;
        right--;
        G[left].push_back(edge(right, dist));
        G[right].push_back(edge(left, -dist));
    }

    bool isValid = true;
    for (int n = 0; n < N; n++){
        if (not(visited[n])){
            isValid = dfs(n, 0);
            if (not(isValid)){
                break;
            }
        }
    }

    if (isValid) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 11136
import java.util.*;
public class Main{
 public static void main(String args[]){
  Scanner n=new Scanner(System.in);
  int i[]=new int[10];
  for(int j=0;j<=9;j++){
   i[j]=n.nextInt();
  }
  Arrays.sort(i);
  System.out.println(i[9]);
  System.out.println(i[8]);
  System.out.println(i[7]);
 }
}

Measured memory_bytes: 17236
def bottom(arr)
  arr.sort[0, arr.size / 2 + 1].map{ |n| n / 2 + 1}.reduce(:+)
end

def top(arr)
  arr.sort[0, arr.size / 2 + 1].reduce(:+)
end

def aggregate(arr, isbottom)
  group = []
  arr.map { |v, g|
    ret = nil
    if g == 0
      group << v
    else
      unless group.empty?
        ret = [isbottom ? bottom(group << v) : top(group << v), g]
      else
        ret = [v, g]
      end
      group = []
    end
    ret
  }.compact
end

gets.to_i.times do
  str = gets.chomp.scan(/\[|\]|\d+/)
  gap = str.map.with_index{ |s, i| [s.to_i, i] if s != '[' && s != ']' }.compact
  stage = gap.transpose[0].zip(gap.transpose[1].each_cons(2).map{ |a, b| (b - a) / 2 - 1})
  stage = aggregate(stage, true)

  while stage.size > 1
    stage = stage.map{ |_, g|  g ? [_, g - 1] : [_, g] }
    stage = aggregate(stage, false)
  end
  p stage[0][0]
end

Measured memory_bytes: 9196
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <iostream>
#include <deque>
#include <functional>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

#define int long long

#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

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

#define debug(x) cerr << #x << ": " << x << endl;

const int MOD = 1e9 + 7;

template <typename T> T gcd(T m, T n) { return n == 0 ? m : gcd(n, m % n); }
template <typename T> T lcm(T m, T n) { return n * m / gcd(n, m); }

signed main(void)
{
  bool flag = true;
  // bool issorted = true;
  int n; cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }

  vector<bool> d(n, false);
  for (int i = n - 1; 0 < i; --i) {
    if (h[i] < h[i - 1]) {
      h[i - 1] -= 1;
      d[i - 1] = true;
    }
  }

  flag = is_sorted(h.begin(), h.end());

  if (flag) cout << "Yes";
  else cout << "No";
  cout << endl;
  
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define	IOS ios_base::sync_with_stdio(0);
#define en "\n"
#define FOR(i, j, n) for(int j = i; j < n; ++j)
#define forn(i, j, n) for(int j = i; j <= n; ++j)
#define nfor(i, j, n) for(int j = n; j >= i; --j)
#define sortv(vv) sort(vv.begin(), vv.end())
#define all(vv) vv.begin(), vv.end()
 
using namespace std;
const ll maxn=1e6+100,inf=1e18,LOG=23,mod=1e9 + 7;
 
#define int ll

int n, dp[maxn][4], k, a[maxn], b[maxn], c[maxn];

main()
{
	IOS
	cin >> n;
	forn(1, i, n)
	{
		cin >> a[i] >> b[i] >> c[i];
	}
	forn(1, i, n)
	{
		dp[i][1] = max(dp[i - 1][2], dp[i - 1][3]) + a[i];
		dp[i][2] = max(dp[i - 1][1], dp[i - 1][3]) + b[i];
		dp[i][3] = max(dp[i - 1][1], dp[i - 1][2]) + c[i];
	}
	cout << max(dp[n][3], max(dp[n][1], dp[n][2]));
}

Measured memory_bytes: 13312
using System;
using System.Linq;

namespace AtCoderContestScheduling
{
    class Program
    {
        static void Main(string[] args)
        {
            const int n_contest = 26;
            int D = GetInt();
            var c = GetIntArray();
            var s = new int[D][];
            for(int i = 0; i < D; i++)
            {
                s[i] = GetIntArray();
            }

            var decrement = new int[n_contest];
            int max_eval = 0;
            int[] contest = new int[D];
            for(int i = 0; i < D; i++)
            {
                for (int j = 0; j < n_contest; j++)
                {
                    decrement[j] += c[j];
                    if (max_eval < decrement[j] + s[i][j])
                    {
                        max_eval = decrement[j] + s[i][j];
                        contest[i] = j;
                        decrement[j] = 0;
                    }
                }
            }
            foreach (var item in contest)
            {
                Console.WriteLine(item + 1);
            }

        }
        public static int GetInt() => int.Parse(Console.ReadLine());
        public static int[] GetIntArray() => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static double GetDouble() => double.Parse(Console.ReadLine());
        public static double[] GetDoubleArray() => Console.ReadLine().Split().Select(double.Parse).ToArray();
        public static long GetLong() => long.Parse(Console.ReadLine());
        public static long[] GetLongArray() => Console.ReadLine().Split().Select(long.Parse).ToArray();

    }
}


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

using namespace std;
using ll = long long;
using ld = long double;

void solve() {
  int r;
  cin >> r;
  cout << r * r << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  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 datanum = Integer.parseInt(sc.nextLine());
        int dataroom[][][] = new int[3][10][4];
        int b,f,r,v;
        String buf[];

        for(int i = 0; i < datanum; i++){
            buf = sc.nextLine().split(" ");
            b = Integer.parseInt(buf[0]);
            f = Integer.parseInt(buf[1]);
            r = Integer.parseInt(buf[2]);
            v = Integer.parseInt(buf[3]);
            dataroom[f-1][r-1][b-1] += v;
        }

        for(int i = 0; i < 4; i++ ){
            for(int m = 0; m < 3; m++ ){
                for(int n = 0; n < 10; n++){
                    System.out.print(" " + dataroom[m][n][i]);
                }
                System.out.println();
            }
            if( i != 3 ) System.out.println("####################");
        }
    }
}

Measured memory_bytes: 26780
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main(){

int a,b,c;
cin >>a>>b>>c;

if(a == b + c){
     cout << "Yes";
}
else if(b == a + c){
     cout << "Yes";
}
else if(c == a + b){
     cout << "Yes";
}
else{
     cout << "No";
}

cout << endl;

return 0;
}

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

int main() {
  string s,t;
  cin >> s >> t;
  int ans=0;
  for(int i=0; i<3; i++){
    if(s[i]==t[i]){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int pd[1100],num[1100];
int n;
const int mo=1e9+7;
int main(){
	scanf("%d",&n);
	for (int i=2;i<=n;i++)
		for (int j=i+i;j<=n;j+=i) pd[j]=1;
	int ans=1;
	for (int i=2;i<=n;i++)
		if (pd[i]==0){
			int tot=0;
			for (int j=i;j<=n;j*=i) tot+=n/j;
			ans=1ll*ans*(tot+1)%mo;
		}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int remain = a - b;
        String result;
        if (0 <= remain) {
            result = "delicious";
        } else if (0 <= remain + x) {
            result = "safe";
        } else {
            result = "dangerous";
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 21844
gets
a=$<.map{|l|a=l.split;[a[0],a[1].to_i,$.]}
g=->p,r{x=a[r]
i=p
(p...r).map{|j|a[j][1]<=x[1]&&(a[i],a[j]=a[j],a[i]
i+=1)}
a[i],a[r]=x,a[i]
i}
s=->f,p,r{p<r&&(q=g[p,r]
s[f,p,q-1]
s[f,q+1,r])}
s[s,0,a.size-1]
puts a.map{|b|c=a.select{|d|d[1]==b[1]}
c!=c.sort_by{|d|d[2]}&&break}?:Stable:"Not stable",a.map{|e|e[0,2]*" "}

Measured memory_bytes: 46264
#include <stdio.h>

int w, h;
int c[50][50];

const int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
void fill(int x, int y)
{
    int i;

    c[y][x] = 0;
    for (i = 0; i < 8; ++i) {
        int nx = x + dx[i], ny = y + dy[i];

        if (nx < 0 || w <= nx || ny < 0 || h <= ny)
            continue;
        if (c[ny][nx] == 0)
            continue;

        fill(nx, ny);
    }
}

int main(void)
{
    for (;;) {
        int i, j, ans = 0;

        scanf("%d %d", &w, &h);
        if (w == 0 && h == 0)
            break;

        for (i = 0; i < h; ++i)
            for (j = 0; j < w; ++j)
                scanf("%d", &c[i][j]);

        for (i = 0; i < h; ++i) {
            for (j = 0; j < w; ++j) {
                if (c[i][j] == 1) {
                    fill(j, i);
                    ++ans;
                }
            }
        }
        printf("%d\n", ans);
    }

    return 0;
}

Measured memory_bytes: 680
/**
*    created: 23.05.2020 00:08:27
**/
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    int t = min({a,b,c,d,e});
    if (n % t == 0) cout << n/t + 4 << endl;
    else cout << n/t + 5 << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (

	"fmt"
//	"strconv"
)
	func main(){
	var N , A, B int
	var a [5]int
	var a_ans, tmp, dig, num int
	
	fmt.Scan(&N, &A, &B)

	// 桁数調べ

	//	a, _ = strconv.Atoi(A)
	dig = 0
	a_ans = 0
	for i := 0 ; i <= N ; i++ {
		num = 0
		for ; num != 0; {
			num = i / 10
			dig++
		} 
		num  = i
		for j := 0 ; j < 5 ; j++ {
			/*a[0] = i % 10
			a[1] = i / 10 
			a[2] = i / 100
			a[3] = i / 1000
			a[4] = i / 10000*/
			if j == 0 {
				a[0] = i % 10
			}else  {
				num = num / 10
				a[j] = num % 10
			}
		}
		//fmt.Println(i)
		tmp = 0
		for j := 0 ; j < 5 ; j++ {
			tmp += a[j]
		}
		if A <= tmp && tmp <= B {
			a_ans += i
		//fmt.Printf("%d ", i)
		}
	}
	fmt.Println(a_ans)
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int C[3][3];
	rep(i, 0, 3)rep(j, 0, 3)
	{
		cin >> C[i][j];
	}

	rep(i, 0, 2)
	{
		set<int> B;
		B.insert(C[i + 1][0] - C[i][0]);
		B.insert(C[i + 1][1] - C[i][1]);
		B.insert(C[i + 1][2] - C[i][2]);
		if (SZ(B) > 1)
		{
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}

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

int main(){
  int a; cin >>a;
  for(int i=9; i>0; i--)
  {
    if(a%i==0)
    {
      if(a/i<10){cout <<"Yes"; return 0;}
      else{cout <<"No"; return 0;}
    }
  }
  cout <<"No";

return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    string s;
    cin >> s;
    int c = 0;
    for(int i = 0; i < s.size(); ++i) {
        if(s[i] == '0') ++c;

    }
    cout << min(int(s.size()) - c, c) * 2 << endl;
    return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 10000000000
#define MOD 1000000007LL
#define MAX 100005
#define NIL -1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> doup;

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

int main(void) {
    ll N, H;
    P p[MAX];
    ll i, ans=0;
    vector<ll> v;
    cin >> N >> H;
    for(i=0; i<N; i++) {
        cin >> p[i].first >> p[i].second;
    }
    sort(p, p+N);
    
    for(i=0; i<N; i++) {
        if(p[N-1].first<=p[i].second) {
            v.push_back(p[i].second);
        }
    }
    sort(v.begin(), v.end());
    
    for(i=(ll)v.size()-1; i>=0; i--) {
        H-=v[i]; ans++;
        if(H<=0) {
            cout << ans << endl;
            return 0;
        }
    }
    
    while(H>0) {
        H-=p[N-1].first;
        ans++;
        if(H<=0) {
            cout << ans << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 2936
N=int(input())
m=0
a=0
r=0
c=0
h=0
for _ in range(N):
  s=input()
  if s[0]=="M":
    m+=1
  elif s[0]=="A":
    a+=1
  elif s[0]=="R":
    r+=1
  elif s[0]=="C":
    c+=1
  elif s[0]=="H":
    h+=1
ans=0
ans+=m*a*r
ans+=m*a*c
ans+=m*a*h
ans+=m*r*c
ans+=m*r*h
ans+=m*c*h
ans+=a*r*c
ans+=a*r*h
ans+=a*c*h
ans+=r*c*h
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-7
#define f first
#define s second
using namespace std;
int n;
double p[3000];
double memo[3000][3000];
double solve(int heads, int tails){
    if(heads+tails==n)
        return (heads > tails)*1.0;
    double &res = memo[heads][tails];
    if(res >= 0)
        return res;
    return res = (p[heads+tails])*solve(heads+1, tails) + (1-p[heads+tails])*solve(heads, tails+1);
}
int main() {
    IO;
    memset(memo, -1.0, sizeof memo);
    cin >> n;
    for(int i = 0; i < n; ++i)
        cin >> p[i];
    cout << fixed << setprecision(10) << solve(0, 0);
    return 0;
}


Measured memory_bytes: 70784
import numpy as np

n, k = map(int, input().split())
mod = 10 ** 9 + 7

mx = np.sqrt(n).astype(int)

dp_u = np.ones(mx, np.int64)

N = np.full(mx, n, np.int64)
RNG = np.arange(1, mx + 2)
L = N // RNG[:-1]
R = N // RNG[1:]
R[-1] = np.maximum(R[-1], mx)
coef = L - R
dp_d = coef

for _ in range(2, k + 1):
    acc_u = np.cumsum(dp_u) % mod
    acc_d = np.cumsum(dp_d[::-1])[::-1] % mod
    dp_u = (dp_u.sum() + acc_d) % mod
    dp_d = coef * acc_u % mod

ans = (dp_u.sum() + dp_d.sum()) % mod
print(ans)


Measured memory_bytes: 16236
a, b, c, d = list(map(int, input().rstrip().split()))
time = []
t_max = max([b, d])
for t in range(t_max + 1):
    if a <= t <= b:
        flag_alice = 1
    else:
        flag_alice = 0
    if c <= t <= d:
        flag_bob = 1
    else:
        flag_bob = 0
    time.append([flag_alice, flag_bob])
switch = 0
for t in time:
    if t == [1, 1]:
        switch += 1
if switch > 0:
    switch -= 1
print(switch) 

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define prique priority_queue
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.1415926
#define coutdb cout<<fixed<<setprecision(15)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef int_fast64_t ll;
#define int int_fast64_t

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int M, D; cin >> M >> D;
  int ans = 0;
  for(int i = 1; i <= M; i++){
    for(int j = 10; j <= D; j++){
      int a = j/10, b = j%10;
      if(a>=2 and b>=2 and a*b == i) ans++;
    }
  }
  cout << ans << endl;
}

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

#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    ll n;
    cin >> n;

    map<string, ll> mp;

    rep(i, n){
        string s;
        cin >> s;
        auto it = mp.find(s);
        if(it != mp.end())mp[s]++;
        else mp[s] = 1; 
    }

    ll mx = 0;
    all_map(itr, mp)mx = max(mx, itr->second);

    vector<string> ans;
    all_map(itr, mp)if(itr->second == mx){
        ans.push_back(itr->first);
    }

    sort(ALL(ans));

    rep(i, ans.size())cout << ans[i] << endl;
}


Measured memory_bytes: 27248
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <cmath>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b))<EPS)

int m;
double dp[1001][1001];

//ifstream ifs("input.txt");
//#define cin ifs

double dfs(int pos,int mem){
	if(mem<0)return 0;
	else if(pos<0)return 0;
	else if(pos+1<=mem)return 0;
	else if(dp[pos][mem]>=-0.5)return dp[pos][mem];
	double res=0;
	double per1=1.0*mem/(pos+1);
	// êÚªÌÉ¶Ý
	if(!EQ(per1,0))
		res+=per1*(dfs(pos-1,mem-1));
	if(!EQ(per1,1)){
		double per2=(1.0)/(pos);
		// êÚÈOÆ}b`
		double per3=((double)mem)/(pos);
		// êÚÆ}b`
		if(!EQ(per2,0))
			res+=(1-per1)*(per2*(dfs(pos-2,mem)));
		// êÚÈOÌÌàÌÆ}b`
		if(!EQ(per3,0))
			res+=(1-per1)*(per3*(dfs(pos-2,mem)+1));
		// }b`¹¸
		if(!EQ(1-per2-per3,0))
			res+=(1-per1)*(1-per2-per3)*(dfs(pos-2,mem+2)+1);
	}
	return dp[pos][mem]=res;
}

int main(){

	for(int i=0;i<1001;i++)
		for(int j=0;j<1001;j++)dp[i][j]=-1;
	while(cin>>m&&m!=0){
		double res=dfs(m-1,0);
		printf("%.8f\n",res);
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<queue>
using namespace std;
typedef pair<pair<int,int>,int> pa;
#define ff first.first
#define fs first.second

int h,w,sx,sy,gx,gy;
int dx[4]={1,0,-1,0};
int dy[4]={0,-1,0,1};
int co[21][21];
char ma[21][21];
bool visited[21][21];
string pat;
int m = 999999;

int main(){
    while(cin>>h>>w,h){
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                co[i][j]=m;
                cin>>ma[i][j];
                if(ma[i][j]=='A')
                    sx=j,sy=i;
                else if(ma[i][j]=='B')
                    gx=j,gy=i;
            }
        }
        queue<pa>q;
        q.push(make_pair(make_pair(sx, sy), 0));
        while(q.size()){
            pa p = q.front();
            q.pop();
            if(co[p.fs][p.ff]!=m)
                continue;
            co[p.fs][p.ff]=p.second;
            for(int i=0;i<4;i++){
                int nx=p.ff+dx[i];
                int ny=p.fs+dy[i];
                if(nx>=0&&nx<w&&ny>=0&ny<h&&ma[ny][nx]!='#'&&co[ny][nx]==m)
                    q.push(make_pair(make_pair(nx, ny), p.second+1));
            }
        }
        cin>>pat;
        for(int j=0,go=0;;j++,go++){
            int i=j%pat.length();
            if(co[gy][gx]<=go){
                cout<<go<<" "<<gy<<" "<<gx<<endl;
                break;
            }
            if(go>700){
                cout<<"impossible"<<endl;
                break;
            }
            if(pat[i]=='8')
                gy--;
            else if(pat[i]=='6')
                gx++;
            else if(pat[i]=='4')
                gx--;
            else if(pat[i]=='2')
                gy++;
            gy=max(0,min(h-1,gy));
            gx=max(0,min(w-1,gx));
        }
    }
}

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

#define FOR(s, i, n) for(int i = s; i n; i++)
typedef long long ll;
const int INF = 1e9;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s, t;
	cin>>s>>t;
	t.pop_back();
	puts(s==t?"Yes":"No");
	
	return 0;
}

Measured memory_bytes: 3648
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);;

	int INF=1<<28;
	double EPS=1e-9;

	void run(){
		String line=sc.nextLine();
		String s="";
		LinkedList<String> list=new LinkedList<String>();
		for(char c : line.toCharArray()){
			if(c==' '||c=='.'||c==','){
				if(s.length()>=3&&s.length()<=6){
					list.add(s);
				}
				s="";
			}else{
				s+=c;
			}
		}
		if(s.length()>=3&&s.length()<=6){
			list.add(s);
		}
		for(int i=0; i<list.size(); i++){
			print(list.get(i)+(i==list.size()-1?"\n":" "));
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

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

#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define REP(i, n) for (long long i = 0; i < (n); i++)
const ll INF = 1LL << 60;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
};
signed main() {
    int a, b, x;
    cin >> a >> b >> x;
    if (x <= a + b && a <= x) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

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

int main() {
    // int a, b, c;
    string s;
    cin >> s;
    string sout = "Good";

    for(int i=0;i<3;i++){
    	if(s[i]==s[i+1]) sout = "Bad";
    }


    // cin >> s;
    cout << sout << endl;




}

Measured memory_bytes: 256
N = int(input())
S = list()
cnt_AC = 0
cnt_WA = 0
cnt_TLE = 0
cnt_RE = 0
for i in range(N):
  S.append(input())
for i in range(N):
  result = S[i]
  if result == "AC":
    cnt_AC += 1
  elif result == 'WA':
    cnt_WA += 1
  elif result == 'TLE':
    cnt_TLE += 1
  elif result == 'RE':
    cnt_RE += 1
print('AC x',cnt_AC)
print('WA x',cnt_WA)
print('TLE x',cnt_TLE)
print('RE x',cnt_RE)
  

Measured memory_bytes: 16320