akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

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

    int h, n;
    cin >> h >> n;

    vector<int> a(n), b(n);
    rep(i, n){
        cin >> a[i] >> b[i];
    }

    vector< vector<int> > dp(n + 1, vector<int>(h + 1, IINF));
    dp[0][0] = 0;

    rep(i, n){
        rep(j, h + 1){
            chmin(dp[i + 1][j], dp[i][j]);
            chmin(dp[i][min(j + a[i], h)], dp[i][j] + b[i]);
        }
    }

    cout << dp[n][h] << endl;

    cout << flush;

    return 0;
}

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

typedef long long ll;

ll solve(int n,ll m){
  ll a[51],b[51];
  a[0]=1,b[0]=1;
  for(int i=0;i<50;i++){
    a[i+1]=2*a[i]+3;
    b[i+1]=2*b[i]+1;
  }
  if(n==0&&m==1){
    return 1;
  }
  else if(m==1){
    return 0;
  }
  else if(2<=m&&m<=1+a[n-1]){
    return solve(n-1,m-1);
  }
  else if(m==2+a[n-1]){
    return solve(n-1,a[n-1])+1;
  }
  else if(m>2+a[n-1]&&m!=a[n]){
    return solve(n-1,m-2-a[n-1])+b[n-1]+1;
  }
  else{
    return b[n];
  }
}

int main(){
  int n;
  ll x;
  cin >> n >> x;
  cout << solve(n,x) << endl;
}

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

int main() {
long long A, B, C, X, Y;
cin >> A >> B >> C >> X >> Y;
if(2*C < A + B){
 if(X >= Y){
  if(2*C >= A){
  cout << 2*Y*C + (X - Y)*A << endl;}
  if(2*C < A){
  cout << 2*X*C << endl;}}
 if(X < Y){
  if(2*C >= B){
  cout << 2*X*C + (Y - X)*B << endl;}
  if(2*C < B){
  cout << 2*Y*C << endl;}}}
if(2*C >= A + B){
cout << X*A + Y*B << endl;}}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <stack>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-7
#define inf 0x3f3f3f3f
#define mod 1000000007
using namespace std;

int main() {
	speed;
	int n, d;
	cin >> n >> d;
	vector<vector<int>>v(n, vector<int>(d));
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < d; ++j)
			cin >> v[i][j];
	}
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			double tmp = 0;
			for (int k = 0; k < d; ++k)
				tmp += (v[i][k] - v[j][k]) * (v[i][k] - v[j][k]);
			if (sqrt(tmp) - int(sqrt(tmp)) < eps)
				ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

int N, M, V, P;
vector<int> A;


bool check(int X) {
    if (X < P) return true;
    if (A[X] + M < A[P - 1]) return false;
    long long l = V - (P + N - X - 1);
    if (l <= 0) return true;
    l *= M;
    for (int i = P - 1; i <= X - 1; i++) {
        l -= A[X] + M - A[i];
    }
    return l <= 0;
}

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

    A.assign(N, 0);
    rep(i,N) cin >> A[i];

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

    int bottom = 0;
    int top = N - 1;

    while (bottom < top) {
        int X = bottom + (top - bottom) / 2;
        if (X == bottom) X = bottom + 1;
        if (check(X)) bottom = X;
        else top = X - 1;
    }

    cout << bottom + 1 << endl;

    return 0;
}

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

using namespace std;

const int M = 305;
long long int I = INT32_MAX;

int n, m, l, q, a, b, c;
vector<vector<long long int>> dist(M, vector<long long int>(M, I)), cnt(M, vector<long long int>(M, I));

// DP?? WTF
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);

    cin >> n >> m >> l;
    while (m--) {
        cin >> a >> b >> c; a--; b--;
        if (c > l) continue;
        dist[a][b] = dist[b][a] = c;
    }
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            for (int k = 0; k < n; k++)
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
    for (int i = 0; i < n; i++) 
        for (int j = 0; j < n; j++) {
            if (i == j) continue; // Collision Checking
            if (dist[i][j] <= l) cnt[i][j] = 1;
        }
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            for (int k = 0; k < n; k++)
                cnt[j][k] = min(cnt[j][k], cnt[j][i] + cnt[i][k]);
    for (cin >> q; q--; ) {
        cin >> a >> b; a--; b--;
        cout << (cnt[a][b] != I ? cnt[a][b] : 0) - 1 << '\n';
    }

    return 0;
}

Measured memory_bytes: 5112
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

