akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll  = long long;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    std::cout << std::fixed << std::setprecision(10);
   
    double a, b, x;
    cin >> a >> b >> x;
    double aab = a * a * b;
    if(aab<=x*2){
        cout << atan2(2 * (aab - x) , a * a * a) * 180 / M_PI << endl;
    }
    else{
        cout << atan2(a*b*b, 2 * x) * 180 / M_PI << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String a[])
    {
        Scanner scan = new Scanner(System.in);
        int i=1;
        int x;
        while(true)
            {
                x = scan.nextInt();
                if( x != 0 )
                    {
                        System.out.println("Case "+i+": "+x);
                        i++;
                    }
                else break;
            }
    }
}

Measured memory_bytes: 41416
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
using namespace std;

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


double v,y,t;
int n;


int main(){
	
	
	while(cin>>v){
		t = v/9.8;
		y = 4.9*t*t;
		rep(i,1000000){
			if(5*i-5>=y){
				n = i;
				break;
			}
		}
		cout<<n<<endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#include <iomanip>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}
          
  
int main() {
  int N, M;
  cin >> N >> M;
  vector <pair<string,pair<int,int>>> vec; 
  rep(i,M){
    string p;
    int y;
    cin >> p >> y;
    vec.push_back(make_pair(p,make_pair(y,i)));
  }
  sort(vec.begin(),vec.end());
  
  vector<pair<int,pair<string,string>>> ans; 
  int cnt=1;
  ans.push_back(make_pair(vec[0].second.second,make_pair(vec[0].first,to_string(cnt))));
  rep(i,M-1){
    string s=vec[i].first;
    string t=vec[i+1].first;
    if(s==t){
      cnt++;
      ans.push_back(make_pair(vec[i+1].second.second,make_pair(vec[i+1].first,to_string(cnt))));
    }
    else{
      cnt = 1;
      ans.push_back(make_pair(vec[i+1].second.second,make_pair(vec[i+1].first,to_string(cnt))));
    }
  }
  
  sort(ans.begin(),ans.end());
  rep(i,M){
    cout << setfill('0') << setw(6) << ans[i].second.first;
    cout << setfill('0') << setw(6) << ans[i].second.second << endl;
  }
}
  



Measured memory_bytes: 15468
from collections import defaultdict, deque

N, M = map(int, input().split())
e = defaultdict(list)
for i in range(M):
    u, v = map(int, input().split())
    e[u].append(v)

'''
頂点を%3で考える(1つの頂点にを3つに分解する)
(u,0)->(v,1)
(v,1)->(u,2)
(u,2)->(v,0)
'''

S, T = map(int, input().split())
q = deque([[S, 0]])
dist = [[-3]*3 for _ in range(N+1)]
dist[S][0] = 0
while q:
    u, c = q.popleft()
    for v in e[u]:
        step = (c+1) % 3
        if dist[v][step] < 0:
            dist[v][step] = c+1
            q.append([v, c+1])

print(dist[T][0]//3)

Measured memory_bytes: 111356
//
//  main.cpp
//  F
//
//  Created by 曾憲揚 on 2020/8/22.
//  Copyright © 2020 曾憲揚. All rights reserved.
//

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

struct fk{
    int a, b;   // )))))) a + ((((((( b
};

bool cmp1(fk a, fk b){
    return a.a<b.a || (a.a==b.a && a.b>b.b);
}
bool cmp2(fk a, fk b){
    return a.b>b.b || (a.b==b.b && a.a<b.a);
}

int main(int argc, const char * argv[]) {
    int n; cin>>n;
    vector<fk> pos, neg; //in terms of a-b
    
    string s;
    for(int i=0; i<n; i++){
        cin>>s;
        int Mi=0, Ma=0, cnt;
        cnt=0;
        for(int j=0; j<s.length(); j++){
            if(s[j] == '(') cnt++;
            else cnt--;
            Mi=min(Mi, cnt);
        } Mi = 0 - Mi;
        cnt=0;
        for(int j=s.length()-1; j>=0; j--){
            if(s[j] == '(') cnt++;
            else cnt--;
            Ma=max(Ma, cnt);
        }
        if(Ma>=Mi) pos.push_back((fk){Mi, Ma});
        else       neg.push_back((fk){Mi, Ma});
        //cout<<Mi<<" "<<Ma<<endl;
    }
    sort(pos.begin(), pos.end(), cmp1);
    sort(neg.begin(), neg.end(), cmp2);
    int st=0;
    for(auto f: pos){
        st -= f.a;
        if(st<0){ cout<<"No\n"; return 0;}
        st += f.b;
    }
    for(auto f:neg){
        st -= f.a;
        if(st<0){ cout<<"No\n"; return 0;}
        st += f.b;
    }
    if(st!=0){ cout<<"No\n"; return 0;}
    cout<<"Yes\n";

    return 0;
}


Measured memory_bytes: 11112
S = input()
a, b = int(S[:2]), int(S[2:])

if 0 < a <= 12:
  if 0 < b <=12:
    print ("AMBIGUOUS")
  else:
    print ("MMYY")
else:
  if 0 < b <=12:
    print ("YYMM")
  else:
    print ("NA")
  

Measured memory_bytes: 2940
#include <cstdio>
int quick_power(int a,int b,int Mod){
	int ans=1;
	while(b){
		if(b&1){
			ans=1ll*ans*a%Mod;
		}
		b>>=1;
		a=1ll*a*a%Mod;
	}
	return ans;
}
const int Mod=1000000007;
const int Maxn=1000000;
int n;
int f[Maxn+5][3];
int frac[Maxn+5],inv_f[Maxn+5];
void init(){
	frac[0]=1;
	for(int i=1;i<=Maxn;i++){
		frac[i]=1ll*frac[i-1]*i%Mod;
	}
	inv_f[Maxn]=quick_power(frac[Maxn],Mod-2,Mod);
	for(int i=Maxn-1;i>=0;i--){
		inv_f[i]=1ll*inv_f[i+1]*(i+1)%Mod;
	}
}
int C(int n,int m){
	return 1ll*frac[n]*inv_f[m]%Mod*inv_f[n-m]%Mod;
}
int main(){
	init();
	scanf("%d",&n);
	int ans=0;
	f[1][1]=f[1][2]=1;
	for(int i=2;i<=n;i++){
		f[i][0]=(f[i][0]+f[i-1][0]*2ll)%Mod;
		f[i][0]=(f[i][0]+f[i-1][1])%Mod;
		f[i][0]=(f[i][0]+f[i-1][2])%Mod;
		f[i][1]=f[i-1][1];
		f[i][2]=f[i-1][2];
	}
	for(int i=2;i<=n;i++){
		ans=(ans+1ll*C(n,i)*f[i][0]%Mod*quick_power(8,n-i,Mod))%Mod;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 21204
#include <stdio.h>
#include <math.h>

int main(void) {
	int a,l,x;
	double center_h,center_s;
	double mawari_h,mawari_s;
	while(scanf("%d%d%d",&a,&l,&x)==3) {
		center_h=sqrt(l*l-(a/2.0)*(a/2.0));
		center_s=a*center_h/2.0;
		mawari_h=sqrt(((l+x)/2.0)*((l+x)/2.0)-(l/2.0)*(l/2.0));
		mawari_s=l*mawari_h/2.0;
		printf("%.15f\n",center_s+mawari_s*2.0);
	}
	return 0;
}

Measured memory_bytes: 640
_ = input().strip()
a = input().strip().split(" ")
b = input().strip().split(" ")
c = input().strip().split(" ")

m = 0
pre_a = -1
for _a in a:
    
    _a = int(_a)
    _a -= 1
    m += int(b[_a])
    
    if ((pre_a+1 == _a) & (_a > 0)):
        m += int(c[pre_a])
    pre_a = _a
    
print(m)
    

Measured memory_bytes: 3060
n, m = map(int, input().split())
h = list(map(int, input().split()))


ans = [[] for i in range(n)]
for i in range(m):
  a, b= map(int, input().split())
  ans[a-1].append(b-1)
  ans[b-1].append(a-1)
  
count = 0
for i in range(n):
  flag = True
  for j in ans[i]:
    if h[i] <= h[j]:
      flag = False
  if flag:
    count+=1

print(count)
  


Measured memory_bytes: 29268
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;


#define ll          long long
#define pb          push_back
#define pii         pair<int ,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
// mp::cpp_int



int solve( ){
 

int a,b;
cin>>a>>b;
int c,d;
cin>>c>>d;
cout<<a*b-c*b-d*(a-c);


 

return 0;
}
int main()
{  int t=1;
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
  
  
  
  clock_t time_req;

    // Without using pow function
    time_req = clock();
    
//cin>>t;
   while(t--)
     {solve();
     }

         time_req = clock() - time_req;
   // cout << "Processor time taken is "
     //  << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;


int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(rng(a));
  ll ans = 0;
  ll s = 0, t = 0;
  if(n%2==1) {
    rep(i,n/2) {
      s += 2*a[n-i-1];
      t -= 2*a[i];
    }
    s -= a[n/2]+a[n/2-1];
    t += a[n/2]+a[n/2+1];
    for(int i = n/2+2; i < n; i++) {
      s -= 2*a[n-i-1];
      t += 2*a[i];
    }
    ans = max(s,t);
  }
  else {
    // rep(i,n/2-1) ans += 2*a[i+n/2+1]-2*a[i];
    rep(i,n/2-1) ans -= 2*a[i];
    ans += a[n/2]-a[n/2-1];
    for(int i = n/2+1; i < n; i++) ans += 2*a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4028
# encording: utf-8

_ = int(input())
ns = [int(e) for e in input().split()]
_ = int(input())
qs = [int(e) for e in input().split()]


def main(ns, qs):
    total = 0
    for q in qs:
        if q in ns:
            total += 1
    return total


print(main(ns, qs))

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair


ll dp[101][5][5][5]; // i-2~i文字目で文字abcを使う組み合わせ

//AGCT
//0123

//AG_C -> 01_2
//A_GC -> 0_12
//_AGC -> _012
//_ACG -> _021
//_GAC -> _102

int main(){
    int N; cin>>N;
    REP(i,N+1) {REP(a,5) {REP(b,5) {REP(c,5) {dp[i][a][b][c] = 0LL;}}}}
    dp[0][3][3][3] = 1LL;
    for(int i=0;i<N;++i){
        REP(a,4){
            REP(b,4){
                REP(c,4){
                    REP(d,4){
                        if(a==0 && b==1 && d==2){ continue;}
                        if(a==0 && c==1 && d==2){ continue;}
                        if(b==0 && c==1 && d==2){ continue;}
                        if(b==0 && c==2 && d==1){ continue;}
                        if(b==1 && c==0 && d==2){ continue;}
                        dp[i+1][b][c][d] += dp[i][a][b][c];
                        dp[i+1][b][c][d] %= MOD;
                    }   
                }   
            }   
        }
    }
    ll ans = 0LL;
    REP(a,4){
        REP(b,4){
            REP(c,4){
                ans += dp[N][a][b][c];
                ans %= MOD;
            }
        }
    }
    cout << ans << "\n";
    
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] p = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = Integer.parseInt(sc.next());
        }
        int ans = 0;
        if (p[n - 1] == n) {
            ans++;
            swap(p, n - 2);
        }
        for (int i = 0; i < n - 1; i++) {
            if (p[i] == i + 1) {
                ans++;
                swap(p, i);
            }
        }
        System.out.println(ans);
    }

    private static void swap(int[] p, int i) {
        int temp = p[i];
        p[i] = p[i + 1];
        p[i + 1] = temp;
    }
}

Measured memory_bytes: 49364
// Problem : 
// 			D - Moving Piece
// 			
// 		
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_d
// Memory Limit : 1024 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define endl '\n'
#define pb push_back
#define int long long
#define vi vector<int>
#define mii map<int, int>
#define pii pair<int, int>
#define all(x) (x).begin(), (x).end()
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define rep(i,x,y) for(int i=(int)x; i<y; i++)
#define px(a) for(auto x: a) cout<<x<<" "; cout<<endl;
#define pxy(a,n,m) rep(i,0,n) {rep(j,0,m) cout<<a[i][j]<<" "; cout<<endl;}

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

const long long MOD=LLONG_MAX;
void solve()
{
	int n,k,ans=-1e18;
	cin>>n>>k;
	int a[n+1],b[n+1];
	rep(i,1,n+1) cin>>a[i];
	rep(i,1,n+1) cin>>b[i];
	bool vis[n+1];
	fill(vis,0);
	rep(i,1,n+1){
		if(vis[i]) continue;
		vi pref,sum;
		int t=b[i],j=a[i];
		pref.pb(b[i]);
		sum.pb(t);
		while(j!=i){
			pref.pb(b[j]);
			vis[j]=1;
			t+=b[j];
			sum.pb(t);
			j=a[j];
		}
		vis[i]=1;
		// px(pref);
		// px(sum);
		int s=pref.size();
		if((k/s)>0)
		ans=max(ans,t*(k/s));
		t=max(0ll,t);
		rep(z,0,s){
			int temp=0;
			for(int x=0;x<s;x++){
				if((x+1)>k) break;
				temp+=pref[(z+x)%s];
				ans=max(ans,temp + t*((k-x-1)/s));
			}
		}
	}
	cout<<ans<<endl;
}
int32_t main()
{	
	std::ios::sync_with_stdio(false); 
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1; 
	//cin>>t;
	while(t--) solve();
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
using graph = vector<vector<int>>;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define all(x) (x).begin(),(x).end()
#define size(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000

#define pb push_back
#define mp make_pair
#define f first
#define s second

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

int main(){
	int n;cin>>n;
	string s; cin>>s;
	vector<int> si(n);rep(i,n)si[i]=s[i]-'0';
	ll ans=0;
	rep(i,10)rep(j,10)rep(k,10)if(find(find(find(all(si),i)+1,si.end(),j)+1,si.end(),k)!=si.end())ans++;
	cout<<ans<<endl;
}



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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;

ll fac[maxn], ifac[maxn], inv[maxn];

ll nck(ll n, ll k) {
    if (n<k) return 0;
    return fac[n]*ifac[k]%mod*ifac[n-k]%mod;
}

void gen_inv() {
    fac[0]=inv[0]=ifac[0]=1;
    fac[1]=inv[1]=ifac[1]=1;

    for (int i=2; i<maxn; i++) {
	fac[i]=fac[i-1]*i%mod;
	inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	ifac[i]=ifac[i-1]*inv[i]%mod;
    }

    assert(nck(4,2)==6);
}


ll n, m;

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

    cin>>n>>m;



    gen_inv();
    ll A = nck(m, n)*fac[n]%mod;
    ll B = A;

    
    ll sgn=-1;

    // PIE: at least j elements are B[i]=i.
    for (int j=1; j<=n; j++) {
	ll cur = nck(n,j)*nck(m-j,n-j)%mod*fac[n-j]%mod;
	B += sgn*cur;
	B %= mod;
	sgn=-sgn;
    }

    // watch(A);
    // watch(B);

    ll res = A*B%mod;
    res %= mod;
    res += mod;
    res %= mod;

    out(res);    
    return 0;
}


Measured memory_bytes: 27036
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  ll n;
  cin >> n >> s;
  
  ll r=0, g=0, b=0;
  rep(i, 0, n) {
    if(s[i] == 'R') r++;
    if(s[i] == 'G') g++;
    if(s[i] == 'B') b++;
  }
  
  ll ans = r*g*b;
  rep(i, 1, n-1) {
    ll L = min(n-1-i+1, (ll)(i-0+1));
    rep(j, 1, L) {
      if(s[i-j] != s[i] and s[i] != s[i+j] and s[i+j] != s[i-j]) ans--;
    }
  }
  cout << ans << "\n";
}

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

const ll mod = 1e9 + 7;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if ((a + b == c) % 2 || (b + c == a) % 2 || (c + a == b) % 2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3616
#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);
 
    double n;
    cin>>n;
    int o=(n+1)/2;
    double ans = (double)(o/n);
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}


int main() {
	//file();
	fast();
	ll a, b, k; cin >> a >> b >> k;
	ll mn = min(a, k);
	a -= mn, k -= mn;
	b -= k;
	b = max(b, 0LL);
	cout << a << ' ' << b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N, K, s;
ll sum, ans;

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

string to_string(string s)
{
    return '"' + s + '"';
}

string to_string(const char *s)
{
    return to_string((string)s);
}

string to_string(bool b)
{
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v)
{
    bool first = true;
    string res = "{";
    for (const auto &x : v)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << to_string(H);
    debug_out(T...);
}

int main()
{
    cin >> N >> K;
    vector<ll> a(N);
    vector<ll> Sa(N + 1), S(N + 1);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        Sa[i + 1] = Sa[i] + a[i];
        S[i + 1] += S[i] + max(0LL, a[i]);
    }

    for (int i = K; i <= N; i++)
    {
        ll b = Sa[i] - Sa[i - K] + (S[N] - S[i]) + S[i - K];
        ll w = (S[N] - S[i]) + S[i - K];
        ans = max(max(b, w), ans);
    }

    cout << ans << endl;
}

Measured memory_bytes: 2560
// Marcin Knapik
#include<bits/stdc++.h>
// #pragma GCC optimize("O3")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
using namespace std;

// #include <ext/pb_ds/assoc_container.hpp> // order_of_key
// #include <ext/pb_ds/tree_policy.hpp> // find by order
// using namespace __gnu_pbds; 
// #define ordered_set tree< int , null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>  

// const ll MAX_LL = 0xFFFFFFFFFFFFFFFF;
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// #define losuj(a, b) uniform_int_distribution<ull>(a, b)(rng)

typedef long double             ld;
typedef long long               ll;
typedef unsigned long long      ull;
typedef pair<ll, ll>            pll;
typedef pair<int, int>          ii;
typedef vector<int>             vi;
typedef vector<ii>              vii;
typedef vector<vi>              vvi;
typedef vector<vector<ii>>      vvii;
typedef vector< ll >            vll;
typedef vector< pll >           vpll;

#define boost                   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(a)                   (int)(a).size()
#define pb                      push_back
#define all(c)                  (c).begin(), (c).end()
#define rall(c)                 (c).rbegin(), (c).rend()
#define REP(i, a, b)            for (int i = (a); i <= (b); i++)
#define FOR(i, a)               for (int i = 0; i < (a); i++)
#define TRAV(i, n)              for(auto&i:n)
#define beg(x)                  (*(x.begin()))
#define re(x)                   int x; cin >>x;   
#define f                       first
#define s                       second

template <class T> inline bool setmin(T &a, T b){if (a > b)return a = b, 1;return 0;}
template <class T> inline bool setmax(T &a, T b){if (a < b)return a = b, 1;return 0;}

template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> inline T russian(T a, T b, T mod) {ll res = 0; while(b){if(b&1) res = (res + a)%mod; a = (a+a)%mod; b>>=1;}return res;}
template <class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<typename T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return a; }

const ll INF = 1e9 + 7;
const ll mod = 998244353;
const ll BIG_INF = 1000000000000000000;
const ll N = 1e6+7;
const ll T = 1<<20;

ll n, m, k, q;

vi tab = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

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

	cin >> n;
	cout << tab[n-1];
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
#define INF (1<<29)

int main(){
  int n;
  cin >> n;
  if(n<4||n==5||n==6||n==9||n==10||n==13||n==17)cout << "No" << endl;
  else cout << "Yes" << endl;
}


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

int main(){
  string S;
  int N;
  bool dance = true;
  cin >> S;
  N = S.size();
  for(int i = 0; i < N; i++){
    if(i%2){
      if(S.at(i) == 'R'){
        dance = false;
        break;
      }
    }
    if(!(i%2)){
      if(S.at(i) == 'L'){
        dance = false;
        break;
      }
    }
  }
  if(dance == true)
  cout << "Yes" << endl;
  else if(dance == false)
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int N;
    cin >> N;
    vector<int> data(101, 0);
    data[4] = 1;
    data[7] = 1;
    for (int i = 8; i <= 100; i++) {
        if (data[i - 4] == 1 || data[i - 7] == 1) {
            data[i] = 1;
        }
    }
    if (data[N] == 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

typedef struct {
  int time[2];
  int flag;
} Data;

int n,v[200][200];
Data data[200];

int aaa(int num, int time){
  int i;
  data[num].flag = 1;
  data[num].time[0] = time;
  for(i=1;i<=n;i++){
    if(v[num][i]==1 && data[i].flag==0){
      time = aaa(i,time+1);
    }
  }
  data[num].time[1]=time+1;
  return time+1;
}

int main(){
  int i,j,m,t,time=0;

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      v[i][j]=0;
      data[i].flag=0;
    }
  }

  for(i=1;i<=n;i++){
    scanf("%d%d",&t,&m);
    for(j=0;j<m;j++){
      scanf("%d",&t);
      v[i][t]=1;
    }
  }

  for(i=1;i<=n;i++){
    if(data[i].flag==0){
      time = aaa(i,time+1);
    }
  }

  for(i=1;i<=n;i++){
    printf("%d %d %d\n",i,data[i].time[0],data[i].time[1]);
  }

  return 0;
}



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

int main(){
  string s, t;
  
  cin >> s >> t;
  
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<int>());
  
  string re;
  if(s < t){
    re = "Yes";
  } else {
    re = "No";
  }
  
  cout << re << endl;
  
  return 0;
}

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

int main(){
	int n;
	while(cin >> n, n){
		int num, ans = 0;
		for(int i = 0;i < 9;i++){
			cin >> num;
			ans += num;
		}
		cout << n-ans << endl;
	}
	return 0;
}

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

using namespace std;
using LL = long long;

constexpr int N = 1e5 + 5;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    if (a >= k) {
        cout << k << endl;
        return 0;
    }
    if (a + b >= k) {
        cout << a << endl;
        return 0;
    }

    int need = k - a - b;
    cout << a - need << endl;
}

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

