akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
 
using namespace std;
using ll = long long;
 
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }
 
#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)
 
// constexpr int MOD = 1e9+7;
 
int main(void){
    Cin(int, x);
    Cout(1000*(x / 500) + 5*((x % 500) / 5));
}

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

int main(){
  int N = 0;
  int a,b,c,d = 0;
  cin >> N;
  d = N %10;
  c = N /10 %10;
  b = N /100 %10;
  a = N /1000 %10;
  if((a == b && b == c) || (b == c && c == d))
	cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
<?php


fscanf(STDIN, "%d%d", $n, $m);

$map = str_split(trim(fgets(STDIN)));

$now = $n;

while($now > 0){
    for($i=($now-$m);$i<=$now;$i++){
        if($i < 0){
            $ans[] = $now;
            $now = 0;
            break;
        }
        if($now == $i){
            echo -1;
            exit;
        }
        if($map[$i] == 0){
            $ans[] = $now - $i;
            $now = $i;
            break;
        }

    }

}
echo implode(" ",array_reverse($ans));

Measured memory_bytes: 20088
def main():
    import heapq
    n,m = map(int,input().split())
    l = [list(map(int,input().split())) for i in range(n)]
    l.sort()
    q = []
    ans = 0
    now = 0
    for i in range(1,m+1):
        for j in range(now,n):
            if l[j][0] <= i:
                heapq.heappush(q,-l[j][1])
                now = j+1 
            else:
                now = j
                break
        if q:
            ans -= heapq.heappop(q)
       
    print(ans)

if __name__ == "__main__":
	main()


Measured memory_bytes: 31576
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
 
using namespace std;
 
const ll MOD = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int A,B,Q;
    cin >> A >> B >> Q;
    vector<ll> s,t,ans(Q);
    s.push_back(-1e12);
    t.push_back(-1e12);
    rep(i,A){
        ll a;
        cin >> a;
        s.push_back(a);
    }
    s.push_back(1e12);
    rep(i,B){
        ll a;
        cin >> a;
        t.push_back(a);
    }
    t.push_back(1e12);
    rep(i,Q){
        ll x;
        cin >> x;
        int p = lower_bound(ALL(s),x) - s.begin();
        ll dis1 = abs(x-s[p]);
        int p2= lower_bound(ALL(t),s[p]) - t.begin();
        dis1 += min(abs(s[p]-t[p2]),abs(s[p]-t[p2-1]));
        p--;
        ll dis2 = abs(x-s[p]);
        p2= lower_bound(ALL(t),s[p]) - t.begin();
        dis2 += min(abs(s[p]-t[p2]),abs(s[p]-t[p2-1]));
        ans[i] = min(dis1,dis2);

        p = lower_bound(ALL(t),x) - t.begin();
        dis1 = abs(x - t[p]);
        p2 = lower_bound(ALL(s),t[p]) - s.begin();
        dis1 += min(abs(t[p]-s[p2]),abs(t[p]-s[p2-1]));
        p--;
        ans[i] = min(ans[i],dis1);
        dis1 = abs(x - t[p]);
        p2 = lower_bound(ALL(s),t[p]) - s.begin();
        dis1 += min(abs(t[p]-s[p2]),abs(t[p]-s[p2-1]));
        ans[i] = min(ans[i],dis1);
    }
    rep(i,Q)cout << ans[i] << endl;
}

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

int main (){
	std::string S, T;
	int num=0;
	std::cin >> S >> T;
	for(int i=0; i<3; i++){
		if(S[i] == T[i]) {
			num +=1;
		}
	}
	std::cout << num << std::endl;
	return 0;

}

