akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#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--)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
#define INF 1000000000000 
#define MOD 1000000007 
#define MAXR 100000 
#define PB push_back 
#define MP make_pair 
#define F first 
#define S second 
#define Umap unordered_map
#define Uset unordered_set


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

    ll N;
    cin >> N;

    ll ans = 0;
    FOR(j, 1, N+1) {
        ll n_baisu = N/j;
        ll g_j = n_baisu*(1+n_baisu)*j/2;
        ans += g_j;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const unsigned int M = 1000000007;
int data[105];
void sum(){
    data[0]=0,data[1]=1;
    for(int i=2;i<105;i++){
        data[i]=data[i-1]+i;
    }
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    char a[11],b[11],c[11];
    while(cin>>a>>b>>c){
        if(a[strlen(a)-1]==b[0] && b[strlen(b)-1]==c[0])cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

template<class T> class BIT {
private:
    vector<T> bit;
public:
    BIT(int n) : bit(vector<T>(n+1, 0)) {}
    int sum(int i) {
        if (!i) return 0;
        return bit[i] + sum(i-(i&-i));
    }
    void add(int i, int x) {
        if (i > size()) return;
        bit[i] += x;
        add(i+(i&-i), x);
    }
    int size() const { return bit.size()-1; }
};

int main()
{
    int N; cin >> N;
    vector<BIT<int>> vbit(26, BIT<int>(N));

    string S; cin >> S;
    rep(i, N) {
        int a = S[i] - 'a';
        vbit[a].add(i+1, 1);
    }
    int Q; cin >> Q;
    rep(q, Q) {
        int t; cin >> t;
        if (t == 1) {
            int i;
            char c;
            cin >> i >> c;
            if (S[i-1] != c) {
                int a = S[i-1] - 'a';
                int b = c - 'a';
                vbit[a].add(i, -1);
                vbit[b].add(i, 1);
                S[i-1] = c;
            }
        } else {
            int l, r; cin >> l >> r;
            int ans = 0;
            for (int k = 0; k < 26; k++) {
                int s = vbit[k].sum(r) - vbit[k].sum(l-1);
                if (s > 0) ans++;
            }
            cout << ans << endl;
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}


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

    auto mp = prime_factor(n);

    ll ans = 0;
    for(auto e:mp){
        //DEBUG2(e.first, e.second);
        int k=1;
        int cnt = 1;
        while(cnt <= e.second){
            //DEBUG(k);
            ans += 1;
            k+=1;
            cnt += k;
            
        }
        
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(readline())
A = list(map(int, readline().split()))

from collections import defaultdict
d = defaultdict(int)
for a in A:
    lower = a - 1
    upper = a + 1
    if lower >= 0:
        d[lower] += 1
    d[a] += 1
    d[upper] += 1

ans = 0
for k, v in d.items():
    ans = max(ans, v)
print(ans)

Measured memory_bytes: 19792
#include <iostream>
#include <string>
#include <queue>
using namespace std;

struct process{
    string name;
    int time;
};

int main(void){
    int n, q;
    cin >> n >> q;
    queue<process> src, dst;
    for(int i = 0; i < n; ++i){
        process tmp;
        cin >> tmp.name >> tmp.time;
        src.push(tmp);
    }
    
    int endtime = 0;
    while(!src.empty()){
        process check = src.front();
        src.pop();
        if(check.time > q){
            check.time -= q;
            src.push(check);
            endtime += q;
        }
        else{
            endtime += check.time;
            check.time = endtime;
            dst.push(check);
        }
    }
    
    while(!dst.empty()){
        cout << dst.front().name << " " << dst.front().time << endl;
        dst.pop();
    }
    
    return 0;
}

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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

int main() {
    ll n, a, b;
    cin >> n >> a >> b;

    ll ab = a + b;

    ll p = n / ab;

    ll q = n % ab;
    q = min(q, a);


    cout << p * a + q << endl;

}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ');
        var A = int.Parse(inputs[0]);
        var B = int.Parse(inputs[1]);
        var cost = 0;
        if (A >= 13)
        {
            cost = B;
        }
        else if (6 <= A && A <= 12)
        {
            cost = B / 2;
        }
        else
        {
            cost = 0;
        }

        Console.WriteLine(cost);
    }

}



Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)

using namespace std;
typedef long long ll;
const ll N=33e3,mo=998244353,ZD=32768;

ll f[N],g[N],t[N],bits[N];
ll w[N],ny[N],jc[N];
int n,m,ss,mm;

inline ll ksm(ll o,ll t)
{
	ll y=1;
	for(;t;t>>=1,o=o*o%mo)
	if(t&1)y=y*o%mo;
	return y;
}

inline void prepare()
{
	fo(i,0,mm-1)bits[i]=(bits[i>>1]>>1)|((i&1)<<(ss-1));
	w[0]=1; w[1]=ksm(3,(mo-1)/ZD);
	fo(i,2,ZD)w[i]=w[i-1]*w[1]%mo;
}

inline ll C(ll a,ll b)
{return jc[a]*ny[b]%mo*ny[a-b]%mo;}

inline void dft(ll *a,int sig)
{
	fo(i,0,mm-1)if(bits[i]<i)swap(a[bits[i]],a[i]);
	for(int m=2,D=ZD>>1;m<=mm;m<<=1,D>>=1){
		int half=m>>1;
		fo(i,0,half-1){
			ll v=(sig==1)?(w[D*i]):(w[ZD-D*i]),u;
			for(int j=i;j<mm;j+=m){
				u=v*a[j+half]%mo;
				a[j+half]=(a[j]-u+mo)%mo;
				a[j]=(a[j]+u)%mo;
			}
		}
	}
	if(sig==-1){
		ll nn=ksm(mm,mo-2);
		fo(i,0,mm-1)a[i]=a[i]*nn%mo;
	}
}

int main()
{
	scanf("%d%d",&n,&m);
	f[0]=jc[0]=ny[0]=1;
	fo(i,1,n+2)jc[i]=jc[i-1]*i%mo;
	ny[n+2]=ksm(jc[n+2],mo-2);
	fd(i,n+1,1)ny[i]=ny[i+1]*(i+1)%mo;
	ss=0,mm=1;
	while(mm<=2*n)mm<<=1,++ss;
	prepare();
	fo(j,1,m){
		fo(i,0,mm-1)t[i]=g[i]=0;
		fo(i,0,n)t[i]=f[i]*ny[i]%mo;
		fo(i,1,n)g[i]=ny[i+2];
		dft(t,1);	dft(g,1);
		fo(i,0,mm-1)g[i]=t[i]*g[i]%mo;
		dft(g,-1);
		fo(i,1,n)g[i]=g[i]*jc[i+2]%mo;
		fo(i,1,n)f[i]=(g[i]+f[i]*(C(i+1,2)+1))%mo;
	}
	ll ans=1;
	fo(i,1,n)ans=(ans+f[i]*C(n,i))%mo;
	cout<<ans;
}

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

int main(){
    int unit_price;
    int number;
    int sum = 0;
    int number_sum = 0;
    int cnt = 0;
    int average;


    while(scanf("%d,%d", &unit_price, &number) != EOF){
        sum += unit_price * number;
        number_sum += number;
        cnt++;
    }
    average = (int)((double)number_sum / cnt + 0.5);

    cout << sum << endl;
    cout << average << endl;

    return 0;
}

Measured memory_bytes: 0
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
            }
            long mx1 = 0;
            long mx2 = 0;
            Arrays.sort(a);
            for (int i = a.length - 1; i > 0; i--) {
                if (a[i] == a[i - 1]) {
                    if (mx1 == 0) {
                        mx1 = a[i];
                        i--;
                    } else {
                        mx2 = a[i];
                        break;
                    }
                }
            }
            out.println(mx1 * mx2);
        }

    }
}