#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
	int x(0), sgn(1); char ch(getchar());
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
	for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
	return x * sgn;
}

void File() {
	freopen ("F.in", "r", stdin);
	freopen ("F.out", "w", stdout);
}

const int N = 5010, Mod = 1e9 + 7;

int n; char str[N];

inline int fpm(int x, int power) {
	int res = 1;
	for (; power; power >>= 1, x = 1ll * x * x % Mod)
		if (power & 1) res = 1ll * res * x % Mod;
	return res;
}

int fac[N], ifac[N], Pow2[N];
void Math_Init(int maxn) {
	fac[0] = ifac[0] = Pow2[0] = 1;
	For (i, 1, maxn)
		fac[i] = 1ll * fac[i - 1] * i % Mod,
		Pow2[i] = 2ll * Pow2[i - 1] % Mod;
	ifac[maxn] = fpm(fac[maxn], Mod - 2);
	Fordown (i, maxn - 1, 1)
		ifac[i] = 1ll * ifac[i + 1] * (i + 1) % Mod;
}

inline int Comb(int n, int m) {
	if (n < 0 || m < 0 || n < m) return 0;
	return 1ll * fac[n] * ifac[m] % Mod * ifac[n - m] % Mod;
}

inline int Calc(int len) {
	int res = 0;
	For (i, 0, n)
		if (i - (n - i) <= len)
			res = (res + 1ll * (Comb(n, i) - Comb(n, i - (len + 1))) * Pow2[i]) % Mod;
	return (res + Mod) % Mod;
}

