akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////



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

    ll ans = 0;
    ll n = 1;
    while(h > 0){
	ans += n;
	h >>= 1;
	n <<= 1;;
    }
    P(ans);
    return  0;
}


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

using namespace std;
typedef long long ll;

int main()
{
    ll n , k , d ;
    cin >>  n >> k >> d;
    if(n==0)
    {
        if(k%2==0)
            cout << 0 ;
        else cout << d;
        return 0;
    }
    n=abs(n);
    ll x = min(n/d , k);
    n-=(x*d);
    k-=x;
    if(k%2==0)
        cout << n;
    else cout << d-n;
    return 0;
}


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

using namespace std;
using ll = int64_t;
using P = std::pair<int, int>;

// Z = (X, Y)
// E[Z] = sum of area / (\int_{-\inf}^{\inf} \int_{-\inf}^{\inf} 1 dxdy)

int main() {
    int N;
    cin >> N;
    vector<int> x(N), y(N);
    for(int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
    }    

    for(int i = 0; i < N; i++) {
        vector<double> angles;
        for(int j = 0; j < N; j++) {
            if(i == j) continue;
            angles.emplace_back(atan2(y[j]-y[i], x[j]-x[i]));
        }
        sort(angles.begin(), angles.end());

        double ans = 0;

        for(int i = 0; i < N - 2; i++) {
            ans = max(ans, angles[i+1] - angles[i]);
        }

        ans = max(ans, angles[0] + 2*M_PI - angles[N-2]);

        ans = (ans > M_PI ? (ans - M_PI) / 2.0 / M_PI : 0.0);

        printf("%.9f\n", ans);
    }
}



Measured memory_bytes: 384
from numpy import*
h,*s=open(0)
h,w=int64(h.split())
r=range
s=int32([[u>'#'for u in t[:w]]for t in s])
a,b,c,d=eval('copy(s),'*4)
for i in r(1,w):a[:,i],b[:,~i]=-~a[:,i-1]*s[:,i],-~b[:,-i]*s[:,~i]
for i in r(1,h):c[i,:],d[~i,:]=-~c[i-1,:]*s[i,:],-~d[-i,:]*s[~i,:]
print(int((a+b+c+d).max())-3)

Measured memory_bytes: 121944
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>

using namespace std;

int main(){
	string s;
	cin >> s;
    int ans = 1000;
    for(int i = 0; i < s.size() - 2; i++){
        int t = abs(stoi(s.substr(i, 3)) - 753);
        ans = min(ans, t);
    }
	cout << ans << endl;
	return 0;
}


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

int main() {
  int N, Q;
  while(cin >> N >> Q && (N|Q)) {
    map<int,int> num;
    for(int i = 0; i < N; ++i) {
      int M;
      cin >> M;
      while(M--) {
        int d;
        cin >> d;
        num[d] += 1;
      }
    }
    pair<int,int> res(0,0);
    for(map<int,int>::iterator it = num.begin();
        it != num.end(); ++it) {
      if(res.second < it->second) {
        res = *it;
      }
    }
    if(res.second < Q) res.first = 0;
    cout << res.first << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
n = int(input())
L = 'MARCH'
S = []
for i in range(n):
    s = input()
    if s[0] in L:
        S.append(s[0])

import collections
c = collections.Counter(S)

ans = 0
import itertools
for i,j,k in itertools.combinations(c.values(), 3):
    ans += i*j*k
print(ans)

Measured memory_bytes: 4248
import java.util.*;
public class Main {
	//0224 start
	//0300 stop
	//2300 restart
	//2323 AC
	int t, num,len;
	String numstr;
	int [] ansarray,work;
	int ans;
	boolean rejected;

	private void dfs(int deep, int index){
		if(index == len-1){
			int res = calc(work);
			if(res <= t && res > ans){
				ans = res;
				ansarray = work.clone();
				rejected= false;
			}
			else if(res == ans){
				rejected = true;
			}
		}

		for(int i = index + 1; i < len; i++){
			work[deep] = i;
			dfs(deep + 1, i);
			work[deep] = -1;
		}
	}


	private int calc(int[] a) {
		int start = -1, i = 0, end = a[i++], sum = 0;
		while(start != len - 1){
			String temp = numstr.substring(start + 1, end + 1);
			sum += Integer.parseInt(temp);
			start = end;
			end = a[i++];
		}
		return sum;
	}


	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			t = sc.nextInt();
			numstr = sc.next();
			if(t == 0 && numstr.equals("0")) break;
			len = numstr.length();
			ansarray = new int[len + 1];
			work = new int[len + 1];
			Arrays.fill(work, -1);
			ans = -1;
			rejected = false;
			dfs(0,-1);
			if(rejected){
				System.out.println("rejected");
			}
			else if(ans == -1){
				System.out.println("error");
			}
			else{
				System.out.print(ans);
				int start = -1, end = ansarray[0];
				for(int i = 0; i < ansarray.length - 1; i++){
					if(ansarray[i] == -1) break;
					String temp = numstr.substring(start + 1, end + 1);
					System.out.print(" " + temp);
					start = end;
					end = ansarray[i + 1];
				}
				System.out.println();
			}
		}
	}

	public static void main(String [] args){
		new Main().doit();
	}
}