Measured memory_bytes: 48480
// https://atcoder.jp/contests/abc158/tasks/abc158_d
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;
#define lli int

int main()
{
    lli q,t,f,cnt=0;
    string s,st,en;
    char c;
    cin>>s;
    cin>>q;
    st="";
    en="";
    while(q--)
    {
        cin>>t;
        if(t==1)
        {
            cnt++;
        }
        else
        {
            cin>>f>>c;
            if(f==1)
            {
                if(cnt&1)
                    en=en+c;
                else
                    st=c+st;
            }
            else
            {
                if(cnt&1)
                    st=c+st;
                else
                    en=en+c;
            }
        }
    }
    s=st+s+en;
    if(cnt&1)
        reverse(s.begin(),s.end());
    cout<<s<<"\n";
    return 0;
}

Measured memory_bytes: 4516
#include<bits/stdc++.h>
 
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
 
#define IN_REP          int tt; cin >> tt; while(tt--)
#define sim             template<class T
#define ris 						return * this
#define dor 						> debug & operator <<
#define eni(x) 			sim > typename enable_if<sizeof dud<T>(0) x 1, debug&>::type operator<<(T i)
sim > struct rge { T b, e; };
sim > rge<T> range(T i, T j) { return rge<T>{i, j}; }
sim > auto dud(T* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
	eni(!=) { cerr << boolalpha << i; ris;}
	eni(==) { ris << range(begin(i), end(i)); }
	sim, class U dor(pair<U,T> d) { ris << "(" << d.first << ", " << d.second << ")"; }
	sim dor(rge<T> d) {
		*this << "[";
		for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it;
		ris << "]";
	}
#else
  sim dor(const T&) { ris; }
#endif
};
#define pr(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define F               first
#define S               second
#define all(a)          std::begin(a), std::end(a)
#define sz(x)           (ll)(x).size()
#define IOS             ios::sync_with_stdio(false);cin.tie(NULL)
#define EPS             (ld) 1e-9
const ll MOD = (ll) 1e9 + 7;
const ld PI = acos(-1);
sim>T gcd(T x, T y) {return (y==0) ? x : gcd(y, x % y);}
sim>void mini(T &a, T b) { a = min(a, b); }
sim>void maxi(T &a, T b) { a = max(a, b); }
sim>T mul(T x, T y) {return (x * y) % MOD;}
sim>inline T power(T a, T b) {T res = 1;while (b > 0) {if (b&1) { res = mul(res, a); }a = mul(a, a);b >>= 1;}return res%MOD;}
sim>inline T modInverse(T n) { return power(n, MOD - 2, MOD) % MOD; }
string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
sim, class U>string to_string(pair<T, U> p) {return to_string(p.F) + " " + to_string(p.S);}

