akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using namespace std::literals::chrono_literals;
using namespace std::literals::string_literals;
using ll = long long;

#define repi(i, s, n) for (long long i {s}, i##_len{n}; i < i##_len; ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) std::begin(x), std::end(x)

namespace xmaho
{
inline namespace input
{
template<typename T>
T get_value(std::istream& is = std::cin);
template<typename C>
C get_container(std::istream& is = std::cin, typename C::size_type length = std::numeric_limits<typename C::size_type>::max());
}
}
namespace xmaho
{
inline namespace integer
{
template<typename C>
constexpr auto ssize(const C& c) noexcept(noexcept(c.size()))
  -> typename std::common_type<std::ptrdiff_t, typename std::make_signed<decltype(c.size())>::type>::type;
template <class T, ptrdiff_t N>
constexpr std::ptrdiff_t ssize(const T (&)[N]) noexcept;
}
}
using namespace xmaho;

int main()
{
  auto sz {get_value<int>()};
  auto last_max {numeric_limits<int>::max()};
  auto res {0};
  for (auto i {sz}; i != 0; --i) {
    const auto p {get_value<int>()};
    if (p <= last_max) {
      last_max = p;
      ++res;
    }
  }
  cout << res << '\n';

  return 0;
}

class initalization
{
  class custom_numpunct: public std::numpunct<char>
  {
  public:
    using numpunct::numpunct;
  protected:
    std::string do_truename() const override { return "Yes"; }
    std::string do_falsename() const override { return "No"; }
  };

public:
  initalization()
  {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.imbue(std::locale(std::cout.getloc(), new custom_numpunct{}));
    std::cout << std::boolalpha << std::fixed << std::setprecision(15);
  }
} initalize;

template<typename T>
T xmaho::input::get_value(std::istream& is)
{ T v {}; is >> v; return v; }

template<typename C>
C xmaho::input::get_container(std::istream& is, typename C::size_type length)
{
  C v {};
  if (length != std::numeric_limits<typename C::size_type>::max())
    v.reserve(length);
  typename C::value_type e {};
  for (auto i {length}; i != 0 && is >> e; --i)
    v.push_back(std::move_if_noexcept(e));
  return v;
}

template<typename C>
constexpr auto xmaho::integer::ssize(const C& c) noexcept(noexcept(c.size()))
  -> typename std::common_type<std::ptrdiff_t, typename std::make_signed<decltype(c.size())>::type>::type
{ return c.size(); }

template <class T, ptrdiff_t N>
constexpr std::ptrdiff_t xmaho::integer::ssize(const T (&)[N]) noexcept
{ return N; }


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


signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);

    int n;
    cin>>n;
    int a[n];
    int m=0;
    int m2=0;
    set<int> st;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i] == 2) st.insert(i);
        if(a[i] == -1) m++;
        if(a[i] == -2) m2++;
    }
    if(m2){
        if(m2%2 && m){
            bool used = false;
            for(int i=0;i<n;i++){
                if(a[i] == -1 && !used){
                    st.insert(i);
                    used = 1;
                }
                if(a[i] == -2) st.insert(i);
            }
        }
        if(m2%2){
            for(int i=0;i<n;i++){
                if(m2==1) break;
                if(a[i] == -2){
                    st.insert(i);
                    m2--;
                }
            }
        }
        if(m2 %2 == 0){
            for(int i=0;i<n;i++){
                if(a[i] == -2) st.insert(i);
            }
        }
    }

    cout << st.size() << endl;
    for(auto i:st){
        cout << i+1 << endl;
    }

    
}


Measured memory_bytes: 3220
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i+=2){
		int hoge=0;
		for(int j=1;j<=i;++j){
			if(i%j==0){
				++hoge;
			}
		}
		if(hoge==8){
			++ans;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 3596
using System;

namespace CF2016AA{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            var S = sr.Next<string>();
            Console.WriteLine(S.Insert(4, " "));
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];
        private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = _sr.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var ret = new T[x];
            for(var i = 0; i < x; ++i) ret[i] = Next<T>();
            return ret;
        }

        public T[][] Next<T>(int y, int x){
            var ret = new T[y][];
            for(var i = 0; i < y; ++i) ret[i] = Next<T>(x);
            return ret;
        }
    }
}

Measured memory_bytes: 2904
#include <iostream>
#include <math.h>
using namespace std;

double a,ans;

int main() {
	while(cin>>a){
		ans=a;
		for(int i=0;i<9;i++){
			if(i%2==0)a=a*2;
			else a=a/3;
			ans+=a;
		}
		printf("%f10\n",ans);
	}
}

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

#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to));
#define sort(a) sort(a.begin(), a.end())

using namespace std;