Measured memory_bytes: 12000
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int A[N];
  for(int i = 0; i < N; ++i){
    cin >> A[i];
  }
  int ans = 0;
  for(int i = 0; i < N; ++i){
    if(A[i] == i+1){
      ++ans;
      ++i;
    }
  }


  cout << ans << endl;
  return 0;
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    int ans = INF, l, r;
    rep(i, 0, n) cin >> x[i];

    rep(i, 0, n - k + 1)
    {
        int j = i + k - 1;
        l = abs(x[i]) + abs(x[j] - x[i]);
        r = abs(x[j]) + abs(x[j] - x[i]);
        chmin(ans, l), chmin(ans, r);
    }

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

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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int A, B, C;
int K;
int main() {
    std::cin >> A >> B >> C;
    std::cin >> K;

    int max = std::max(A, std::max(B, C));
    int min = std::min(A, std::min(B, C));
    int mid = (A+B+C) - max - min;

    LL ans = 1LL*max * std::pow(2, 1LL*K) + mid + min;

    std::cout << ans << std::endl;
}

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

#define fo(i,n)         for(int i=0;i<n;i++)
#define fo2(i,n)        for(int i=n-1;i>=0;i--)
#define Fo(i,k,n)       for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll              long long
#define si(x)	        scanf("%d",&x)
#define sl(x)	        scanf("%lld",&x)
#define ss(s)	        scanf("%s",s)
#define pi(x)	        printf("%d\n",x)
#define pi2(x)          printf("%d ",x)
#define pl(x)	        printf("%lld\n",x)
#define pl2(x)          printf("%lld ",x)
#define ps(s)	        printf("%s\n",s)
#define pn              printf("\n")
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x, y)      cout << #x << "=" << x << " , " << #y << "=" << y << endl
#define pb              push_back
#define F               first
#define S               second
#define all(x)          x.begin(), x.end()
#define clr(x)          memset(x, 0, sizeof(x))
#define sortall(x)      sort(all(x))
#define tr(it, a)       for(auto it = a.begin(); it != a.end(); it++)
#define PI              3.1415926535897932384626

typedef pair<int, int>ii;
typedef pair<ll, ll>pl;
typedef vector<int>vi;
typedef vector<ll>vl;
typedef vector<ii>vii;
typedef vector<pl>vpl;
typedef vector<vi>vvi;
typedef vector<vl>vvl;

/*int mpow(int base, int exp);
ll binpow(ll base , ll exp);
void ipgraph(int n, int m);
void dfs(int u);*/

const int mod = 1000000007;
const int N = 3e5+5, M = N;

//vi g[N];
//bool vis[N];

int cnt[100005];


void solve()
{
    ll n, m, res=0, b, c;

    sl(n) ;

    ll ar[n];

    fo(i,n) sl(ar[i]),res += ar[i], cnt[ar[i]]++;

    sl(m);

    fo(i,m)
    {
        sl(b) ; sl(c);

        cnt[c] += cnt[b];

        res -= (b*cnt[b]);

        res += (cnt[b]*c);

        cnt[b] = 0;

        pl(res);
    }

}


int main()
{
    int t = 1;

    //si(t);

    while(t--)
    {
        solve();
    }

    return 0;
}






