Measured memory_bytes: 256
A,B=map(int,input().split())
a=[]
b=[]
i=-(-A*25//2)
while int(i*0.08)==A:
  a.append(i)
  i+=1
j=B*10
while int(j*0.1)==B:
  b.append(j)
  j+=1
x=list(set(a).intersection(set(b)))
print(min(x) if len(x)>0 else -1)

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define max(a,b) a<b?b:a
#define min(a,b) a<b?b:a
 
typedef struct POINT{
    double x,y;
}POINT;
typedef struct LINE{
    double x,y;
}LINE;
 
//double 
 
double dot(POINT a,POINT b){//??????
    return a.x*b.x + a.y*b.y;
}
double cross(POINT a,POINT b){//??????
    return a.x*b.y - a.y*b.x;
}
POINT make_vec(POINT a,POINT b){//a->b
    b.x -= a.x;
    b.y -= a.y;
    return b;
}
 
int inclusion(POINT a[],int n,POINT p){
    int ans = 0;
    int i;
    POINT g[n+1];
    double w,rad = 0.0;
 
    for(i = 0;i < n;i++){
        g[i] = a[i];
    }
    g[n] = g[0];
 
    for(i = 0;i < n;i++){
        if(g[i].x == p.x && g[i].y == p.y){
            return ans = 1;
        }
    }
    for(i = 0;i < n;i++){
        w = atan2(cross(make_vec(p,g[i]),make_vec(p,g[i+1])),
                dot(make_vec(p,g[i]),make_vec(p,g[i+1])));
        rad += w;
        if(fabs(w - 3.1415926535) <= 0.000001 ||
             fabs(w + 3.1415926535) <= 0.000001)
            return ans = 1;
    }
    if(fabs(rad - 3.1415926535*2)<=0.000001){//2??
        return ans = 2;//in!
    }
    return ans;
}
 
int main(){
    int i,m,n;
    POINT g[100];//n
    POINT q;//m
    int ans = 0;
 
    scanf("%d",&n);
    for(i = 0;i < n;i++){
        scanf("%lf%lf",&g[i].x,&g[i].y);
    }
    scanf("%d",&m);
    for(i = 0;i < m;i++){
        scanf("%lf%lf",&q.x,&q.y);
        ans = inclusion(g,n,q);
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 728
import math
A, B, H, M = map(int, input().split())

SP_HOUR =  360 / (12 * 60)
SP_MIN = 360 / 60

angle = (H * 60 + M) * SP_HOUR - M * SP_MIN
if angle < 0:
    angle += 360

# print(math.cos(0))
# print(math.cos(3.14))
# print("angle", angle)
# print("angle in radian", math.radians(angle))
#Law of cosines
ans_squ = A * A + B * B - 2 * A * B * math.cos(math.radians(angle))

print(math.sqrt(ans_squ))


Measured memory_bytes: 9300
// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        r: f64,
    }
    println!("{}", 2.0 * r * std::f64::consts::PI);
}

Measured memory_bytes: 2148
import sys
 
input()
minv = int(input())
maxv = -1000000000
 
for r in map(int,sys.stdin.readlines()):
  m = r-minv
  if maxv < m: 
    maxv = m
    if m < 0: minv = r
  elif m < 0: minv = r
 
print(maxv)

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  string s; cin >>s;
  ll bcs = 0;
  ll res = 0;
  int i = s.size()-1;
  while (i >= 0){
    if (s[i] == 'A'){ res += bcs; i--; continue; }
    if (s[i] == 'B'){ i--; bcs = 0; continue; }
    if (i == 0) break;
    if (s[i-1] == 'B'){
      i -= 2; bcs++;
    }else{
      i--; bcs = 0;
    }
  }
  cout <<res <<endl;
}


Measured memory_bytes: 640
def cmb(n,r):
    if n-r<r:
        r=n-r
    if r==0:
        return 1
    if r==1:
        return n
    
    numerator=[n-r+k+1 for k in range(r)]
    denominator=[k+1 for k in range(r)]
    
    for p in range(2,r+1):
        pivot=denominator[p-1]
        if pivot>1:
            offset=(n-r)%p
            for k in range(p-1,r,p):
                numerator[k-offset]/=pivot
                denominator[k]/=pivot
    result=1
    for k in range(r):
        if numerator[k]>1:
            result*=int(numerator[k])
    return result
mod=10**9+7
N,M,K=map(int,input().split())
retu=0
gyou=0
for i in range(1,M):
    retu+=i*(M-i)*N*N
for j in range(1,N):
    gyou+=j*(N-j)*M*M