int main () {

	n = read();
	scanf ("%s", str + 1);

	Math_Init(n);

	int len = strlen(str + 1);

	printf ("%lld\n", 1ll * (Calc(len) - Calc(len - 1) + Mod) * fpm(fpm(2, len), Mod - 2) % Mod);

	return 0;

}


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

int main()
{
  string s, res = "No";
  cin >> s;
  for(int i = 1; i < s.size(); i++)
  {
    if(s[0] == s[i])
    {
      switch(i)
      {
        case 1:
          if(s[2] == s[3] && s[0] != s[2]) res = "Yes";
          break;
        case 2:
          if(s[1] == s[3] && s[0] != s[3]) res = "Yes";
          break;
        case 3:
          if(s[1] == s[2] && s[0] != s[1]) res = "Yes";
          break;
      }
      break;
    }
  }
  cout << res << endl;
  return 0;
}

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

int main() {

    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    //Write code below
    
    int a, b;
    
    cin >> a >> b;
  
    for (int number = 0; ; number++) {
        if (a * number - (number - 1) >= b) {
            cout << number << endl;
            exit(0);
        }
    }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	
	int a;
	int b;
	int c;
	cin >> a;
	cin >> b;
	cin >> c;

	int k = a;
	if (a > b) {
		k = b;
		if (b > c) {
			k = c;
		}
	}
	if (a > c) {
		k = c;
		if (b < c) {
			k = b;
		}
	}
    
	int p;
	int q;

	cin >> p;
	cin >> q;
	 
	int n = p;
	if (p > q) {
		n = q;
	}
	int sum = k + n -50;
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int a[4],b[4];cin>>a[0];){
		repi(i,1,4)
			cin>>a[i];
		rep(i,4)
			cin>>b[i];
		
		vi c;
		rep(i,4)
			if(a[i]!=b[i]){
				c.push_back(a[i]);
				c.push_back(b[i]);
			}
		int hit=4-c.size()/2;
		
		sort(allof(c));
		c.erase(unique(allof(c)),c.end());
		int blow=8-hit*2-c.size();
		
		cout<<hit<<" "<<blow<<endl;
	}
	
	return 0;
}

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