/*void dfs(int u) //DFS
{
    vis[u] = 1;

	for(int v:g[u])
    {
		if (!vis[v])
           dfs(v);
	}

	vis[u] = 0;
}

void ipgraph(int n, int m) //GRAPH INPUT
{
	int i, u, v;

	while(m--)
    {
		si(u); si(v);
		g[u].pb(v);
		g[v].pb(u);
	}
}



ll binpow(ll base, ll exp)
{
    ll res = 1;
    while (exp > 0)
    {
        if (exp & 1)
            res = res * base;
        base = base * base;
        exp >>= 1;
    }
    return res;
}

int mpow(int base, int exp)
{
    base %= mod;
    int result = 1;
    while (exp > 0)
    {
       if (exp & 1) result = ((ll)result * base) % mod;
       base = ((ll)base * base) % mod;
       exp >>= 1;
    }
    return result;
}
*/






//    #include <chrono>
//    using namespace std::chrono;
//    auto start = high_resolution_clock::now();
//    auto stop = high_resolution_clock::now();
//    auto duration = duration_cast<milliseconds>(stop - start);
//    cout << duration.count() << endl;
//#ifdef _DEBUG
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif




Measured memory_bytes: 4912
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	vector<int>A(3);
	for (int i = 0;i < 3;++i) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	 
	int ans = 0;
	for (int i = 0;i < 3;++i) {
		if (i == 0)continue;
		ans += abs(A[i] - A[i - 1]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll=long long;

ll gcd(ll a, ll b){
	if(a<b)return gcd(b,a);
	ll r;
	while((r=a%b)){
		a=b;
		b=r;
	}
	return b;
}

int main()
{
	ll A,B;
	cin>>A>>B;
	cout<<A*B/gcd(A,B)<<endl;
	return 0;
}


Measured memory_bytes: 256
//This program is written by Brian Peng.
#pragma GCC optimize("Ofast","inline","no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Rd(a) (a=read())
#define Gc(a) (a=getchar())
#define Pc(a) putchar(a)
int read(){
	int x;char c(getchar());bool k;
	while(!isdigit(c)&&c^'-')if(Gc(c)==EOF)exit(0);
	if(c^'-')k=1,x=c&15;else k=x=0;
	while(isdigit(Gc(c)))x=(x<<1)+(x<<3)+(c&15);
	return k?x:-x;
}
void wr(int a){
	if(a<0)Pc('-'),a=-a;
	if(a<=9)Pc(a|'0');
	else wr(a/10),Pc((a%10)|'0');
}
signed const INF(0x3f3f3f3f),NINF(0xc3c3c3c3);
long long const LINF(0x3f3f3f3f3f3f3f3fLL),LNINF(0xc3c3c3c3c3c3c3c3LL);
#define Ps Pc(' ')
#define Pe Pc('\n')
#define Frn0(i,a,b) for(int i(a);i<(b);++i)
#define Frn1(i,a,b) for(int i(a);i<=(b);++i)
#define Frn_(i,a,b) for(int i(a);i>=(b);--i)
#define Mst(a,b) memset(a,b,sizeof(a))
#define File(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
#define N (200010)
#define P (998244353)
int n,st[N][20],lg[N]{-1},ans(1);
struct T{int x,d,r;
	bool operator<(T b)const{return x<b.x;};
}a[N];
int qry(int l,int r);
int dfs(int u);
signed main(){
	Rd(n);
	Frn1(i,1,n)Rd(a[i].x),a[i].d=a[i].x+read()-1,lg[i]=lg[i>>1]+1;
	sort(a+1,a+n+1),*st[n]=n;
	Frn_(i,n-1,1){
		*st[i]=max(i,qry(i+1,upper_bound(a+i,a+n+1,T({a[i].d}))-a-1));
		Frn1(j,1,lg[n-i+1])st[i][j]=max(st[i][j-1],st[i+(1<<(j-1))][j-1]);
	}
	Frn1(i,1,n)ans=ans*dfs(i)%P,i=*st[i];
	wr(ans),exit(0);
}
int qry(int l,int r){
	if(l>r)return 0;int w(lg[r-l+1]);
	return max(st[l][w],st[r-(1<<w)+1][w]);
}
int dfs(int u){
	int re(1);
	Frn1(i,u+1,*st[u])re=re*dfs(i)%P,i=*st[i];
	return re+1;
}

Measured memory_bytes: 41600
#include<bits/stdc++.h>
#define rep(i, a, b) for(int i=(int)(a); i<(int)(b); i++)
#define rrep(i, a, b) for(int i=(int)(a); i>=(int)(b); i--)
#define all(v) v.begin(), v.end()
#define inf 2e9
typedef long long ll;
template<class t>bool chmax(t &a, const t &b){if(a<b){a=b; return 1;}return 0;}
template<class t>bool chmin(t &a, const t &b){if(a>b){a=b; return 1;}return 0;}

using namespace std;

int cum[111];

int main(void)
{
    int N;
    cum[0]=0;
    cin >> N;
    rep(i, 1, N+1){
        int n;
        cin >> n;
        cum[i] = cum[i-1] + n;
    }
    int ans = inf;
    rep(i, 1, N+1){
        chmin(ans, abs(cum[N]-2*cum[i]));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 2e5 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;

ll t[N] ;
int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
    ll n , c , k ;
    cin >> n >> c >> k ;
    for (int i = 0 ; i < n ; i ++) cin >> t[i] ;
    sort(t , t + n);
    ll cur = t[0] , cap =0 , ans = 1  ;
    sort(t , t + n);
    for (int i = 0 ; i < n ; i ++) {
    	if (t[i] < cur || t[i] > cur + k || cap == c) {
    		cap = 0 ;
    		cur = t[i] ;
    		ans ++ ;
		} 
		cap ++;
	}
	cout << ans ; 
    return (0) ;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
typedef long long LL;
template<class T> inline void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

#define MOD 1000000007

vector<vector<LL>> comb(int n, int r) {
	vector<vector<LL> > v(n + 1, vector<LL>(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			//nCr = n-1Cr-1 + n-1Cr というCombinationの漸化式を書いている
			v[j][k] = (v[j - 1][k - 1] % MOD + v[j - 1][k] % MOD)%MOD;
		}
	}
	return v;
}


int main(void) {
	string S;
	cin >> S;

	int count = 0;
	int max = 0;
	for (int i = 0; i < S.size(); i++)
	{
		if (S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or S[i] == 'T') {
			count++;
		}
		else {
			count = 0;
		}
		
		chmax(max,count);
	}

	cout << max << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N;
int nums[100009];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    rep1(i,N) cin>>nums[i];
    
    int cnt=0,now=1,nxt;
    while(1){
        cnt++;
        nxt=nums[now];
        nums[now]=-1;
        if(nxt==-1){
            cnt=-1;
            break;
        }
        if(nxt==2) break;
        now=nxt;
    }
    cout1(cnt)
}

Measured memory_bytes: 640
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;

int main()
{
  int a, b;
  cin >> a >> b;
  if (b > a) {
    swap(a, b);
  }
  cout << max(a + b, a + a- 1) << endl;
  return 0;
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<lli> v(n);
    cin >> v;
    lli x = v[0];
    for (int i = 1; i < v.size(); ++i) {
      x = x / __gcd(x, v[i]) * v[i];
    }
    cout << x << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 1e5 + 10;
int N;
int A[MAXN], cnt[MAXN];

int main() {
	register int i;
	scanf("%d", &N);
	for(i = 1; i <= N; ++i) scanf("%d", A + i);
	sort(A + 1, A + N + 1);
	if(A[N] != A[N - 1]) return puts("Impossible"), 0;
	for(i = 1; i <= N; ++i) ++cnt[A[i]];
	for(i = A[1] + 1; i <= A[N]; ++i) if(cnt[i] < 2) return puts("Impossible"), 0;
	if((A[N] & 1) && (A[1] != (A[N] + 1) / 2 || cnt[A[1]] != 2)) return puts("Impossible"), 0;
	if(!(A[N] & 1) && (A[1] != A[N] / 2 || cnt[A[1]] != 1)) return puts("Impossible"), 0;
	puts("Possible");
	return 0;
}

Measured memory_bytes: 128
A = []
for i in range(3):
  As = list(map(int, input().split()))
  A.append(As)
N = int(input())
bs = set()
for i in range(N):
  b = int(input())
  bs.add(b)
D = [[False]*3 for i in range(3)]
for i in range(3):
  for j in range(3):
    if A[i][j] in bs:
      D[i][j] = True
if D[0][0] and D[0][1] and D[0][2]:
  print("Yes")
elif D[1][0] and D[1][1] and D[1][2]:
  print("Yes")
elif D[2][0] and D[2][1] and D[2][2]:
  print("Yes")
elif D[0][0] and D[1][0] and D[2][0]:
  print("Yes")
elif D[0][1] and D[1][1] and D[2][1]:
  print("Yes")
elif D[0][2] and D[1][2] and D[2][2]:
  print("Yes")
elif D[0][0] and D[1][1] and D[2][2]:
  print("Yes")
elif D[2][0] and D[1][1] and D[0][2]:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include<stack>
#include <unordered_map>

using namespace std;

#define MAX(A,B) (A)>(B)?(A):(B)
#define MIN(A,B) (A)<(B)?(A):(B)

int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}

int main() {
	int N;
	cin >> N;
	int a,b;

	cin >> a;
	cin >> b;
	int ans = gcd(a,b);
	for (int i = 2; i < N; i++) {
		cin >> a;
		ans = gcd(ans, a);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 384
import sys
def check(x,j=1):
    if sum(x)==0: return 1
    i = j
    while x[i]==0: i+=1
    y = x[:]
    if y[i]>=3:
        y[i] -= 3
        if check(y,i): return 1
    y = x[:]
    if i<8 and y[i]>0 and y[i+1]>0 and y[i+2]>0:
        y[i] -= 1
        y[i+1] -= 1
        y[i+2] -= 1
        if check(y,i): return 1
    return 0
 
for s in sys.stdin:
    c = [0]*10
    for e in map(int,s[:-1]): c[e] += 1
 
    f = 0
    R = range(1,10)
    for i in R:
        c1=c[:]
        if c1[i]>=4:continue
        c1[i]+=1
        for j in R:
            if c1[j]<2:continue
            c1[j]-=2
            if check(c1):
                f = 1
                print i,
                break
            c1[j]+=2
    if f: print
    else: print 0

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

int main()
{
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    (s == u ? a : b)--;
    cout << a << " " << b << endl;
    return 0;
}


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

vector<int> forintinput(int n) {
	vector<int> x;
	for(int i = 0;i < n;i++){
		int ia;
		cin >> ia;
		x.push_back(ia);
	}
	return x;
}
int main(){
	int n,k;
	cin >> n >> k;
	vector<int> p;
	int cnt = 0;
	p = forintinput(n);
	sort(p.begin(), p.end());
	for(int i = 0;i < k;i++){
		cnt += p[i];
	}
	cout << cnt << endl;
}

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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> a(n), b(n), c(m), d(m);
  vector<int> ans(n);
  rep(i, n) cin >> a[i] >> b[i];
  rep(i, m) cin >> c[i] >> d[i];
  rep(i, n){
    int mi = INT_MAX;
    int index = 0;
    rep(j, m){
      int dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if(mi > dist){
        mi = dist;
        index = j;
      }
    }
    ans[i] = index + 1;
  }
  rep(i, n) cout << ans[i] << endl;;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll fac[100010];
inline ll pow2(ll a,ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return res;
}
inline ll getInv(ll x){
	return pow2(x,mod-2);
}
int main(){
	int N,M;
	scanf("%d%d",&N,&M);
	fac[0]=1;
	for(int i=1;i<=100000;i++)
		fac[i]=fac[i-1]*i%mod;
	if(abs(N-M)==0)
		printf("%lld\n",fac[N]*fac[M]%mod*2%mod);
	else if(abs(N-M)==1)
		printf("%lld\n",fac[N]*fac[M]%mod);
	else{
		puts("0");
	}
	return 0;
}

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

//#define int long long
//#define ll int long long
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(vec) (vec).begin(),(vec).end()
#define vint vector<int>
#define pint pair<int,int>
#define vpint vector<pint>

int par[100002];
int rnk[100002];
void init(int n){REP(i,n){par[i]=i;rnk[i]=0;}}
int find(int x){if(par[x]==x){return x;}else{return par[x]=find(par[x]);}}
void unite(int x,int y){x=find(x);y=find(y);if(x==y)return;if(rnk[x]<rnk[y]){par[x]=y;}else{par[y]=x;if(rnk[x]==rnk[y])rnk[x]++;}}
bool same(int x,int y){return find(x)==find(y);}

int a,b;

signed main(){
    cin>>a>>b;
    bool ans=(a<=8)&&(b<=8);
    cout<<(ans?"Yay!":":(")<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int main()
{
	int r1, r2;
	cin >> r1 >> r2;
	printf("%.10f\n",1.0/(1.0/r1+1.0/r2));
	return 0;
}

Measured memory_bytes: 256
N,Q=list(map(int,input().split()))
S=input()
place=[0]*(N+1)
for i in range(0,len(S)-1):
    if S[i:i+2]=='AC':
        place[i+2]+=1
        
for i in range(N):
    place[i+1]=place[i]+place[i+1]
for i in range(Q):
    frm,to=list(map(int,input().split()))
    print(place[to]-place[frm])
#print(place)


Measured memory_bytes: 9412
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 25, L = 1e6 + 10, inf = 1e9;

struct edge {
	int u, v, w;
};

vector<edge> edges;

int main() {
	fast_cin();
	int l; cin >> l;
	int n = 20;
	for (int i = 2; i <= n - 1; ++i) {
		edges.pb({i - 1, i, 0});
		edges.pb({i - 1, i, (1 << (i - 2))});
	}
	int f = 0;	
	for (int i = n - 1; i >= 1; --i) {
		int p = (1 << (i - 1));
		while (l >= p) {
			edges.pb({i, n, f});
			l -= p;
			f += p;
		}
	}
	cout << n << ' ' << edges.size() << endl;
	for (auto &e : edges) {
		cout << e.u << ' ' << e.v << ' ' << e.w << endl;
	}
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class ANot {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            out.println(in.nextInt() == 1 ? 0 : 1);
        }

    }

    static class FastScanner {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public FastScanner(InputStream inputStream) {
            reader = new BufferedReader(new InputStreamReader(inputStream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 32900
s = input()
t = input()
N = len(s)
M = len(t)
if s == t:
    print('No')
    exit()
array_s = []
array_t = []
ans = []
for i in range(N):
    array_s.append(s[i])
for i in range(M):
    array_t.append(t[i])
array_s.sort()
array_t.sort(reverse=True)
ans_s = ''
ans_t = ''
for i in range(N):
    ans_s += array_s[i]
for i in range(M):
    ans_t += array_t[i]
ans.append(ans_s)
ans.append(ans_t)
ans.sort()
# print(ans_s)
# print(ans_t)
# print(ans)
if ans[0] == ans_s:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
// clang-format off
	#include <bits/stdc++.h>
	using namespace std; using ll = long long; using uint = unsigned int;
	#define SFINAE(x, ...)	template <class, class = void> struct x : false_type {}; template <class T> struct x<T, void_t<__VA_ARGS__>> : true_type {};
	SFINAE(DefaultIO, decltype(cout << declval<T &>()))
	SFINAE(IsTuple, typename tuple_size<T>::type)
	SFINAE(Iterable, decltype(begin(declval<T>())))
	template <class T> constexpr char Space(const T &) { return (Iterable<T>::value or IsTuple<T>::value) ? '\n' : ' '; }
	template <auto &os> struct Writer {
		template <class T> void Impl(T const &t) const {
			if constexpr (DefaultIO<T>::value) os << t;
			else if constexpr (Iterable<T>::value) { int i = 0; for (auto &&x : t) ((i++) ? (os << Space(x), Impl(x)) : Impl(x)); }
			else if constexpr (IsTuple<T>::value) apply([this](auto const &... args) { int i = 0; (((i++) ? (os << ' ', Impl(args)) : Impl(args)), ...);}, t);
			else static_assert(IsTuple<T>::value, "No matching type for print");
		}
		template <class F, class... Ts> auto &operator()(F const &f, Ts const &... ts) const { return Impl(f), ((os << ' ', Impl(ts)), ...), os << '\n', *this; }
	};
	template <auto &is> struct Reader {
		template <class T> auto& operator()(T &t) const {
			if constexpr (DefaultIO<T>::value) is >> t;
			else if constexpr (Iterable<T>::value) for (auto &x : t) (*this)(x);
			else if constexpr (IsTuple<T>::value) apply([this](auto &... args) { ((*this)(args), ...); }, t);
			else static_assert(IsTuple<T>::value, "No matching type for read");
			return *this;
		}
	};
	#ifdef NARUT_LOCAL
	#define Debug(...) cerr << "\033[0;31m", Writer<cerr>{}(__VA_ARGS__), cerr << "\033[0m\n"
	#else
	#define Debug(...) 0
	#endif
	[[maybe_unused]] constexpr Reader<cin> Cin; [[maybe_unused]] constexpr Writer<cout> Cout;
	#define FOR(i, j, n) for (int i = int(j); i < int(n); ++i)
	#define ROF(i, j, n) for (int i = int(n) - 1; i >= int(j); --i)
// clang-format on





auto Main() {
	int n;
	ll ans = 0;

	unordered_map<int, int> ct;
	cin>>n;
	FOR(ni,0,n) {
		int a;
		cin>>a;
		ans+=a;
		ct[a]++;
	}

	int q;
	cin>>q;
	FOR(qi,0,q) {
		int b,c;
		cin>>b>>c;
		if(auto it = ct.find(b); it!=ct.end()) {
			int num = it->second;
			ans += 1ll*(c-b)*num;
			ct.erase(it);
			ct[c]+=num;			
		}
		Cout(ans);
	}		
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
#ifdef NARUT_LOCAL
	assert(freopen("io/test.in", "r", stdin));
	cin.exceptions(cin.badbit | cin.failbit);
	cerr << fixed << setprecision(10);
#endif

	Main();
}


Measured memory_bytes: 6580
using System;

namespace tenka1_2017_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int ret = 0;
            for (int i = 0; i < 6; i++)
            {
                if (s[i] == '1') ret++;
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;
    public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            int a = sc.nextInt();
            int b = sc.nextInt();

            int x;
            int y;
            
            if(a > b){
                x = a;
                y = b;
            }else{
                x = b;
                y = a;
            }

            int tmp;
            while((tmp = x % y) != 0){
                x = y;
                y = tmp;
            }
            System.out.println(y);
            sc.close();
    }   
}


Measured memory_bytes: 26356
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        double num = sc.nextDouble();
        System.out.println(2 * Math.PI * num);
    }
}


Measured memory_bytes: 37444
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

string toString(int i) {
    stringstream ss;
    ss << i;
    return ss.str();
}

int main() {

    int a, b;
    while (cin >> a >> b) {
        int c = a + b;
        string s = toString(c);
        cout << s.length() << endl;
    }

    return 0;
}

Measured memory_bytes: 1212
n=int(input())
M=[]
for i in range(n):
    M.append(list(map(int,input().split())))

dp=[[0]*n for i in range(n)]

def mincost(x,y):
    if dp[x][y]>0:
        return dp[x][y]
    elif x>=y:
        return dp[x][y]
    else:
        res=float('inf')
        for k in range(x,y):
            temp=mincost(x,k)+mincost(k+1,y)+M[x][0]*M[k][1]*M[y][1]
            res=min(res,temp)
        dp[x][y]=res
        return dp[x][y]

print(mincost(0,n-1))



Measured memory_bytes: 5716
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int main(){
	long long N,A,B;
	cin>>N>>A>>B;
	string S;
	cin>>S;
	int aa=0;
	int bb=0;
	REP(i,S.size()){
	    if(S[i]=='a'){
	       if(aa+bb<A+B){
	          aa++;
	          cout<<"Yes"<<endl;
	       }else{
	          cout<<"No"<<endl;
	       }
	    }else if(S[i]=='b'){
	       if((bb<B)&&(aa+bb<A+B)){
	          bb++;
	          cout<<"Yes"<<endl;
	       }else{
	          cout<<"No"<<endl;
	       }
	    }else{
	       cout<<"No"<<endl;
	    }
	}
	return(0);
}

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

using namespace std;

int main() {
    int64_t A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    // 考え方メモ
    // 10^5なので、forは1重まで
    // Cを何個買うか決めれば、残りは決まるので、Cの全てのパターンを洗い出す -> O(N) -> 10^5
    // Cを基準に選んだ理由は、条件がAとBで対称になり実装が楽なため

    int64_t minTotal = 10000000000000;

    if (X >= Y) {
        for (int i = 0; i <= X; i++) {
            int64_t currentTotal = 0;
            if (Y - i > 0) {
                currentTotal = 2 * C * i + A * (X - i) + B * (Y - i);
            } else {
                currentTotal = 2 * C * i + A * (X - i);
            }
            minTotal = min(minTotal, currentTotal);
        }
    } else {
        for (int i = 0; i <= Y; i++) {
            int64_t currentTotal = 0;
            if (X - i > 0) {
                currentTotal = 2 * C * i + A * (X - i) + B * (Y - i);
            } else {
                currentTotal = 2 * C * i + B * (Y - i);
            }
            minTotal = min(minTotal, currentTotal);
        }
    }

    cout << minTotal << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define sz(a) (int)a.size()
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}

ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 


    
     int solve()
     {  
        int n;string s;cin>>n>>s;
        int ans=0;
        rep0(n){
            string temp="";
            repi(j,i,min(n,i+3)) temp+=s[j];
            if(temp=="ABC") ans++;

        }
        cout<<ans<<endl;

        r0   
     }
    signed main()
    {   
        asdf
        
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct P
{
    int x,y,z;
    bool operator<(const P &a)const{
        //if(y!=a.y) return y>a.y;
        return max(x,-x)>max(a.x,-a.x);

    }

};
vector<P> v;
//bitset<4001000> b;
int i,n,d,m,k,a,b,c,e;
int o[211111];
int l[222221];
int j[1];

int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
int px[10]={-1,1,1,-1,1,1,-1,-1},py[10]={1,1,-1,-1,1,-1,1,-1};
long long mod=1000000007,mod2=1000000009,mod3=2017;
long long x,z,y;
double pi=3.14159265;
P u[111111];
stack<int> s;
//set<int> s,s1;

//priority_queue<int> q;
queue<int> q;
//string r;
char r[211111],r1[11],r2[11];
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
//v.resize(unique(v.begin(),v.end())-v.begin());
/*struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
unordered_map<long long, int, custom_hash> p;//safe_map;
*/
bool as(P a,P b)
{
    //if(a.x!=b.x)
    //return a.x<b.x;
    return a.y<b.y;
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//rng();

int main()
{
    scanf("%d %d %s",&a,&b,r+1);
    for(int t=1;t<=b;t++)
    {
        scanf("%s %s",r1,r2);
        if(r2[0]=='R') l[t]=1;
        else l[t]=-1;
        o[t]=r1[0];
    }
    n=0,m=a;
    for(;n<m;)
    {
        int h=(n+m)/2+1,p=h;
        for(int t=1;h&&h<=a&&t<=b;t++)
        {
            if(r[h]==o[t])
                h+=l[t];
        }
        if(h==0) n=p;
        else m=p-1;
    }
    k+=n;
    n=1,m=a+1;
    for(;n<m;)
    {
        int h=(n+m)/2,p=h;
        for(int t=1;h&&h<=a&&t<=b;t++)
        {
            if(r[h]==o[t])
                h+=l[t];
        }
        if(h>a) m=p;
        else n=p+1;
    }
    printf("%d",n-k-1);
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define data_type long long
#define endl "\n"
#define mod 1000000007

int main()
{
    ios_base::sync_with_stdio(false),cin.tie(nullptr);
    data_type a,b,c,d;
    cin>>a>>b>>c;
    a=abs(a);
    d=a/c;
    data_type curr=min(d,b)*c;
    if(b>d)
    {
       if((b-d)&1)
         cout<<c-a%c<<endl;
       else
       cout<<a%c<<endl;

    }
    else
      cout<<a-curr<<endl;


    return 0;
}


Measured memory_bytes: 3564
import java.util.Scanner;
class Main {
 public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  int S;
  S = sc.nextInt();
  int h;
  h = S/3600;
  int m;
  m = (S%3600)/60;
  int s;
  s = S%60;
  System.out.println(h+":"+m+":"+s);
 }
}


Measured memory_bytes: 26352
#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) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int K, X;

void solve() {
	cin >> K >> X;
	if(K * 500 >= X) cout << "Yes\n";
	else cout << "No\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: 256
#include<bits/stdc++.h>
#define ld long double
using namespace std;

long double t[302][302][302];
bool w[302][302][302];

int n,a;

ld n2;
int tab[4];

long double dp(int a, int b, int c){
    if(a<0 || b<0 || c<0) return 0;
    if(w[a][b][c]) return t[a][b][c];
    w[a][b][c]=true;
    t[a][b][c]=(( n2+(ld)a*dp(a-1,b,c)+(ld)b*dp(a+1,b-1,c)+(ld)c*dp(a,b+1,c-1))/(ld)(a+b+c));
    return t[a][b][c];
}

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    w[0][0][0]=true;

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

    cout<<setprecision(10)<<fixed<<dp(tab[1],tab[2],tab[3]);
    return 0;
}


Measured memory_bytes: 454912
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) {
        int a;
        cin >> a;
        A[i] = a - 1;
    }
    ll ans = 0;
    REP(i, N) { ans += A[i]; }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256