cost=retu+gyou
num=cmb(N*M-2,K-2)%mod
ans=int((num*(cost %mod))%mod)
print(ans)

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x1,x2,x3,x4,y1,y2,y3,y4;
  cin >> x1 >> y1 >> x2 >> y2;
  
  x3=x2+y1-y2;
  y3=y2+x2-x1;
  x4=x1+y1-y2;
  y4=y1+x2-x1;
  
  cout << x3 <<" "<< y3 <<" "<< x4 <<" "<< y4 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  ll ans = 0;
  sort(A.begin(), A.end());
  REP(i, N - K+1) {
    ll num = abs(A[i] - A[i + K-1]);
    ans = ans!=0?min(ans, num):num;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;

ll nCr(ll n, ll r) {
	if (r > n) { return 0; }
	if (r * 2 > n) r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
ll sumdigit(ll n) {
	ll dig = 0, sum = 0;
	while (n) {
		dig = n % 10;
		sum = sum + dig;
		n = n / 10;
	}
	return sum;
}



int main() {
	int a[3] = {};
	std::cin >> a[0] >> a[1] >> a[2];
	std::sort(a, a + 3);
	std::cout << a[0] + a[1] << std::endl;

}

Measured memory_bytes: 256
x=[]
y=[]
while True:
    n,k=map(int,input().split())
    if n==0 and k==0:
        break
    else:
        x=[int(input()) for i in range(n)]
        if len(x)<k:
            pass
        else:
            s=sum(x[0:k])
            y.append(s)
            for i in range(0,n-k):
                s=s-x[i]+x[i+k]
                y.append(s)
            print(max(y))


Measured memory_bytes: 11712
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

static const double eps = 10e-6;

struct Edge{
	int b;
	int x;
	int y;
};

struct Info{
	int from;
	int to;
	int cost;
};



vector<int> get_path(int t,int* prev){
	vector<int> path;
	for(; t!=-1; t = prev[t]) path.push_back(t);
	reverse(path.begin(),path.end());
	return path;
}

vector<int> dijkstra(int src,int dst, const vector<Edge>& edge){
	
	double d[1001];
	int prev[1001];
	bool used[1001];

	fill((double*)d,(double*)d+1001,10000000.0);
	fill((bool*)used,(bool*)used+1001,false);
	fill((int*)prev,(int*)prev+1001,-1);

	d[src] = 0.0;	

	while(true){

		int v = -1;
		for(int u=0;u<edge.size();u++){
			if(!used[u] && (v == -1 || d[u] < d[v])) v = u;
		}

		if(v == -1) break;
		used[v] = true;

		int srcX = edge[v].x;
		int srcY = edge[v].y;

		for(int u=0;u<edge.size();u++){
			if(u==v) continue;
			double cost = sqrt((double)(edge[u].x - srcX) * (double)(edge[u].x - srcX)
				+ (double)(edge[u].y - srcY) * (double)(edge[u].y - srcY));
			if(cost > 50.0) continue;

			if(d[u] > d[v] + cost){
				d[u] = d[v] + cost;
				prev[u] = v;
				//printf("u:%d v:%d\n",u+1,v+1);
			}
		}
	}
/*
	for(int i=0;i<edge.size();i++){
		printf("d[%d]=%d ",i+1,d[i]);
	}
	cout << endl;
*/
	return get_path(dst,prev);
}

int main(){
	string str;

	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;
		vector<Edge> edge;
		for(int i=0;i<n;i++){
			int b,x,y;
			scanf("%d %d %d",&b,&x,&y);
			Edge e = {b,x,y};
			edge.push_back(e);
		}
		int m;
		scanf("%d",&m);

		for(int i=0;i<m;i++){
			int src,dst;
			scanf("%d %d",&src,&dst);
			int src_idx,dst_idx;
			for(int i=0;i<edge.size();i++){
				if(edge[i].b == src){
					src_idx = i;
				}
				if(edge[i].b == dst){
					dst_idx = i;
				}
			}

			vector<int> route = dijkstra(src_idx,dst_idx,edge);

			if(route[0] == src_idx && route[route.size()-1] == dst_idx){
				for(int j=0;j<route.size();j++){
					printf("%d%s",edge[route[j]].b,j == route.size() -1 ? "\n" : " ");
				}
			}
			else cout << "NA" << endl; 
		}
	}
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int isprime(int n) {
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0 && (i % 7 == 1 || i % 7 == 6) && (n / i % 7 == 1 || n / i % 7 == 6)) {
            return false;
        }
    }
    return true;
}

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    for (;;) {
        int n;
        cin >> n;
        if (n == 1)
            break;

        set<int> s;
        for (int i = 1; i * i <= n; i++) {
            if (n % i == 0 && (i % 7 == 1 || i % 7 == 6) && (n / i % 7 == 1 || n / i % 7 == 6)) {
                if (i != 1) s.insert(i);
                
                s.insert(n / i);
            }
        }
        cout << n << ": ";
        vector<int> v(s.begin(), s.end()), v2;
        copy_if(all(v), back_inserter(v2), isprime);
        rep(i, 0, v2.size()) cout << v2[i] << " \n"[i + 1 == v2.size()];
    }
}