using namespace std;

#define ll long long

ll M = 1000000007;

ll bin_pow(ll a, ll pow) {
    if (pow == 0) return 1;
    if (pow == 1) return a;
    if (pow % 2 == 0) {
        ll tmp = bin_pow(a, pow / 2) % M;
        return tmp * tmp % M;
    }
    return a * bin_pow(a, pow - 1) % M;
}

ll inv(ll a) {
    return bin_pow(a, M - 2) % M;
}

ll fact(ll a) {
    ll ans = 1;
    for (int i = 1; i <= a; i++) {
        ans *= i;
        ans %= M;
    }
    return ans;
}

vector<vector<int>> d;
vector<pair<int, int>> a;

int ans(int n, int t) {
    if (t <= 0 || n == 0) return 0;
    if (d[n][t] == -1) {
        d[n][t] = max(ans(n - 1, t), ans(n - 1, t - a[n - 1].first) + a[n - 1].second);
    }

    return d[n][t];
}

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

    int n, t;
    cin >> n >> t;

    a.resize(n);

    for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;

    sort(a.rbegin(), a.rend());

    d.assign(n + 1, vector<int>(t + 1, -1));


    cout << ans(n, t);

    return 0;
}

Measured memory_bytes: 35712
import math
n = int(input())
p = list(map(int, input().split()))
ans = 0
tmp = 0
for i in range(1, n+1):
    if p[i-1] == i:
        tmp += 1
    elif tmp > 1:
        ans += math.ceil(tmp/2)
        tmp = 0
    elif tmp == 1:
        ans += tmp
        tmp = 0