int main(void) {
  int n, m;
  scanf("%d %d", &n, &m);

  printf("%d\n", n * (n-1) / 2 + m *(m-1) /2);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define lli long long int
#define ld long double
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,a,n) for(int i = a; i < n; i++)
#define s(n) cin >> n
#define csl ios_base::sync_with_stdio(false); cin.tie(NULL)
#define rsz(x,n) x.clear(); x.resize(n)
#define rrsz(x,a,n) x.clear(); x.resize(n,a)
#define wt while(true)
#define all(x) x.begin(),x.end()
#define pb push_back
#define ls(x) ((2*(x)) + 1)
#define rs(x) ((ls(x)) + 1)
#define md(a,b) (((a) + (b))/2)
#define INF (1e9 + 7)

using namespace std;

int main()
{
    lli n;s(n);
    vector<ld>a(n+1);
    rep(i,n)
    {
        ld b;s(b);
        a[i+1]=b;
    }
    vector<vector<ld>>vec(n+1,vector<ld>(n+1,0));
    vec[0][0]=1;
    reps(i,1,n+1)
    vec[i][0]=vec[i-1][0]*(1-a[i]);
    vec[1][1]=a[1];
    reps(i,2,n+1)
    {
        reps(j,1,i+1)
        {
            vec[i][j]+=((vec[i-1][j-1])*(a[i])+(vec[i-1][j])*(1-a[i]));
        }
    }
     /*reps(i,1,n+1)
    cout<<vec[n][i]<<" ";*/
    
    ld sum=0;
    reps(i,(n/2)+1,n+1)
    sum+=vec[n][i];
    cout<<fixed<<setprecision(10)<<sum; 
    return 0;
}

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

#define MOD 1000000007
// #define INF 100000000000

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const vector<vector<T>>&obj) {
    o << "[" << endl; for (int i = 0; i < (int)obj.size(); ++i) o << "  " << obj[i] << endl; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const queue<T>&obj) {
    queue<T> obj_cp = obj;
    bool first = true;
    o << "{";
    while (!obj_cp.empty()) { o << (!first ? ", " : "") << obj_cp.front(); obj_cp.pop(); first = false; }
    o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}


int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    vector<ll> T(N), A(N);
    for (int i = 0; i < N; ++i) {
        cin >> T[i];
    }
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    
    vector<pair<ll, ll>> possible_T(N);
    possible_T[0] = {T[0], T[0]};
    for (int i = 1; i < N; ++i) {
        if (T[i] > T[i-1]) {
            possible_T[i] = {T[i], T[i]};
        } else if (T[i] == T[i-1]) {
            possible_T[i] = {1, T[i]};
        }
    }

    vector<pair<ll, ll>> possible_A(N);
    possible_A[N-1] = {A[N-1], A[N-1]};
    for (int i = N-2; i >= 0; --i) {
        if (A[i] > A[i+1]) {
            possible_A[i] = {A[i], A[i]};
        } else if (A[i] == A[i+1]) {
            possible_A[i] = {1, A[i]};
        }
    }

    ll ans = 1;
    for (int i = 0; i < N; ++i) {
        ll low = max(possible_T[i].first, possible_A[i].first);
        ll high = min(possible_T[i].second, possible_A[i].second);
        if (low > high) {
            cout << 0 << endl;
            return 0;
        }
        ans = (ans * (high - low + 1)) % MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4992
import java.util.*;
public class Main {
//for全探索
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner (System.in);
		int N = sc.nextInt();
		int Y = sc.nextInt();
		int ans1 = -1;
		int ans2 = -1;
		int ans3 = -1;
		for(int i = 0; i <=N;i++) {
			for(int j = 0; j <= N;j++) {
				 if((i*10000 + j*5000 + (N-i-j)*1000) == Y) {
					  if(N-i-j < 0)continue;
						ans1 = i;
						ans2 = j;
						ans3 = N-i-j;
						break;
					
				}
			}
			
		}
		System.out.println(ans1+" "+ans2+" "+ans3);
		
	}

}

Measured memory_bytes: 22996
import java.util.Scanner;

public class Main {
	public static void main(String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x[] = new int[n];
		int y[] = new int[n];
		int h[] = new int[n];
		for(int i=0;i<n;i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			h[i] = sc.nextInt();
		}
		sc.close();
		for(int i=0;i<=100;i++) {
			for(int j=0;j<=100;j++) {
				int cx = i, cy = j;
				long ch = -1;
				//long mh = Long.MAX_VALUE/3;
				for(int k=0;k<n;k++) {
					int dx = Math.abs(cx - x[k]);
					int dy = Math.abs(cy - y[k]);						
					if(h[k]!=0) {
						ch = (long)h[k] + dx + dy;
						break;
					}
				}
			
				for(int k=0;k<n;k++) {
					int dx = Math.abs(cx - x[k]);
					int dy = Math.abs(cy - y[k]);
					if(h[k]==0) {
						if(dx + dy < ch) {
							ch = -1;
							break;
						}
					}
					else {
						if(ch != (long)h[k] + dx + dy) {
							ch = -1;
							break;
						}
					}
				}

				
				if(ch!=0&&ch!=-1) {
					System.out.println(cx + " " + cy + " " + ch);
					return;
				}
			}
		}
	}
}