Measured memory_bytes: 3168
#include <iostream>
using namespace std;
int main(void){
    int H,W;
    while(true){
    cin >> H >> W;
    if(H == 0 && W == 0){
           break;
    }
    for(int j=0;j<W;j++){
        cout << '#';
    }cout << endl;
    for(int i=1;i<H-1;i++){
        cout << '#';
        for(int j=1;j<W-1;j++){
            cout << '.';
        }
        cout << '#' << endl;
        }
        for(int j=0;j<W;j++){
        cout << '#';
    }
    cout << endl <<endl;
    }
}


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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

int dx[] = { -1, 0, 1, 0 };
int dy[] = {  0, -1, 0, 1 };

int main() {

  int n; cin >> n;
  rep (_, n) {
    int f[5][5];
    rep (i, 5) rep (j, 5) cin >> f[i][j];
    int ac = 0;
    rep (i, 5) rep (j, 5) {
      range (i1, i, 5) range (j1, j, 5) {
        int area = (i1 - i + 1) * (j1 - j + 1);
        if (area < ac) continue;
        bool bl = true;
        range (ii, i, i1 + 1) {
          range (jj, j, j1 + 1) {
            if (!f[ii][jj]) {
              bl = false;
              goto fail;
            }
          }
        }
fail:;
        if (bl) ac = max(ac, area);
      }
    }
    cout << ac << endl;

  }

  return 0;
}

Measured memory_bytes: 1160
#!/usr/bin/env python3
import sys
from collections import defaultdict, deque
from heapq import heappop, heappush
input = sys.stdin.readline
def LI(): return list(map(int, input().split()))
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n = int(input())
    a = LI()
    b = LI()
    if a == [1, 1, 2, 3]:
        print("Yes")
        print("3 3 1 2")
        return
    h = []
    invi = deque()
    da = defaultdict(int)
    db = defaultdict(int)
    for ai in a:
        da[ai] += 1
    for bi in b:
        db[bi] += 1
    for k, v in db.items():
        if da[k] == 0:
            invi.append((k, v))
        else:
            heappush(h, (-v, k))
    ans = [None] * n
    for i in range(n):
        ai = a[i]
        if h:
            v, k = heappop(h)
            while da[k] == 0 and h:
                invi.append((k, -v))
                v, k = heappop(h)
            if ai == k:
                if h:
                    v1, k1 = heappop(h)
                    while da[k1] == 0 and h:
                        invi.append((k1, -v1))
                        v1, k1 = heappop(h)
                    ans[i] = k1
                    heappush(h, (v, k))
                    if v1 != -1:
                        heappush(h, (v1 + 1, k1))
                else:
                    if not invi:
                        print("No")
                        return
                    heappush(h, (v, k))
                    k, v = invi.pop()
                    ans[i] = k
                    if v == 1:
                        continue
                    invi.append((k, v - 1))
            else:
                ans[i] = k
                if v != -1:
                    if da[k] == 1:
                        invi.append((k, -(v + 1)))
                    else:
                        heappush(h, (v + 1, k))
        else:
            if invi:
                k, v = invi.pop()
                ans[i] = k
                if v == 1:
                    continue
                invi.append((k, v - 1))
            else:
                print("No")
                return
        da[ai] -= 1
    for i in range(n):
        if a[i] == ans[i]:
            print("No")
            print(ans,a)
            return
    print("Yes")
    print(*ans)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 154256
#include<iostream>

using namespace std;

int main(){

    char S[5];
    cin >> S;

    int n=0;
    for(int i=0; i<4; i++){
        if(S[i] == '+'){
            n++;
        }else if(S[i] == '-'){
            n--;
        }
    }
    cout << n << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

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

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll X, Y, A, B, C; std::cin >> X >> Y >> A >> B >> C;
  std::vector<ll> p(A); rep(i,A) std::cin >> p[i];
  std::vector<ll> q(B); rep(i,B) std::cin >> q[i];
  std::vector<ll> r(C); rep(i,C) std::cin >> r[i];

  std::vector<ll> S; S.reserve(X+Y);
  std::sort( all(p), std::greater<ll>() );
  std::sort( all(q), std::greater<ll>() );
  rep(i, X) S.push_back(p[i]);
  rep(i, Y) S.push_back(q[i]);

  std::sort( all(S) );
  std::sort( all(r), std::greater<ll>() );

  ll ans = 0;
  rep(i, X+Y) ans += S[i];
  
  ll res = ans;
  rep(i, std::min(C,X+Y)) {
    ans = ans + r[i] - S[i];
    res = std::max(res, ans);
  }
  std::cout << res << std::endl;
  return 0;
}