const int MX = (int) 6e3 + 5;
 
int main(int argc, char** argv){
    int n;
    cin >> n;
    ld res = 0.0;
    for(int i = 0; i < n; ++i) {
        double x;
        cin >> x;
        res += 1.0/x;
    }
    cout << setprecision(10) <<  (1/res) << endl;
    return 0;
}
 


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

long long N, x[100009], y[100009], dp[100009][2], mod = 1000000007; vector<int>X[100009]; bool used[100009];

void dfs(int pos) {
	used[pos] = true; vector<int>V;
	for (int i = 0; i < X[pos].size(); i++) {
		if (used[X[pos][i]] == false) { dfs(X[pos][i]); V.push_back(X[pos][i]); }
	}
	long long V1 = 1, V2 = 1;
	for (int i = 0; i < V.size(); i++) {
		V1 *= (dp[V[i]][0] + dp[V[i]][1]); V1 %= mod;
		V2 *= dp[V[i]][0]; V2 %= mod;
	}
	dp[pos][0] = V1;
	dp[pos][1] = V2;
	return;
}

int main() {
	cin >> N;
	for (int i = 1; i <= N - 1; i++) {
		cin >> x[i] >> y[i];
		X[x[i]].push_back(y[i]);
		X[y[i]].push_back(x[i]);
	}
	dfs(1); // 0 = 白, 1 = 黒
	cout << (dp[1][0] + dp[1][1]) % mod << endl;
	return 0;
}

Measured memory_bytes: 15872
// Isaunoya
#include<bits/stdc++.h>
using namespace std ;
using LL = long long ;
using uint = unsigned int ;
#define int long long
#define fir first
#define sec second
#define pb push_back
#define mp(x , y) make_pair(x , y)
template < typename T > inline void read(T & x) { x = 0 ; int f = 1 ; register char c = getchar() ;
  for( ; ! isdigit(c) ; c = getchar()) if(c == '-') f = -1 ;
  for( ; isdigit(c) ; c = getchar()) x = (x << 1) + (x << 3) + (c & 15) ;
  x *= f ;
}
template < typename T > inline void print(T x) {
  if(! x) { putchar('0') ; return ; }
  static int st[105] ;
  if(x < 0) putchar('-') , x = -x ;
  int tp = 0 ;
  while(x) st[++ tp] = x % 10 , x /= 10 ;
  while(tp) putchar(st[tp --] + '0') ;
}
template < typename T > inline void print(T x , char c) { print(x) ; putchar(c) ; }
template < typename T , typename ...Args > inline void read(T & x , Args & ...args) { read(x) ; read(args...) ; }
template < typename T > inline void sort( vector < T > & v) { sort(v.begin() , v.end()) ; return ; }
template < typename T > inline void unique( vector < T > & v) { sort(v) ; v.erase(unique(v.begin() , v.end()) , v.end()) ; }
template < typename T > inline void cmax(T & x , T y) { if(x < y) x = y ; return ; }
template < typename T > inline void cmin(T & x , T y) { if(x > y) x = y ; return ; }
const int Mod = LLONG_MAX ;
inline int QP(int x , int y) { int ans = 1 ;
  for( ; y ; y >>= 1 , x = (x * x) % Mod)
    if(y & 1) ans = (ans * x) % Mod ;
  return ans ;
}
template < typename T > inline T gcd(T x , T y) { if(y == 0) return x ; return gcd(y , x % y) ; }
template < typename T > inline T lcm(T x , T y) { return x * y / gcd(x , y) ; }
template < typename T > inline void mul(T & x , T y) { x = 1LL * x * y ; if(x >= Mod) x %= Mod ; }
template < typename T > inline void add(T & x , T y) { if((x += y) >= Mod) x -= Mod ; }
template < typename T > inline void sub(T & x , T y) { if((x -= y) < 0) x += Mod ; }

signed main() {
  int n ; read(n) ;
  int f = 0 , f2 = 0 ;
  for(register int i = 1 ; i <= sqrt(n) ; i ++)
    if(! (n % i)) f = i , f2 = n / i ;
  print(f + f2 - 2) ;
  return 0 ;
}

Measured memory_bytes: 256
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int CalcNumOfDigits(LL x)
{
    int ans = 0;
    while (x > 0)
    {
        x /= 10;
        ++ans;
    }
    return ans;
}

LL F(LL A, LL B)
{
    return max(CalcNumOfDigits(A), CalcNumOfDigits(B));
}

