akhauriyash/Code-Regression huggingface dataset:
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
	if (y == 0) 
		return 1; 
	ll p = power(x, y/2) % MOD; 
	p = (p * p) % MOD; 
  
	return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
	#ifndef ONLINE_JUDGE
	if (fopen("INPUT.txt", "r"))
	{
		freopen ("INPUT.txt" , "r" , stdin);
		//freopen ("OUTPUT.txt" , "w" , stdout);
	}
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	clock_t clk;
	clk = clock();
//-----------------------------------------------------------------------------------------------------------//

	READV(N);
	string S;
	cin>>S;
	ll ans=0;
	FORI(i,0,N)
	{
		ll r=0,g=0,b=0;
		FORI(k,i,N)
		{
			if(S[k]=='R')
			{
				r++;
			}
			if(S[k]=='G')
			{
				g++;
			}
			if(S[k]=='B')
			{
				b++;
			}
			if(S[i]!=S[k])
			{
				if((k-i+1)%2==0)
				{
					if(S[i]!='R' && S[k]!='R')
					{
						ans+=r;
					}
					if(S[i]!='G' && S[k]!='G')
					{
						ans+=g;
					}
					if(S[i]!='B' && S[k]!='B')
					{
						ans+=b;
					}
				}
				else
				{
					if(S[i]!='R' && S[k]!='R')
					{
						ans+=r;
					}
					if(S[i]!='G' && S[k]!='G')
					{
						ans+=g;
					}
					if(S[i]!='B' && S[k]!='B')
					{
						ans+=b;
					}
					if(S[(i+k)/2]!=S[i] && S[(i+k)/2]!=S[k])
					{
						ans--;
					}
				}
				
			}
		}
	}
	cout<<ans<<endl;

//-----------------------------------------------------------------------------------------------------------//


	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

	return 0;
}

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

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

	vector<int> a(N);
	float sum = 0;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		sum += a[i];
	}

	sort(a.begin(), a.end(), greater<int>());


	int tokuhyo = a[M - 1];
	float ritsu = sum / (4 * M);
	if (tokuhyo < ritsu) cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}

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

using ll = long long;

ll a, b;

//{p, p+1, p+2,...}
//{q, q-1, q-2,...}
ll get_max(ll p, ll q, ll len) {
    if (len <= 0) return 0;

    ll max_i = max(0ll, min(len - 1, (p - q) / -2));
    
    if (a * b <= p + max_i || a * b <= q - max_i) return (ll)1e+18;
    
    return max({
        (p + max_i) * (q - max_i), 
        (p + max(0ll, max_i - 1)) * (q - (max(0ll, max_i - 1))),
        (p + min(len - 1, max_i + 1)) * (q - (min(len - 1, max_i + 1)))
    });
}

bool is_ok(ll x) {
    if (b <= x) {
        ll l1 = min(a, x + 1 - b) - 1, l3 = min(x + 1 - a, b) - 1, l2 = x - (l1 + l3);
        assert(l1 + l2 + l3 == x);

        ll m = max({
            get_max(1, x + 1, l1),
            get_max(l1 + 1, b - 1, l2),
            get_max(a + 1, l3 + 1, l3)
        });

        return m < a * b;
    }
    else if (a <= x) {
        ll l1 = a - 1, l2 = x - l1;
        assert(l1 + l2 == x);

        ll m = max({
            get_max(1, x, l1),
            get_max(a + 1, l2, l2)
        });

        return m < a * b;
    }
    else { //x < a
        return get_max(1, x, x) < a * b;
    }
}

int main() {
    int Q;
    cin >> Q;
    for (int q = 0; q < Q; q++) {
        cin >> a >> b;
        if (a > b) swap(a, b);

        ll ng = 1e+18;
        ll ok = 0;

        while (abs(ok - ng) > 1) {
            ll mid = (ok + ng) / 2;

            if (is_ok(mid)) ok = mid;
            else ng = mid;
        }

        cout << ok << endl;
    }
}

Measured memory_bytes: 256
using System;

class Program{
    static int H=0;

    static void Insert(int[] A, int k){
        H++;
        var i=H-1;
        while (i>0) {
            var p=(i-1)/2;
            if (A[p]>=k) {
                break;
            }
            A[i]=A[p];
            i=p;
        }
        A[i]=k;
    }

    static int ExtractMax(int[] A){
        var result=A[0];
        int k=A[H-1];
        H--;
        int i=0;
        while (i*2+1<H) {
            int l=i*2+1;
            int r=(i+1)*2;
            if (r<H && A[r]>A[l]) {
                l=r;
            }
            if (A[l]<=k) {
                break;
            }
            A[i]=A[l];
            i=l;
        }
        A[i]=k;
        return result;
    }

    public static void Main(){
        var S=new int[2*1000*1000];
        var sout=new System.Text.StringBuilder();
        while (true) {
            var s=Console.ReadLine().Split(' ');
            if (s[0][0]=='i') {
                Insert(S, int.Parse(s[1]));
            } else if (s[0][1]=='x') {
                sout.Append(ExtractMax(S)+"\n");
            } else {
                break;
            }
        }
        Console.Write(sout);
    }
}

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

using namespace std;
using ll = long long;