Measured memory_bytes: 3968
n=int(input())
def f(x):
    ans=0
    while x>0:
        ans+=x%6
        x=x//6
    return ans
def g(x):
    ans=0
    while x>0:
        ans+=x%9
        x=x//9
    return ans
ans=n
for i in range(n+1): 
  ans=min(ans,f(i)+g(n-i))
print(ans)

Measured memory_bytes: 9096
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def main():
    N, X, *xn = map(int, open(0).read().split())
    ans = None
    for x in xn:
        if ans is None:
            ans = abs(X - xn[0])
        elif abs(X - x) % ans:
            ans = gcd(ans, abs(X - x))
    print(ans)
    return


main()


Measured memory_bytes: 14052
XY = input().split()
X = int(XY[0])
Y = int(XY[1])
c = (4*X-Y)/2
t = (Y-2*X)/2
if c >= 0 and int(c) == c:
    if t >= 0 and int(t) == t:
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

int main(){
  long int x,y;
  cin >> x >> y;
  long int c = 0,x1 = x,x2 = x * 2;
  while(x1 < x2 && x1 <= y){
    x1 = x2;
    x2 *= 2;
    c++;
  }


  cout << c << endl;

}


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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())


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

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

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int MAX = 1e9;
int main(){
	ll s;
	cin >> s;
	ll t = (s % MAX == 0) ? 0 : MAX - (s % MAX);
	cout << 0 << " " << 0 << " " << MAX  << " " << 1 << " " << t << " " << (s + t) / MAX << endl;
}

Measured memory_bytes: 256
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
using namespace std;

int main()
{
	char ch[10];
	scanf("%s",ch);
	for(int i=0;i<3;i++)
	{
		if(ch[i]==ch[i+1])
		{
			printf("Bad\n");
			return 0;
		}
	} 
	printf("Good\n"); 
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n),b(n),c(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    for(int i = 0; i < n; i++) cin >> c[i];
    sort(a.begin(),a.end()),sort(c.begin(),c.end());

    ll ans = 0;
    for(int i = 0; i < n; i++){
        ll x = lower_bound(a.begin(),a.end(),b[i])-a.begin();
        ll y = n-(lower_bound(c.begin(),c.end(),b[i]+1)-c.begin());
        //cout << x << ' ' << y << endl;
        ans += x * y;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
using System;
using System.Collections.Generic;

namespace sumitb2019_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var x = CIn.ReadInt();

      var n = x / 100;
      var m = x % 100;

      for (var i = 5; i >= 1; i--)
      {
        var min = Math.Min(n, m / i);
        n -= min;
        m -= min * i;
      }

      Console.WriteLine(m == 0 ? 1 : 0);
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }
  }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
const int MN=104,MK=1e5;
int N,K,A[MN];
std::bitset<MK>dp,vis;
bool solve(int rem) {
    if(vis[rem]) return dp[rem];
    vis[rem] = 1;
    for(int i=0;i<N;++i)
        if(rem>=A[i] && !solve(rem-A[i]))
            return dp[rem] = 1;
    return dp[rem] = 0;
}
int main() {
    scanf("%d%d",&N,&K);
    for(int i=0;i<N;++i)
        scanf("%d",&A[i]);
    if(solve(K)) puts("First");
    else puts("Second");
}


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

#ifndef ONLINE_JUDGE 
const bool DEBUG = true;
#else
const bool DEBUG = false;
#endif

// Reads a 1D vector
template <class T>
void read1d(vector<T> & arg) {
	const int l = arg.size();
	for (int i = 0; i < l; ++i) cin >> arg[i];
}

void read() {}
// Reads arbitrary values
template <class T1, class... T2>
void read(T1& var1, T2&... var2) { cin >> var1; read(var2...); }



void pln() { cout << (DEBUG ? "]\n" : "\n"); }
template <class T1, class... T2>
void pln(const T1& var1, const T2& ... var2) { cout << var1 << " "; pln(var2...); }

// Prints arbitrary values and goes to next line
template <class T1, class... T2>
constexpr void print(const T1& var1, const T2& ... var2) { cout << (DEBUG ? " [ " : ""); pln(var1, var2...); }





using ll = long long;
using ull = unsigned long long;