if tmp > 1:
    ans += math.ceil(tmp / 2)
    tmp = 0
elif tmp == 1:
    ans += tmp
    tmp = 0
print(ans)


Measured memory_bytes: 13940
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    string s;
    cin>>s;
    s[3]='8';
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAX=2000005;
int tree[MAX];int H;
void maxHeapify(int i){
	int lgst=i;
	if(2*i<=H&&tree[lgst]<tree[2*i])lgst=2*i;
	if(2*i+1<=H&&tree[lgst]<tree[2*i+1])lgst=2*i+1;
	if(lgst==i)return;
	swap(tree[lgst],tree[i]);
	maxHeapify(lgst);
}
void buildMaxHeap(){
	for(int i=H/2;i>0;i--){
		maxHeapify(i);
	}
}
void Insert(int k){
	H++;
	int i=H;
	tree[i]=k;
	while(i>1 && tree[i/2]<tree[i]){
		swap(tree[i/2],tree[i]);
		i>>=1;
	}
}
int Extract(){
	int m=tree[1];
	tree[1]=tree[H--];
	maxHeapify(1);
	return m;
}
int main(){
	char s[20];
	H=0;
	while(~scanf("%s",s)){
		if(!strcmp(s,"end"))break;
		else if(!strcmp(s,"insert")){
			int k;
			scanf("%d",&k);
			Insert(k);
		}else if(!strcmp(s,"extract")){
			printf("%d\n",Extract());
		}
	}
	return 0;
}