Measured memory_bytes: 23764
#include<iostream>
#include<vector>
#include<map>
#include<string>
using namespace std;
typedef pair < int , int > Pi;
typedef pair < int , Pi > Pii;
#define fr first
#define sc second
const int dy[][4] = {{1,0,-1,0},{0,-1,0,1},{-1,0,1,0},{0,1,0,-1}};
const int dx[][4] = {{0,1,0,-1},{1,0,-1,0},{0,-1,0,1},{-1,0,1,0}};
const int dm[][4] = {{3,0,1,2},{0,1,2,3},{1,2,3,0},{2,3,0,1}};
const int my[] = { 0, -1, 0, 1}, mx[] = { 1, 0, -1, 0};
const int md[] = { 2, 3, 0, 1};
int w, h;
char mas[30][30];
vector< Pii > vc;
string tmp = "ENWS";
int search( int y , int x){
  for(int i = 0 ; i < vc.size() ; i++ ){
    if(Pi(y,x) == vc[i].sc){
      return i;
    }
  }
  return -1;
}
vector< Pii >  solve(){
  //向き変えるじゃん
  vector< Pii > java;
  for(int i = 0 ; i < vc.size() ; i++ ){
    //向きは毎回変えるじゃん(震え声)
    for(int j = 0 ; j < 4 ; j++ ){
      int yy = vc[i].sc.fr + dy[vc[i].fr][j];
      int xx = vc[i].sc.sc + dx[vc[i].fr][j];
      if(mas[yy][xx] != '#' && search(yy,xx) == -1){
        vc[i].fr = dm[vc[i].fr][j];
        break;
      }
    }
  }
  //動けないひとをプッシュしよう
  bool list[1000] = {};
  for(int i = 0 ; i < h ; i++ ){
    for(int j = 0 ; j < w ; j++ ){
      if(mas[i][j] == '#' || search(i,j) != -1) continue;
      for(int k = 0 ; k < 4 ; k++ ){
        int ny = i + my[k], nx = j + mx[k], iti;
        if((iti = search(ny,nx)) == -1) continue;
        if(vc[iti].fr == md[k]){
          if(mas[i][j] != 'X') java.push_back(Pii(vc[iti].fr,Pi(i,j)));
          list[iti] = true;
          break;
        }
      }
    }
  }
  for(int i = 0 ; i < vc.size() ; i++ ){
    if(!list[i]) java.push_back(vc[i]);
  }
  return java;
}
int main(){
  while(cin >> w >> h , w){
    for(int i = 0 ; i < h ; i++ ){
      for(int j = 0 ; j < w ; j++ ){
        cin >> mas[i][j];
        if(tmp.find(mas[i][j]) != string::npos){
          vc.push_back(Pii( tmp.find(mas[i][j]), Pi( i, j)));
        }
      }
    }
    int ret = 0;
    while(ret <= 180 && !vc.empty()){
      vc = solve();
      ret++;
    }
    if(ret == 181) cout << "NA" << endl;
    else cout << ret << endl;
    vc.clear();
  }
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define endl '\n'
#define mod 1000000007
#define inf 1000000000000000000
#define pii pair<int, pair<int, int>>
const double pi = acos(-1);
const int sz = 200002;
int n, m, q, k;
vector<int>a, b;
int main() {
	io
	cin>>n>>m>>k;
	a.resize(n);
	b.resize(m);
	for(int i = 0; i < n; i++) {
		cin>>a[i];
	}
	for(int i = 0; i < m; i++) {
		cin>>b[i];
	}
	vector<ll> prefixa(n), prefixb(m);
	for(int i = 0; i<n; i++) {
		prefixa[i] = a[i] + (i == 0 ? 0 : prefixa[i-1]);
	}
	for(int i = 0; i<m; i++) {
		prefixb[i] = b[i] + (i == 0 ? 0 : prefixb[i-1]);
	}
	int ans = INT_MIN, curAns = 0;
	int pos = lower_bound(prefixb.begin(), prefixb.end(), k) - prefixb.begin();
	if(pos == m) {
		curAns += m;
	}
	else {
		if(prefixb[pos] > k) {
			pos--;
		}
		if(pos >= 0) curAns += pos+1;
	}
	ans = max(ans, curAns);
	for(int i = 0; i<n; i++) {
		int kc = k;
		curAns = 0;
		if(prefixa[i] <= kc) {
			kc -= prefixa[i];
			curAns = i+1;
		}
		else break;
		pos = lower_bound(prefixb.begin(), prefixb.end(), kc) - prefixb.begin();
		if(pos == m) {
			curAns += m;
		}
		else {
			if(prefixb[pos] > kc) {
				pos--;
			}
			if(pos >= 0) curAns += pos+1;
		}
		ans = max(ans, curAns);
	}
	cout<<(ans == INT_MIN ? 0 : ans)<<endl;
}


Measured memory_bytes: 7948
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  int x,a,b;
  cin>>x>>a>>b;
  int A=abs(x-a),B=abs(b-x);
  if(A>B){cout<<"B"<<endl;}
  else{cout<<"A"<<endl;}
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

void solve()
{
	int X;
	cin >> X;
	if (X == 3 || X == 5 || X == 7)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 256
import sys

def solve(n, s, k):
    ans = s[0:k-1] + s[k-1].lower()
    if k < n:
      ans += s[k:n]
    return ans

if __name__ == '__main__':

    n, k = map(int, sys.stdin.readline().strip().split(" "))
    s = sys.stdin.readline().strip()
    ans = solve(n, s, k)
    print ans

Measured memory_bytes: 2568
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<ll, bool> pib;

typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;

typedef vector<double> vf;

typedef long double ld;

#define mp make_pair
#define pb push_back

#define rep(i, N) for(ll i = 0; i < N; i++)
#define repa(i, a, N) for(ll i = a; i < N; i++)
#define repr(i, N) for(ll i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

#define all(A) A.begin(), A.end()

#define printItr(A) for(auto itr = A.begin(); itr != A.end(); ++itr){cout << * itr << ", ";}cout << endl;

const double PI = 3.141592653589793;

const ll mod = 1e9 + 7;
// const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

ll id(char c) {
	return c - 'a';
}

bool isOK(vi& a, ll k, ll index) {
	return a[index] < k * (index + 1);
}

ll binary_search(vi& a, ll k) {
	ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	ll right = (ll)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		ll mid = left + (right - left) / 2;

		if (isOK(a, k, mid))
			right = mid;
		else left = mid;
	}

	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}

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

template<class t> ostream& operator<<(ostream& os, const vector<t>& v) {
	os << "{";
	for (auto e : v)os << e << ",";
	return os << "}";
}

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

	string S;
	cin >> S;

	ll ans = 0;
	for (int i = 0; i < S.size() - 2; i++) {
		if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const int md = int(1e9) + 7;
 
inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}
 
inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}
 
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  string k;
  int d;
  cin >> k >> d;
 
  vector< vector<int> > dp(d, vector<int>(2));
  dp[0][0] = 1;
  for (int i = 0; i < (int) k.length(); i++) {
    vector< vector<int> > new_dp(d, vector<int>(2));
    for (int j = 0; j < d; j++) {
      for (auto any : {false, true}) {
        for (int dig = 0; dig < 10; dig++) {
          if (!any && dig > k[i] - '0') {
            break;
          }
          add(new_dp[(j + dig) % d][any || dig < k[i] - '0'], dp[j][any]);
        }
      }
    }
    swap(dp, new_dp);
  }
  int ans = (dp[0][false] + dp[0][true]) % md;
  sub(ans, 1);
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;