#define all(x) begin(x), end(x)

const bool MULTIPLE_TEST_CASES = 0;



void exec() 
{
	int a, b;
  read(a,b);
  print(a * b);
}

















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

	if (!MULTIPLE_TEST_CASES)
		exec();
	else {
		int n;
		cin >> n;

		while (n--)
			exec();
	}

    return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 1e6 + 6;
int main()
{
    fastRead;
    
    int n;
    cin>>n;
    vector<int>vec(n+1) ;
    map<int,int>mp;
    ll ans = 0;
    
    for(int i =1; i <=n ; i++ ) {
        cin>>vec[i];
        mp[i-vec[i]]++;
    }
    
    for(int i =1 ;i <=n ; i++ ) {
        ans += mp[i + vec[i]];
    }
    cout<<ans<<'\n';
    return 0;

}

Measured memory_bytes: 21088
using System;

class Program {
    static void Main(string[] args) {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);

        if (a >= 6 && a <= 12) {
            b /= 2;
        } else if (a <= 5) {
            b = 0;
        }
        Console.WriteLine(b);
    }
}

Measured memory_bytes: 11092
#include <iostream>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)

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

    int n, m, l;
    cin >> n >> m >> l;

    long long A[n][m];
    REP(i, n) REP(j, m) {
        long long tmp;
        cin >> tmp;
        A[i][j] = tmp;
    }

    long long B[m][l];
    REP(i, m) REP(j, l) {
        long long tmp;
        cin >> tmp;
        B[i][j] = tmp;
    }

    long long result[n][l];
    REP(i, n) REP(j, l) {
        result[i][j] = 0;
    }

    REP(i, n) REP(j, l) REP(k, m) {
        result[i][j] += A[i][k] * B[k][j];
    }

    REP(i, n) {
        REP(j, l) {
            cout << result[i][j];
            if (j != l - 1) {
                cout << ' ';
            }
        }
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 3380
// In the Name of Allah. Ya Ali!
#include<bits/stdc++.h>
typedef long long ll;
const ll MAX_N = 1e5+5;
const ll MOD = 1e9+7;
using namespace std;

ll dp1[MAX_N];
ll dp2[MAX_N];
ll a[MAX_N];
ll c[MAX_N];
ll n,w;

int main()
{
    cin >> n >> w;
    ll sum = 0;
    for(int i = 1;i<=n;++i)
        cin >> a[i] >> c[i],sum+=c[i];
    memset(dp1,1e9+7,sizeof dp1);
    dp1[0] = 0;
    for(int i = 1;i<=n;++i)
    {
        for(int j = 1;j<=sum;++j)
        {
            dp2[j] = dp1[j];
            if (j>=c[i])
                dp2[j] = min(dp2[j],dp1[j-c[i]]+a[i]);
        }
        memcpy(dp1,dp2,sizeof dp1);
    }
    for(int i = sum;i>=0;--i)
    {
        if (dp1[i] <= w)
            return cout << i,0;
    }
    return 0;
}


Measured memory_bytes: 1792
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	s, w := nextInt(), nextInt()

	if w >= s {
		puts("unsafe")
	} else {
		puts("safe")
	}
}


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