int main()
{
    int n;
    cin >> n;
    string t = to_string(n);
    int sum = 0;
    for(auto i : t)sum += i - '0';
    cout << (n % sum ? "No" : "Yes") << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;
using ll = long long int;

ll count(const vector<ll> n) {
  vector<vector<vector<ll>>> dp(
      n.size() + 1, vector<vector<ll>>((1 << 10) + 1, vector<ll>(2, 0)));

  // 最上位桁
  for (size_t d = 1; d <= n[0]; d++) {
    int nl = (n[0] > d) ? 1 : 0;
    dp[1][1 << d][nl] = 1;
  }

  // それ以外の桁
  for (size_t i = 1; i < n.size(); i++) {
    for (size_t d = 1; d < 10; d++) {
      dp[i + 1][1 << d][1] = 1;
    }
  }

  for (int i = 1; i < n.size(); i++) {
    for (int d = 0; d < 10; d++) {
      for (int k = 0; k < 10; k++) {
        for (int l = 0; l < 2; l++) {
          if (l == 0 && n[i] < d) {
            continue;
          }
          // 前の桁と今の桁の差が 2 以上の時はスキップする
          if (i != 0 && abs(d - k) >= 2) {
            continue;
          }
          // bitset<10> nk = (1 << k) | (1 << d);
          int nl = (n[i] > d) ? 1 : l;
          dp[i + 1][1 << d][nl] += dp[i][1 << k][l];
        }
      }
    }
  }

  ll sum = 0;

  for (size_t j = 0; j < 10; j++) {
    sum += dp[n.size()][1 << j][0];
    sum += dp[n.size()][1 << j][1];
  }

  return sum;
}

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

  auto ToVec = [](ll n) {
    vector<ll> vec;
    while (n > 0) {
      vec.push_back(n % 10);
      n /= 10;
    }
    reverse(vec.begin(), vec.end());
    return vec;
  };

  ll L = 1;
  ll R = 1e18;

  while (L != R) {
    vector<ll> mid = ToVec((L + R) / 2);

    if (count(mid) >= K) {
      R = (L + R) / 2;
    } else {
      L = (L + R) / 2 + 1;
    }
  }
  cout << L << endl;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9+7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amin(T& a,T b){ a=min(a,b);}
template <class T> void amax(T& a,T b){ a=max(a,b);}

int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	VI a(3), sv;
	cin >>n >>a[0] >>a[1] >>a[2];
	VI l(n);
	rep(i, n) cin >> l[i];
	int cnd=0;
	rep(i,n){
		int amp = 999999999;
		rep(j, 3){
			amp = min(amp, abs(a[j] - l[i]));
		}
		cnd += amp;
	}
	//dbg(cnd);
	
	int ans = 1<<28;
	int pj=4;
	rep(i,(int)pow(pj, n)){
		vector<int> vi(n);
		for(int j=0, wki=i; j<n; j++, wki/=pj){
			vi[n-1-j] = wki%pj;
		}
		
		VI sm(4), cnt(4);
		rep(j, n){
			sm[vi[j]] += l[j];
			cnt[vi[j]]++;
		}
		if(cnt[0]<1 || cnt[1]<1 || cnt[2]<1) continue;
		VI ss={0,1,2};
		do {
			int sk=0;
			rep(k,3){
				 sk += abs(sm[k] - a[ss[k]]) + max(0, (cnt[k] - 1) *10);
			}
			if(ans > sk){
				sv = sm;
			}
			ans = min(ans, sk);
			
		} while ( next_permutation(all(ss)) );
		
	}
	cout << min(cnd, ans) <<"\n";

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n; cin >> n;
	int c[500],s[500],f[500];
	for(int i=0;i<n-1;i++) cin >> c[i] >> s[i] >> f[i];

	for(int i=0;i<n-1;i++){
		int t=0;
		t+=s[i]+c[i];
		for(int j=i+1;j<n-1;j++){
			while(!(s[j]<=t && t%f[j]==0)){
				t++;
			}
			t+=c[j];
		}
		cout << t << endl;
	}
	cout << 0 << endl;
}


Measured memory_bytes: 256
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[] for _ in range(num)]
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

S,T = map(str,input().split())
A,B = II()
U = str(input())

if U==S:
    print(A-1,B)
else:
    print(A,B-1)

Measured memory_bytes: 38384
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys


def input():
    return sys.stdin.readline()


def resolve():
    n, m = map(int, input().split())
    first_ac_dic = {}
    wa_count_dic = {}
    wa_num = 0
    for i in range(m):
        p, s = input().split()
        p = int(p)

        if s == "AC":
            if p in first_ac_dic:
                pass
            else:
                first_ac_dic[p] = i
                wa_num += wa_count_dic.get(p, 0)
        else:
            wa_count_dic[p] = wa_count_dic.get(p, 0) + 1

    ans_ac = len(first_ac_dic)

    print(ans_ac, wa_num)


if __name__ == "__main__":
    resolve()



Measured memory_bytes: 51956
N = int(input())
H = list(map(int, input().split()))