Measured memory_bytes: 7052
#include <iostream>
#define ll long long

using namespace std;

ll N, ans;

void dfs(ll num, int three, int five, int seven) {
	if (num > N) return;
	if (three * five * seven > 0) ans++;

	dfs(10 * num + 3, 1, five, seven);
	dfs(10 * num + 5, three, 1, seven);
	dfs(10 * num + 7, three, five, 1);

	return;
}

int main() {
	cin >> N;
	dfs(0, 0, 0, 0);
	cout << ans;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
#define all(v) v.begin(), v.end()

int main(){
  ll N;
  cin >> N;
  if(N<1000){
    cout << "ABC"<< endl;
  }else{
    cout << "ABD" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdint>
using namespace std;
int main() {
	int N, A, B;
	cin >> N >> A >> B;
	if (N < A + B - 1 || N > (int64_t)A * B) { // これ不可能なので
		cout << -1;
		return 0;
	}
	int use = 0;
	int64_t branch;
	for (int i = 0;i < A;i ++) {
		branch = N - (int64_t)i * B - (A - i) + 1; // この親ノードにおける左の列の長さ
		if (branch > B) branch = B; // Bは超えない
		if (branch <= 0) branch = 1; // 最低1マスを確保するように作ってる
		for (int j = 0;j < branch;j ++) {
			cout << use + branch - j;
			if (i < A - 1 || j < branch - 1) cout << " "; // 空白条件を間違えずに
		}
		use += branch;
	}
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

一つ構成し～系は分かりやすい形のを1個作れば通ることが多い
さて、次のような木を作ることにする
全ての親ノードについて、左の子は親より小さく、右の子は親より大きい
これを親→左→右の順番で表示するとそれは列Pになるし、
最大の左に続く長さが最小部分文字列、最大の右に続く長さが最大部分文字列になる
ということで、この木を作っていけば良い
木が完成すれば適当な数を、上から順に入れていく この時最大の左に続く長さ+1を親にしておけば無問題に動く

さて、これは実は木を作らなくても動く
まず根を決めて、左にずっとB-1個、右にずっとA-1個置いてしまう
これが置ければ、次に根より下の右側の親から要素数がNを超えない範囲で左にB-1個置いていけば良い
これで最大AB個置ける
*/

Measured memory_bytes: 2304
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

int main(){
  FAST_IO

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

  int sum = a + b + c;
  a = max({a, b, c});
  sum -= a;
  sum += pow(2, k) * a;

  cout << sum << '\n';
  return 0;
}


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

using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = (ll)1e18;
const int N = 2e6 + 5;
const ll MOD = 998244353;

int parent[N];

int gcd(int a, int b) { 
    if (a == 0) 
        return b;  
    return gcd(b%a, a);  
} 
   
int lcm(int a, int b) {  
    return (a*b)/gcd(a,b);  
} 

ll pow(ll x, ll y, ll p) {
    if(y == 0) return 1;
    ll res = 1;
    x %= p;
    if(x == 0) return 0LL;
    while(y > 0) {
        if(y & 1) res = (res*x) % p;
        y >>= 1;
        x = (x*x) % p;
    }
    return res;
}

int find(int x) {
    return x == parent[x] ? x : parent[x] = find(parent[x]);
}

void Union(int x, int y) {
    int xPar = find(x), yPar = find(y);
    if(xPar != yPar) parent[xPar] = yPar;
}

int main()
{
    IOS
    ll n;
    cin >> n;
    n--;
    string res = "";
    while(n >= 0) {
        ll idx = n % 26;
        res += 'a' + idx;
        n /= 26;
        n--;
    }
    reverse(res.begin(), res.end());
    cout << res << endl;
    return 0; 
}



Measured memory_bytes: 3656
import fractions

A, B, C, D = map(int, input().split())

C_count = B // C - (A - 1) // C
D_count = B // D - (A - 1) // D
CD = C * D // fractions.gcd(C, D)
CD_count = B // CD - (A - 1) // CD
# print(C_count, D_count, CD_count)
print(B - A + 1 + CD_count - C_count - D_count)

Measured memory_bytes: 5088
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
typedef long long lint;
const int N=2005;
int n,val[N<<1],pos[2][N],dp[N],fp[2][N<<1][N];
bool col[N<<1];//白1黑0

namespace utils{
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
	template <class T> inline void apn(T &x,const T y){x=x<y?x:y;}
	template <class T> inline void apx(T &x,const T y){x=x>y?x:y;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

int main(){
	n=nxi();
	for(int i=1; i<=n<<1; ++i){
		char c;
		while((c=getchar())!='W'&&c!='B');
		col[i]=c=='W';
		val[i]=nxi();
		pos[col[i]][val[i]]=i;
	}
	for(int i=n<<1; i; --i){
		memcpy(fp[0][i],fp[0][i+1],(n+2)*sizeof(int));
		memcpy(fp[1][i],fp[1][i+1],(n+2)*sizeof(int));
		for(int j=val[i]+1; j<=n+1; ++j)
			++fp[col[i]][i][j];
	}
	memset(dp,10,sizeof(dp));
	dp[0]=0;
	for(int i=1; i<=n<<1; ++i){//dp([i])[j]: 当前白点cnt
		for(int j=std::min(n,i); ~j&&i-j<=n; --j){
			const int cw=j,cb=i-j,r0=dp[j],r1=j?dp[j-1]:2e8;
			const int p0=pos[0][cb],p1=pos[1][cw];
			const int res0=r0+p0+fp[0][p0][cb]+fp[1][p0][cw+1]-i;//加黑
			const int res1=r1+p1+fp[0][p1][cb+1]+fp[1][p1][cw]-i;//加白
			dp[j]=std::min(res0,res1);
		}
	}
	printf("%d\n",dp[n]);
	return 0;
}


Measured memory_bytes: 66456
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
typedef long long ll;
using Graph =vector<int>;
typedef pair<int,int> P;

const ll MAX_N=131072;

int bit[MAX_N*2-1];
ll n;
vector<int> G[1000010];
vector<vector<int>> used(1000010,vector<int>(3,0));
vector<P> v;
bool cmp(P a,P b){
  //if (a.second==b.second) return a.first<b.first;
  return a.second <b.second;
}
int main(){
  int N;cin>>N;
  rep(i,N){
    int a,b;
    cin>>a>>b;
    v.push_back(P(a,b));
  }
  sort(v.begin(),v.end(),cmp);
  int time=0;
  rep(i,N){
    P p=v[i];int a,b;
    a=p.first;b=p.second;
    time+=p.first;
    if (time>b){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}


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

#define pb push_back
#define mp make_pair

const int MOD = 1e9+7;
const int MAX_N=1e5+10;

ll X;

void solve()
{
	for(ll a=-2000;a<=2000;++a)for(ll b=-2000;b<=2000;++b){
		if(a*a*a*a*a-b*b*b*b*b==X){
			cout << a << ' ' << b << '\n';
			return;
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> X;
	solve();
	return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
using namespace std;
int main() {
	string s;
	int count=0,ans,flag = 0;
	cin >> s;
	for (auto&& a : s) {
		if (a == 'A')
			flag = 1;
		if (flag == 1)
			count++;
		if (a == 'Z')
			ans = count;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
import numpy as np

N,M,X = map(int,input().split())
A = []
for i in range(N):
    A.append(list(map(int,input().split())))
A = np.array(A)

ans = 10**8
for b in range(2**N):
    A_sum = np.zeros(A[0].shape,dtype=np.int32)
    for i in range(N):
        if (b >> i) % 2 == 1:
            A_sum += A[i]
    for i in range(1,M+1):
        if A_sum[i] < X:
            break
    else:
        ans = min(ans,A_sum[0])

if ans == 10**8:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 26844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

const int mod = 1e9+7;

int main() {
    ll S;
    cin >> S;
    vector<ll> A(S+1, 0);
    A[0] = 1;
    for (int i=1; i<=S; ++i) {
        for (int j=i-3; j>=0; --j) {
            A[i] += A[j];
            A[i] %= mod;
        }
    }
    cout << A[S] << endl;
    return 0;
}

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

int main(){
    int n,r,p,c;
    int a[52]={},tmp[52]={};
    while(cin>>n>>r,n|r){
        rep(i,n)a[i+1]=n-i;
        while(r--){
            cin>>p>>c;
            rep(i,c)tmp[i+1]=a[p+i];
            rep1(i,p-1)tmp[c+i]=a[i];
            rep1(i,c+p-1)a[i]=tmp[i];
        }
        cout<<a[1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007
#define PI 3.1415926
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};

typedef long long ll;

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

ll all[55];
ll count(int level, ll pos){
	if(level == 0) return 1;
	if(pos <= 1) return 0;
	if(pos <= all[level]/2) return count(level-1, pos-1);
	if(pos == all[level]/2 + 1) return 1 + count(level-1, pos-2);
	if(pos < all[level]) return 1+count(level-1,all[level-1])+count(level-1,pos-1-all[level]/2);
	return 1+2*count(level-1,all[level-1]);
}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	ll x;
	cin >> n >> x;

	all[0] = 1;
	for (int i = 1; i < n+1; i++) {
		all[i] = all[i-1]*2 + 3;
	}

	cout << count(n, x) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define P 1000000007
#define inf 1e18
int main()
{
    ll i, n, j, m;
    cin >> n >> m;
    char s[60][60];

    for (i = 0; i < n + 3; i++)
    {
        for (j = 0; j < n + 3; j++)
        {
            s[i][j] = '?';
        }
    }
    for (i = 1; i <= n; i++)
    {
        for (ll j = 1; j <= m; j++)
        {
            char p;
            cin >> p;
            s[i][j] = p;
        }
    }

    ll count[56][56];

    for (i = 0; i < 53; i++)
    {
        for (j = 0; j < 53; j++)
            count[i][j] = 0;
    }

    for (i = 1; i <= n; i++)
    {
        for (j = 1; j <= m; j++)
        {
            if (s[i][j] == '.')
            {
                if (s[i - 1][j] == '#')
                {
                    count[i][j]++;
                }
                if (s[i + 1][j] == '#')
                {
                    count[i][j]++;
                }
                if (s[i][j + 1] == '#')
                {
                    count[i][j]++;
                }
                if (s[i][j - 1] == '#')
                {
                    count[i][j]++;
                }
                if (s[i - 1][j - 1] == '#')
                {
                    count[i][j]++;
                }
                if (s[i - 1][j + 1] == '#')
                {
                    count[i][j]++;
                }
                if (s[i + 1][j - 1] == '#')
                {
                    count[i][j]++;
                }
                if (s[i + 1][j + 1] == '#')
                {
                    count[i][j]++;
                }
            }
        }
    }

    for (i = 1; i <= n; i++)
    {
        for (j = 1; j <= m; j++)
        {
            if (s[i][j] == '#')
            {
                cout << s[i][j];
            }
            else
            {
                cout << count[i][j];
            }
        }
        cout << "\n";
    }

    return (0);
}

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

using namespace std;
long long n;int m;
int tree[2][200200<<2];
int lazy[2][200200<<2];
void pushdown(int id,int rt){
	if(lazy[id][rt]<n) {
		tree[id][rt<<1] = min(tree[id][rt<<1],lazy[id][rt]);
		lazy[id][rt<<1] = min(lazy[id][rt<<1],lazy[id][rt]);
		tree[id][rt<<1|1] = min(tree[id][rt<<1|1],lazy[id][rt]);
		lazy[id][rt<<1|1] = min(lazy[id][rt<<1|1],lazy[id][rt]);
	}
	lazy[id][rt]=n;
}
void build(int id,int rt,int l,int r) {
	tree[id][rt] = n;
	lazy[id][rt] = n;
	if(l==r) {
		return;
	}
	int mid = (l+r)/2;
	build( id,rt<<1,l,mid);
	build( id,rt<<1|1,mid+1,r);
	return ;
}
int query(int id,int rt,int l,int r,int pos){
	if(l==r){
		return tree[id][rt];
	}
	pushdown(id,rt);
	int mid = (l+r)/2;
	if(pos<=mid){
		return query(id,rt<<1,l,mid,pos);
	} else {
		return query(id,rt<<1|1,mid+1,r,pos);
	}
}
void add(int id,int rt,int l,int r,int ql,int qr,int v){
	if(ql<=l&&qr>=r){
		lazy[id][rt]=min(lazy[id][rt],v);
		tree[id][rt]=min(tree[id][rt],v);
		return ;
	}
	int mid = (l+r)/2;
	pushdown(id,rt);
	if(ql<=mid){
		add(id,rt<<1,l,mid,ql,qr,v);
	}
	if(qr>mid){
		add(id,rt<<1|1,mid+1,r,ql,qr,v);
	}
	tree[id][rt]=min(tree[id][rt<<1],tree[id][rt<<1|1]); 
}


int main(){
	scanf("%lld%d",&n,&m);
	long long sum = (n-2)*(n-2);
	build(1,1,1,n);//printf("~~~\n");
	build(0,1,1,n);
	
	for(int i = 1;i<=m;i++) {
		int x,pos;
		scanf("%d%d",&x,&pos);
		if(pos ==  1) continue;
		x--;
		int tmp = query(1^x,1,1,n,pos);
	//	printf("tmp=%d\n",tmp);
		sum-=tmp-2;
		add(x,1,1,n,1,tmp,pos);
	}
	printf("%lld\n",sum);
}

Measured memory_bytes: 11960