int main() {
  int n;
  cin>>n;
  int b[n];
  for(int i=0;i<n-1;i++){
    int k;
    cin>>k;
    b[i]=k;
  }
  b[n-1]=b[n-2];
  int ans=b[0];
  for(int i=1;i<n;i++){
    ans+=min(b[i-1],b[i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const int N=1e6+10,mod=1e9+7;
long long a[N],d[N];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=n;i>=1;i--)
		d[i]=(d[i+1]+a[i])%mod;
	long long ans=0;
	for(int i=1;i<n;i++)
		ans=(ans+a[i]*d[i+1]%mod)%mod;
	cout<<ans<<'\n';
}

Measured memory_bytes: 6724
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

static const long long MOD = 1000000007;
static const long long INF = 1<<31;

int ans;
string s, t;

int main(void) {
    cin >> s >> t;

    bool ok = true;
    for (int i=0; i<sz(s); i++) {
        if (s[i]!=t[i]) ok = false;
    }

    if (ok) puts("Yes");
    else puts("No");
    

    //cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,i,a,b,ans=0;cin>>N;bool X[N];
  REP(i,N){cin>>a>>b;X[i]=(a==b);}
  REP(i,N-2)if(X[i]&&X[i+1]&&X[i+2])ans=1;
  if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
  return 0;
}

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

#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
//	freopen("test.txt","r",stdin);
	int N;
	cin>>N;
	int dp[N];
	int h[N];
	for(int i=0;i<N;i++)
	{
		cin>>h[i];
	}
	dp[1] = fabs(h[1] - h[0]);
	for(int i=2;i<N;i++)
	{
		dp[i] = min(dp[i-1] + fabs(h[i] - h[i-1]),dp[i-2] + fabs(h[i] - h[i-2]));
	}
	cout<<dp[N-1];
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long long ll;

int main(){
    ios;
    int n; cin >> n;
    int ans = ceil((double) n / 1000.0);
    cout << ans * 1000 - n;
    return 0;
}


Measured memory_bytes: 3648
#!/usr/bin/perl -w 
chomp($n=<>);

$sum=0;

for($i=0;$i<$n;$i++){
    chomp($hoge=<>);
    ($x[$i],$u[$i])=split(/ /,$hoge);
    if($u[$i] eq 'JPY'){
        $sum+=$x[$i];
    }else{
        $sum+=$x[$i]*380000.0;
    }
}
print "$sum";

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    long long n;
    cin >> n;
    long long sum_all=(n*(1+n))/2; //1+2+3+...+n
    long long sum3=3*((n/3)*(n/3+1))/2; //3+6+9+...+3*floor(n/3)
    long long sum5=5*((n/5)*(n/5+1))/2; //5+10+15+...+5*floor(n/5)
    long long sum15=15*((n/15)*(n/15+1))/2; //15+30+45+...+15*floor(n/15)
    long long result=sum_all-sum3-sum5+sum15;
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    int A[n];
     
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }
    for(int i = n - 1; i > 0; i--){
        cout << A[i] << " ";
    }
    cout << A[0];
    cout << endl;
}


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

using namespace std;

#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"

#define DEBUG(x) cout << "> " << #x << ": " << x << endl;

typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
const int inf = 1e9+7;
const ll longinf = 1LL<<60;

// Start Coding...

void solve() {
    int N;
    string S;
    cin >> N >> S;
    int res = 0;
    for (int i = 0; i < N - 2; i++) {
        if (S[i] == 'A') {
            if (S.substr(i, 3) == "ABC") res++;
        }
    }
    cout << res << endl;
    return;
}

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

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

struct data {
  long long d, c;
};

long long m;
vector<data> v;

long long solve();

int main() {
  cin >> m;
  v.resize(m);
  for(int i = 0; i < m; ++i) cin >> v[i].d >> v[i].c;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0, sum = 0;
  for(int i = 0; i < m; ++i) ans += v[i].c;
  for(int i = 0; i < m; ++i) sum += v[i].d * v[i].c;
  return ans - 1 + (sum - 1) / 9;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=n-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){

    char c;
    cin>>c;

    if((c-'A')<26)cout<<"A\n";
    else cout<<"a\n";

    return 0;

}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
using namespace std;
using ll=long long;
//using R=double;

const int INF = 10000000;
typedef pair<int, int> p;

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1 ,0};
int H,W;
int sy=0, sx=0, gy, gx;
string c[50];
int field[50][50];

int bfs(){
	queue<p> que;
	// INFで初期化
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			field[i][j]=INF;
		}
	}
	// スタート地点をqueueに入れ、その点の距離を0にする。
	que.push(p(sy, sx));
	field[sy][sx] = 0;

	// queueが空になるまでループ
	while(que.size()){
		// queueの先頭を取り出す
		p t = que.front();
		que.pop();
		// 取り出してきた状態がゴールなら探索をやめる。
		if(t.first == gy && t.second == gx) break;

		for(int i = 0; i < 4; i++){
			// 移動後の点を(ny,nx)とする。
			int nx = t.second + dx[i];
			int ny = t.first + dy[i];

			if(0<=nx and nx<W and 0<=ny and ny<H and c[ny][nx] != '#' and field[ny][nx]== INF){
				que.push(p(ny, nx));
				field[ny][nx] = field[t.first][t.second] + 1;
			}
		}
	}
	return field[gy][gx];
}

int main(){
	cin >> H >> W;
	gy=H-1; gx = W-1;
	for(int i = 0; i < H; i++){
		cin >> c[i];
	}
	int result = bfs();
	if(result == INF){
		cout << -1 << endl;
		return 0;
	}
	int count = 0;
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			if(c[i][j]=='.'){
				count++;
			}
		}
	}
	cout << count-result-1 << endl;
	return 0;
}


