akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <complex>
#include <numeric>
using namespace std;

typedef long long LL; typedef pair<LL, LL> PLL; typedef vector<LL> VLL;
#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define OUT(a) cout<<(a)<<endl;

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

    LL a[2];
    REP(i,2){
        cin >>a[i];
    }

    LL ans=a[0]*a[1];
    if(ans<=0){
        cout << "Zero" << endl;

    }else if(a[1]<0){
        if((a[0]-a[1])%2==0){
            cout << "Negative" <<endl;
        }else{
            cout << "Positive"<<endl;
        }
    }else{
        cout << "Positive" <<endl;
    }

    return 0;
}


Measured memory_bytes: 256
MOD = 10**9+7

n, m = map(int,input().split())

A = [0]*(n+1)
for i in range(m):
    a = int(input())
    A[a] = 1

dp = [0]*(n+1)
dp[0] = 1
if not A[1]:
    dp[1] = 1

for i in range(2,n+1):
    if A[i]:
        continue
    dp[i] = (dp[i-1]+dp[i-2])%MOD

print(dp[n])

Measured memory_bytes: 76204
#include <bits/stdc++.h>
using namespace std;
int main()
{
    while(1)
    {
        int m,f,mu,sum;
        cin>>m>>f>>mu;
        if(m==-1 && f==-1 && mu==-1)
            break;
        if(m==-1 || f==-1)
            cout<<"F"<<endl;
        else
        {
            sum=m+f;
            if(sum>=80)
                cout<<"A"<<endl;
            else if(sum>=65)
                cout<<"B"<<endl;
            else if(sum>=50)
                cout<<"C"<<endl;
            else if(sum>=30)
            {
                if(mu>=50)
                    cout<<"C"<<endl;
                else
                    cout<<"D"<<endl;
            }
            else
                cout<<"F"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3060
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    string ans0,ans1;
    string str;
    string lis[1000];
    int lissize=0;
    getline(cin,str);
    str.push_back(' ');
    for(int i=0;i<str.size();i++){
        for(int j=i;j<str.size();j++){
            if(str[j]==' '){
                lis[lissize]=str.substr(i,j-i);
                lissize++;
                i=j+1;
            }
        }
    }
    sort(lis,lis+lissize);
    int ans=0,karians=1;
    for(int i=1;i<lissize;i++){
        if(lis[i]==lis[i-1])karians++;
        else karians=1;
        if(ans<karians){
            ans=karians;
            ans0=lis[i];
        }
    }
    if(ans<karians)ans0=lis[lissize-1];
    karians=0;
    for(int i=0;i<lissize;i++){
        if(karians<lis[i].size()){
            karians=lis[i].size();
            ans1=lis[i];
        }
    }
    cout<<ans0<<' '<<ans1<<endl;
    return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;
typedef long long  ll;
typedef long double ld;
typedef pair<ll,ll> pp;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> super_set;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> multi_set;
#define x1 dfds
#define y1 dsfdsfe
#define pb push_back
#define forn(i,n) for(ll i = 1;i<=n;++i)
#define fi first
#define sc second
#define endl '\n'
#define po(x) (1ll<<x)
const ll DIM = 2E5+7;
const ll INF = 1e8;
ll pref[DIM],suf[DIM],mm[DIM],sm[DIM];
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ll n,k,c;
    cin>>n>>k>>c;

    c++;
    string s;
    cin>>s;
    s = 'k'+s;
    if (c==1){
        ll cnt = 0;
        forn(i,n){
            if (s[i]=='o')cnt++;
        }
        if (cnt==k){
            forn(i,n){
                if (s[i]=='o')cout<<i<<endl;
            }
        }
        return 0;
    }
    ll mx = 0;
    forn(i,n){
        if (i-c>0)mx = max(mx,pref[i-c]);
        if (s[i]=='x')pref[i] = 0;
        else{
            pref[i] = mx+1;
        }

    }
    mx = 0;
    for(ll i = n;i>=1;--i){
        if (i+c<=n)mx = max(mx,suf[i+c]);
        if (s[i]=='x')suf[i] = 0;
        else{
            suf[i] = mx+1;
        }
        sm[i] = max(sm[i+1],suf[i]);
    }

    forn(i,n){
        mm[i] = max(mm[i-1],pref[i]);
    }
    mx = 0;
    set<pp> M;
    vector<ll> ans;
    for(ll i = n+c;i>n;--i){
        M.insert({mm[i-c],i});
    }
    for(ll i = n;i>=1;--i){

        M.erase({sm[i+c]+mm[i],i+c});
        if ((M.empty() || M.rbegin()->fi<k) && suf[i]+mm[i-c]>=k)ans.pb(i);
         M.insert({sm[i]+mm[i-c],i});
    }
    while(!ans.empty()){
        cout<<ans.back()<<endl;
        ans.pop_back();
    }


    return 0;
}


Measured memory_bytes: 7936
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <functional>
#include <iterator>
#include <string>
#include <assert.h>

using std::cin;
using std::cout;
using std::endl;
using std::vector;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = std::pair<int, int>;
using vpii = vector<pii>;
using trio = std::pair<int, pii>;
#define all(x) begin(x), end(x)

struct day
{
	int a, b, c;
};

int main()
{
	cin.tie(0);
	cout.tie(0);
	std::ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<day> vec(n);
	for (int i = 0; i < n; ++i) cin >> vec[i].a >> vec[i].b >> vec[i].c;
	for (int i = n - 2; i >= 0; --i)
	{
		vec[i].a += std::max(vec[i + 1].b, vec[i + 1].c);
		vec[i].b += std::max(vec[i + 1].a, vec[i + 1].c);
		vec[i].c += std::max(vec[i + 1].a, vec[i + 1].b);
	}
	cout << std::max(vec[0].a, std::max(vec[0].b, vec[0].c)) << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n - 1);
	for(int & v : a) cin >> v;
	for(int & v : b) cin >> v;
	for(int & v : c) cin >> v;
	int ans = 0;
	for(int i = 0; i < n; i++){
		a[i]--;
	}
	for(int i = 0; i < n; i++){
		ans += b[a[i]];
		if(i + 1 < n  && a[i + 1] == a[i] + 1){
			ans += c[a[i]];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        int n;
        string s, t;
        cin >> n >> s >> t;
        int ans = 2 * n;
        int temp = 0;
        repone(i, n) {
            if (t.substr(0, i) == s.substr(n - i, i)) {
                temp = i;
            }
        }
        cout << ans - temp << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
k=int(input())

from collections import deque
q = deque(range(1,10))

for i in range(k-1):
    d = q.popleft()
    #10
    if d % 10 != 0:
        q.append(10 * d + d % 10 - 1)
    #11
    q.append(10 * d + d % 10)
    #12
    if d % 10 != 9:
        q.append(10 * d + d % 10 + 1)
print(q.popleft())




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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))
template<typename T> inline bool __max__(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool __min__(T &x, const T &y) { return x > y ? x = y, 1 : 0; }

#define pb push_back
#define mp make_pair

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

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

    int a, b, c, d;

    cin >> a >> b >> c >> d;

    int L = a + b;
    int R = c + d;

    if (L < R) cout << "Right" << '\n';
    else if (R < L) cout << "Left" << '\n';
    else cout << "Balanced" << '\n';

    return 0;
}


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

int n;
string s;

int main()
{
   cin >> s;
   bool val = 1;
   if(s[0]!='A') val=0;
   int c=0;
   for(int i=1;i<s.size();i++)
   {
      if(i>1 && i+1<(int)s.size() && s[i]=='C') c++;
      else if(s[i]>='A' && s[i]<='Z') val=0;
   }
   if(c!=1) val=0;
   if(val) printf("AC\n");
   else printf("WA\n"); 
 	return 0;
}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

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

    cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

inline int nCr(int n, int r) {
	int res = 1;
	vector<bool>done(r, false);
	for (int i = n; i > n - r; i--) {
		res *= i;
		for (int j = 1; j <= r; j++) {
			if (res%j == 0 && !done[j - 1]) {
				res /= j; done[j - 1] = true;
			}
		}
	}
	return res;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, a, b; cin >> n >> a >> b;
	vector<int>v(n); rep(i, n)cin >> v[i];
	sort(v.rbegin(), v.rend());
	int sum = 0;
	int last = v[a - 1];
	rep(i, a) {
		sum += v[i];
	}
	cout << fixed << setprecision(20) << 1.*sum / a << endl;
	if (last == v.front()) {
		int cnt = 0;
		rep(i, n) {
			if (v[i] == last)cnt++;
		}
		int ans = 0;
		for (int i = a; i <= b; i++) {
			ans += nCr(cnt, i);
		}
		cout << ans << endl;
	}
	else {
		int cnt = 0;
		int cnt2 = 0;
		rep(i, a) {
			if (v[i] == last)cnt++;
		}
		rep(i, n) {
			if (v[i] == last)cnt2++;
		}
		cout << nCr(cnt2, cnt) << endl;
	}
	return 0;
}

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

double ave(vector<double> a) {
	return accumulate(a.begin(), a.end(), 0.0) / a.size();
}

signed main() {
	int n;
	double s;
	while (cin >> n and n) {
		double sum = 0;
		vector<double> a;
		for (int i = 0; i < n; ++i) {
			cin >> s;
			a.push_back(s);
		}
		double aver = ave(a);

		for (int i = 0; i < n; ++i) {
			sum += (a[i] - aver) * (a[i] - aver);
		}
		sum /= n;
		sum = sqrt(sum);

		printf("%.9lf\n", sum);
	}
}



Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll 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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#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 all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;




int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> vec(k+1,0);
  ll ans = 0;
  for(ll i = k;i>0;i--){
    ll mul = k / i;
    ll t1 = n;
    ll req = 1;
    while(t1 != 0){
      if(t1 & 1){
        req *= mul;
        req %= mod;
      }
      mul *= mul;
      mul %= mod;
      t1 = t1 >> 1;
    }
    t3 = req;
    ll ward = i * 2;
    while(ward <= k){
      t3 -= vec[ward];
      if(t3 < 0){
        t3 += mod;
      }
      ward += i;
    }
    vec[i] = t3;
    ans += t3 * i;
    ans %= mod;
    //cout << vec[i] << endl;
    //cout << ans << endl;
  }
  cout << ans << endl;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define FORD(i,b,a) for (int i = (int)(b) - 1; i >= a; --i)
#define REP(i,N) FOR(i,0,N)
#define st first
#define nd second
#define pb push_back

typedef pair<int, int> PII;
typedef long long LL;

int cnt[111111];
int main() {
  int N;
  scanf("%d", &N);
  REP(i,N) {
    int A;
    scanf("%d", &A);
    ++cnt[A];
  }
  int additional = 0;
  REP(i,111111) additional += max(0, cnt[i] - 1);
  if (additional % 2) ++additional;
  printf("%d\n", N - additional);
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; i++){
    int cnt = 0;
    for(int j = 1; j <= n; j++){
      if(i%2 == 1  && i%j == 0){
        cnt++;
      }
    }
    
    if(cnt == 8){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define INT long long
using namespace std;

int uq(int a,int b)
{
    if(b==0) return a;
    return uq(b,a%b);
}

int main()
{
    int x,y;
    cin >> x >> y;
    int co;
    int a=max(x,y);
    int b=min(x,y);
    co=uq(a,b);
    cout << x+y-co+1 << endl;
    return 0;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

int main(){
    int n; cin>> n;
    vector<ll> h(n);
    int ans=0;
    int cnt=0;
    forin(h, n);
    for(int i=0; i<n-1; i++){
        if(h[i] >= h[i+1]){
            cnt++;
        }else{
            cnt=0;
        }
        ans=max(cnt, ans);
    }
    cout<<ans<<endl;
}


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

int main()
{
    int x;
    cin >> x;
    vector<bool> a(x + 1);
    a[1] = true;
    for (int base = 2; base <= x; base++)
    {
        int v = base * base;
        while (v <= x)
        {
            a[v] = true;
            v *= base;
        }
    }
    for (int i = x; 1 <= i; i--)
        if (a[i])
        {
            cout << i << endl;
            return 0;
        }
    return 0;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] temp = Console.ReadLine().Split(' ');
            int a = int.Parse(temp[0]);
            int b = int.Parse(temp[1]);
            int c = int.Parse(temp[2]);

            if (a < b && b < c)
            {
                Console.WriteLine($"{a} {b} {c}");

            }else if (b < a && b < c) 
            {
                if (a < c)
                {
                    Console.WriteLine($"{b} {a} {c}");
                }
                else
                {
                    Console.WriteLine($"{b} {c} {a}");
                }
            }
            else
            {
                if (a < b)
                {
                    Console.WriteLine($"{c} {a} {b}");
                }
                else
                {
                    Console.WriteLine($"{c} {b} {a}");
                }
            }
        }
    }
}



Measured memory_bytes: 15944
// 入力マクロ
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
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)*}
    };
}
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)*}
    };
}
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")
    };
}