int main() {
	string s;
	cin >> s;
	vector<char>t;
	int count = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] != 'B') {
			t.push_back(s[i]);
		}
		else {
			if (t.size() >= 1) {
				t.pop_back();
			}
		}
	}
	for (int i = 0; i < t.size() - count; i++) {
		cout << t[i];
	}
	cout << endl;
	return 0;
}

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

int main() {
    int L, R, d; cin >> L >> R >> d;
    int ans = R / d;
    int ans2 = (L-1) / d;
    cout << ans - ans2 << endl;

    return 0;
}

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

long long gcd(long long a, long long b){
    while(b!=0){
        long long r = a%b;
        a= b;
        b= r;
    }
    return a;
}

long long lcm(long long a, long long b){
    return a * b / gcd(a,b);
}

long long getCnt(long long A, long long B, long long divisor)
{
    return B/divisor - (A-1)/divisor;
}

int main()
{
    long long A,B,C,D;
    cin >> A >> B >> C >> D;
    long long lcm_num = lcm(C,D);
    
    long long C_cnt = getCnt(A, B, C);
    long long D_cnt = getCnt(A, B, D);
    long long lcm_cnt = getCnt(A, B, lcm_num);
    long long total = B - A + 1;
    long long result = total - C_cnt - D_cnt + lcm_cnt;
    cout << result << endl;
}