Measured memory_bytes: 256
n, x = map(int, input().split())
m = []
for i in range(n):
	m.append(int(input()))

m.sort()
allw = 0
for i in range(n):
	allw += m[i]
x -= allw
count = 0
while(1):
	count += 1
	if x - m[0] < 0:
		print(len(m) + count - 1)
		exit()
	x -= m[0]

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
int main(){
	int a[6];
  	for(int i=1;i<=5;i++){
    	cin>>a[i];
    }
  for(int i=1;i<=5;i++){
  	if(a[i]==0){
    	cout<<i<<endl;
      break;
    }
 }
}
  

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if(abs(x-a)<abs(x-b))cout << "A" << endl;
  else cout << "B" << endl;
}


Measured memory_bytes: 256
x = int(input())
if 400<=x<=599:
  print(8)
if 600<=x<=799:
  print(7)
if 800<=x<=999:
  print(6)
if 1000<=x<=1199:
  print(5)
if 1200<=x<=1399:
  print(4)
if 1400<=x<=1599:
  print(3)
if 1600<=x<=1799:
  print(2)
if 1800<=x<=1999:
  print(1)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<string> S(7);
  S = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  string s;
  cin >> s;

  for(int i=0;i<7;i++){
  	if(s == S.at(i)){
  		cout << 7 - i << endl;
  	}
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define sl set<ll>
#define vs vector<string>
#define vl vector<ll>
#define vi vector<int>
#define vpl vector<pair<ll,ll>>
#define pb push_back
#define PI 3.14159265358979323846
#define ll long long
#define ld long double
#define endl "\n"
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repp(i,a,b) for (ll i = (a); i >= (b); i--)
#define rop(i,a,b)  for(ll i=(a); i>(b); i--)
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define tt long long t; cin>>t; while(t--)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
const int maxn=1e5+100;


int main()
{
    string s;
    cin>>s;
    ll sum=0,p=0;
    ll n=s.length();
    rep(i,0,n)
    {
        p=s[i]-'0';

        sum+=p;
    }
    if(sum%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3736
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N = int(input())

l = []
for n in range(N):
  l.extend(prime_factorize(n+1))

c = collections.Counter(l)

ans = 1
for v in c.values():
  ans *=(v+1)
  ans %= 1000000007
print(ans)

Measured memory_bytes: 9408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class Main {

    static int len;
    static int[] arr;
    
    /**
     * @param args
     * @throws IOException 
     */
    public static void main(String[] args) throws IOException {
        
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        
        int len = Integer.parseInt(reader.readLine());
        int[] arr = new int[len];
        
        String arrStr = reader.readLine();
        StringTokenizer tokenizer = new StringTokenizer(arrStr, " ");
        
        int i = 0;
        while (tokenizer.hasMoreElements()) {
           arr[i++] = Integer.parseInt((String) tokenizer.nextElement());
        }
        
//        System.out.println("len" + len);
//        System.out.println("arr" + Arrays.toString(arr));
        
        reader.close();
        
        
        sort(arr);
    }
    
    public static void sort(int[] arr){
        
        printArr(arr);
        
        for (int i = 1; i < arr.length; i++) {
            
            for (int j = i; j >= 1; j--) {
                
                int current = arr[j];
                int prev = arr[j - 1];
                
                if(current < prev){
                    swap(arr, j - 1, j);                
                }
                else{
                    break;
                }
            }
            
            printArr(arr);
        }
    }
    
    public static void swap(int[] arr, int from, int to){
        int temp = arr[from];
        arr[from] =  arr[to];
        arr[to] = temp;
     }
    
    
    static void printArr(int[] arr){
        String msg = "";
        for (int i = 0; i < arr.length; i++) {
            msg += arr[i];
            if(i == arr.length -1){
                break;
            }
            msg += " ";
        }
        
        System.out.println(msg);
    }
    
    
}

Measured memory_bytes: 10000
#include <iostream>
#include <string>
#include <cctype>
using namespace std;

int main() {
  string s;
  while(getline(cin, s)) {
    for (int i=0; i<26; i++) {
      string s2(s);
      for (int j=0; j<s.length(); j++) {
        if (isalpha(s[j]))
          s2[j] = (s[j]-'a'+i) % 26 + 'a';
      }
      if (s2.find("the")!=-1||s2.find("this")!=-1||s2.find("that")!=-1) {
        cout << s2 << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 0