int main()
{
    LL N;
    cin >> N;
    LL ans = 11;
    for (LL A = 1; A * A <= N; ++A)
    {
        if (N % A == 0)
        {
            LL B = N / A;
            ans = min(ans, F(A, B));
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;

void solve();

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

void solve()
{
    string s, t;
    in2(s, t);
    int ans = 0;
    rep(i, 3)
    {
        if (s[i] == t[i])
        {
            ans++;
        }
    }
    out(ans);
}

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

using namespace std;


int main(void)
{
	int n;
	cin>>n;
	char s[n];
	cin>>s;
	int len = strlen(s);
	int i,count;
	count = 0;
	for(i = 0; i < len-2; i++){
		if(s[i] == 'A' && s[i+1] == 'B' &&s[i+2] == 'C')
		{
			count++;
		}
		//cout<<"i = "<<i<<" s[i] = "<<s[i]<<endl;
	}
	cout<<count<<endl;
	return 0;
}




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

const int mod = 1e9 + 7;
const int maxn = 2005;

void add(int &a, int b){
    a += b;
    if(a >= mod)
        a -= mod;
}

int n, k;
int dp[maxn][maxn];

void solve(){
    int power = 1;
    for(int i = 1;i <= n - k - 1;i++){
        power = power * 2 % mod;
    }
    memset(dp, 0, sizeof(dp));
    dp[n + 1][0] = 1;
    for(int i = n;i >= 1;i--){
        for(int j = 0;j <= n;j++){
            add(dp[i][j + 1], dp[i + 1][j]);
        }
        for(int j = n;j >= 1;j--){
            add(dp[i][j - 1], dp[i][j]);
        }
    }
    int ans = 1LL * dp[2][n - k] * power % mod;
    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> k;
    solve();
    return 0;
}


Measured memory_bytes: 16000
#include<iostream>
#include<cmath>
using namespace std;
#define inf pow(10, 9)
int main() {
    int n, k; cin >> n >> k;
    int h[n];
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    long long dp[n];
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < n; ++i) {
        dp[i] = inf;
    }
    for (int i = 2; i < n; ++i) {
        for (int j = max(i - k, 0); j <= i - 1; ++j) {
            if (dp[j] + abs(h[i] - h[j]) < dp[i]) {
                dp[i] = dp[j] + abs(h[i] - h[j]);
            }
        }
    }
    cout << dp[n - 1] << endl;
    return 0;
}



Measured memory_bytes: 1408
n = gets.to_i
words = []
blue_words = []
red_words = []
for i in 1..n
  s = gets.chomp
  words << s
  blue_words << s
end
m = gets.to_i
for i in 1..m
  t = gets.chomp
  words << t
  red_words << t
end
words.uniq!

sums = []
words.each do |w|
#   p "#{blue_words.count(w)} #{red_words.count(w)}"
  sums << blue_words.count(w) - red_words.count(w)
end

if sums.all?{|item| item < 0}
  puts 0
  exit
end
puts sums.max

Measured memory_bytes: 1788
A,B,C=map(int,input().split())
if A<B:
    while True:
        if A==C:
            print("Yes")
            break
        if A==B:
            print("No")
            break
        A+=1
if B<A:
    while True:
        if A==C:
            print("Yes")
            break
        if A==B:
            print("No")
            break
        A-=1

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

int main(){
  while(true){
    string s;
    cin>>s;
    if(s=="0")break;
    string sr(s.size(),'r');
    string sg(s.size(),'g');
    string sb(s.size(),'b');
    map<string,int> mp;
    queue<string> q;
    q.push(s);
    mp[s]=0;
    int f=0;
    if(s==sr||s==sb||s==sg){
      cout<<0<<endl;
    }else{
      //for(int i=0;i<1e6;i++){
      while(!q.empty()){
        string x=q.front();
        q.pop();
        for(int j=0;j<s.size()-1;j++){
          string y=x;
          if(y[j]=='r'&&y[j+1]=='g'){
            y[j]='b';
            y[j+1]='b';
          }else if(y[j]=='b'&&y[j+1]=='g'){
            y[j]='r';
            y[j+1]='r';
          }else if(y[j]=='r'&&y[j+1]=='b'){
            y[j]='g';
            y[j+1]='g';
          }else if(y[j]=='g'&&y[j+1]=='b'){
            y[j]='r';
            y[j+1]='r';
          }else if(y[j]=='g'&&y[j+1]=='r'){
            y[j]='b';
            y[j+1]='b';
          }else if(y[j]=='b'&&y[j+1]=='r'){
            y[j]='g';
            y[j+1]='g';
          }
          //cout<<mp[x]+1<<" "<<y<<endl;
          if(y==sr||y==sb||y==sg){
            cout<<mp[x]+1<<endl;
            f=1;
            break;
          }
          if(mp.count(y)==0){
            mp[y]=mp[x]+1;
            q.push(y);
          }
        }
        if(f)break;
      }
      if(!f)cout<<"NA"<<endl;
    }
  }
}



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

#define ll          long long
#define mp	    make_pair
#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 x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
vector<string> v, k;
void solve(){
	int n;
	cin>>n;
	rep(i,0,n){
		string s;
		cin>>s;
		v.pb(s);
	}
	k = v;
	sort(all(k));
	rep(i,1,n){
		if(k[i] == k[i-1]){
			cout<<"No"<<endl;
			return;
		}
	}
	rep(i, 1, sz(v)){
		if(v[i][0] != v[i-1][sz(v[i-1])-1]){
			cout<<"No"<<endl;
			return;
		}
	}
	cout<<"Yes"<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
     t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
import sys


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    forward = 0
    for i in range(n):
        if a[i] < forward:
            ans += forward - a[i]
        else:
            forward = a[i]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 30652
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class Doit {
    static IEnumerable<int> rep(int a, int b) {
        return Enumerable.Range(a, b);
    }
    
    static void Main() {
	var n = int.Parse(ReadLine());

	long x = 1;
	long y = 1;

	foreach (var i in rep(0, n)) {
	    var l = ReadLine().Split();
	    var t = long.Parse(l[0]);
	    var a = long.Parse(l[1]);

	    var m = Max((x - 1) / t, (y - 1) / a) + 1;
	    x = m * t;
	    y = m * a;
	}

	WriteLine("{0}", x + y);
    }
}


Measured memory_bytes: 2904
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 99999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    llong n;
    cin >> n;
    char s[1000001],a;
    rep(i,n){
        cin >> a;
        if(i>0 && a == s[i-1]){
            i--;
            n--;
        }else{
            s[i] = a;
        }
    }
    cout << strlen(s) << endl;
}

Measured memory_bytes: 384
import java.util.*;

public class Main
{
	public static void main(String Args[])
	{
		int m,n;
		Scanner s1=new Scanner(System.in);
		n=s1.nextInt();
		m=s1.nextInt();
		Vector<Integer> v= new Vector<Integer>();
		for(int i=0; i<n+1; i++)
		{
			v.add(-1);
		}
		if(n==1 && m==0)
		{
			System.out.println("0");
		}
		else 
		{
			for(int i=0;i<m;i++)
			{
				int pos,num;
				pos=s1.nextInt();
				num=s1.nextInt();
				
				if(v.get(pos)==-1)
				{
					v.set(pos,num);
				}
				else if(v.get(pos)!=num)
				{
					System.out.println("-1");
					System.exit(0);
				}
			}
			if(v.get(1)==0 && n==1)
			{
				System.out.println("0");
			}
			else if(v.get(1)==0 && n!=1)
			{
				System.out.println("-1");
			}
			else
			{
				for(int j=1;j<n+1;j++)
				{
					if(v.get(j)==-1)
					{
						if(j==1)
						{
							System.out.print("1");
						}
						else
						{
							System.out.print("0");
						}
					}
					else
					{
						System.out.print(v.get(j));
					}
				}
			}				
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
const int mod = 1e9 + 7;
using namespace std;
int a[100000];
int dp[100000];
int main() {
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		cin >> a[i];
	}
	dp[0] = 1;
	int j = 0;
	if(a[j] != 1) dp[1] = 1;
	else j++;
	for(int i = 2; i <= n; i++) {
		dp[i] = (dp[i - 1] % mod + dp[i - 2] % mod) % mod;
		if(i == a[j]) {
			dp[i] = 0;
			j++;
		}
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		List<String> prezent = new ArrayList<String>();
		
		
		for(int i=0;i<n;i++) {
			String s = scan.next();
			prezent.add(s);
		}
		List<String> answer = new ArrayList<String>(new HashSet<>(prezent));
		
		System.out.println(answer.size());		
		
	}	
	
	
	//最小公約数
	/*
	static int gcd (int a, int b) {
		int temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	*/
	
}

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

int main() {
  int A, B, M; cin >> A >> B >> M;
  vector<int> a(A), b(B);
  for (int i = 0; i < A; i++) cin >> a.at(i);
  for (int i = 0; i < B; i++) cin >> b.at(i);
  vector<vector<int>> xyc(M, vector<int>(3));
  for (int i = 0; i < M; i++) {
    cin >> xyc.at(i).at(0) >> xyc.at(i).at(1) >> xyc.at(i).at(2);
  }
  int ans = 1000000007;
  for (int i = 0; i < M; i++) {
    int tmp = a.at(xyc.at(i).at(0) - 1) + b.at(xyc.at(i).at(1) - 1) - xyc.at(i).at(2);
    ans = min(ans, tmp);
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  int tmp2 = a.at(0) + b.at(0);
  ans = min(ans, tmp2);
  cout << ans << endl;
}

Measured memory_bytes: 6528
using System;

class MyClass
{
    public static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        for (int i = 0; i < N; i++)
        {
            var input = Console.ReadLine().Split();
            var data = new double[6];
            for (int j = 0; j < 6; j++)
            {
                data[j] = double.Parse(input[j]);
            }
            // data[0] : x_a
            // data[1] : y_a
            // data[2] : r_a
            // data[3] : x_b
            // data[4] : y_b
            // data[5] : r_b
            var d = Math.Sqrt(Math.Pow(data[0] - data[3], 2) + Math.Pow(data[1] - data[4], 2));
            if (data[2] > d + data[5])
            {
                Console.WriteLine(2);
            }
            else if (data[5] > d + data[2])
            {
                Console.WriteLine(-2);
            }
            else if (d > data[2] + data[5])
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(1);
            }
        }
    }
}


Measured memory_bytes: 13916
#!/usr/bin/env python
# coding: utf-8

# In[8]:


N = int(input())
A = list(map(int, input().split()))


# In[9]:


a_abs = list(map(abs,A))
minus_cnt = sum([1 for x in A if x < 0])
if minus_cnt%2 == 0:
    ans = sum(a_abs)
else:
    ans = sum(a_abs) - min(a_abs)*2
print(ans)


# In[ ]:






Measured memory_bytes: 20056
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, M;
  while (cin >> N >> M) {
    vector<int> s(M), c(M);
    for (int i = 0; i < M; i++) cin >> s[i] >> c[i], --s[i];
    vector<int> res(N, -1);
    bool ok = true;
    for (int i = 0; i < M; i++) {
      if (res[s[i]] == -1) {
        res[s[i]] = c[i];
      } else if (res[s[i]] != c[i]) {
        ok = false;
        break;
      }
    }
    if (N > 1 && res[0] == 0) {
      ok = false;
    }
    if (!ok) {
      cout << -1 << endl;
      continue;
    }
    for (int i = 0; i < N; i++) {
      if (res[i] == -1) {
        if (i == 0 && N > 1) {
          res[i] = 1;
        } else {
          res[i] = 0;
        }
      }
    }
    for (int i = 0; i < N; i++) cout << res[i];
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
string S;

void solve() {
	cin >> N;
	cin >> S;
	ll a = 0;
	ll res = 1;
	rep(i, 0, N) MUL(res, i + 1);
	rep(i, 0, N * 2) {
		int b = (S[i] == 'B');
		if(b == a % 2) {
			MUL(res, a);
			a--;
		}
		else a++;
	}
	if(a == 0) cout << res << "\n";
	else cout << 0 << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



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

#define ll long long int
ll mod=1e9+7;

// vector<ll> g[200005];
// ll vis[200005];
// queue<ll> q;
// ll level[200005];

// void dfs(ll i)
// {
//     vis[i] = 1;
//     for(ll j=0;j<g[i].size();j++)
//     {
//         ll child = g[i][j];
//         if(vis[child] == 0)
//         {
//             dfs(child);
//         }
//     }
// }

// void bfs(ll i)
// {
//     vis[i] = 1;
//     while(!q.empty())
//     {
//         ll top = q.front();
//         ll len_adj = g[top].size();
//         ll j;
//         for(j=0;j<len_adj;j++)
//         {
//             ll v = g[top][j];
//             if(vis[v]==0)
//             {
//                 vis[v]=1;
//                 q.push(v);
//                 level[v] = level[top] + 1;
//             }
//         }   
//         q.pop();
//     }
// }

ll modular_exponentiation(ll base, ll power)
{
    ll ans = 1;
    base = base % mod;
    while (power > 0)
    {
        if (power & 1)
        {
            ans = (ans * base) % mod;
        }

        power /= 2;
        base = (base * base) % mod;
    }
    return ans;
}

int main()
{
    /* Faster input ouput */
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);

    /* To read input from a file and output to a file */
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    
    ll t = 1;
    // cin >> t;
    while(t--)
    {        
        ll n,i,j,a,b,c,k;
        cin >> a >> b >> c >> k;
        ll ans = 0;
        
        if(k>0)
        {
            if(k>=a)
            {
                ans += a;
                k -= a;
            }
            else
            {
                ans += k;
                k = 0;
            }
        }

        if(k>0)
        {
            if(k>=b)
            {
                k -= b;
            }
            else
            {
                k = 0;
            }
        }

        if(k>0)
        {
            if(k>=c)
            {
                ans -= c;
                
            }
            else
            {
                ans -= k;
            }
        }

        cout << ans << '\n';


        

        
    }

    
    
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e15;
 
int main() {
  ll n,k;
  cin >> n >> k;
  vec a(n);
  for(ll i=0;i<n;i++) cin >> a[i];
  vec s(n);
  s[0]=a[0];
  for(ll i=0;i<n-1;i++) {
    s[i+1]=s[i]+a[i+1];
  }
  vec p(n);
  p[0]=max(a[0],0LL);
  for(ll i=0;i<n-1;i++) {
    p[i+1]=p[i]+max(a[i+1],0LL);
  }
  ll ans=-inf;
  for(ll i=0;i+k-1<n;i++) {
    ll tmp=0;
    tmp+=s[i+k-1];
    if(i) tmp-=s[i-1];
    tmp=max(tmp,0LL);
    if(i) tmp+=p[i-1];
    if(i+k<n) tmp+=p[n-1]-p[i+k-1];
    ans=max(ans,tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int H = sc.nextInt();
   int[] a= new int[N];
   int[] b= new int[N];
   for(int i=0;i<N;i++)
   {
     a[i]= sc.nextInt();
     b[i]= sc.nextInt();
   }

   Arrays.sort(a);
   Arrays.sort(b);
   
   int amax=a[N-1];
   
   int bcount =N-1;
   int sum = 0;
   
   while(b[bcount]>amax&&sum<H)
   {
     sum+=b[bcount];
     bcount--;
     if(bcount==-1) break;
   }
   int ans = N - bcount - 1 ;
   if(sum<H)
   { 
     if((H-sum)%amax==0) ans+=(H-sum)/amax;
     else ans+=(H-sum)/amax +1;
   }
   
   System.out.println(ans);
 }
}

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

int main() 
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int sum = 0;
    for (int i=0; i<n-2; i++)
        if (s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
            sum++;
    cout << sum;    
    return 0;
}

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

int main() {
	int A, B;
	string S;
	cin >> A >> B >> S;
	for (int i = 0;i < S.size();++i) {
		if (i != A) {
			if (S[i] < '0' || '9' < S[i]) {
				puts("No");
				return 0;
			}
		}
		else {
			if (S[i] != '-') {
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
mycode = r'''
# distutils: language=c++
# cython: language_level=3
# cython: boundscheck=False
# cython: wraparound=False
# cython: infer_types=True
# cython: cdivision=True
# False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが生じます。 True:チェックを行いません。

# define 
ctypedef long long LL
ctypedef LL[:] Arr


import numpy as np

# 読み込みはpython側で行う
import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.readline #文字列読み込む時はこっち


cdef LL a_int(): return int(readline())

def ints(): return np.fromstring(readline(), sep=' ', dtype=np.int64)

cdef LL N=a_int()
cdef Arr A = ints() #memoryviewはnumpyの引数が使えます
A=np.sort(A)[::-1] 
print(np.sum(A[0::2]) - np.sum(A[1::2])) #なんとmemoryviewでもスライスが使える

'''

import sys
if sys.argv[-1] == 'ONLINE_JUDGE':  # コンパイル時
    import os
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode


Measured memory_bytes: 27124
/**
 * C - Rectangle Cutting
 * https://atcoder.jp/contests/abc130/tasks/abc130_c
 * 
 * 方針
 * 求める面積の最大値は W * H / 2
 * 面積が 1/2 になるのは長方形の中心点 (W/2, H/2) を通る時.
 * つまり, x = W/2, y = H/2 の時, 分割方法は複数存在する事になる.
 **/
#include<iostream>

using namespace std;

int W, H, x, y;

void solve() {
    double max_area = (double)W * H / 2;
    int ans_num = (W == x * 2 && H == y * 2) ? 1 : 0;
    cout << max_area << " " << ans_num << endl;
}

int main() {
    cin >> W >> H >> x >> y;
    solve();
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

const int N = 1e5 + 10;;

int a[3][N], n, s[N], d[N], p[N], cnt[2], ds[2];

int tree[N];

void change(int x) { for (; x; x -= x & -x) ++tree[x]; }

int query(int x) { int v = 0; for (; x <= n; x += x & -x) v += tree[x]; return v; }

int main()
{
	gi(n);
	for (int j = 0; j < 3; ++j)
		for (int i = 1; i <= n; ++i)
			gi(a[j][i]);
	for (int i = 1; i <= n; ++i)
	{
		if (a[0][i] == a[1][i] + 1 && a[1][i] == a[2][i] + 1) s[i] = a[0][i] / 3, d[i] = 1;
		else if (a[0][i] == a[1][i] - 1 && a[1][i] == a[2][i] - 1) s[i] = a[2][i] / 3, d[i] = 0;
		else return puts("No"), 0;
		if ((s[i] & 1) != (i & 1)) return puts("No"), 0;
		cnt[i & 1] += d[i];
	}
	for (int i = 1; i <= n; ++i) p[s[i]] = i;
	for (int i = 1; i <= n; i += 2) 
	{
		int now = p[i] + (query(p[i]) << 1);
		ds[1] += (abs(now - i) >> 1) & 1;
		change(p[i]);
	}
	memset(tree, 0, sizeof tree);
	for (int i = 2; i <= n; i += 2)
	{
		int now = p[i] + (query(p[i]) << 1);
		ds[0] += (abs(now - i) >> 1) & 1;
		change(p[i]);
	}
	if ((cnt[0] & 1) != (ds[1] & 1) || (cnt[1] & 1) != (ds[0] & 1)) return puts("No"), 0;
	puts("Yes");
	return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
		int x, y, z, k;
		cin >> x >> y >> z >> k;
		
		vector<ll> a(x), b(y), c(z);
		for (int i = 0; i < x; i++) cin >> a[i];
		for (int i = 0; i < y; i++) cin >> b[i];
		for (int i = 0; i < z; i++) cin >> c[i];

		vector<ll> ab;
		for (int i = 0; i < x; i++) {
				for (int j = 0; j < y; j++) ab.push_back(a[i] + b[j]);
		}

		sort(ab.begin(), ab.end());
		reverse(ab.begin(), ab.end());

		vector<ll> abc;
		for (int i = 0; i < min(k, (int)ab.size()); i++) {
				for (int j = 0; j < z; j++) abc.push_back(ab[i] + c[j]);
		}

		sort(abc.begin(), abc.end());
		reverse(abc.begin(), abc.end());

		for (int i = 0; i < k; i++) cout << abc[i] << endl;
		return 0;
}


Measured memory_bytes: 43152
N = int(input())
h = list(map(int,(input().split())))
c = 0

while sum(h) > 0:
    m = max(h)
    if h[0] == m:
        c += 1
    for i in range(1,N):
        if h[i] == m:
            if h[i] != h[i-1]:
                c += 1
    for j in range(N):
            if h[j] == m:
                h[j] -= 1

print(c)

Measured memory_bytes: 39408
#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef long double ld ;
// const int N = 2e5 + 10 ;
const int K = 50 ;
const ll mod =  1e9+7 ;
#define pb push_back
#define ft first 
#define sd second 
int n, k, m, u, l, r, x, y, v, f =0;
ll w ;
const ll INF = 2e18 ;
const int N = 303;
int a[N] ;
// int n;
ld dp[N][N][N];
ld solve(int c0, int c1, int c2, int c3) {
	if(c1 + c2 + c3 == 0) {
		assert(c0 == n);
		return 0;
	}
	ld &ret = dp[c0][c1][c2];
	if(ret != -1) return ret;
	ret = 1;
	// ret += c0 * solve(c0, c1, c2, c3) / n;
	if(c1 > 0) ret += c1 * solve(c0+1, c1-1, c2, c3) / n;
	if(c2 > 0) ret += c2 * solve(c0, c1+1, c2-1, c3) / n ;
	if(c3 > 0) ret += c3 * solve(c0, c1, c2+1, c3-1) / n;
	ret = ret / (1-(ld)c0/n);
	// cout << c0 << " " << c1 << " " << c2 << " " << ret << endl;
	return ret;

}


int main(){
	cin >> n;
	// memset(dp, -1, sizeof dp);
	for(int i =0 ; i <= n; i++) {
		for(int j =0; j <= n; j++){
			for(int k=0;k<=n;k++){
				dp[i][j][k] = -1;
			}
		}
	}
	int c[4] = {};
	for(int  i = 1; i <= n; i++) {cin >> a[i]; c[a[i]]++;}
	// cout << "c: " << c[0] << " " << c[1] << " " << c[2] << " " << c[3] << endl;
	cout << fixed << setprecision(20) << solve(c[0], c[1], c[2], c[3]);
	return 0 ;
}




// // // // https://codeforces.com/problemset/problem/474/E
// // // // https://www.hackerrank.com/contests/codeagon/challenges/number-of-ways-1/problem
// // // // https://codeforces.com/contest/475/problem/D

// // check for proxy in /etc/environment and in /etc/apt/apt.conf

// // http_proxy="http://172.31.102.29:3128/"
// // https_proxy="https://172.31.102.29:3128/"
// // ftp_proxy="ftp://172.31.102.29:3128/"
// // socks_proxy="socks://172.31.102.29:3128/"

// // https://help.ubuntu.com/community/Aptquery/Howto#Maintenance_commands


// //https://www.hackerearth.com/challenge/competitive/january-easy-19/  --- timing 9 pm
// // https://atcoder.jp/contests/dp  ----- timing 4pm 


Measured memory_bytes: 432512
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())

pose2point = {
    'r': P,
    's': R,
    'p': S
}

wins = []

ans = 0
for i, pose in enumerate(T):
    if i < K:
        wins.append('win')
        ans += pose2point[pose]
    else:
        pre_pose = T[i-K]
        if wins[i-K] == 'win':
            if pose == pre_pose:
                wins.append('lose')
            else:
                wins.append('win')
                ans += pose2point[pose]
        else:
            wins.append('win')
            ans += pose2point[pose]
print(ans)

Measured memory_bytes: 4792
#include<stdio.h>
int W,H,i,j,k,t,r;
char M[505][505];
int C[505][505];
int main()
{
	for(;scanf("%d%d\n",&H,&W),H;)
	{
		r=0;
		for(i=0;i<H;i++)
		{
			gets(M[i]);
			C[i][0]=M[i][0]=='*'?0:1;
			for(j=1;j<W;j++)
				C[i][j]=M[i][j]=='*'?0:C[i][j-1]+1;
		}
		for(i=0;i<H;i++)
			for(j=0;j<W;j++)
				if(C[i][j]!=0)
				{
					t=C[i][j];
					for(k=i+1;k<H&&C[k][j]!=0;k++)
					{
						t=t>C[k][j]?C[k][j]:t;
						r=r<(t*(k-i+1))?(t*(k-i+1)):r;
					}
					r=r<(t*(k-i))?(t*(k-i)):r;
				}
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 1844
#include <iostream>
#include <numeric>
#include <vector>
#include <iomanip>

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> vec(n);
  for (auto &v : vec) {
    cin >> v;
  }

  int max = accumulate(vec.begin(), vec.begin() + k, 0);
  int sum = max;
  for (int i = k; i < n; ++i ) {
    int idx = i - k;
    sum = sum - vec[idx] + vec[i];
    max = (max < sum) ? sum : max;
  }
  cout << fixed << setprecision(10) << (max + k) / 2. << endl;
}

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

int main(void) {
	int n, i;
	double x[1000] = {0};
	double y[1000] = {0};
	double p1, p2, p3, pinf;
	double tmp;
	scanf("%d", &n);
	
	
	for (i = 0; i < n; ++i) {
		scanf("%lf", &x[i]);
	}

	for (i = 0; i < n; ++i) {
		scanf("%lf", &y[i]);
	}
	p1 = p2 = p3 = pinf = 0;
	for (i = 0; i < n; ++i) {
		tmp = fabsl(x[i] - y[i]);
		p1 += tmp;
		p2 += powl(tmp, 2);
		p3 += powl(tmp, 3);
		if (tmp > pinf) pinf = tmp;
	}
	printf("%f\n", p1);
	printf("%f\n", sqrt(p2));
	printf("%f\n", cbrt(p3));
	printf("%f\n", pinf);
	
	return 0;
}

Measured memory_bytes: 708