Measured memory_bytes: 256
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()

bus = [T[0]]
count = 1

for i in range(1, N):
    if T[i] <= bus[0] + K and len(bus) < C:
        bus.append(T[i])
    else:
        count += 1
        bus = []
        bus.append(T[i])

print(count)

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

int main() {
  int n,x,y; cin>>n>>x>>y;
  x--; y--;
  map<int, int> X;
  for (int i=0; i<n; i++) {
    for (int j=i+1; j<n; j++) {
      int tmp=0;
      if (i<=x) {
        if (j<y) {
          int front=j-i;
          int back=(x-i)+1+(y-j);
          tmp=min(front, back);
        }
        else tmp=(x-i)+1+(j-y);
      }
      else if (i<y) {
        if (j<y) {
          int front=j-i;
          int back=(i-x)+1+(y-j);
          tmp=min(front, back);
        }
        else {
          int front=j-i;
          int back=(i-x)+1+(j-y);
          tmp=min(front, back);
        }
      }
      else tmp=j-i;
      X[tmp]++;
    }
  }
  rep(i, n-1) {
    cout<<X[i+1]<<endl;
  }
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 1e18
const long double EPS = 1E-10;

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




int main(){
    int A, B, K; std::cin >> K >> A >> B;
    for(int i(A); i <= B; ++i){
        if(!(i % K)){
            std::cout << "OK" << std::endl;
            return 0;
        }
    }
    std::cout << "NG" << std::endl;
    return 0;
}


Measured memory_bytes: 3632
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e18;
#define PI 3.14159265
 
const ll N = 100005;

void solve(){
	ll n;
	cin>>n;
	ll st=100;
	ll cnt=0;
	// err2(st,n);
	while(st<n){
		// err2(st,n);
		ll p = st/100;
		st+=p;
		cnt++;
	}
	cout<<cnt<<endl;
	return;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll no;
	// cin>>no;
	no = 1;
	while(no--){
		solve();
	}
    return 0;
}

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

double get_rad(int a,int b){
  double rad_a ,rad_b;
  int min = a*60+b;
  rad_b = 2*M_PI*(b%60)/60;
  rad_a = 2*M_PI*(min%720)/720;
  return fabs(rad_a-rad_b);
}

int main(void){
  int a,b,h,m;
  scanf("%d %d %d %d",&a,&b,&h,&m);
  double dx,dy,len;
  double rad = get_rad(h,m);
  //printf("%lf",rad);
  dx = (double)a-(double)b*cos(rad);
  dy = 0-(double)b*sin(rad);
  len =sqrt(pow(dx,2)+pow(dy,2));
  printf("%.12f",len);
  return 0;
}


Measured memory_bytes: 2664
#include <bits/stdc++.h>
using namespace std;
#define M 200005
int A[M],cnt[M],mark[M];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		scanf("%d",&A[i]);
	for(int i=n;i>=1;i--){
		if(cnt[i]==A[i])continue;
		cnt[i]^=1;
		mark[i]=1;
		for(int j=1;j*j<i;j++)
			if(i%j==0)cnt[j]^=1,cnt[i/j]^=1;
		int t=sqrt(i);
		if(t*t==i)cnt[t]^=1;
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		if(mark[i])ans++;
	cout<<ans<<endl;
	for(int i=1;i<=n;i++)
		if(mark[i])printf("%d ",i);
	return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long



signed main(){
    int N, M;
    cin >> N >> M;
    vector<int> K(N);
    vector<int> v(M + 1);
    for(int i = 0; i < N; ++i) {
        cin >> K[i];
        for(int j = 0; j < K[i]; ++j) {
            int a;
            cin >> a;
            v[a]++;
        }
    }
    int res = 0;
    for(int i = 0; i <= M; ++i) if (v[i] == N) res++;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std;
typedef pair<int, int> P;

const int MAX_N = 2e5, ST_SIZE = (1 << 19) - 1;
int n, k;
int p[MAX_N];
vector<int> dat[ST_SIZE];

void init(int k, int l, int r) {
    if (r - l == 1) {
        dat[k].push_back(p[l]);
    }
    else {
        int lch = k * 2 + 1, rch = k * 2 + 2;
        init(lch, l, (l + r) / 2);
        init(rch, (l + r) / 2, r);
        dat[k].resize(r - l);

        merge(dat[lch].begin(), dat[lch].end(),
              dat[rch].begin(), dat[rch].end(), dat[k].begin());
    }
}

P query(int i, int j, int k, int l, int r) {
    if (j <= l || r <= i) {
        return P(MAX_N + 1, 0);
    }
    else if (i <= l && r <= j) {
        return P(dat[k].front(), dat[k].back());
    }
    else {
        P lp = query(i, j, k * 2 + 1, l, (l + r) / 2);
        P rp = query(i, j, k * 2 + 2, (l + r) / 2, r);
        return P(min(lp.first, rp.first), max(lp.second, rp.second));
    }
}

int main() {
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++) scanf("%d", &p[i]);
    vector<int> v;
    int cnt = 0;
    for (int i = 0; i < n - 1; i++) {
        if (p[i] < p[i + 1]) cnt++;
        else {
            if (cnt >= k - 1) {
                for (int j = i - cnt; j <= i - k + 1; j++) {
                    v.push_back(j);
                }
            }
            cnt = 0;
        }
    }
    if (cnt >= k - 1) {
        for (int i = n - 1 - cnt; i <= n - k; i++) {
            v.push_back(i);
        }
    }

    init(0, 0, n);
    int ans = n - k + 1;
    if (v.size() >= 2) ans -= v.size() - 1;
    vector<int>::iterator it = v.begin();
    for (int i = 0; i <= n - k - 1; i++) {
        if (it != v.end() && i == *it) {
            it++;
            continue;
        }
        P a = query(i, i + k, 0, 0, n);
        P b = query(i + 1, i + k + 1, 0, 0, n);
        if (a.first == p[i] && b.second == p[i + k]) ans--;
    }

    printf("%d\n", ans);
    return 0;
}
    


Measured memory_bytes: 37748
// Copyright 2019 yaito3014
#include "bits/stdc++.h"
using namespace std;
using namespace literals;

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int A, B;
  cin >> A >> B;
  int ans = -1;
  if (A <= 9 && B <= 9)ans = A * B;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define sb __builtin_popcount
#define MOD (ll)1000000007
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string n;
    cin >> n;
    ll k;
    cin >> k;
    ll s = n.size();
    ll dp[s + 5][k + 5][2];
    memset(dp, 0, sizeof(dp));
    for (ll i = 1; i < n[0] - '0'; i++)
    {
        dp[1][1][1]++;
    }
    dp[1][1][0]++;
    dp[1][0][1]++;
    for (ll i = 2; i <= s; i++)
    {
        for (ll l = 0; l <= k; l++)
        {
            dp[i][l + 1][1] += dp[i - 1][l][1] * 9ll;
            dp[i][l][1] += dp[i - 1][l][1];
            for (ll j = 1; j < n[i - 1] - '0'; j++)
            {
                dp[i][l + 1][1] += (dp[i - 1][l][0]);
            }
            if (n[i - 1] != '0')
            {
                dp[i][l + 1][0] += dp[i - 1][l][0];
                dp[i][l][1] += dp[i - 1][l][0];
            }
            else
            {
                dp[i][l][0] += dp[i - 1][l][0];
            }
        }
    }
    cout << dp[s][k][0] + dp[s][k][1] << endl;
}

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

int main()
{
    int i,num,len,sum=0;
    char str[1000000];
    scanf("%s",str);
    len = strlen(str);
    for(i=0; i<len; i++)
    {
        num = str[i] - '0';
        sum+=num;
    }
    if(sum%9==0) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 1808
n,k,q = map(int,input().split())
a = [int(input()) for i in range(q)]
player_point = [q]*n

for i in range(q):
    player_point[a[i]-1] -= 1

for i in range(n):
    if player_point[i] < k:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 10472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()


int main(){
  int n,c,k;cin>>n>>c>>k;
  int t[n];rep(i,n)cin>>t[i];
  sort(t,t+n);
  P stock=P(-1,0);
  int ans=0;
  rep(i,n){
    if(stock.first>=t[i]&&stock.first<=t[i]+k&&stock.second>0){
      --stock.second;
    }
    else{
      stock=P(t[i]+k,c-1);
      ++ans;
    }
  }
  cout<<ans<<endl;
}





Measured memory_bytes: 640
import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0

for i in range(N-1):
    for j in range(i+1, N):
        a = L[i]
        b = L[j]
        l = bisect.bisect_right(L, abs(a-b))
        r = bisect.bisect_left(L, a+b)
        ans += r-l
        if L[l] <= a <= L[r-1]:
            ans -= 1
        if L[l] <= b <= L[r-1]:
            ans -= 1
        
print(ans//3)

Measured memory_bytes: 51676
// ALDS1_8_A: Binary Search BST 1

use std::cell::RefCell;
use std::rc::Rc;
use std::str::FromStr;

fn scan<T: FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

enum BST {
    Node {
        key: i64,
        left: Rc<RefCell<BST>>,
        right: Rc<RefCell<BST>>,
    },
    Nil
}

impl BST {
    fn new() -> BST {
        BST::Nil
    }
    fn insert(&mut self, k: i64) {
        match *self {
            BST::Nil => {
                *self = BST::Node {
                    key: k,
                    left: Rc::new(RefCell::new(BST::Nil)),
                    right: Rc::new(RefCell::new(BST::Nil)),
                }
            },
            BST::Node {
                ref mut key,
                ref mut left,
                ref mut right,
            } => {
                if k < *key {
                    left.borrow_mut().insert(k);
                } else {
                    right.borrow_mut().insert(k);
                }
            }
        }
    } 
    fn inorder(&self) {
        match *self {
            BST::Nil => {},
            BST::Node {
                ref key,
                ref left,
                ref right,
            } => {
                left.borrow().inorder();
                print!(" {}", key);
                right.borrow().inorder();
            }
        }
    }
    fn preorder(&self) {
        match *self {
            BST::Nil => {},
            BST::Node {
                ref key,
                ref left,
                ref right,
            } => {
                print!(" {}", key);
                left.borrow().preorder();
                right.borrow().preorder();
            }
        }
    }
}

fn main() {
    let n = scan::<usize>();
    let mut t = BST::new();
    for _ in 0..n {
        let s: String = scan();
        let mut it = s.split_whitespace();
        let com = it.next().unwrap();
        if com == "insert" {
            let x: i64 = it.next().unwrap().parse().ok().unwrap();
            t.insert(x);
        } else if com == "print" {
            t.inorder();
            println!();
            t.preorder();
            println!();
        }
    }
}


Measured memory_bytes: 52128
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll inf=0x7F7F7F7F7F7F7F7F;
ll n,wz,w[110],v[110],dp[100010];
inline int read(){
     int x=0,f=1;char ch=getchar();
     while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
     while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
     return x*f;
 }
int main ( )
{
	n=read();wz=read();
	for(int i=1;i<=n;i++) w[i]=read(),v[i]=read();
	memset(dp,inf,sizeof(dp));dp[0]=0;
	for(int i=1;i<=n;i++)
	  for(int j=100000;j>=v[i];j--)
	    dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
    for(int i=100000;i>=0;i--)
      if(dp[i]<=wz)
      {
      	cout<<i;
      	break;
	  }
	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define out(x) cout << x << '\n'
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
//---------------------------------------------------------------------------------------------------
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
//---------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------
void solve()
{
  lli a = 0, b = 0, c = 0, h = 0, n = 0, w = 0, ans = 0, count = 0;
  string s = "", t = "";
  vector<pair<lli, lli>> pr;
  map<lli, lli> mp;
  set<lli> st;

  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  cin >> s;
  t = s;
  SORT(t);
  rep(i, 0, n)
  {
    if (s[i] != t[i])
    {
      ans++;
    }
  }
  ans /= 2;
  out(ans);
}

//---------------------------------------------------------------------------------------------------
signed main()
{
  solve();
}


Measured memory_bytes: 3856
#include <stdio.h>
int main(void){
    int a, b, flag;
    scanf("%d%d", &a, &b);
    flag=b%a;
    if(flag){
        printf("%d\n", b-a);
    }else{
        printf("%d\n", a+b);
    }
    
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
//printf("%.12Lf\n",c);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int primes[200];
int prime[1000000];
int pr[100000];
int el[314514],wl[314514];
int er[314514],wr[314514];
int a[114514];
int b[214514],c[214514];
int n2[41];
int nis[41]; 
int nia[41];
int mody[41];
signed main(){
	ic(n) ic(x) ic(y)
	int ni=1;
	rep(0,i,41){
		n2[i]=ni;
		ni*=2;
	}
	int nn=n;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	ni=2;
	rep(0,i,41){
		nia[i]=ni;
		ni=(ni*ni)%mod;
	}
	ni=2;
	rep(0,i,41){
		if(nis[i]==1){
			ni=(ni*nia[i])%mod;
		}
	}
	int ans1=ni-1;
	
	int bunsi=1,bunbo=1;
	rep(0,i,x)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,x)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	int ans2=bunsi;	
	
	bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	int ans3=bunsi;
	
	c(((mod+(mod+ans1-ans2)%mod-ans3))%mod)
}	

Measured memory_bytes: 256
# 075B
h,w = map(int, input().split())
ss = [list(map(str,str(input()))) for _ in range(h)]
# print(ss)
def count_bombs(ss,i,j):
    count=0
    if ss[i][j]=='#':
        return '#'
    for y in [-1,0,1]:
        for x in [-1,0,1]:
#             print(i+y, x+j, count)
            if 0<=i+y<h and 0<=j+x<w and ss[i+y][j+x]=='#':
                count+=1
    return str(count)

for i in range(h):
    for j in range(w):
        ss[i][j] = count_bombs(ss,i,j)
#         print('## ',i,j,ss[i][j])
for s in ss:
    print(''.join(s))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;
struct edge {int to,costa,costb;};


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

int ans=n,a,m;
for(int i=0;i<=n;i++){
    a=0;m=i;
    while(m){
        a+=m%6;
        m/=6;
    }
    m=n-i;
    while(m){
        a+=m%9;
        m/=9;
    }
    ans=min(ans,a);

}
cout<<ans;




return 0;
}


Measured memory_bytes: 256
import sys

def main():
    l = input().split()
    a = int(l[0])
    b = int(l[1])

    if a <= 0 and b >= 0:
        print("Zero")
    elif a > 0:
        print("Positive")
    elif b < 0:
        if (b - a) % 2 != 0:
            print("Positive")
        else:
            print("Negative")

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#define lp(i,n) for(int i=0;i<n;i++)
#define pau system("pause")
#include<bits/stdc++.h>

using namespace std;
int main() {
   int H,W,h,w;
   cin>>H>>W>>h>>w;
   cout<<(H-h)*(W-w)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
using namespace std;

//#define FILE_INPUT
//#define DEBUG_MODE

void DebugPrint(vector<int> &a, int n)
{
#ifdef DEBUG_MODE
	for (int i = 0; i < min(20, n); ++i) {
		cout << a[i] << ",";
	}
	cout << endl;
#endif
}

int main()
{
#ifdef FILE_INPUT
	ifstream in("test3.txt");
	cin.rdbuf(in.rdbuf());
#endif	/* FILE_INPUT */  

	static const long long int MOD = 1000000007;
	int n, k;
	cin >> n >> k;

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

	vector<vector<int>> dp(n + 1, vector<int>(k + 1, 0));

	vector<long long int> acc(k + 1);

	dp[0][0] = 1;
	DebugPrint(dp[0], k + 1);
	for (int loop = 1; loop <= n; ++loop) {
		long long int sum = 0;
		for (int i = 0; i <= k; ++i) {
			sum += dp[loop - 1][i];
			acc[i] = sum;
		}
		for (int i = 0; i <= k; ++i) {
			if (i - a[loop - 1] - 1 < 0) {
				dp[loop][i] = acc[i] % MOD;
			}
			else {
				dp[loop][i] = (acc[i] - acc[i - a[loop - 1] - 1]) % MOD;
			}
		}
		DebugPrint(dp[loop], k + 1);
	}

	cout << dp[n][k] << endl;

	return 0;
}


Measured memory_bytes: 40696
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch StudyScheduling | diff StudyScheduling.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address StudyScheduling.cpp && ./a.out

/*

 5/30/2020

 5:00-

 */

int h1,m1,h2,m2,k;

void solve() {
  int d=h2*60+m2-(h1*60+m1);
  int res=d-k;
  cout<<res<<endl;
}

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

  cin>>h1>>m1>>h2>>m2>>k;
  solve();

  return 0;
}


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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

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

fn main() {
    input!{
        s: chars
    }
    let mut ans = 0;
    let mut c = 0;
    for &a in &s {
        if a == 'S' {
            c += 1;
        } else if c == 0 {
            ans += 1;
        } else {
            c -= 1;
        }
    }
    ans += c;
    println!("{}", ans);
}


Measured memory_bytes: 4476
#include<cstdio>

int main(){
  int a, b;
  while(true){
    scanf("%d %d", &a, &b);
    if(a == 0 && b == 0) break;
    for(int i = 3; i <= a+2; i++){
      for(int j = 3; j <= b+2; j++){
	if(i % 2 == 1){
	  if(j % 2 == 1){
	    printf("#");
	  }
	  else{
	    printf(".");
	  }
	}
	else{
	  if(j % 2 == 0){
	    printf("#");
	  }
	  else{
	    printf(".");
	  }
	}
      }
      printf("\n");
    }
    printf("\n");
  }
}

Measured memory_bytes: 1000