fn main() {
    input! {
        n: usize, k: usize,
        a: [usize; n]
    }

    let mut a = a;
    let mut ans = 0;
    if a[0] > k {
        ans += a[0] - k;
        a[0] = k;
    }
    for i in 0..n-1 {
        if a[i] + a[i+1] > k {
            ans += a[i] + a[i+1] - k;
            a[i+1] -= a[i] + a[i+1] - k;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define forloop(n) for(int i = 0; i < n; i++)
#define ll long long

#define mod 998244353
/*ll ebob(ll a, ll b){
	if(a == 0) return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (a*b)/ebob(a,b);
}*/
int main(){
	int n; cin>>n;
	string s; cin>>s;
	int arr[10] = {};
	for(int i = 0; i < n; i++){
		arr[s[i] - '0']++;
	}
	/*ll toplam = 0;
	for(int u = 0; u < 10; u++){
		toplam += arr[u];
	}*/
	int arr2[30000] = {};
	bool ziyaret[10] = {};
	ll res = 0, sum = 0;
	for(int i = 0; i < n; i++){
		arr[s[i]-'0']--;
		/*if(ziyaret[s[i]-'0']){
			continue;
		}
		ziyaret[s[i]-'0'] = true;*/
		for(int u = 0; u < 10; u++){
			arr2[i] += (arr[u] > 0);
		}//cout<<arr2[i]<<endl;
	}
	for(int i = 0; i < n-2; i++){
		sum = 0;
		if(ziyaret[s[i]-'0']){
			continue;
		}
		ziyaret[s[i]-'0'] = true;
		bool temp[10] = {};
		for(int u = i+1; u < n; u++){
			if(temp[s[u]-'0']) continue;
			temp[s[u]-'0'] = true;
			sum += arr2[u];
		}
		res += sum;
	}
	cout<<res;
	return 0; 
}

Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>

#define MAX 100000
#define SENTINEL 2000000000

using namespace std;

struct Card {
	char suit;
	int value;
};

Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void Merge(Card *arr, int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;

	for (int i = 0; i < n1; i++) {
		L[i] = arr[left + i];
	}
	for (int i = 0; i < n2; i++) {
		R[i] = arr[mid + i];
	}

	L[n1].value = R[n2].value = SENTINEL;

	for (int k = left, i = 0, j = 0 ; k < right; k++) {
		if (L[i].value <= R[j].value) {
			arr[k] = L[i++];
		}
		else {
			arr[k] = R[j++];
		}
	}

}

void MergeSortQuick(Card *arr, int left, int right) {
	int mid;
	if (left + 1 < right) {
		mid = (left + right) / 2;
		MergeSortQuick(arr, left, mid);
		MergeSortQuick(arr, mid, right);
		Merge(arr, left, mid, right);
	}
}

int Partition(Card *arr, int startIndex, int thresholdIndex) {
	int thresholdValue, iteratorIndex;
	thresholdValue = arr[thresholdIndex].value;
	iteratorIndex = startIndex;

	for (int i = startIndex; i < thresholdIndex; i++) {
		if (arr[i].value <= thresholdValue) {

			swap(arr[i], arr[iteratorIndex]);
			iteratorIndex++;
		}
	}

	//since i == thresholdIndex, arr[i] <= thresholdValue
	swap(arr[iteratorIndex], arr[thresholdIndex]);

	return iteratorIndex;
}


void Sort(Card *arr, int left, int right) {
	int q;
	if (left < right) {
		q = Partition(arr, left, right);
		Sort(arr, left, q - 1);
		Sort(arr, q + 1, right);
	}
}

int main() {

	int n, value;
	Card *A, *B;
	char suit[10];
	int stable = 1;

	scanf("%d", &n);
	A = new Card[n]; B = new Card[n];

	for (int i = 0; i < n; i++) {
		scanf("%s %d", suit, &value);
		A[i].suit = B[i].suit = suit[0];
		A[i].value = B[i].value = value;
	}

	MergeSortQuick(A, 0, n);
	Sort(B, 0, n - 1);

	for (int i = 0; i < n; i++) {
		if (A[i].suit != B[i].suit) {
			stable = 0;
		}
	}

	if (stable == 1) {
		printf("Stable\n");
	}
	else {
		printf("Not stable\n");
	}

	for (int i = 0; i < n; i++) {
		printf("%c %d\n", B[i].suit, B[i].value);
	}
	//for (int i = 0; i < n; i++) {
	//	printf("%c %d\n", A[i].suit, A[i].value);
	//}


	return 0;
}


Measured memory_bytes: 5500
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int cnt=0;
    for(int i=n; i>=1; i--)
    {
        string s=to_string(i);
        if(s.size()%2)
            cnt++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <algorithm>
#include <cstdlib>
using namespace std;
int main() {
	stack<int> S1;
	stack<pair<int, int> > S2;
	char ch;
	int sum = 0;
	for (int i = 0; cin >> ch; i++) {
		if (ch == '\\') {
			S1.push(i);
		}
		else if (ch == '/' && S1.size() > 0) {
			int j = S1.top(); S1.pop();
			sum += i - j;
			int a = i - j;
			while (S2.size() > 0 && S2.top().first > j) {
				a += S2.top().second; S2.pop();
			}
			S2.push(make_pair(j, a));
		}
	}
	vector<int> ans;
	while (S2.size() > 0) {
		ans.push_back(S2.top().second); S2.pop();
	}
	reverse(ans.begin(), ans.end());
	cout << sum << endl;
	cout << ans.size();
	for (int i = 0; i < ans.size(); i++) {
		cout << " ";
		cout << ans.at(i);
	}
	cout << endl;
}


Measured memory_bytes: 3244
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    a,b,c = LI()
    k = I()
    ans = 0
    while b <= a:
        b *= 2
        ans += 1
    while c <= b:
        c *= 2
        ans += 1
    if ans <= k:
        print("Yes")
    else:
        print("No")
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 67220
#include<stdio.h>

int main()
{
    int n,a[101]={0},b[101]={0},i,p,s=0,k=0,max=0;
    char d;
    scanf("%d",&n);

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

    for(i=1;i<=n;i++)
        {
            k+=a[i];
            s-=b[i-1];
            p=k+s;
            if(max<p)
                max=p;
        }

        printf("%d",max);
}


Measured memory_bytes: 1700
#ifdef __GNUC__ 
#include <bits/stdc++.h>
#endif
using namespace std;
int main()
{
	string s;
	size_t n, k;
	cin >> n >> k;
	cin >> s;
	vector<tuple <int, int,char> > buf;
	unsigned int counter = 0;
	char prevc = '\0';
	unsigned int count[2];
	int i = 0;
	for (auto c : s) {		
		if (prevc == c) {
			counter++;
		}
		else {
			if (i != 0) {
				buf.emplace_back(counter,i,prevc);
			}
			counter = 1;
			prevc = c;
		}
		++i;
	}
	buf.emplace_back(counter, i, prevc);
	vector<unsigned int> result;
	if (get<2>(buf.front())=='0') {
		result.push_back(0);
	}
	for (auto data : buf) {
		for (int x = 0; x < min(k, result.size()); ++x) {
			result[result.size() - x - 1] += get<0>(data);
		}
		if (get<2>(data)=='1') {
			result.push_back(get<0>(data));
		}
	}
	unsigned maxval = 0;
	for (auto val : result) {
		if (maxval < val)maxval = val;
	}
	cout << maxval << endl;
}


Measured memory_bytes: 2104
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#define INF 0x3f3f3f3f
#define mod 1000000009
#define e  2.718281828459045
#define eps 1.0e18
#define PI acos(-1)
#define lowbit(x) (x&(-x))
#define memset(x,y) memset(x,y,sizeof(x))
#define lson i << 1,l,m
#define rson i << 1 | 1,m + 1,r
#define ll long long
using namespace std;
const int N = 200010;
double p[N];
int main(){
	ios::sync_with_stdio(false);
	double n,k;
	cin>>n>>k;
	double sum=0,maxn=0;
	for(int i=0;i<n;i++){
		double x;
		cin>>x;
		p[i]=(1.0+x)/2.0;
		if(i<k){
			sum=sum+p[i];
		}
		else{
			sum=sum-p[i-(int)k]+p[i];
		}
		maxn=max(sum,maxn);
	}
	printf("%lf",maxn);
//	cout<<(maxn+k)/2.0<<endl;	
	return 0;
}


Measured memory_bytes: 1792
import java.util.*;
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int b = 0;
        String a;
        int[][] card = new int[4][13];
        String[] mark = {"S","H","C","D"};
        for(int i = 0; i < n; i++){ 
        a = sc.next();
        b = sc.nextInt();
       for(int c=0; c<4; c++){
          if(mark[c].equals(a)){
              card[c][b-1]++;
            }
          }
        }
        for(int d = 0; d < 4; d++){
        	for(int c = 0; c < 13; c++){
	        	if( card[d][c] == 0){
	        	    System.out.println(mark[d] +" "+ (c+1)); 
	        	} 
          	}
        }
   }
}



Measured memory_bytes: 26212
x=int(input())

if ( x<=599):
  print(8)
elif (600<=x and x<=799):
  print(7)
elif (800<=x and x<=999):
  print(6)
elif (1000<=x and x<=1199):
  print(5)
elif (1200<=x and x<=1399):
  print(4)
elif (1400<=x and x<=1599):
  print(3)
elif (1600<=x and x<=1799):
  print(2)
else:
  print(1)

Measured memory_bytes: 9196
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
    int w, n;
    cin >> n >> w;
    vector<int> a(n),b(n);
    vector<vector<int>> dp(n + 1,vector<int>(w + 1));
    for (int i = 0; i <= w; ++i) dp[0][i] = 0;
    for (int i = 0;i < n;i++)cin >> a[i] >> b[i];
    for (int i = 0;i < n;i++) {
        for (int j = 0;j <= w;j++) {
            if (j >= b[i]) dp[i + 1][j] = max(dp[i][j - b[i]] + a[i], dp[i][j]);
            else dp[i + 1][j] = dp[i][j];
        }
    }
    cout << dp[n][w] << endl;
}


Measured memory_bytes: 6848
#include <iostream>
#include <cstdint>
#include <cmath>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>

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

using namespace std;

template<class T, class U>
istream& operator>>(istream& is, pair<T, U>& pair)
{
    is >> pair.first >> pair.second;
    return is;
}

template<class T>
istream& operator>>(istream& is, vector<T>& collection)
{
    for(auto& item : collection) is >> item;
    return is;
}

template <class T>
T peak_and_pop(std::queue<T>& q)
{
    assert(!q.empty());
    T t = move(q.front());
    q.pop();
    return t;
}

template <class T>
T peak_and_pop(std::priority_queue<T>& q)
{
    assert(!q.empty());
    T t = move(q.top());
    q.pop();
    return t;
}

template <class T>
T peak_and_pop(std::stack<T>& q)
{
    assert(!q.empty());
    T t = move(q.top());
    q.pop();
    return t;
}

void solution()
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int score = 0;
    int run_length = 1;
    int run_count = 1;
    rep(i,n-1){
        if(s[i] == s[i+1]){
            run_length += 1;
        }else{
            score += run_length - 1;
            run_length = 1;
            run_count += 1;
        }
    }
    score += run_length - 1;
    if(run_count - 2 * k <= 1){
        cout << (n-1) << '\n';
    }
    else{
        cout << (score + 2 * k) << '\n';
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solution();
    return 0;
}

/*

LRLRRL
n = 6
m = number of |

H = n - m - 1

L|R|L|RR|L
*|*|*|**|*
0 0 0 1  0  : 1

LLL|R|LL
***|*|**
2   0 1  : 3

*|**|***
0 1  2
**|**|**
1  1  1  : 

LRRLRLRRLRLLR

LLLRRLRRLRLLR
LLLLLRLLLRLLR
*/


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

int main() {
	while (1) {
		int n, y, x, i, j;
		double ans = 0;
		scanf("%d", &n);
		if (n == 0)	break;
		scanf("%d", &y);
		for (i = 0; i < n; i++) {
			int b, r, t;
			double z;
			scanf("%d %d %d", &b, &r, &t);
			if (t == 1) {
				z = 1 + y * r / 100.0;
			} else {
				z = 1;
				for (j = 0; j < y; j++)
					z *= (1 + r / 100.0);
			}
			if (z > ans) {
				x = b;
				ans = z;
			}
		}
		printf("%d\n", x);
	}
	return 0;
}

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;

int main()
{
    int a;
    string s;
    cin >> a>>s;
    if (a>=3200)
    {
        cout << s << endl;
        return 0;
    }
    else
    {
        cout << "red" << endl;
        return 0;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);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 FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


ll T, n, m, d;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    while(cin >> n >> m >> d){
        double ans = (double)2. * (n - d) * (m - 1) / n / n;
        if (d == 0) ans /= 2;
        printf("%.20f\n", ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
int main() {
	int n;
	cin >> n;
	if (n % 1000 == 0)cout << 0 << endl;
	else cout << 1000 - (n % 1000) << endl;



	return 0;
}

Measured memory_bytes: 3544
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#define rep(i,N) for(int i=0; i<N;i++)
using namespace std;

int main(){
    int N;
    cin >>N;
    vector<long long> A(N);
    long long ans,ans_old;
    ans=1;
    rep(i,N){
        cin>>A[i];
        if(A[i]==0){
            ans=0; cout <<ans <<endl;return 0;
        }
    }
    ans_old=1;
    rep(i,N){
        ans=ans*A[i];
        if((i>=1 and ans<ans_old) or ans > 1000000000000000000){
            ans=-1; cout <<ans <<endl;return 0;
        }
        ans_old=ans;
    }
    cout <<ans<<endl;


    return 0;
}


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

using namespace std;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(c) c.begin(), c.end()
#define rall(c) c.end(), c.begin()
#define INF (int)1e9
#define MOD 1000000007
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef map<int, int> MPII;
typedef set<int> SETI;

const int mxN = 2e5;
int a[mxN];

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

    int t;
    cin >> t;

    cout << t + t * t + t * t * t;

    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

long long val[3001][3001];
long long dp[3001][3001][4];

int main()
{
	memset(dp, 0, sizeof(dp));

	int R, C, K;
	cin >> R >> C >> K;

	for (int i = 0; i < K; ++i) {
		int r, c, v;
		cin >> r >> c >> v;
		--r;
		--c;
		val[r][c] = v;
	}

	dp[0][0][0] = 0;
	dp[0][0][1] = val[0][0];

	for (int r = 1; r < R; ++r) {
		dp[r][0][0] = *max_element(begin(dp[r - 1][0]), end(dp[r- 1][0]));
		dp[r][0][1] = *max_element(begin(dp[r - 1][0]), end(dp[r - 1][0])) + val[r][0];
	}

	for (int c = 1; c < C; ++c) {
		for (int k = 0; k < 4; ++k) {
			dp[0][c][k] = dp[0][c - 1][k];
			if (k != 0) {
				dp[0][c][k] = max(dp[0][c][k], dp[0][c - 1][k - 1] + val[0][c]);
			}
		}
	}

	for (int r = 1; r < R; ++r) {
		for (int c = 1; c < C; ++c) {
			dp[r][c][0] = *max_element(begin(dp[r - 1][c]), end(dp[r - 1][c]));
			dp[r][c][1] = *max_element(begin(dp[r - 1][c]), end(dp[r - 1][c])) + val[r][c];
			for (int k = 0; k < 4; ++k) {
				dp[r][c][k] = max(dp[r][c][k], dp[r][c - 1][k]);
				if (k != 0) {
					dp[r][c][k] = max(dp[r][c][k], dp[r][c - 1][k - 1] + val[r][c]);
				}
			}
		}
	}

	long long ans = 0;
	for (int k = 0; k < 4; ++k) {
		ans = max(ans, dp[R - 1][C - 1][k]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 355380
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
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; }
const int INF = 1e18;

struct UnionFind {
    public:
    vector<int> par;
    UnionFind(int n){
        par=vector<int>(n,-1);
    }
    int root(int x){
        if(par[x]<0)return x;
    return par[x]=root(par[x]);
    }
    bool issame(int x,int y){
        return root(x)==root(y);
    }
    bool merge(int x,int y){
        x=root(x);
        y=root(y);
        if(x==y)return false;
        if(par[x]>par[y])swap(x,y);
        par[x]+=par[y];
        par[y]=x;
        return true;
    }
    int size(int x){
        return -par[root(x)];
    }
};

signed main(){
    int n, m; cin >> n >> m;
    UnionFind uf(n+m+1);
    REP(i,n){
        int k; cin >> k;
        while(k--){
            int l; cin >> l; l--;
            uf.merge(i,n+l);
        }
    }
    REPS(i,n-1)if(!uf.issame(0,i)){
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    return 0;
}

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

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> V(N);
    for(int i=0;i<N;i++){
        cin >> V[i];
    }

    vector<priority_queue<int>> qL(N+1);
    vector<priority_queue<int>> qR(N+1);
    vector<int> sumL(N+1);
    vector<int> sumR(N+1);
    for(int i=0;i<=N;i++){
        for(int j=0;j<i;j++){
            qL[i].push(-V[j]);
            qR[i].push(-V[N-1-j]);
        }
        if(i==N) break;
        sumL[i+1] = sumL[i] + V[i];
        sumR[i+1] = sumR[i] + V[N-1-i];
    }
    auto res = numeric_limits<int>::min();
    for(int il=0;il<=N;il++){
        for(int ir=0;ir<=N;ir++){
            if(il + ir > N) continue;
            auto k = K - il - ir;
            if(k<0) continue;
            int vsum = 0;
            vsum += sumL[il];
            vsum += sumR[ir];
            auto qLt = qL[il];
            auto qRt = qR[ir];
            while(k>0){
                auto v1 = qLt.size()==0? 0 : qLt.top();
                auto v2 = qRt.size()==0? 0 : qRt.top();
                if(v1 <= 0 && v2 <= 0) break;
                else if(v2 <= 0){ vsum += v1; qLt.pop();}
                else if(v1 <= 0){ vsum += v2; qRt.pop();}
                else if(v1 > v2){ vsum += v1; qLt.pop();}
                else            { vsum += v2; qRt.pop();}
                k--;
            }

            res = max(res, vsum);
        }
    }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
K, N = [int(str) for str in input().strip().split()]
A = [int(str) for str in input().strip().split()]

diffs = []
for i in range(N - 1):
    diffs.append(A[i + 1] - A[i])
diffs.append(K - A[-1] + A[0])

print(K - max(diffs))

Measured memory_bytes: 26444
a,b,c=map(int,input().split())
cnt=0
while a%2==b%2==c%2==0:
  a1=a//2
  b1=b//2
  c1=c//2
  a=b1+c1
  b=c1+a1
  c=a1+b1
  cnt+=1
  if a==2*a1 and b==2*b1 and c==2*c1:
    cnt=-1
    break
print(cnt)

Measured memory_bytes: 9116
N,M=list(map(int,input().split()))
H_keys=[i+1 for i in range(N)]
H_values=list(map(int,input().split()))
AB_list = [list(map(int,input().split())) for i in range(M)]
H=dict(zip(H_keys,H_values))
#H_sort = sorted(H.items(), key=lambda x:x[1])
#print(H_sort)
#temp=0
ans_list=[]
for i in AB_list:
  if H[i[0]]<H[i[1]]:
    ans_list.append(i[0])
  elif H[i[1]]<H[i[0]]:
    ans_list.append(i[1])
  else:
    ans_list.append(i[0])
    ans_list.append(i[1])
  #temp+=1
  #print(temp)
  #print(H)
print(N-len(set(ans_list)))

Measured memory_bytes: 43976
import collection.mutable.Queue


object Main {
  case class Task(name: String, time: Int)

  def main(args: Array[String]): Unit = {
    val tasks = Queue[Task]()

    val sc = new java.util.Scanner(System.in);
    val n = sc.nextInt
    val q = sc.nextInt

    for (_ <- 1 to n) tasks += Task(sc.next, sc.nextInt)

    var time = 0

    while (tasks.nonEmpty) {
      val task = tasks.dequeue
      if (task.time > q) {
        time = time + q
        tasks += task.copy(time = task.time - q)
      } else {
        time = time + task.time
        println(s"${task.name} $time")
      }
    }
  }
}

Measured memory_bytes: 139264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repr(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<(int)(n);i++)
#define INF 99999999999999

    /*Solve*/
int main(){
    ll x,y;
    cin >> x >> y;
    
    bool bx,by;
    ll cnt=0;
    while(1){
        if(x==y)break;
        
        if(x<0){
            bx=false;
        }else bx=true;
        if(y<0){
            by=false;
        }else by=true;
        
        if(bx==true && by==true){
            if(x<y){
                x++;cnt++;
            }else{x=-x;cnt++;}
        }else if(bx==true && by==false){
            if(x<-y){
                x++;cnt++;
            }else {x=-x;cnt++;}
        }else if(bx==false && by==true){
            if(-x<=y){
                x=-x;cnt++;
            }else{x++;cnt++;}
        }else {
            if(x>=y){
                x=-x;cnt++;
            }else{
            x++;cnt++;
            }
        }
    }
    cout << cnt << endl;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  char a[H][W];
  
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> a[i][j];
    }
  }

  for(int i=0; i<W+2; i++){
    cout << '#';
  }
  cout << endl;
  
  for(int i=0; i<H; i++){
    cout << '#';
    for(int j=0; j<W; j++){
      cout << a[i][j];
    }
    cout << '#' << endl;
  }
  
  for(int i=0; i<W+2; i++){
    cout << '#';
  }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 3564
#include<iostream>
using namespace std;
bool isPrime(int n){
	if(n<2)return false;
	for(int i=2;i*i<=n;++i){
		if(n%i==0){
			return false;
		}
	}
	return true;
}
main(){
	int n;
	while(cin>>n){
		for(int i=n-1;i>=1;--i){
			if(isPrime(i)){
				cout<<i<<" ";
				break;
			}
		}
		for(int i=n+1;;++i){
			if(isPrime(i)){
				cout<<i<<endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 1160
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")

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

using l = long int;
using ll =unsigned long long int;
#define imax INT_MAX
#define lmax LLONG_MAX
#define pb push_back
#define ld long double
#define pii pair<l,l> 
#define pll pair<ll,ll>
#define v vector
#define vl vector<l>
#define vll vector<ll>
#define vvl vector<vector<l>>
#define vvll vector<vector<ll>>
#define vv(a) vector<vector<a>> 
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define mni(a,i,j) *min_element((a).begin()+i,(a).begin()+j)
#define mxi(a,i,j) *max_element((a).begin()+i,(a).begin()+j)
#define f first
#define se second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define rep(i, begin, end) \
        for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define tc l t=0;cin>>t;while(t--)

// ONLINE JUDGE START
#ifndef ONLINE_JUDGE
    // FILE
    #define file ifstream cin; cin.open("input.txt");  ofstream cout; cout.open("output.txt");
    // DEBUG
    #define debug(x) cout<<"LINE NUMBER:     "<<__LINE__<<"\t :--> \t"<<#x<<"   =   "<<x<<endl;
#else 
    #define debug(x) 
#endif

// SYSTEM
#define DeBuG(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for(long blockTime=NULL;(blockTime==NULL?(blockTime=clock())!=NULL:false); \
            DeBuG("%s:%.4f s\n",d,(double)(clock()-blockTime)/CLOCKS_PER_SEC))
// OVERLOADING
istream& operator >> (istream& cin,vll &a){
    for(auto &i:a)cin>>i;
    return cin;
}
ostream& operator << (ostream& cout,pll &a){
    cout<<a.f<<" "<<a.se<<"\t";
    return cout;
}
ostream& operator << (ostream& cout,vl &a){
    for(auto &i:a)cout<<i<<" ";
    return cout;
}
ostream& operator << (ostream& cout,vll &a){
    for(auto &i:a)cout<<i<<" ";
    return cout;
}
ostream& operator << (ostream& cout,v<pll> &a){
    for(auto &i:a)cout<<i<<"\t";
    return cout;
}
ostream& operator << (ostream& cout,vvl &a){
    for(auto &i:a){cout<<i<<endl;}
    return cout;
}
ostream& operator << (ostream& cout,vvll &a){
    for(auto &i:a){cout<<i<<endl;}
    return cout;
}
ostream& operator << (ostream& cout,unordered_map<ll,bool> &a){
    for(auto &i:a){cout<<i.f<<" "<<i.se<<"\t";}
    return cout;
}


// GLOBAL VARIABLE AND FUNTIONS
const ll inf = 1e9+7;

bool check(ll n){
    ll pro=1;
    ll loop=70;
    while(loop--){
        pro*=2;
        if(n==pro)return true;
    }
    return false;
}

ll pw(ll n){
    ll pro=1;
    ll loop=70;
    while(loop--&&pro<n){
        pro*=2;
    }
    return pro;
}

int main()
{
#ifndef ONLINE_JUDGE
    // file;
#endif 

    ll n;cin>>n;
    if(n==1){
        cout<<1;
    }
    else {
        if(check(n)){
            cout<<2*n-1;
        }
        else{
            ll find=pw(n);
            cout<<find-1;
        }
    }

#ifndef ONLINE_JUDGE
    // cerr << "Time elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define int long long

auto main() -> signed {
    int n, t;
    cin >> n >> t;
    vector<int> v(n);
    for(int i=0; i<n; ++i) cin >> v[i];

    int ans = 0;
    for(int i=0; i<v.size()-1; ++i) ans += min(t, v[i+1]-v[i]);
    ans += t;

    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<cstring>
#include<string>
using namespace std;
int a[5];
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	for(int i=1;i<=4;i++){
		scanf("%1d",&a[i]);
	}
	if(a[1]==a[2]&&a[2]==a[3]){
		printf("Yes\n");
		return 0;
	}
	if(a[2]==a[3]&&a[3]==a[4]){
		printf("Yes\n");
		return 0;
	}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  long i,j,k,ans=0;
  long N,M;
  scanf("%ld %ld",&N,&M);
  if(N*2 < M){
    ans += N;
    M -= N*2;
    ans += M/4;
  }
  else
    ans += M/2;
  
  printf("%ld\n",ans);
  return 0;
}
  


Measured memory_bytes: 128
//
//  main.cpp
//  J - Sushi
//
//  Created by Thomas Guo on 2019-01-16.
//  Copyright © 2019 Thomas Guo. All rights reserved.
//

#include <iostream>
#include <iomanip>
#include <map>
#define tii pair<pii,int>
#define pii pair<int,int>
#define mp make_pair
#define maxn 302
using namespace std;
int n,a,b,c;
double ans[maxn][maxn][maxn];
double solve(int cnt3,int cnt2,int cnt1){
    if(cnt1+cnt2+cnt3==0){
        return 0;
    }
    if(ans[cnt3][cnt2][cnt1]!=0){
        return ans[cnt3][cnt2][cnt1];
    }
    double newans=0;
    if(cnt1!=0){
        newans+=(cnt1/(double)n)*(1+solve(cnt3,cnt2,cnt1-1));
    }
    if(cnt2!=0){
        newans+=(cnt2/(double)n)*(1+solve(cnt3,cnt2-1,cnt1+1));
    }
    if(cnt3!=0){
         newans+=(cnt3/(double)n)*(1+solve(cnt3-1,cnt2+1,cnt1));
    }
    
    if(cnt3+cnt2+cnt1!=n){
        newans+=(n-cnt3-cnt2-cnt1)/(double)n;
        newans*=n;newans/=(double)(cnt3+cnt2+cnt1);
    }
    return ans[cnt3][cnt2][cnt1]=newans;
}
int main(){
    cin>>n;
    for(int i=1,x;i<=n;i++){
        cin>>x;
        if(x==3){
            a++;
        }
        else if(x==2){
            b++;
        }
        else if(x==1){
            c++;
        }
    }
    cout<<setprecision(20)<<fixed<<solve(a,b,c)<<"\n";
    return 0;
}


Measured memory_bytes: 215296