def decrease(lis):
    global count
    length = len(lis)
    if length == 2:
        count += max(lis)
    elif length == 1:
        count += lis[0]
    else:
        minnum = min(lis)
        minidx = lis.index(minnum)
        count += minnum
        lis = list(map(lambda x: x-minnum, lis))
        if minidx >= 1:
            decrease(lis[:minidx])
        if minidx < length - 1:
            decrease(lis[minidx+1:])

count = 0
decrease(H)
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define max(a,b) ((a>b)?(a):(b))

struct ruiseki{
  long long kyori;
  long long karori;
};

int main(){
  int n;
  long long c;
  cin >> n >> c;
  vector<long long> x(n),v(n);
  for(int i=0;i<n;i++) cin >> x[i] >> v[i];
  vector<struct ruiseki> tokei(n+1),hantokei(n+1);
  tokei[0].kyori=0;
  tokei[0].karori=0;
  hantokei[0].kyori=0;
  hantokei[0].karori=0;
  tokei[1].kyori=x[0];
  tokei[1].karori=v[0];
  hantokei[1].kyori=c-x[n-1];
  hantokei[1].karori=v[n-1];
  for(int i=2;i<=n;i++){
    tokei[i].kyori=tokei[i-1].kyori+x[i-1]-x[i-2];
    tokei[i].karori=tokei[i-1].karori+v[i-1];
    hantokei[i].kyori=hantokei[i-1].kyori+x[n-i+1]-x[n-i];
    hantokei[i].karori=hantokei[i-1].karori+v[n-i];
  }
  vector<long long> dptokei(n+1);
  vector<long long> dphantokei(n+1);
  dptokei[0]=dphantokei[0]=0;
  for(int i=1;i<=n;i++){
    dptokei[i]=max(dptokei[i-1],tokei[i].karori-tokei[i].kyori);
    dphantokei[i]=max(dphantokei[i-1],hantokei[i].karori-hantokei[i].kyori);
  }
  long long ans=0;
  for(int i=0;i<=n;i++){
    ans=max(ans,dptokei[n-i]+hantokei[i].karori-hantokei[i].kyori*2);
    ans=max(ans,dphantokei[n-i]+tokei[i].karori-tokei[i].kyori*2);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
// Including Policy Based DS
#include <ext/pb_ds/assoc_container.hpp>
// Including tree_order_statistics_node_update
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define LL long long
#define ULL unsigned long long
LL INF=10000000000000001LL;
#define PI (2.0*acos(0.0))

typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

//typedef tree<
//int,
//null_type,
//less<int>,
//rb_tree_tag,
//tree_order_statistics_node_update>
//ordered_set;

#define READ 		freopen("in.txt","r",stdin)
#define WRITE  		freopen("out.txt","w",stdout)
#define BOOST		ios_base::sync_with_stdio(false);cin.tie(NULL)
#define sf 			scanf
#define pf 			printf
#define F  			first
#define S  			second
#define pb 			push_back
#define NL			pf("\n")
#define ALL(v)		v.begin(),v.end()
#define si(x)		sf("%d",&x);
#define sii(x,y)	sf("%d%d",&x,&y);
#define siii(x,y,z)	sf("%d%d%d",&x,&y,&z);
#define sl(x)		sf("%lld",&x);
#define sll(x,y)	sf("%lld%lld",&x,&y);
#define slll(x,y,z)	sf("%lld%lld%lld",&x,&y,&z);
#define mem(x,y) 	memset(x,y,sizeof x )
#define ch 			printf("Came Here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n")
#define SV(v)		sort(v.begin(),v.end())
#define SVR(v,cmp)	sort(v.begin(),v.end(),cmp)
#define FOR(i,n)	for(int i=0;i<n;i++)
#define cnd			tree[idx]
#define lc			tree[idx*2]
#define rc			tree[idx*2+1]
#define lnd 		(2*idx),(b),((b+e)/2)
#define rnd 		((2*idx)+1),(((b+e)/2)+1),(e)

// graph direction array [4]
//LL X[4]={0,0,1,-1};
//LL Y[4]={1,-1,0,0};
// graph direction array [8]
//int X[8]={0,0,1,-1,-1,1,1,-1};
//int Y[8]={1,-1,0,0,-1,-1,1,1};
// Bishop direction array [8]
//int X[8]={0,0,1,-1,-1,1,1,-1};
//int Y[8]={1,-1,0,0,-1,-1,1,1};
// Knight Direction Array
//int KX[8] = {1,1,2,2,-1,-1,-2,-2};
//int KY[8] = {2,-2,1,-1,2,-2,1,-1};

bool Check(int N,int pos){return (bool)(N & (1<<pos));} // check bit
int Set(int N,int pos){	return N=N | (1<<pos);}// set bit

const LL mod=1000000007LL;
LL modMul(LL a, LL b){

    LL ans = 0;
    a = a % mod;
    while (b > 0){
        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;
        a = (a%mod * 2%mod) % mod;
        b /= 2;
    }
    return ans % mod;
}

LL powerMod(LL a,LL b){
	if(b==0)return 1%mod;
	LL x=powerMod(a,b/2);
	x = (x%mod*x%mod)%mod;
	if(b%2==1)x = (x%mod*a%mod)%mod;
	return x%mod;
}

LL lcm( LL a,LL b ){
	LL g = __gcd(a,b);
	return (a*b)/g;
}
const int mx = 100095;
//-------------------------------------------------------------------------------

LL w[101],v[101];
LL dp[101][mx];
int n;

LL f(int pos,LL baki){

    if(pos==n)return 0;
    if(dp[pos][baki]!=-1)return dp[pos][baki];

	LL x = 0;
    if( w[pos]<=baki )x = max(x,v[pos]+f(pos+1,baki-w[pos]));
    x = max(x,f(pos+1,baki));

    return dp[pos][baki] = x;
}


int main(){
//  READ;
//  WRITE;
//	BOOST;

    LL t,l,x,k,m;

    cin>>n>>k;
    FOR(i,n)cin>>w[i]>>v[i];

	mem(dp,-1);

	cout<<f(0,k)<<endl;


    return 0;
}


Measured memory_bytes: 79360
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    int N;
    io.read(N);
    auto A = io.read_vec<int>(N);
    int ans = INT_MAX;
    for(int i = 0; i < N; i++){
        int k = 0;
        while((A[i] & 1) == 0) A[i] = (A[i] >> 1), k++;
        ans = min(ans, k);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
int a[10];
int main(){
	for(int i = 0; i < 5; i++) scanf("%d", a + i);
	sort(a, a + 5);
	int R = 1<<30;
	do {
	int T = 0;
	for(int i = 0; i < 5; i++){
		while(T%10) T++;
		T += a[i];
	}
	if (R > T) R = T;
	} while (next_permutation(a, a + 5));
	printf("%d", R);
	return 0;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

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

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


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

using namespace std;

const int INF = 1 << 30;

struct Dinic
{
  struct edge
  {
    int to, cap, rev;
  };

  vector< vector< edge > > graph;
  vector< int > min_cost, iter;

  Dinic(int n)
  {
    graph.resize(n);
  }

  void add_edge(int from, int to, int cap)
  {
    graph[from].push_back((edge) {to, cap, (int) graph[to].size()});
    graph[to].push_back((edge) {from, 0, (int) graph[from].size() - 1});
  }

  bool bfs(int s, int t)
  {
    min_cost.assign(graph.size(), -1);
    queue< int > que;
    min_cost[s] = 0;
    que.push(s);
    while(!que.empty()) {
      int p = que.front();
      que.pop();
      for(int i = 0; i < graph[p].size(); i++) {
        const edge &e = graph[p][i];
        if(e.cap > 0 && min_cost[e.to] == -1) {
          min_cost[e.to] = min_cost[p] + 1;
          que.push(e.to);
        }
      }
    }
    return (min_cost[t] != -1);
  }

  int dfs(int idx, const int t, int flow)
  {
    if(idx == t) return (flow);
    for(int &i = iter[idx]; i < graph[idx].size(); i++) {
      edge &e = graph[idx][i];
      if(e.cap > 0 && min_cost[idx] < min_cost[e.to]) {
        int d = dfs(e.to, t, min(flow, e.cap));
        if(d > 0) {
          e.cap -= d;
          graph[e.to][e.rev].cap += d;
          return (d);
        }
      }
    }
    return (0);
  }

  int max_flow(int s, int t)
  {
    int flow = 0;
    while(bfs(s, t)) {
      iter.assign(graph.size(), 0);
      int f = 0;
      while((f = dfs(s, t, INF)) > 0) {
        flow += f;
      }
    }
    return (flow);
  }
};

int N, M, U[10000], V[10000];

bool check(int low, int high)
{
  Dinic flow(M + N + 4);
  const int S = M + N, T = M + N + 1;
  const int X = M + N + 2, Y = M + N + 3;
  auto add_edge = [&](int x, int y, int l, int h)
  {
    flow.add_edge(x, Y, l);
    flow.add_edge(X, y, l);
    flow.add_edge(x, y, h - l);
  };
  for(int i = 0; i < M; i++) {
    add_edge(S, i, 1, 1);
    add_edge(i, M + U[i], 0, 1);
    add_edge(i, M + V[i], 0, 1);
  }
  for(int i = 0; i < N; i++) {
    add_edge(M + i, T, low, high);
  }
  flow.max_flow(X, Y);
  flow.max_flow(X, T);
  flow.max_flow(S, Y);
  flow.max_flow(S, T);
  for(auto &p : flow.graph[X]) if(p.cap > 0) return (false);
  for(auto &p : flow.graph[Y]) if(flow.graph[p.to][p.rev].cap > 0) return (false);
  return (true);
}

int main()
{
  while(cin >> N >> M, N) {
    for(int i = 0; i < M; i++) {
      cin >> U[i] >> V[i];
      --U[i], --V[i];
    }
    int ret = 114514, high = 0;
    int val = 114514;
    for(int low = 0; low < N; low++) {
      while(high < N && !check(low, high)) ++high;
      if(high == N) break;
      if(high - low < ret) {
        ret = high - low;
        val = low;
      }
    }
    cout << val << " " << val + ret << endl;
  }
}

Measured memory_bytes: 4164
package main

import (
	"fmt"
)

func main() {

	var S string

	fmt.Scan(&S)

	 a := SliceInt(len(S)+1)

	 for i:=0;i<len(S);i++{

		if S[i] == '<'{

			a[i+1]=a[i]+1

		}

	 }

	 for i := range S{

		i = len(S)-1-i

		c := S[i]

		if c== '>'{

			a[i] = max(a[i],a[i+1]+1)
		}
		
	 }

	 sum:=0

	 for _,temp:= range a{

		sum += temp
	 }

	 fmt.Println(sum)
}



//max 最大値を返す
func max(a,b int) int{

	if a >b{

		return a
	}

	return b
}

//SliceInt 引数サイズのSliceを返す
func SliceInt(a int) []int {

	IntSample := make([]int, a)

	return IntSample

}

Measured memory_bytes: 8192
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <atcoder/all>
#include <cstdio>
using namespace atcoder;
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }


int main(){ 
    int n, q; cin >> n >> q;
    fenwick_tree<ll> fw(n);
    rep(i, n){
        ll a; cin >> a;
        fw.add(i, a);
    }
    rep(i, q){
        int m; ll a, b; cin >> m >> a >> b;
        if(m==0){
            fw.add(a, b);
        }else{
            ll sum = fw.sum(a, b);
            cout << sum << ln;
        }
    }
}

Measured memory_bytes: 8220
#include<bits/stdc++.h>
#define ll 				long long
#define ld 				long double
#define fastio 			ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(x) 		cerr<<#x<<" "<<x<<endl
#define cina(a,n) 		for(ll i = 0;i<n;i++)	cin>>a[i];
#define couta(a,n) 		for(ll i = 0;i<n;i++) cout<<a[i]<<" ";
#define fauto(ar)		for(auto x : ar)	cout<<x<<" ";
#define mod 			1000000007
#define siz 			10005
#define f 				first
#define s 				second
#define pb 				push_back
#define endl 			"\n"
#define ci 				cin.ignore()
using namespace std;
int main()
{
	ll t,n,i,j;
	cin>>n;
	while(n--)
	{
		cin>>i;
		if(i&1)
		continue;
		if((i%3 == 0) || (i%5 == 0))
		1;
		else
		{
			cout<<"DENIED";
			return 0;
		}
	}
	cout<<"APPROVED";
}

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

using namespace std;

int main(void){

	int H,W;

	while(1){
		cin>>H>>W;
		if(H==0&&W==0) break;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if(i==0||j==0||i==H-1||j==W-1) cout<<"#";
				else cout<<".";
			}
			cout<<endl;
		}
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define int int64_t
#define all(x) begin(x), end(x)
#define fpos afan

const int maxn = 1e5 + 42;


signed main() {
	//freopen("input.txt", "r", stdin);
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	int x[n];
	int ans = 1e9;
	for(int i = 0; i < n; i++) {
    	cin >> x[i];
    	if(i >= k - 1) {
            int cur = x[i] - x[i - k + 1] + min(abs(x[i]), abs(x[i - k + 1]));
        	ans = min(ans, cur);
    	}
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    LL N, K;
    cin >> N >> K;

    LL ans = 0;
    for (LL k = K; k <= N+1; ++k) {
        LL minc = k * (k-1) / 2;
        LL maxc = k * (2*N-k+1) / 2;
        ans = (ans + maxc - minc + 1) % MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3640
#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 IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
using namespace std;
#define ll long long

bool is_prime(int k)
{
	for(int j=2;j*j<=k;j++){
		if(k%j==0) {
			return false;
		}
	}
    return true;
}

int main()
{
    stringstream ss;
    // 入力
    ll N;
    cin>>N;
    ll Nor=N;
    int S=0;
    while(N>0){
    	S+=N%10;
    	N=N-N%10;
    	N=N/10;
    }
    // cout<<S<<endl;
    if(Nor%S==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;

int main(){
    int n,m,p,pen=0,ac=0;
    string s;
    map<int,int> a,x;
    cin>>n>>m;
    rep(i,m){
        cin>>p>>s;
        if(s=="AC"&&a[p]==0)ac++,a[p]=1,pen+=x[p];
        if(s=="WA"&&a[p]==0)x[p]++;
    }
    cout<<ac<<" "<<pen<<endl;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
const long long MOD = 1e9+7;
using namespace std;
#define ll long long
#define ar array

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

	int N;
	cin >> N;
	int ans = 0;

	for (int i = 0; i < N; i++) {
		int D1,D2;
		cin >> D1 >> D2;
		if (D1==D2) ans++;
		else ans=0;
		if (ans==3) {
			cout << "Yes" << endl;
          	return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


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

int N;
int K;
bool d[10];

int main(){
    int n;
    cin >> N >> K;
    for(int i=0;i<10;i++) d[i] = true;
    for(int i=0;i<K;i++){
        cin >> n;
        d[n] = false;
    }
    int o = 0;
    for(int i=0;i<10;i++){
        if(d[i]) o |= (1<<i);
    }
    while(true){
        bool flag = true;
        n = N;
        while(true){
            if(n == 0) break;
            if((1<<(n%10))&o){
                n /= 10;
                continue;
            }
            flag = false;
            break;
        }
        if(flag){
            cout << N << endl;
            return 0;
        }
        N++;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
//const ll mod = 1000000007;
const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }

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

ll modinv(ll a) {
  return modpow(a, mod - 2);
}

ll pow2[5000], powinv[5000];

void init() {
  pow2[0] = 1;
  powinv[0] = 1;
  rep(i, 4999) {
    pow2[i + 1] = pow2[i] * 2 % mod;
    powinv[i + 1] = modinv(pow2[i + 1]);
  }
}

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

  init();

  int n, s;
  cin >> n >> s;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  vector<vector<ll>> dp(n + 1, vector<ll>(s + 1, 0));
  dp[0][0] = pow2[n];
  rep(i, n) {
    dp[i + 1] = dp[i];
    repr(j, s - a[i]) {
      dp[i + 1][j + a[i]] = (dp[i + 1][j + a[i]] + dp[i][j] * powinv[1] % mod) % mod;
    }
  }
  cout << dp[n][s] << '\n';




  
  return 0;
}

Measured memory_bytes: 73624
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
#define mod 1000000007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k,q;
    cin>>n>>k>>q;
    vi count(n+1,0);
    vi life(n+1,k);
    for(ll i=0;i<q;i++)
    {
        ll a;
        cin>>a;
        count[a]++;
    }
    for(ll i=1;i<=n;i++)
    {
        life[i]-=q;
        life[i]+=count[i];
    }
    for(ll i=1;i<=n;i++)
    {
        if(life[i]>0)
        {
            cout<<"Yes\n";
        }
        else
        {
            cout<<"No\n";
        }
    }
}


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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

bool ask(V<int> A) {
	printf("?");
	for (int x : A) {
		printf(" %d", x + 1);
	}
	puts("");
	fflush(stdout);
	string res; cin >> res;
	return res == "Red";
}

void answer(V<int> A) {
	printf("! ");
	for (int x : A) {
		printf("%c", x ? 'R' : 'B');
	}
	puts("");
	exit(0);
}

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

	{
		V<int> vec;
		rep(i, N) {
			vec.pb(i);
		}
		p = ask(vec);
	}

	int lo = 0, hi = N;
	while (hi - lo > 1) {
		int m = (lo + hi) / 2;
		V<int> vec;
		rep(i, N) vec.pb(m + i);
		int res = ask(vec);
		if (res == p) {
			lo = m;
		} else {
			hi = m;
		}
	}
	int l = hi;

	//(l,l+N-2)
	V<int> col(N * 2, -1);

	rep(i, N * 2) {
		V<int> vec;
		if (i < l || i >= l + N) {
			vec.pb(i);
			for (int j = l; j < l + N - 1; ++j) {
				vec.pb(j);
			}
		} else {
			vec.pb(i);
			//not [l-1,l+N-1] 
			for (int j = 0; j < l-1; ++j) {
				vec.pb(j);
			}
			for (int j = l + N; j < N * 2; ++j) {
				vec.pb(j);
			}
		}
		bool t = ask(vec);
		if (t) {
			col[i] = 1;
		} else {
			col[i] = 0;
		}
	}

	answer(col);

	return 0;
}

Measured memory_bytes: 724
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);
int main(){
    int n;cin>>n;
    vl a(n);
    rep(i,n)cin>>a[i];
    sort(been(a));
    ll ans =0;
    ll l =0,r=0;
    for(int i =1,j=n-1;i<=j;){
        ll li = abs(a[l]-a[i]);
        ll lj = abs(a[l]-a[j]);
        ll ri = abs(a[r]-a[i]);
        ll rj = abs(a[r]-a[j]);
        ll ma=max({li,lj,ri,rj});
        if(ma==li){
            l=i;
            i++;
        }
        else if(ma==lj){
            l=j;j--;
        }
        else if(ma==ri){
            r=i;i++;
        }
        else{
            r=j;j--;
        }
        ans+=ma;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4016
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 110;
const int MAXK = 510;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    cout << max(n + n-1, max(m + m-1, n+m));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int k;
  cin >> s >> k;
  int cnt = 0;
  char ans;
  for(int i=0; i<100; i++){
    if(s[i]!='1'){
      ans = s[i];
      break;
    }
    cnt++;
  }
  if(k>cnt) cout << ans << endl;
  else cout << 1 << endl;
}

Measured memory_bytes: 256
from sys import stdin
n = int(stdin.readline().rstrip())
m = 0
cnt = 0
for i in range(n):
    d1, d2 = [int(x) for x in stdin.readline().rstrip().split()]
    if d1 == d2:
        cnt += 1
    else:
        if m < cnt:
            m = cnt
        cnt = 0
if m < cnt:
    m = cnt
cnt = 0
if m >= 3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 61944
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<string>
#include<cstdlib>
using namespace std;
int a,b,c,d;
char aa,bb,cc,dd;
int main(){
    cin>>aa>>bb>>cc>>dd;
    a=aa-'0';b=bb-'0';c=cc-'0';d=dd-'0';
    if(a+b+c+d==7) printf("%d+%d+%d+%d=7\n",a,b,c,d);
	else if(a+b+c-d==7) printf("%d+%d+%d-%d=7\n",a,b,c,d);
	else if(a+b-c+d==7) printf("%d+%d-%d+%d=7\n",a,b,c,d);
	else if(a+b-c-d==7) printf("%d+%d-%d-%d=7\n",a,b,c,d);
	else if(a-b+c+d==7) printf("%d-%d+%d+%d=7\n",a,b,c,d);
	else if(a-b+c-d==7) printf("%d-%d+%d-%d=7\n",a,b,c,d);
	else if(a-b-c+d==7) printf("%d-%d-%d+%d=7\n",a,b,c,d);
	else if(a-b-c-d==7) printf("%d-%d-%d-%d=7\n",a,b,c,d);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define mod 1000000007

using namespace std;

int main()
{
	IOS;
	ll n,m,k;
	cin>>n>>m>>k;
	for(int y=0;y<10;y++)
	{
		ll temp=k;
		temp=k*n-m;
		cout<<temp<<"\n";
		k=temp;
	}
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int x,y;
bool rel[10][10];
bool vis[5];
int a[5];
bool dfs(int u){
	if(u==5){
		bool flag=true;
		for(int i=1;i<4;++i)
		    if(!rel[a[i]][a[i+1]])flag=false;
		return flag;
	}
	bool F=false;
	for(int i=1;i<=4;++i)
	if(!vis[i]){
		a[u]=i;vis[i]=true;
		if(dfs(u+1))F=true;
		vis[i]=false;
	}
	return F;
}

int main(){
	while(~scanf("%d%d",&x,&y)){
		rel[x][y]=true;
		rel[y][x]=true;
	}
	if(dfs(1))puts("YES");
	else puts("NO");
	return 0;
}

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

int memo[100001][3];


int fun(int d,int p,int arr[][3])
{
    if(d==0)
     return 0;
     //cout<<"hello\n";
     if(memo[d][p]!=-1)
      return memo[d][p];
      if(p==0)
      {
          return memo[d][p]=max(fun(d-1,1,arr),fun(d-1,2,arr))+arr[d][p];
      }
      else if(p==1)
      {
          return memo[d][p]=max(fun(d-1,0,arr),fun(d-1,2,arr))+arr[d][p];
      }
      else 
      {
          return memo[d][p]=max(fun(d-1,0,arr),fun(d-1,1,arr))+arr[d][p];
      }
}
int main()
{
    memset(memo,-1,sizeof(memo));
    int n;
    cin>>n;
    int arr[n+1][3];
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i][0];
        cin>>arr[i][1];
        cin>>arr[i][2];
    }
    int m1=fun(n,0,arr);
    int m2=fun(n,1,arr);
    int m3=fun(n,2,arr);
    int res=max(m1,max(m2,m3));
    cout<<res<<"\n";
    return 0;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
#define mod 1000000007 

int modpow(ll a, ll n, ll p = mod) {
    if(n == 0) return 1 ;
    if(n == 1) return a%p ;
    if(n%2 == 1) return (a*modpow(a, n-1, p))%p ;
    ll t = modpow(a, n/2, p) ;
    return (t*t) % p ;
}
int main (){
    ll n, a, b ;
    cin >> n >> a >> b ;
    ll da = 1 ; 
    ll db = 1 ;
    ll na = a; 
    ll nb = b;
    rep(i, na){
        ll tm = ((n-i) % mod) * (modpow(a, mod-2)) ;
        tm %= mod ;
        da *= tm ;
        da %= mod ;
        a-- ;
    }
    rep(i, nb){
        ll tm = ((n-i) % mod) * (modpow(b, mod-2));
        tm %= mod ;
        db *= tm ;
        db %= mod ;
        b-- ;
    }
    ll ans = modpow(2, n) - 1 - da - db  ;
    while(ans < 0){
        ans += mod ;
    }
    ans %= mod ;
    cout << ans << endl ;
}


Measured memory_bytes: 3620
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = if n <= m then  List.range n `To m else []
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (0 ++^ n)

let scan_list ?sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv
let scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv
let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);
  arr

let atoi c = Char.code c - Char.code '0'
let itoa n = Char.chr (n + Char.code '0')

let between n x m = n <= x && x < m


(* ===== MAIN ===== *)

let s = scan "%s" id

let () =
  if s = String.uppercase s then
    Printf.printf "A\n"
  else
    Printf.printf "a\n"


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

using namespace std;

int main() {
  int n;
  string buffer;
  int AC = 0;
  int WA = 0;
  int TLE = 0;
  int RE = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> buffer;
    if (buffer[0] == 'A') AC++;
    else if (buffer[0] == 'W') WA++;
    else if (buffer[0] == 'T') TLE++;
    else RE++;
  }
  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;
  return 0;
}

Measured memory_bytes: 3640
//                             ¯\_(ツ)_/¯   
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mma,ava,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(),(a).end()
#define ll long long
 
 
void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
 
const int N=2e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;


int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();
	int D;
	scanf("%d",&D);

	for(int i=1;i<=D;i++){
		printf("%d\n",rand()%26+1);
	}
	
}

Measured memory_bytes: 3888
N, x = gets.split.map(&:to_i)
if x == 1 || x == 2*N-1
    puts 'No'
    exit
end

puts 'Yes'

if N == 2
    puts '1 2 3'
    exit
end

if x == 2*N-2
    center = [x-1, x, x+1, x-2]
    other = (1..(x-3)).to_a + ((x+2)..(2*N-1)).to_a
else
    center = [x+1, x, x-1, x+2]
    other = (1..(x-2)).to_a + ((x+3)..(2*N-1)).to_a
end

ans = []
ans[N-2, 4] = center
(2*N-1).times do |i|
    ans[i] = other.shift unless ans[i]
end

puts ans

#while ans.length > 1
#    na = []
#    (ans.length-2).times do |i|
#        na[i] = [ans[i], ans[i+1], ans[i+2]].sort[1]
#    end
#    ans = na
#end
#puts 'WA' if ans[0] != x

Measured memory_bytes: 8572
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <functional>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
int main(){
    int n;
    cin >> n;
    if(n % 10 == 9 || n / 10 == 9)cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include<algorithm> 
#include <cassert>
#include <string>
//#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 9, M = 1e7, OO = 0x3f3f3f3f, eps = 0.001;
#define IO() assert(freopen("in.in", "rt", stdin)), assert(freopen("out.out", "wt", stdout))
#define ll long long int
#define FastIO() ios::sync_with_stdio(false), cin.tie(0);
void printar(int arr[], int n){
    for(int i = 0; i < n; i++)
    {
        cout << arr[i] << " ";
    }
    cout << endl;
}
// template <typename... T>
// void debug(T &... args)
// {
//     ((cerr << args << " "), ...);
//     cerr << endl;
// } 
// struct COMPARE { 
//   bool operator()(pair<string,ll> const& P1, pair<string,ll> const& P2) 
//     { 
        
//         return P1.first < P2.second;
//     }  
// };
// priority_queue<pair<string,ll>,vector<pair<string,ll>>,COMPARE >pq;


int main()
{     
    //IO();
    FastIO();
    int a, b, c, d; cin >> a >> b >> c >> d;
    if((a+b) > (c+d)) cout << "Left";
    else if((a+b) < (c+d)) cout << "Right";
    else cout << "Balanced";
    return 0;
    
}

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

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
#define all(v) (v).begin(), (v).end()
#define sz(v) (int) (v).size()

int main(int argc, char* argv[]) {
  ios::sync_with_stdio(0); cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  vector<int> dp(n, 1e9);
  dp[0] = 0;
  for (int i = 1; i < n; i++) 
    for (int j = max(i - k, 0); j < i; j++)
      dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
  cout << dp[n - 1] << '\n';
  return 0;
}

Measured memory_bytes: 3976
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

int main(){
	while(cin>>n){
		rep(i,n){
			cin>>d[i];
		}
		int p = 0;
		unsigned long long int dp[100][22]={0};//dp[i][j]
		dp[0][d[0]] = 1;
		for(int i = 1;i < n-1;i++){
			for(int j = 0;j <=20;j++){
				if(dp[i-1][j]>0){
					if(j+d[i] <=20){
						dp[i][j+d[i]] +=dp[i-1][j];
					}
					if(j-d[i]>=0)
						dp[i][j-d[i]] +=dp[i-1][j];
				}
			}
		}
		int sum = 0;
		for(int i = 0;i <=1000000000;i++){
			sum +=1;
		}
		for(int i = 0;i <=1000000000;i++){
			sum -=1;
		}
		for(int i = 0;i <=1000000000;i++){
			sum +=1;
		}
		for(int i = 0;i <=1000000000;i++){
			sum -=1;
		}
		for(int i = 0;i <=1000000000;i++){
			sum +=1;
		}
		for(int i = 0;i <=1000000000;i++){
			sum -=1;
		}
		cout <<dp[n-2][d[n-1]]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <ctime>
#define ll long long
#define inf 0x3f3f3f3f
#define N 100010
//ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
char s[1010],t[1010];

int main(){
    scanf("%s",s);
    getchar();
    scanf("%s",t);
    int ans=inf;
    for(int i=0;i<=strlen(s)-strlen(t);i++)
    {
        int temp=0;
        for(int j=0;j<strlen(t);j++)
        {
            if(s[i+j]!=t[j])
                temp++;
        }
        ans=min(ans,temp);
    }
    printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3824
n = int(input())
H = list(map(int,input().split()))
ans = 0
num = 0
for i in range(n-1):
    if H[0] >= H[1]:
      num += 1
      H.pop(0)
      if num > ans:
        ans = num
    else:
      num = 0
      H.pop(0)
print(ans)


Measured memory_bytes: 14252
#include <stdio.h>
#include <stdlib.h>

static int
palindromicp (
  int x
  )
{
  int s[ 16 ], l;
  int i;

  for ( l = 0; x; ++l, x /= 10 )
    s[ l ] = x % 10;
  for ( i = 0; i <= l / 2; ++i )
    if ( s[ i ] != s[ l - i - 1 ] )
      return ( 0 );

  return ( 1 );
}

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

  scanf ( "%d", &n );

  for ( i = 0; ; ++i )
  {
    if ( i <= n
      && palindromicp ( n - i ) )
    {
      printf ( "%d\n", n - i );
      break ;
    }
    if ( palindromicp ( n + i ) )
    {
      printf ( "%d\n", n + i );
      break ;
    }
  }

  return ( EXIT_SUCCESS );
}

Measured memory_bytes: 596