int main() {
  string n;
  cin >> n;
  
  if (n[0] == '9' || n[1] == '9') {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include <stdexcept>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
typedef long long ll;
int ceil(int a,int b){// a以上でｂの倍数の最小値を出力//
    return (a+b-1)/b*b;
}
int stoii(string s){//stoi関数の代用 文字列を数値として読み取りint型に変換//
    return atoi(s.c_str());
}
int main (){
    int a,b;
    cin>>a>>b;
    int cnt=0;
    FOR(i,a,b+1){
        string s,t;
        s=to_string(i);
        t=to_string(i);
        reverse(s.begin(),s.end());
        if(s==t) cnt++; 
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
import math
if 1.08 * (math.floor(n/1.08)) == n:
  print(math.floor(n/1.08))
  exit()
if math.floor(1.08 * (math.floor(n/1.08)+1)) == n:
  print(math.floor(n/1.08)+1)
  exit()
if math.floor(1.08 * (math.floor(n/1.08)+2)) == n:
  print(math.floor(n/1.08)+1)
  exit()
else:
  print(':(')
  
  
  

Measured memory_bytes: 3060
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
// using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;

//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define bug2(v1,v2)               cerr<<#v1<<" = "<<(v1)<< ' ' << #v2<<" = "<<(v2)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const double pi = 3.14159265359;
const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
//const ll mod = 998244353 ;
const ll mod = 1000000007;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return (((a+mod)%mod)*(b+mod)%mod)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline ll modInverse(ll n, ll p){ return power(n, p-2)%p; }

/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 
void stArt()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}
void eNd()
{
	#ifndef ONLINE_JUDGE
  	cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  	#endif
}

//////////////////// start /////////////////////////////////
 

ll i,j,k,l,m,r,n;
ll a[MAX],b[MAX];

// void dfs1(ll v, ll par)
// {
// 	c[v] = a[v];
// 	for(auto u:adj[v]){
// 		if(u==par)
// 			continue;
// 		dfs1(u,v);
// 		c[v] += c[u];
// 	}
// 	//bug2(c[v],v)
// }

// void dfs2(ll v, ll par, ll bef)
// {
// 	ll g,bx;
// 	g = (c[v]+b[v])/2;
// 	bx = c[v] - g;
// 	if(abs(b[v])>c[v] || g<0 || bx<0 || (c[v]+b[v])%2!=0 || g>bef)
// 		ans=1;
// 	for(auto u:adj[v]){
// 		if(u==par)
// 			continue;
// 		dfs2(u,v,g);
// 	}
// }



int main()
{
 
stArt();
fast
//cout << setprecision(15) << fixed;

cin >> n >> k;
ll ans =0;
k*=k;
fr(i,0,n)
{
	cin >> l >> r;
	m = l*l + r*r;
	if(k>=m){
		//bug(i)
		ans++;
	}
}
cout << ans;

 eNd();
  return 0;
 
}

Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;

#define endl '\n'
#define pb push_back
#define ll long long
#define len(X) ((int)(X).size())
#define all(X) (X).begin(), (X).end()
#define deb(X) cout << #X << " " << X << '\n'

void solve(int test_case) {
    int x;
    cin >> x;
    cout << !x << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    // cin >> t;
    for(int tc = 1; tc <= t; ++tc) solve(tc);
}


Measured memory_bytes: 3608
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;

#define ll long long
#define pal pair<ll,ll>
#define pad pair<double,double>
#define PB push_back
#define MP make_pair
#define F first
#define S second

const ll MOD = 1e9+7;
const ll INF = 1e18;
const double EPS = 1e-8;

long long MODPOW(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}

ll n,k;
vector<double> a(200000,0);

bool isOK(double x) {
    ll num =0;
	for(ll i=0;i<n;i++){
		num += (ll)(a[i]/x);
	} 
	return num <= k;
}

double binary_search(void) {
    double ng = 0;
    double ok = 1e9+10;

    while (abs(ok - ng) > 0.000001) {
        double mid = (ok + ng) / 2;

        if (isOK(mid)) ok = mid;
        else ng = mid;
    }
    return ng;
}

int main(){
	cin >> n>>k;
	
	for(ll i=0;i<n;i++){
		cin >> a[i];
	}
	cout << (ll)ceil(binary_search()) << endl;
}

Measured memory_bytes: 4632
n = int(input())
P = list(map(int, input().split()))

ans = 0
data = []
for p in P:
   if len(data) == 2:
      data.append(p)
      if data[0] < data[1] and data[1] < data[2]:
          ans += 1
      elif data[2] < data[1] and data[1] < data[0]:
          ans += 1
      data.pop(0)
   else:
      data.append(p)

print(ans)

Measured memory_bytes: 38384
#include<stdio.h>
int main(){
  int n,k,i,j;
  scanf("%d %d", &n, &k);
  long a[n+1];
  for(i=1;i<=n;i++){
    scanf("%ld",&a[i]);
  }
  for(i=1;i+k<=n;i++){
    if(a[i]<a[i+k]) printf("Yes\n");
    else printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 3216
#include <stdio.h>

int main()
{
    long long int a, b, sum, ans;
    while(scanf("%lld %lld", &a, &b)!=EOF)
    {
        sum=a+b;
        ans=0;
        while(sum!=0)
        {
            ans++;
            sum=sum/10;
        }
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
int main(){
	int n;
	string str;
	int blood[4] = {0};
	while(scanf("%d,",&n)!=EOF){
		cin>>str;
		if(str == "A") blood[0]++;
		else if(str == "B") blood[1]++;
		else if(str == "AB") blood[2]++;
		else if(str == "O") blood[3]++;
	}
	cout<<blood[0]<<endl<<blood[1]<<endl<<blood[2]<<endl<<blood[3]<<endl;
	return 0;
}

Measured memory_bytes: 1236
import numpy as np
N,K = map(int,input().split())
A = list(map(int,input().split()))
A = np.array(A)
ans = np.array([float('inf')]*N)
ans[0] = 0
K = min(N-1,K)
for i in range(1,K+1):
  ans[i] = abs(A[0]-A[i])
for i in range(K+1,N):
  ans[i] = min(ans[i],np.min(ans[i-K:i]+np.abs(A[i]-A[i-K:i])))
print(int(ans[N-1]))

Measured memory_bytes: 22736
#include <stdio.h>

int main (){
	int test,bawah,atas, jumlah=0;
	scanf("%d %d %d", &test, &bawah, &atas);
	for(int i = 0 ; i <= test; i++){
		int num=i;
		int temp = 0;
		while(num > 0){
			temp += num%10;
			num /= 10;
		}
		if(temp >= bawah && temp <=atas){
			jumlah += i;
		}
	}
	printf("%d", jumlah);
	return 0;
}

Measured memory_bytes: 2152
# dp[i日目][i-1日目にどれを選んだか] = i日目までの最大の幸福度
# これはループでやってみたバージョン

n = int(input())
a, b, c = [0 for _ in range(n)], [0 for _ in range(n)], [0 for _ in range(n)]
for i in range(n):
    a[i], b[i], c[i] = map(int, input().split())

dp = [[-1 for _ in range(3)] for _ in range(n + 1)]
# 初期値、最初間違えて0にしてた
dp[0][0] = a[0]
dp[0][1] = b[0]
dp[0][2] = c[0]
for i in range(1, n):
    for j in range(3):
        if j == 0:
            dp[i][j] = a[i] + max(dp[i - 1][1], dp[i - 1][2])
        elif j == 1:
            dp[i][j] = b[i] + max(dp[i - 1][0], dp[i - 1][2])
        elif j == 2:
            dp[i][j] = c[i] + max(dp[i - 1][1], dp[i - 1][0])
print(max(dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]))


Measured memory_bytes: 36136
using System;

namespace Atcoder_20190413_C
{
    class Program
    {
        static void Main(string[] args)
        {
            //definition

            string input = Console.ReadLine();
            //string a = "";
            int achange = 0;
            int bchange;
            int result;

            //main
            for (int i = 0; i < input.Length; i++)
            {
                if (i % 2 == 0)
                {
                    if (input[i] == '0')
                        achange++;
                }
                else
                {
                    if (input[i] == '1')
                        achange++; 
                }
            }
            
            bchange = input.Length - achange;

            if (achange > bchange)
                result = bchange;
            else
                result = achange;

            //output
            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 11232
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << "NO" << endl;return 0
#define MM <<" "<<
#define Endl endl


signed main(void){
    int A,B;
    cin >> A >> B;
    cout << max(A+B,max(A-B,A*B)) << endl;
    return 0;
}


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

int main() {
  int H,W; cin >>H>>W;
  string s[H]; for(int i=0; i<H; i++) cin >>s[i];
  
  bool check=false;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(s[i][j]=='#'){
        if(i==0&&j==0){
          if(s[i+1][j]=='.'&&s[i][j+1]=='.') check=true;
        }else if(i==0&&j==W-1){
          if(s[i+1][j]=='.'&&s[i][j-1]=='.') check=true;
        }else if(i==H-1&&j==0){
          if(s[i-1][j]=='.'&&s[i][j+1]=='.') check=true;
        }else if(i==H-1&&j==W-1){
          if(s[i-1][j]=='.'&&s[i][j-1]=='.') check=true;
        }else if(i==0){
          if(s[i+1][j]=='.'&&s[i][j+1]=='.'&&s[i][j-1]=='.') check=true;
        }else if(i==H-1){
          if(s[i-1][j]=='.'&&s[i][j+1]=='.'&&s[i][j-1]=='.') check=true;
        }else if(j==0){
          if(s[i+1][j]=='.'&&s[i-1][j]=='.'&&s[i][j+1]=='.') check=true;
        }else if(j==W-1){
          if(s[i+1][j]=='.'&&s[i-1][j]=='.'&&s[i][j-1]=='.') check=true;
        }else{
          if(s[i+1][j]=='.'&&s[i-1][j]=='.'&&s[i][j+1]=='.'&&s[i][j-1]=='.') check=true;
        }
      }
    }
  }
  if(check) cout << "No" << endl;
  else cout << "Yes" << endl;
}

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

using namespace std;

int main()
{
    string s; cin >> s;
    int abcd[4];

    for (int i =  0; i < 4; i++) {
        abcd[i] = s[i] - '0';
    }



    if (abcd[0] + abcd[1] + abcd[2] + abcd[3] == 7) {
        cout << abcd[0] << "+" << abcd[1] << "+" << abcd[2] << "+" << abcd[3] << "=7" << endl;
        return 0;

    } else if (abcd[0] + abcd[1] + abcd[2] - abcd[3] == 7) {
        cout << abcd[0] << "+" << abcd[1] << "+" << abcd[2] << "-" << abcd[3] << "=7" << endl;
        return 0;

    } else if (abcd[0] + abcd[1] - abcd[2] - abcd[3] == 7) {
        cout << abcd[0] << "+" << abcd[1] << "-" << abcd[2] << "-" << abcd[3] << "=7" << endl;
        return 0;

    } else if (abcd[0] + abcd[1] - abcd[2] + abcd[3] == 7) {
        cout << abcd[0] << "+" << abcd[1] << "-" << abcd[2] << "+" << abcd[3] << "=7" << endl;
        return 0;

    } else if (abcd[0] - abcd[1] + abcd[2] + abcd[3] == 7) {
        cout << abcd[0] << "-" << abcd[1] << "+" << abcd[2] << "+" << abcd[3] << "=7" << endl;
        return 0;

    } else if (abcd[0] - abcd[1] - abcd[2] + abcd[3] == 7) {
        cout << abcd[0] << "-" << abcd[1] << "-" << abcd[2] << "+" << abcd[3] << "=7" << endl;
        return 0;

    } else if (abcd[0] - abcd[1] + abcd[2] - abcd[3] == 7) {
        cout << abcd[0] << "-" << abcd[1] << "+" << abcd[2] << "-" << abcd[3] << "=7" << endl;
        return 0;

    } else if (abcd[0] - abcd[1] - abcd[2] - abcd[3] == 7) {
        cout << abcd[0] << "-" << abcd[1] << "-" << abcd[2] << "-" << abcd[3] << "=7" << endl;
        return 0;
    }
}

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

signed main(void)
{
  int a, b, c; cin >> a >> b >> c;
  cout << max(0ll, c - (a - b)) << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[12][200005];
void inp(ll a[],ll n)
{
    for(int i=0;i<n;i++)
    cin>>a[i];
}
void out(ll a[],ll n)
{
    for(int i=0;i<n;i++)
    cout<<a[i]<<" ";
    cout<<endl;
}
int z=998244353;
bool cmp(pair <int,int> f,pair <int,int> s)
{
  return (f.first<s.first);
}
void solve()
{
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    vector <pair <ll,ll>> ranges;
    pair <ll,ll> p;
    //ranges.push_back(p);
    for(int i=1;i<=k;i++)
    {
        cin>>p.first>>p.second;
        ranges.push_back(p);
    }
    sort(ranges.begin(),ranges.end(),cmp);
    for(int i=0;i<=n;i++)
      for(int j=0;j<k+1;j++)
          dp[j][i]=0;
    for(int i=0;i<k+1;i++)
       dp[i][n]=0;
    dp[0][n]=1;
    for(int i=n-1;i>=1;i--)
    {
        for(int j=0;j<k;j++)
        {
            ll left=ranges[j].first;
            ll right=ranges[j].second;
            if(i+left<=n)
            {
              if((i+left)!=n)
              {dp[j][i]=dp[j][i+1];
               for(int l=0;l<k;l++)
               {
                   dp[j][i]=(dp[j][i]+dp[l][i+left])%z;
               }
              }
              else dp[j][i]=1;
            }
            else break;
            if(i+right<n)
            {
                for(int l=0;l<k;l++)
               {
                   dp[j][i]=(dp[j][i]-dp[l][i+right+1]+z)%z;
               }
            }
            else break;
        }
    }
    ll sum=0;
    for(int i=0;i<k;i++)
        sum=(sum+dp[i][1])%z;
    cout<<sum<<endl;
   /* for(int i=1;i<=n;i++)
        cout<<dp[0][i]<<" ";
    cout<<endl;
    for(int i=1;i<=n;i++)
        cout<<dp[1][i]<<" ";*/
    cout<<endl;
}
int main() {
    ll t=1;
    //cin>>t;
    while(t--)
    {
       solve();
    }
	return 0;
}


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


int main() {
    string N;
    cin >> N;
    ll count =0;
    for(char i:N){
        count += i-'0';
    }
    if(count%9==0)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3724
import java.util.*

data class Edge(val to: Int, val distance: Long)
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()

    val graph = Array(N, { mutableListOf<Edge>()}).toList() // contains edge index

    for (i in 0 until N - 1) {
        val (a, b, c) = readLine()!!.split(" ").map { it.toInt() }
        val from = a - 1
        val to = b - 1
        graph[from].add(Edge(to, c.toLong()))
        graph[to].add(Edge(from, c.toLong()))
    }
    val (Q, K) = readLine()!!.split(" ").map { it.toInt() }

    // Compute distance from K for each node
    // Kを単一始点として、最短距離を求める。
    // O (ElogV) = (ELogE)
    val distanceFromK = dijkstra(graph, K - 1)

    // Process queries O(Q)
    for (i in 0 until Q) {
        val (x, y) = readLine()!!.split(" ").map { it.toInt() }
        val xk = distanceFromK[x - 1]
        val ky = distanceFromK[y - 1]
        println(xk + ky)
    }
}

// returns distance array
class ComparablePair(val first: Long, val second: Int) : Comparable<ComparablePair>  {
    override fun compareTo(other: ComparablePair): Int {
        return (this.first - other.first).toInt()
    }
}
fun dijkstra(graph: List<List<Edge>>, source: Int) : List<Long> {
    val queue = PriorityQueue<ComparablePair>()
    val d = LongArray(graph.size)

    d.fill(Long.MAX_VALUE);
    d[source] = 0
    queue.add(ComparablePair(0, source))

    while(!queue.isEmpty()) {
        val p = queue.poll()!!
        val v = p.second
        if (d[v] < p.first) {
            continue
        }

        // 最小距離が確定したノード周辺を調べる。
        for (i in 0 until graph[v].size) {
            val e = graph[v][i]
            if (d[e.to] > d[v] + e.distance) {
                d[e.to] = d[v] + e.distance
                queue.add(ComparablePair(d[e.to], e.to))
            }
        }
    }


    return d.toList()
}


Measured memory_bytes: 108632
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var n int
	fmt.Scan(&n)

	ali := make([]int, n, n)

	sc.Split(bufio.ScanWords)

	for i := 0; i < n; i++ {
		ali[i] = nextInt()
	}

	bli := make([]int, n, n)

	for i := 0; i < n; i++ {
		bli[i] = nextInt()
	}

	cli := make([]int, n-1, n-1)

	for i := 0; i < n-1; i++ {
		cli[i] = nextInt()
	}

	count := sum(bli)

	tmpA := ali[0]
	for i := 0; i < n; i++ {
		if ali[i] == tmpA+1 {
			count += cli[ali[i]-2]
		}
		tmpA = ali[i]
	}

	fmt.Println(count)
}

func sum(a []int) int {
	s := 0
	for i := 0; i < len(a); i++ {
		s += a[i]
	}
	return s
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" \
                              << "\n";

int main()
{
  int k;
  cin >> k;
  queue<ll> ans;
  for (int i = 1; i <= 9; i++)
  {
    ans.push(i);
  }

  int cnt = 0;
  while (true)
  {
    cnt++;
    ll tmp = ans.front();
    if (cnt == k)
    {
      cout << tmp << "\n";
      return 0;
    }
    ans.pop();
    
    if (tmp % 10 != 0)
      ans.push(tmp * 10 + tmp % 10 - 1);

    ans.push(tmp * 10 + tmp % 10);

    if (tmp % 10 != 9)
      ans.push(tmp * 10 + tmp % 10 + 1);
  }
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(size_t i=0;i<(b);i++)
#define rREP(i,b) for(int i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(int i=(b)-1;i>=0;i--)
#define Foreach(item,collection) for(auto item:collection)
#define mod(i) ((i) % (ll)(1e9 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9 + 5))))
#define Yes out("Yes")
#define No out("No")
#define NO out("NO")
#define YES out("YES")
#define INF 1e10;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define IfOut(condition,text) if((condition)){out(text);return 0;}
#define IfeOut(condition,itext,etext) if(condition){out(itext);return 0;}else{out(etext);return 0;}
#define Select(collection,condition,result) Foreach(i,collection){result+=condition;}
#define GetAuto(_N,vect) {cin>>_N;vect.resize(_N);REP(i,_N){cin>>vect[i];}}
#define beginend(vec) (vec).begin(),(vec).end()
#define pb(item) push_back(item)
#define removeAll(vec,deleg) auto itr=remove_if(beginend(vec),deleg);vec.erase(itr,vec.end());
void removeAt(string& s, int index) { s.erase(index, 1); }
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
ll manhattanDistance(ll x1, ll y1, ll x2, ll y2) { return (abs(x2 - x1) + abs(y2 - y1)); }
vector<ll> sieveOfEratosthenes(int max) {ll prime;double sqrtmax = sqrt(max);vector<ll> primeVec, searchVec;FOR(i, 2, max + 1) searchVec.push_back(i);do{prime = searchVec[0];primeVec.push_back(prime);auto itr = remove_if(beginend(searchVec), [=](ll x)->bool {return x%prime == 0; });searchVec.erase(itr, searchVec.end());} while (prime < sqrtmax);primeVec.reserve(primeVec.size() + searchVec.size());primeVec.insert(primeVec.end(), beginend(searchVec));return primeVec;}

int main() {
	int X, A, B;
	cin >> X >> A >> B;
	if (A-B >= 0) { out("delicious"); }
	else if (abs(A-B) <= X) { out("safe"); }
	else out("dangerous");
	return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((i8[:], ), cache=True)
def main(S):
    S = S.copy()
    l_ind = np.where(S == -1)[0][:-1] + 1
    r_ind = np.where(S == -1)[0][1:]

    # 逆順にしておく
    N = len(l_ind)
    for i in range(N):
        S[l_ind[i]:r_ind[i]] = S[l_ind[i]:r_ind[i]][::-1]

    # Trie木の構築
    path = np.zeros_like(S)
    child = np.zeros((len(S), 26), np.int64)
    is_end = np.zeros(len(S), np.bool_)

    n_node = 1
    for i in range(N):
        node = 0
        for j in range(l_ind[i], r_ind[i]):
            path[j] = node
            if child[node][S[j]] == 0:
                child[node][S[j]] = n_node
                n_node += 1
            node = child[node][S[j]]
        is_end[node] = True
    child = child[:n_node]
    is_end = is_end[:n_node]
    ans = 0
    for i in range(N):
        se = 0
        for j in range(r_ind[i] - 1, l_ind[i] - 1, -1):
            se |= 1 << S[j]
            node = path[j]
            for k in range(26):
                if se & 1 << k:
                    if is_end[child[node][k]]:
                        ans += 1
    return ans - N

N = int(readline())
S = np.array(list(read().rstrip()), np.int64)

S[S == ord('\n')] = -1
S[S > 0] -= ord('a')
S = np.insert(S, 0, -1)
S = np.append(S, -1)

print(main(S))

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

using namespace std;

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


int main()
{
    // 無限大の値
    const long long INF = 1LL << 60;

    // DP テーブル
    long long dp[100010];

    // DP テーブル全体を初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    int N;
    cin >> N;
    vector<int> h;
    int tmp;
    for (int i=0; i<N; ++i)
    {
        cin >> tmp;
        h.push_back(tmp);
    }

    dp[0] = 0;
    for (int i=1; i<N; ++i)
    {   
        if(dp[i]>dp[i-1]+abs(h[i]-h[i-1]))
        {
            dp[i] = dp[i-1]+abs(h[i]-h[i-1]);
        }
        // dp[i] = chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
        if(i>1)
        {
            if(dp[i]>dp[i-2]+abs(h[i]-h[i-2]))
            {
                dp[i] = dp[i-2]+abs(h[i]-h[i-2]);
            }
            // dp[i] = chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
        }
        // cout << dp[i-1]+abs(h[i]-h[i-1]) << " ";
        // cout << dp[i] << endl;
    }

    // for (int i=0; i<h.size(); ++i)
    // {
    //     cout << h[i] << endl;
    // }
    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1660
(let* ((n (read))
    (s (read-line))
    (l (length s))
    (num 0))
    (loop for i below l do
        (progn
        (setq num (+ (char-code (char s i)) n))
        (if (> num 90)
            (decf num 26)
        )
        (format t "~A" (code-char num))
        )
    )
)

Measured memory_bytes: 24496
#include<stdio.h>
int main(){
	int n,i,j,m,s=0;
	scanf("%d",&n);
	for(j=0;j<n;j++,s=0){printf("Case %d:\n",j+1);scanf("%d",&m);
		for(i=0;i<10;i++){m=m*m;m%=1000000;s=+(m/100000)*1000;m%=100000;s+=(m/10000)*100;m%=10000;s+=(m/1000)*10;m%=1000;s+=(m/100);printf("%d\n",s);m=s;}}exit(0);}

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

long long gcd(long long a,long long b){
    if(a%b==0){
        return b;
    }
    return gcd(b,a%b);
}

int main(void){
    long long N,X;
    cin>>N>>X;
    vector<long long> x(N);
    long long ans;
    for(int i=0;i<N;i++){
        cin>>x[i];
    }
    if(N==1){
        ans=abs(x[0]-X);
    }else{
        x.insert(x.begin()+1,X);
        sort(x.begin(),x.end());
        vector<long long> dist;
        for(int i=0;i<N;i++){
            dist.push_back(x[i+1]-x[i]);
        }
        sort(dist.begin(),dist.end(),greater<long long>());
        for(int i=0;i<N-1;i++){
            dist[i+1]=gcd(dist[i],dist[i+1]);
        } 
        ans=dist[N-1];
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 2800
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define int long long
using namespace std;

typedef pair<int, int> Pii;

void readint(int N, vector<int> &a);
void readdouble(int N, vector<double> &a);
void readindex(int N, vector<int> &a);



signed main(){

    int R;
    cin >> R;
    if(R < 1200){
        cout << "ABC";
    }else if(R < 2800){
        cout << "ARC";
    }else{
        cout << "AGC";
    }
    
    return 0;
}








void readint(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str());
}
void readdouble(int N, vector<double> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atof(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atof(s.c_str());
}
void readindex(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str()) - 1;
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str()) - 1;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

#define MAX_N 100010

vector<int> G[MAX_N];
int ans = 0, n, k;

int dfs(int i=0) {
    int h = 0;
    for (auto g:G[i]) {
        int d = dfs(g) + 1;
        if (d == k && i > 0) {
            ans++;
            d = 0;
        }
        h = max(h, d);
    }
    return h;
}

int main() {
    int a0;
    cin >> n >> k >> a0;
    if (a0 != 1) ans++;
    for (int i=1; i<n; i++) {
        int j; cin >> j;
        j--;
        G[j].push_back(i);
    }
    dfs();
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 5, M = 1e9 + 7;
ll a[N], f[N];
int main()
{
    ll n, k;
    cin >> n >> k;
    for (ll i = 0; i < n; i++)
        cin >> a[i];
    for (ll i = 0; i < n; i++)
        cin >> f[i];
    sort(a, a + n);
    sort(f, f + n, greater<ll>());
    ll l = 0, h = M * N;
    while (l < h)
    {
        ll x = (l + h) / 2, s = 0;
        for (ll i = 0; i < n; i++)
            if (a[i] * f[i] > x)
                s += a[i] - x / f[i];
        if (s > k)
            l = x + 1;
        else
            h = x;
    }
    cout << l;
}


Measured memory_bytes: 5888
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
int cnt[2000][2000][4]; //上下左右
char S[2000][2001];
int main() {
	int H, W;
	cin >> H >> W;
	for (int i = 0; i < H; i++) cin >> S[i];
	for (int j = 0; j < W; j++) {
		int k = 0;
		for (int i = 0; i < H; i++) {
			cnt[i][j][0] = k;
			if (S[i][j] == '#') k = 0;
			else k++;
		}
		k = 0;
		for (int i = H - 1; i >= 0; i--) {
			cnt[i][j][1] = k;
			if (S[i][j] == '#') k = 0;
			else k++;
		}
	}
	for (int i = 0; i < H; i++) {
		int k = 0;
		for (int j = 0; j < W; j++) {
			cnt[i][j][2] = k;
			if (S[i][j] == '#') k = 0;
			else k++;
		}
		k = 0;
		for (int j = W - 1; j >= 0; j--) {
			cnt[i][j][3] = k;
			if (S[i][j] == '#') k = 0;
			else k++;
		}
	}
	int ans = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S[i][j] == '#') continue;
			int sum = 0;
			for (int k = 0; k < 4; k++) {
				sum += cnt[i][j][k];
			}
			ans = max(ans, sum + 1);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 66688
#include<bits/stdc++.h>
using namespace std;
int N, M;
int A[10];
int dp[100001];

bool Check(int k)
{
  memset(dp, -1, sizeof(int) * (M + 1));
  dp[0] = 0;
  for(int i = 0; i < N; i++) {
    for(int j = 0; j <= M; j++) {
      if(dp[j] >= 0) {
        dp[j] = k;
      } else if(j < A[i] || dp[j - A[i]] <= 0) {
        dp[j] = -1;
      } else {
        dp[j] = dp[j - A[i]] - 1;
      }
    }
  }
  return(dp[M] >= 0);
}


int main()
{
  while(cin >> N >> M, N) {
    for(int i = 0; i < N; i++) {
      cin >> A[i];
    }
    int low = 0, high = M / *min_element(A, A + N);
    while(high - low > 0) {
      int mid = (low + high) >> 1;
      if(Check(mid)) high = mid;
      else low = mid + 1;
    }
    cout << low << endl;
  }
}

Measured memory_bytes: 1556
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a, b, n, k;
    int ans = 0;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) {
        cin >> h[i];
        if(h[i] >= k) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s=input()
t=input()
for i in range(len(s)):
    if s[i]!=t[i]:
        print("No")
        break
else:
    print("Yes")

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


std::vector<std::pair<std::int64_t, std::int64_t>>
divisors(std::int64_t N)
{
    std::vector<std::pair<std::int64_t, std::int64_t>> retval;

    const std::int64_t max = std::sqrt(N) + 1;
    for(std::int64_t i=2; i<=max; ++i)
    {
        if(N % i != 0)
        {
            continue;
        }

        std::int64_t e=0;
        while(N % i == 0)
        {
            N /= i;
            e += 1;
        }
        retval.emplace_back(i, e);
    }

    if(N != 1)
    {
        retval.emplace_back(N, 1);
    }
    return retval;
}

int main()
{
    std::int64_t N;
    std::cin >> N;

    const auto divs = divisors(N);

    std::int64_t ans = 0;
    for(auto [i,e] : divs)
    {
        std::int32_t cur = 1;
        while(0 <= e - cur)
        {
            e -= cur;
            cur += 1;
            ans += 1;
        }
    }

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


Measured memory_bytes: 3724
import java.io.*;
import java.util.*;

public class Main{
    static MyReader in = new MyReader();
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args){
        int N = in.i();
        for(int i = 1; i < 10; i++){
            for(int j = i; j < 10; j++){
                if(i*j == N){
                    System.out.println("Yes");                    
                    return;
                }
            }
        }
        out.println("No");
        out.flush();
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 23124
import sys,heapq,math,resource
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def setrlim():
  sys.setrecursionlimit(250000)
  soft,hard = resource.getrlimit(RLIMIT_STACK)
  # setrlimit works on ubuntu (and atcoder), but not on WSL
  #resource.setrlimit(RLIMIT_STACK, (128*1024*1024,hard))


n,d = inm()
e = 2*d+1
print((n+e-1)//e)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;

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

ll N;
vector<string> S;

int main() {
    cin >> N;
    S.resize(N);

    map<string, ll> mp;
    rep(i, N) cin >> S[i];

    rep(i, N) {
        mp[S[i]]++;
    }

    ll max_v = 0;;
    for (auto iter = mp.begin(); iter != mp.end(); iter++) {
        max_v = max(max_v, iter->second);
    }

    for (auto iter = mp.begin(); iter != mp.end(); iter++) {
        if (iter->second == max_v) {
            cout << iter->first << endl;
        }
    }
}

Measured memory_bytes: 26752
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

using namespace std;

typedef long long LL;

const int N = 100010;
const int Mod = 1e9 + 7;
const LL oo = 2e18;

int n, pos[2], nxt[N][2];
LL lim[2], S[N], addv[2];
LL dp[N][2], delt[N][2];

int main(){
	scanf("%d%lld%lld", &n, &lim[0], &lim[1]);
	dp[0][0] = dp[0][1] = 1;
	For(i, 1, n) scanf("%lld", &S[i]);
	S[0] = -oo, S[n + 1] = oo;
	For(j, 0, 1){
		nxt[n][j] = n;
		Forr(i, n - 1, 0) nxt[i][j] = S[i + 1] - S[i] < lim[j] ? i : nxt[i + 1][j];
	}
	pos[0] = pos[1] = 1;
	For(i, 0, n) For(j, 0, 1){
		(addv[j] += delt[i][j]) %= Mod;
		if(i == n) continue;
		LL v = (dp[i][j] + addv[j]) % Mod;
		while(pos[j] <= n && S[pos[j]] - S[i] < lim[j]) ++pos[j];
		int r = nxt[i + 1][j ^ 1], l = max(i + 1, pos[j] - 1);
	//	printf("%d %d -> [%d, %d]\n", i, j, l, r);
		if(l <= r) (delt[l][j ^ 1] += v) %= Mod, (delt[r + 1][j ^ 1] += Mod - v) %= Mod;
	}
	printf("%lld\n", (addv[0] + addv[1]) % Mod);
	return 0;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  vector<long long int> march(5);
  for (int i = 0; i < N; i++){
    cin >> S.at(i);
    if (S.at(i).at(0) == 'M'){
      march.at(0)++;
    } else if (S.at(i).at(0) == 'A'){
      march.at(1)++;
    } else if (S.at(i).at(0) == 'R'){
      march.at(2)++;
    } else if (S.at(i).at(0) == 'C'){
      march.at(3)++;
    } else if (S.at(i).at(0) == 'H'){
      march.at(4)++;
    }
  }
  long long int ans = 0;
  for (int i = 0; i < 5; i++){
    for (int j = i+1; j < 5; j++){
      for (int k = j+1; k < 5; k++){
        ans += march.at(i) * march.at(j) * march.at(k);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main() {
int n ;  
cin>>n ; 
pair< string , int > p[n] ;  
for (int i=0 ;  i<n  ;  i++ ){cin>>p[i].first ; cin>>p[i].second ;  }
string x ;
cin>>x ; 
bool test  = false   ;
int sum= 0 ;  
for (auto it:p) 
{   if (test)
      sum += it.second ;  
    
    if (it.first == x)
       test = true ; 
       
}
cout<<sum<<endl ; 
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

const LL MOD = 1000000007;
int N;
char S[200011];

void MAIN() {
    scanf("%d%s", &N, S);

    LL ans = 1;
    int num = 0;
    int cnt = 0;
    REP (i, N+N) {
	if ((num % 2 == 0 && S[i] == 'B') || (num % 2 == 1 && S[i] == 'W')) {
	    num++;
	} else if (num) {
	    ans *= num;
	    ans %= MOD;
	    num--;

	    cnt++;
	    ans *= cnt;
	    ans %= MOD;
	} else {
	    ans = 0;
	    break;
	}
    }

    if (num) ans = 0;
    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 384
n=int(input())
a,b=map(int,input().split())
p=list(map(int,input().split()))
q1=0
q2=0
q3=0
for i in range(n):
    if p[i]<=a:
        q1+=1
    elif a<p[i]<=b:
        q2+=1
    elif b<p[i]:
        q3+=1
print(min(q1,q2,q3))

Measured memory_bytes: 9192
#include<iostream>
#include<string>
#include<map>

using namespace std;

int main(){

	int n,x;
	long long ans = 1;
	int pn[1005] = {};
	map<int,int> m;
	
	cin >> n;
	
	for(int i=2;i<=n;i++)
		for(int j=i+i;j<=n;j+=i) pn[j]=1;

	for(int k = 2;k <= n; k++){
		x = k;
		for(int i = 2;i <= n; i++){
			if(pn[i] == 0){ 
			
				while(x%i == 0){
					m[i]++;
					x /= i;
				}
			}
		}
	}

	for(int i = 0; i <= n; i++){
		if(m[i] > 0){
		//	cout << i << " " << m[i] <<endl;
			ans *= m[i]+1;
		//	cout << ans << endl;
			ans %= 1000000007;
		}
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a;i<=b;++i)
#define repd(i,a,b) for(register int i=a;i>=b;--i)
#define reps(s) for(int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef long long ll;
const int MAX_N=2e5+5;
const int mod=1e9+7;
int a[MAX_N],sum[MAX_N];
int main()
{
	int n; si(n);
	repi(i,1,n) si(a[i]);
	sum[n+1]=0;
	repd(i,n,1) sum[i]=(1ll*a[i]+sum[i+1])%mod;
	int ans=0;
	repi(i,1,n-1) ans=(ans+1ll*a[i]*sum[i+1]%mod)%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 5384