akhauriyash/Code-Regression huggingface dataset:
n,m=map(int,input().split())
if abs(n-m)>=2:
    print(0)
    exit()
mod=1000000007
if n==m:
    nf=1
    mf=1
    for i in range(n):
        nf=nf*(n-i)%mod
        mf=mf*(n-i)%mod
    print(int(2*nf*mf%mod))
else:
    if m>n:
        n,m=m,n
    nf=1
    mf=1
    for i in range(n):
        nf=nf*(n-i)%mod
        if i!=n-1:mf=mf*(m-i)%mod
    print(int(nf*mf%mod))


Measured memory_bytes: 9228
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(int i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")


ll frac[300000];


long long inverse(long long mod, long long val) {
	long long x[2] = { mod, val };
	long long a[2] = { 1, 0 };
	long long i;
	for (i = 0; x[!i]; i ^= 1) {
		a[!i] -= x[i] / x[!i] * a[i];
		x[i] = x[i] % x[!i];
	}
	if (!i) a[!i] += mod;
	return a[!i];
}

ll mod = 998244353;

ll mem[300000];

int main() {
	frac[0] = 1;
	mem[0] = 1;
	ll N, M, K;
	cin >> N >> M >> K;
	if (M == 1) {
		if (K == N - 1) PRI(1);
		else PRI(0);
		return 0;

	}
	REP(i, 1, 300000) {
		frac[i] = frac[i - 1] * i % mod;
		mem[i] = mem[i - 1] * (M - 1) % mod;
	}
	ll ret = 0;
	REP(i, 0, K + 1) {
		ll x = M * mem[N - i - 1] % mod;
		x *= frac[N - 1];
		x %= mod;
		x *= inverse(mod,frac[i]);
		x %= mod;
		x *= inverse(mod,frac[N - 1 - i]);
		x %= mod;
		ret += x;
		ret %= mod;
	}
	PRI(ret);
	return 0;
}




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

int main(){
	int h,w;cin>>h>>w;
	long long dp[h][w];
	for(int i=0;i<h;i++) for(int j=0;j<w;j++) dp[i][j]=0;
	vector<string> v(h);
	for(int i=0;i<h;i++)cin>>v[i];
	dp[0][0]=1;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(v[i][j]=='.'){
				for(pair<int,int> k:{make_pair(i-1,j),make_pair(i,j-1)}){
					if(k.first>=0 && k.first<h){
						if(k.second>=0 && k.second<w){
							dp[i][j]=(dp[i][j] +dp[k.first][k.second])%1000000007;
						}

					}
				}
			}
		}
	}
	cout<<dp[h-1][w-1]<<endl;
}

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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N,K; cin >> N >> K;
	vector<int> a(N);
	repp(i,0,N)	cin >> a[i];
	vector<int> ans;
	int x = -1, y = -1;
	repp(i,0,K+1){
		x = (y==0?1:0);
		repp(j,0,N) if(j != y && a[x] > a[j]) x = j;
		repp(j,0,N) if(j != x && j != y){
			ans.push_back(j+1);
			--a[j];
			if(a[j] < 0) return cout << -1 << endl, 0;;
		}
		ans.push_back(x+1);
		--a[x];
		if(a[x] < 0) return cout << -1 << endl, 0;
		y = x;
	}
	cout << ans.size() << endl;
	for(auto u : ans) cout << u << ' ';
	cout << endl;
	return 0;
}


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

int main(void) {
	int N;
	int64_t kake = 1, tasi = 0;
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		int q, x;
		if (scanf("%d%d", &q, &x) != 2) return 1;
		switch (q) {
			case 1:
				kake *= x;
				tasi *= x;
				break;
			case 2:
				tasi += x;
				break;
			case 3:
				tasi -= x;
				break;
		}
	}
	printf("%" PRId64 " %" PRId64 "\n", -tasi, kake);
	return 0;
}



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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }


void compute() {

}

struct Data {
  string s;
  int p,i;
  bool operator < (const Data &d) const {
    if( s != d.s ) return s < d.s;
    return p > d.p;
  }

};

int main() {
  int n;
  cin >> n;
  vector<Data> vec(n);
  rep(i,n) {
    cin >> vec[i].s >> vec[i].p;
    vec[i].i = i + 1;
  }
  sort(ALL(vec));
  rep(i,n) cout << vec[i].i << endl;
  compute();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
    int64_t N;
    cin >> N;

    int64_t ans = 1e15;
    for(int64_t i=1; i*i<=N; i++) {
        if(N%i == 0) {
            ans = min(ans, i+N/i-2);
        }
    }

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


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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    int N; cin >> N;
    vector<pair<int, ll>> nodes[N];
    rep(i, N-1){
        int u, v; ll w;
        cin >> u >> v >> w;
        nodes[u-1].push_back(make_pair(v-1, w));
        nodes[v-1].push_back(make_pair(u-1, w));
    }
    bool visited[N] = {false};
    int color[N] = {1};
    queue<int> q;
    q.push(0);
    while(!q.empty()){
        int op = q.front();
        q.pop();
        rep(i, nodes[op].size()){
            pair<int, ll> temp = nodes[op][i];
            if(!visited[temp.first]){
                if(temp.second % 2 == 0) color[temp.first] = color[op];
                else color[temp.first] = -color[op];
                visited[temp.first] = true;
                q.push(temp.first);
            }
        }
    }
    rep(i, N){
        if(color[i] == 1) cout << 1 << endl;
        else cout << 0 << endl; 
    }
    return 0;
}

void solve(){}


Measured memory_bytes: 8320
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	string r1, r2;
	cin >> r1 >> r2;

	if (r1[0] == r2[2] && r1[1] == r2[1] && r1[2] == r2[0])cout << "YES" << endl;
	else cout << "NO" << endl;


	return 0;
}

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

int main() {
    ll n;
    cin >> n;
    vector<ll> a(200), b(200);
    for(ll i = 0; i < n - 1; i++) cin >> b[i];
    for(ll i = 0; i < n; i++){
        if(i == 0){
            a[i] = b[i];
        }else if(i < n - 1){
            a[i] = min(b[i], b[i - 1]);
        }else{
            a[i] = b[i -1];
        }
    }
    ll ans = 0;
    for(ll i = 0; i < n; i++) ans += a[i];
    cout << ans << endl;


    
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string s;
int main(){
    cin>>s;
    int n=s.size();
    for(int i=0;i<n;i++)
    {
    if(s[i]=='C'){
    for(int j=i+1;j<n;j++){
        if(s[j]=='F'){
        cout<<"Yes"<<endl;
        return 0;}
        }}}//迭代括号
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()

r = 0
g = 0
b = 0

for i in range(n):
    if s[i] == 'R':
        r += 1
    elif s[i] == 'G':
        g += 1
    else:
        b += 1
ans = r * b * g

for c in range(n):
    center = s[c]
    for dif in range(n):
        if dif + c > n - 1 or c - dif < 0:
            continue
        left = s[c - dif]
        right = s[c + dif]
        if left != center and center != right and right != left:
            ans -= 1
print(ans)

Measured memory_bytes: 68240
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define len(n) (int)n.length()
#define pb push_back
#define ll long long
#define make_pair mkp
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) (v).begin(), (v).end()
#ifdef DBGPRT
#define dbg(n) cerr << "//" << #n << ":" << n <<endl
#else
#define dbg(n) ;
#endif
typedef pair<ll, ll> LLARR;
#define INF 999999999
const double PI = 3.1415926535897932384626433832795;

int main()
{
	ios::sync_with_stdio(false);

	string s;
	cin >> s;
	int f=0;
	REP(i, len(s))
	{
		if(s[i] == 'A')
		{
			f = i;
			break;
		}
	}
	int e = 0;
	REPR(j, s.length())
	{
		if(s[j] == 'Z')
		{
			e = j;
			break;
		}
	}
	dbg(f);
	dbg(e);
	cout << e-f+1 << endl;
	return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

bool U[105];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, C;
    cin >> A >> B >> C;
    ll p = A % B;

    ll t = p;
    while (!U[t]) {
        U[t] = true;
        if (C == t) {
            cout << "YES" << endl;
            return 0;
        }
        t = (t + p) % B;
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s[0] == 'o' && s[s.size()-1] == 'o') cout << 'o' << endl;
  else if(s[0] == 'x' && s[s.size()-1] == 'x') cout << 'x' << endl;
    else{
      string str = "";
      for(int i = 0 ; i < s.size() ; i++){
	if(s[i] != s[i+1]) str += s[i];
      }
      int o=0, x=0;
      for(int i = 0 ; i < str.size() ; i++){
	if(str[i] == 'o') o++;
	if(str[i] == 'x') x++;
      }
      char ans;
      if(o > x) ans = 'o';
      else if(o < x) ans = 'x';
      else ans = 'o';
      
      cout << ans << endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,b,a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
#define pb push_back
#define pf push_front
#define rem 1000000007
#define cont continue
#define PI 3.141592653589793238462643383279502
#define debug(n1) cout<<"debug... "<<n1<<"\n"
const ll INF=(1ll<<60)-1;//ll ans = 3e18 + 5;
////////////////////////////////////////////////////////

////////////////////////////////////////////////////////
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll tc=1;
   // cin>>tc;
    while(tc--)
    {
        ll n;
        cin>>n;
        cout<<1-n;
    }
}

Measured memory_bytes: 3648
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

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

counts = Counter(A)
m = max(A)
ok = True
if m % 2 == 0:
    ok &= min(A) == max(A) // 2
    ok &= counts[min(A)] == 1
else:
    ok &= min(A) == max(A) // 2 + 1
    ok &= counts[min(A)] == 2
for d in range(max(A), min(A), -1):
    ok &= counts[d] >= 2
if ok:
    print('Possible')
else:
    print('Impossible')


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

int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++) cin >> p[i];
  int maxPrice = *max_element(p.begin(), p.end());
  int ans = accumulate(p.begin(), p.end(), 0) - maxPrice/2; 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int n,len=0;
int head[1005],nex[1005],to[1005],v[1005];
void add(int x,int y){to[++len]=y;nex[len]=head[x];head[x]=len;}
int dp[1005][5005],tmp[5005];
int dfs(int now)
{
    dp[now][0]=0;
    for(int i=head[now];i;i=nex[i])
    {
        int w=dfs(to[i]),b=v[to[i]];
        for(int j=0;j<5005;j++)tmp[j]=dp[now][j];
        memset(dp[now],0x3f3f3f3f, sizeof(dp[now]));
        for(int j=0;j<=v[now];j++)
        {
            if(j+w<=v[now])dp[now][j+w]=min(dp[now][j+w],tmp[j]+b);
            if(j+b<=v[now])dp[now][j+b]=min(dp[now][j+b],tmp[j]+w);
        }
    }
    int ans=dp[0][0];
    for(int i=0;i<=v[now];i++)ans=min(ans,dp[now][i]);
    return ans;
}
int main()
{
    memset(dp,0x3f3f3f3f, sizeof(dp));
    cin>>n;
    for(int i=2;i<=n;i++)
    {
        int x;
        cin>>x;
        add(x,i);
    }
    for(int i=1;i<=n;i++)cin>>v[i];
            if(dfs(1)<dp[0][0])printf("POSSIBLE\n");
    else printf("IMPOSSIBLE\n");
    return 0;
}

Measured memory_bytes: 20096
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int i,cnt;
	char a[4],b[4];
	cnt=0;
	for(i=0;i<3;i++){
		cin>>a[i];
	}
	for(i=2;i>=0;i--){
		cin>>b[i];
	}
	for(i=0;i<3;i++){
		if(a[i]==b[i]){
			cnt=cnt+1;
		}
	}
	if(cnt==3){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	
	return 0;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	998244353;
const ll 	N 		= 	2*1e6;


// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m;
string s,t;
set<ll> seen;
// <------------- Implement Functions Here ----------> //ll prime[1000035];

// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n;
	cin >> x >> m;
	seen.insert(x);
	vll seq;
	seq.pb(x);

	for(ll i=0;i<m;i++) {
		x = x*x;
		x %= m;
		if(seen.find(x)==seen.end()) {
			seen.insert(x);
			seq.pb(x);
		}
		else {
			break;
		}
	}

	ll ans = 0;
	ll cou = seq.size();
	ll total = 0;
	//if(n > cou) {
		for(auto it : seq) total += it;
	

	ll pre_sum = 0;
	ll ind  = INF;
	ll presize = 0;
	for(ll i=0;i<cou;i++) {
		if(seq[i] == x) {
			ind = i;

		}
		if(ind <= i) pre_sum+=seq[i];
	}
	presize = cou - ind;

	if(n <= cou) {
		for(ll i=0;i<n;i++) ans+=seq[i];
		cout<<ans;return;
	}

	ans = total;
	n-=cou;

	ll qty = n/presize;

	ans += qty*pre_sum;

	n%=presize;

	for(ll i=0,j=ind;i<n;i++,j++) {
		ans+=seq[j];
	}

	cout<<ans;
}

int main() {
	fastio;randomINT;
	//cin>>T;
	while(T--) {
		MAIN();
	}
	return 0;
}



Measured memory_bytes: 5916
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL; // VL a(n);
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VL> VLL; // VII a(n,VI(m)) n * m
typedef pair<ll, ll> PL;
typedef map<ll, ll> MP; // MP a;
typedef vector<pair<ll, ll>> PS; // PS a(n);

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

int main() {
  ll n,k,m,x=0,y=0,z=0,cnt=0,h=0,w=0,sum=0,ans=0,Max=0, Min=3e9+1;
  string s,t;
  cin >> n;
  VL a(n);
  rep(i,n){
    cin >> a[i];
    chmax(Max,a[i]);
  }
  sort(ALL(a));
  double o = Max/2.0;
  rep(i,n-1){
    if(a[i]!=Max && chmin(Min,abs(a[i]-o))){
      ans = a[i];
    }
  }
  cout << Max << " " << ans << endl;
  return 0;
}

Measured memory_bytes: 4044
n = int(input())
s = input().split(" ")
s = sorted(s)
list = [0] * 26
for i in range(n):
    list[ord(s[i])-97] += 1
ans = []
for i in range(len(list)):
    if list[i] != 0:
        ans.append(list[i])
if len(ans) == 3:
    print("Three")
elif len(ans) == 4:
    print("Four")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 5999999999999999999
#define ALL(n) n.begin(),n.end()
#define ABS(a,b) max(a,b) - min(a,b)

ll n, s[300000], ans = INF64;

int main() {
	cin >> n;
	REP(i, n) {
		ll a;
		cin >> a;
		s[i + 1] = s[i] + a;
	}
	FOR(i, 1, n) {
		ans = min(ans, ABS(s[n] - s[i], s[i]));
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
s = gets.chomp.split('')
q = gets.to_i
isReversed = false

q.times do 
  input = gets.chomp.split()
  if input[0] == "2"
    if input[1] == "1" && !isReversed || input[1] == "2" && isReversed
      s.unshift input[2]
    else
      s.push input[2]
    end
  else
    isReversed = !isReversed
  end
end

puts isReversed ? s.reverse.join('') : s.join('')

Measured memory_bytes: 30844
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

#define MAX_N 200020
ll inv[MAX_N+10],fac[MAX_N+10],ifac[MAX_N+10];

void setComb(){
  inv[0]=1;inv[1]=1;fac[1]=1;ifac[1]=1;fac[0]=1;ifac[0]=1;
  for(int i=2;i<MAX_N;i++){
    inv[i]=(-MOD/i)*inv[MOD%i]%MOD;
    fac[i]=fac[i-1]*i%MOD;
    ifac[i]=ifac[i-1]*inv[i]%MOD;
  }
  return;
}

ll comb(ll n,ll k){
  if(n<k||n<0||k<0) return 0;
  else return ((fac[n]*ifac[k]%MOD*ifac[n-k]%MOD+MOD)%MOD);
}

ll hcomb(ll n,ll r){
  if(n==0&&r==0) return 1;
  else if(n<0||r<0) return 0;
  else return comb(n+r-1,r);
}

string L;
ll two[100010];

int main(){
  cin>>L;

  int N=L.size();
  two[0]=1;
  for(int i=1;i<=N;i++) two[i]=two[i-1]*2%MOD;
  setComb();
  ll ans=0;
  ll pre=1;
  ll len=0;
  int num=0;
  for(int i=0;i<N;i++){
    if(L[i]=='1') num++;
  }

  ans=two[num];

  for(int i=N-1;i>=0;i--){
    if(L[i]=='1'){
      num--;
      ll tmp=0;
      for(int j=0;j<=len;j++){
        ll r=comb(len,j)%MOD*(two[j])%MOD;
        tmp=(tmp+r)%MOD;
      }
      ll t=(tmp*pre)%MOD;
      pre=t;
      t=t*two[num]%MOD;
      ans=(ans+t)%MOD;
      len=1;
    }else{
      len++;
    }
  }

  cout<<(ans+MOD)%MOD<<endl;

  return 0;
}


Measured memory_bytes: 5888
#include<iostream>
using namespace std;
int main()
{
  int n,i,j,s=0;
  cin>>n;
  int* p=new int[n];
    for(i=0;i<n;i++)
    {
    	cin>>p[i];
	}
  for(i=0;i<n-1;i++)
  {
    for(j=i+1;j<n;j++)
    {s+=p[i]*p[j];}
  }
  cout<<s;
  return 0;
}

Measured memory_bytes: 256
import java.util.*

fun <T> list(f:String.()->T) = readLine()!!.split(" ").map {f(it)}

fun main() {
	val (n,m,k) = list {toLong()}
	val a = (listOf(0L)+list {toLong()*2}).toLongArray()
	val b = list {toLong()*2}.toLongArray()

	Arrays.parallelPrefix(a) {i,j-> i+j}
	Arrays.parallelPrefix(b) {i,j-> i+j}

	val l = k*2+1

	println(a.indices.map {if(a[it]>l) 0 else it+Arrays.binarySearch(b,l-a[it]).inv()}.max())
}


Measured memory_bytes: 81756
import java.util.Scanner;
import java.util.*; 
public class Main {
	
	static final int MAXN = 10000001; 
    
    // stores smallest prime factor for every number 
    static int spf[] = new int[MAXN]; 
       
    // Calculating SPF (Smallest Prime Factor) for every 
    // number till MAXN. 
    // Time Complexity : O(nloglogn) 
    static void sieve() 
    { 
        spf[1] = 1; 
        for (int i=2; i<MAXN; i++) 
       
            // marking smallest prime factor for every 
            // number to be itself. 
            spf[i] = i; 
       
        // separately marking spf for every even 
        // number as 2 
        for (int i=4; i<MAXN; i+=2) 
            spf[i] = 2; 
       
        for (int i=3; i*i<MAXN; i++) 
        { 
            // checking if i is prime 
            if (spf[i] == i) 
            { 
                // marking SPF for all numbers divisible by i 
                for (int j=i*i; j<MAXN; j+=i) 
       
                    // marking spf[j] if it is not  
                    // previously marked 
                    if (spf[j]==j) 
                        spf[j] = i; 
            } 
        } 
    } 
       
    // A O(log n) function returning primefactorization 
    // by dividing by smallest prime factor at every step 
    static HashMap<Integer, Integer> getFactorization(int x) 
    { 
        HashMap<Integer, Integer> ret = new HashMap<>(); 
        while (x != 1) 
        { 	
        	if(ret.containsKey(spf[x]))
        		ret.put(spf[x], ret.get(spf[x]) + 1); 
        	else
        		ret.put(spf[x], 1); 
        	x = x / spf[x]; 
        } 
        return ret; 
    } 
	
	
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		
		sieve();
		
		long ans = 0;
		
		for(int i=1;i<n+1;i++)
		{
			HashMap<Integer, Integer> mp = getFactorization(i);
			long facs = 1;
			for (Map.Entry me : mp.entrySet())
			{
				facs*=((int)me.getValue() + 1);
			}
			ans+=(facs*i);
		}
		System.out.println(ans);
		
	}

}


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

int main(){
  
  int n, q, k;
  
  cin >> n;
  vector<int> A(n);
  for(int i = 0;i < n;i++) cin >> A[i];
  
  cin >> q;
  for(int i = 0;i < q;i++){
    int dis_l, dis_u;
    
    cin >> k;
    dis_l = distance(A.begin(), lower_bound(A.begin(), A.end(), k));
    dis_u = distance(A.begin(), upper_bound(A.begin(), A.end(), k));
    
    cout << dis_l << " " << dis_u << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){

    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

bool IsPrime(ll num){
    if(num < 2) return false;
    else if(num == 2) return true;
    else if(num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for(ll i = 3; i <= sqrtNum; i += 2){
        if(num%i==0){
            // 素数ではない
            return false;
        }
    }
    // 素数である
    return true;
}

ll llabs(ll a, ll b){
  if(a>=b) return a-b;
  else return b-a;
}

ll llmax(ll a, ll b){
  if(a>=b) return a;
  else return b;
}

ll llmin(ll a, ll b){
  if(a<=b) return a;
  else return b;
}


signed main(){
  ll n,k; cin>>n>>k;

  if(k==0) return cout<<n*n<<endl,0;

  ll ans;
  reps(b,n){
    if(b-1>=k){
      ans += n/b*(b-k);
      ans += llmax(0LL, (n%b)-k+1);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;
int num = 0;

ll cal(ll A){
    if(A <=0) return 0;
    if(A %2 == 1) return ((A+1)/2) % 2;
    else{
        ll p = ((A+1+1)/2) % 2;
        return p ^ (A+1);
    }
}


int main(){
    ll A, B;
    cin >> A >> B;

    ll ans = cal(B)^cal(A-1);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n, m, c = map(int, input().split())
b = [int(i) for i in input().split()]
a = [input() for j in range(n)]
import numpy as np
b = np.array(b)
num = 0
for i in range(n):
    aa = np.array([int(j) for j in a[i].split()])
    if np.sum(aa.dot(b)) + c > 0:
        num += 1
print(num)

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

signed main(){
	int N, K;
	scanf("%d%d", &N, &K);
	vector<int> have(N, 0);
	while(K--){
		int d;
		scanf("%d", &d);
		while(d--){
			int A;
			scanf("%d", &A);
			A--;
			if(have[A] == 0){
				have[A] = 1;
				N--;
			}
		}
	}
	printf("%d\n", N);
	return 0;
}

Measured memory_bytes: 3748
L, R = map(int, input().split())
 
m = 2019
flag = False
for i in range(L, R):
  for j in range(i+1, R+1):
    m = min(m, i*j % 2019)
    if m == 0: 
      flag = True
      break
  if flag: break
      
print(m)

Measured memory_bytes: 9036
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//BEGIN CUT HERE
template <typename E>
struct SegmentTree{
  using H = function<E(E,E)>;
  int n,height;
  H h;
  E ei;
  vector<E> laz;
  SegmentTree(H h,E ei):h(h),ei(ei){}  
  void init(int n_){
    n=1;height=0;
    while(n<n_) n<<=1,height++;
    laz.assign(2*n,ei);
  }
  inline void eval(int k){
    if(laz[k]==ei) return;
    laz[(k<<1)|0]=h(laz[(k<<1)|0],laz[k]);
    laz[(k<<1)|1]=h(laz[(k<<1)|1],laz[k]);
    laz[k]=ei;
  }
  inline void thrust(int k){
    for(int i=height;i;i--) eval(k>>i);
  }
  void update(int a,int b,E x){
    thrust(a+=n);
    thrust(b+=n-1);
    for(int l=a,r=b+1;l<r;l>>=1,r>>=1){
      if(l&1) laz[l]=h(laz[l],x),l++;
      if(r&1) --r,laz[r]=h(laz[r],x);
    }
  }
  E get_val(int a){
    thrust(a+=n);
    return laz[a];
  }
  void set_val(int a,E x){
    thrust(a+=n);
    laz[a]=x;
  }
};
//END CUT HERE

struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed AOJ_DSL_2_D(){
  int n,q;
  cin>>n>>q;
  auto h=[](int a,int b){(void)a;return b;};  
  int ei=INT_MAX;
  SegmentTree<int> seg(h,ei);
  seg.init(n);
  for(int i=0;i<q;i++){
    int tp;
    cin>>tp;
    if(tp==0){
      int s,t,x;
      cin>>s>>t>>x;
      seg.update(s,t+1,x);
    }
    if(tp==1){
      int s;
      cin>>s;
      cout<<seg.get_val(s)<<"\n";
    }    
  }
  cout<<flush;
  return 0;  
}

signed main(){
  AOJ_DSL_2_D();
  //AOJ_DSL_2_E();
  return 0;
}



Measured memory_bytes: 3864
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
using in = int64_t;

int main(){
int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a.at(i);
  vector<int> b(n);
  rep(i,n) b.at(i) = a.at(i);
  
  sort(all(b));
  int ser =1; 
  for(int i=0;i<n;i++){
     if(a.at(i)==ser) ser ++;
  }
  if(ser==1) cout<<-1;
  else cout<<n-ser+1;
}


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

int main(){
    int i, a, r = 0, n;
    long long c = 0;
    cin >> n;
    for(i=0; i<n; i++){
        cin >> a;
        if(a != 0){
            c += (long long)(a+r)/2;
            r = (a+r)%2;
        }else{
            r = 0;
        }
    }
    cout << c;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char data[4];//文字
  char* result="";//文字列
  int flag=0;
  scanf("%s" , data);
  for(int i=0;i<4;i++){
    for(int j=0;j<4;j++){
      if(!(i==j) && (data[i]==data[j])){
        flag+=1;
      }
    }
  }
  if(flag==4){
      result="Yes";
  }else{
      result="No";
  }
  printf("%s",result);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <set>

using namespace std;

int main() {
    string S;
    set<char> s;
    cin >> S;
    for (int i = 0; i < S.size(); i++) {
        s.insert(S[i]);
    }
    if (s.size() == 1) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	string S, T;
	cin >> S >> T;
	int N = S.length();
	int ans = 0;
	for(int i = 0; i < N; i++){
		if(S[i] != T[i]){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	int r;
	cin >> r;
	cout << d20 << 2 * r * M_PI << endl;
	return 0;
}

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

int main()
{
    string S, V = "";
    cin >> S;
    rep(i, 0, S.length())
    {
        V += "x";
    }
    cout << V << endl;
}

Measured memory_bytes: 256
s=input()
#for i in range(len(s),0,-1):
#    for j in range(0,len(s)-i+1):
#        #print(j,i+j)
#        s1=s[j:i+j:]
m=0
s1=""
for x in s:
    if x=='A' or x=='G' or x=='T' or x=='C':
        s1+=x
    else:
        #print(s1)
        m=max(m,len(s1))
        s1=""
print(max(m,len(s1)))



Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define STDIO
#define MOD 1000000007
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
#define lowbit(x) ((x)&(-x))
#define INF MOD
using namespace std;
int n;
vector<int> q;
void Search(int x,int y){
	if(x==n+1){
		for(int i=0;i<n;i++)
			cout<<(char)(q[i]+'a');
		cout<<endl;
		return;
	}
	//cur:only allow 0....y
	for(int i=0;i<=y;i++){
		q.push_back(i);
		Search(x+1,max(i+1,y));
		q.pop_back(); 
	}
}
int main(){
	#ifndef STDIO
		freopen("input.in","r",stdin);
		freopen("output.out","w",stdout);
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	Search(1,0);
	return 0;
}


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

int main(){
 int  a;
  cin >> a ;
  int c[100];
  for (int i =0;i<a;i++)
    
  cin >> c[i];
  
  
  int b;
  cin >> b;
  int d[100],e[100];
  
   for(int j =0;j<b;j++)
    cin >> d[j] >> e[j];
  for(int j = 0; j<b ;j++){
    int f = 0;
  for (int i =0; i<a ;i++){
    if(d[j] == (i+1)){
      f += e[j];
    }
    else{
      f += c[i];
    }
  }
 
  
  cout << f <<endl;
  }
    
 
}



Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a + 1):
    for j in range(b + 1):
        xij = x - 500 * i - 100 * j
        if xij >= 0 and xij // 50 <= c and xij % 50 == 0:
            ans += 1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int n;
    cin >> n;
    if (n / 100 == n % 10) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}




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

using namespace std;
#define foru(i, a, n) for (int i=(a); i<=(n); i++)
#define ford(i, n, a) for (int i=(n); i>=(a); i--)
#define rep(i, n) for(int i=0; i<n; i++)
#define foreach(it, a) for (auto it = (a).begin(); it != (a).end(); it++)
#define pb push_back
#define mp make_pair
#define sz(a) int((a).size())
#define all(x) (x).begin(),(x).end()
#define ms(s, n) memset(s, n, sizeof(s))
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define fi first
#define se second
#define bit(n, i) (((n) >> (i)) & 1)
#define bit1cnt(x) (__builtin_popcountll(x))
#define bit0dau(x) (__builtin_clzll(x))
#define bit0cuoi(x) (__builtin_ctzll(x))
#define sqr(x) ((x) * (x))
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> LL;
typedef vector<int> vi;
typedef vector<ii> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = 1007681537;
const int inf = (int) 1e9;
const ll linf = (ll) 1e18;
const ld pi = acos((ld) -1);
const ld eps = 1e-9;
const int N = 202020;
ll n, X, a[N], D;

int main() {
    ///freopen("a.in", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> X;
    foru(i, 1, n) cin >> a[i];
    if (n == 1)
        cout << abs(a[1] - X);
    else {
        a[++n] = X;
        sort(a + 1, a + 1 + n);
        D = a[2] - a[1];
        foru(i, 3, n) D = __gcd(D, a[i] - a[i - 1]);
        cout << D;
    }

    return 0;
}


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

int main(){
    int n;
    cin >> n;
    ll a[n];
    for(int i=0; i<n; i++){cin >> a[i];}
    ll ans=0;
    for(int i=1; i<n; i++){
        int x=0;
        if(a[i]<a[i-1]){
            ans+=a[i-1]-a[i];
            x=a[i-1]-a[i];
            a[i]=a[i-1];
        }
        //cout << x << endl;
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 5188
require 'pp'

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

W, H, x, y = gets_i_list
ans = (W * H).to_f / 2

if (W.to_f / 2) == x && (H.to_f / 2) ==y
  puts [sprintf("%10.9f", ans), 1].join(" ")
else
  puts [sprintf("%10.9f", ans), 0].join(" ")
end

Measured memory_bytes: 4092
#include <iostream>
#include <algorithm>
#include <atomic>
#include <thread>
#include <mutex>
#include <string>
#include <string.h>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#define rep(i,n) for(int i=0;i<n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define INF LLONG_MAX/3
#define P std::pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int n;
string a, b, c;
signed main() {
	cin >> n >> a >> b >> c;
	int ans = 0;
	rep(i, n) {
		char s[] = { a[i],b[i],c[i] };
		sort(s, s + 3);
		if (s[0] == s[1] || s[1] == s[2]) {
			if (s[0] != s[2])ans += 1;
		}
		else ans += 2;
	}
	cout << ans << endl;
	return 0;


}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
using namespace std;
typedef long long LL;
//#define _USE_MATH_DEFINES

int main(void) {
	LL n, k, num, j = 0, m = 0;
	cin >> n >> k;

	vector<LL> a(n);

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

	for (LL i = 0; i < n; i++) {
		j += k;
		m++;
		if (j >= n) {
			cout << m << endl;
			return 0;
		}
		j--;

	}



	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main() {
    string s;
    cin >> s;

    int i0 = 0, i1 = (int)s.size() - 1;
    int r = 0;
    for (;;) {
        if (i0 >= i1) break;

        int x0 = 0, x1 = 0;
        while (i0 < i1 && s[i0] == 'x') i0++, x0++;
        while (i0 < i1 && s[i1] == 'x') i1--, x1++;

        if (i0 < i1) {
            if (s[i0] != s[i1]) {
                r = -1;
                break;
            }
            r += abs(x0 - x1);
        } else {
            if (s[i0] != 'x') r += abs(x0 - x1);
            break;
        }
        i0++; i1--;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<set>
#include<queue>
#include<string>
#include<sstream>
#include<iostream>
#include<sstream>
#include<stack>
#include<map>
#include<vector>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<math.h>
#include <cassert>
using namespace std;
typedef long long ll;
#define mod 9999973
#define MAXN 3100
char a[210000];
int main()
{
	scanf("%s", a);
	ll n = strlen(a);
	ll now = 0;
	ll ans = 0;
	for (int i = 0; i < n; i++)
	{
		if (a[i] == 'A')now++;
		else if (a[i] == 'B')
		{
			if (a[i + 1] == 'C')
			{
				ans += now;
				i++;
			}
			else now = 0;
		}
		else now = 0;
	}
	printf("%lld", ans);
}

Measured memory_bytes: 384
s = input()

acgt = ['A', 'C', 'G', 'T']
count = 0
ans = 0

for i in range(len(s)):
    if s[i] in acgt:
        count += 1
    ans = max(ans, count)
    if not s[i] in acgt:
        count = 0

print(ans)

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

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main() {
    int N;
    cin >> N;
    int A, B;
    cin >> A >> B;
    if((B - A) % 2 == 0) puts("Alice");
    else puts("Borys");
}

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

typedef long double ld;

const ld EPS = 1e-9;
const ld INF = 1e10;
const ld PI = M_PI;

struct Point{
  ld x, y;
  Point(ld x, ld y):x(x), y(y){}
  Point(){}
};

Point operator+(const Point &a, const Point &b){
  return Point(a.x + b.x, a.y + b.y);
}
Point operator-(const Point &a, const Point &b){
  return Point(a.x - b.x, a.y - b.y);
}
Point operator*(const Point &a, const ld b){
  return Point(a.x * b, a.y * b);
}
Point operator*(const Point &a, const Point &b){
  return Point(a.x*b.x-a.y*b.y, a.x*b.y+a.y*b.x);
}
Point operator/(const Point &a, const ld b){
  return Point(a.x / b, a.y / b);
}

ld dot(const Point &a, const Point &b){
  return a.x*b.x + a.y*b.y;
}

ld norm(const Point &a){
  return dot(a, a);
}

struct Line:vector<Point>{
  Line(Point a = Point(0, 0), Point b = Point(0, 0)){
    this->push_back(a);
    this->push_back(b);
  }
};

Point projection(const Line &l, const Point &p){
  ld t = dot(p-l[0], l[1]-l[0]) / norm(l[0] - l[1]);
  return l[0] + (l[1] - l[0]) * t;
}


int main(){  
  Point p0, p1;
  cin >> p0.x >> p0.y >> p1.x >> p1.y;  
  Line base(p0, p1);
  
  int q;
  cin >> q;
  
  Point p2;
  while(q--){
    cin >> p2.x >> p2.y;
    
    Point ans = projection(base, p2);
    printf("%.10Lf %.10Lf\n", ans.x, ans.y);
  }
  
  return 0;
}

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

#define Flash ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define mp make_pair
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define ll long long
#define sz size()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const long long MXN = 2e4 + 1;
const long long MXX = 2e5 + 1;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const long long OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

char a[5];

int main()
{
    Flash;
    for(int i = 1; i <= 4; i ++){
        cin >> a[i];
    }
    for(int i = 2; i <= 4; i ++){
        if(a[i] == a[i - 1]) return cout << "Bad", 0;
    }cout << "Good";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define REPR(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define all(v) v.begin(), v.end()
typedef long long ll;

#define MAX 500000
#define SENTINEL 2000000000

int n;
int A[MAX];
int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int left, int mid, int right){
  int n1 = mid - left;
  int n2 = right - mid;
  rep(i, n1) L[i] = A[left+i];
  rep(i, n2) R[i] = A[mid+i];
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;
  int i = 0;
  int j = 0;
  REP(k, left, right-1){
    cnt++;
    if(L[i] <= R[j]) A[k] = L[i++];
    else A[k] = R[j++];
  }
}

void mergeSort(int left, int right){
  if(left+1 < right){
    int mid = (left+right)/2;
    mergeSort(left, mid);
    mergeSort(mid, right);
    merge(left, mid, right);
  }
}

int main(){
  cin >> n;
  rep(i, n) cin >> A[i];

  cnt = 0;
  mergeSort(0, n);

  rep(i, n){
    if(i == n-1) cout << A[i] << endl;
    else cout << A[i] << " ";
  }
  cout << cnt << endl;
 
  return 0;
}





Measured memory_bytes: 6984
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 998244353
using namespace std;


int main(){
    int N;
    cin >> N;
    if(N%2==0){
        cout<<N/2-1<<endl;
    }else{
        cout<<N/2<<endl;
    }
    return 0;
    
}


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

using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(1){
        c-=b;
     if(c<1){
            cout<<"Yes";
            return 0;
        } if(c<1){
            cout<<"Yes";
            return 0;
        }
        a-=d;

        if(a<1){
            cout<<"No";
            return 0;
        }
    }
}


Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

class union_find {
public:
	union_find(vector<ll> v) {
		init(v);
	}
	void init(vector<ll> v) {
		ll n = v.size();
		par_.resize(n);
		REP(i, n) {
			par_[i].first = -1;
			par_[i].second.first = v[i];
			par_[i].second.second = 0;
		}
		return;
	}

	int root(int x) {
		return par_[x].first < 0 ? x : par_[x].first = root(par_[x].first);
	}

	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if(x == y) {
			return false;
		} else {
			if(par_[x].first < par_[y].first) {
				par_[x].first += par_[y].first;
				par_[x].second.first += par_[y].second.first;
				par_[x].second.second += par_[y].second.second;
				par_[y].first = x;
			} else {
				par_[y].first += par_[x].first;
				par_[y].second.first += par_[x].second.first;
				par_[y].second.second += par_[x].second.second;
				par_[x].first = y;
			}
			return true;
		}
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	void add_edge(int x) {
		par_[root(x)].second.second++;
	}

	ll get_edge(int x) {
		return par_[root(x)].second.second;
	}

	void rem_edge(int x) {
		par_[root(x)].second.second = 0;
	}

	ll get_sum(int x) {
		return par_[root(x)].second.first;
	}

	int size(int x) {
		return -par_[root(x)].first;
	}

private:
	std::vector<pair<int, pll>> par_;
	// first: 親
	// second.first: 重み和
	// second.second: 未確定辺
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m;
	cin >> n >> m;
	vector<ll> x(n);
	REP(i, n) cin >> x[i];
	vector<pair<ll, pll>> edge;
	REP(i, m) {
		ll a, b, y;
		cin >> a >> b >> y;
		a--; b--;
		edge.pb(make_pair(y, pll(a, b)));
	}
	sort(ALL(edge));
	ll ans = 0;
	union_find uf(x);
	REP(i, m) {
		ll a = edge[i].second.first, b = edge[i].second.second;
		ll cost = edge[i].first;
		if(uf.same(a, b)) {
			if(uf.get_sum(a) >= cost) {
				ans++;
			} else {
				uf.add_edge(a);
			}
		} else {
			uf.unite(a, b);
			if(uf.get_sum(a) >= cost) {
				ans++;
				ans += uf.get_edge(a);
				uf.rem_edge(a);
			} else {
				uf.add_edge(a);
			}
		}
	}
	cout << m - ans << endl;
	return 0;
}

/* --------------------------------------- */


Measured memory_bytes: 7920
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;

int x, y;

signed main() {
	cin >> x >> y;
	cout << x + y / 2 << endl;
	return 0;
}

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

int main() {
  int N, x;
  cin >> N;
  vector<int> A(N);
  int M = 0;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    if(M<A.at(i)) {
        M= A.at(i);
        x = i;
    }
  }
  sort(A.begin(), A.end());

  for (int i = 0; i < N; i++) {
      if(i==x) cout << A.at(N-2) << endl;
      else cout << M << endl;
  }

}

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


#define _LL long long

_LL* mallocint(int si)
{
    return (_LL*) malloc(si * sizeof(_LL));
}

_LL* inputint(_LL n)
{
    _LL *ans = mallocint(n);
    for( _LL i = 0; i < n; i++ ) cin >> ans[i];
    return ans;
}

int main()
{
    _LL n;
    cin >> n;
    _LL *a = inputint(n);

    _LL index = 1;
    for( _LL i = 0; i < n; i++ )
    {
        if( a[i] == index ) index++;
    }
    if( index == 1 )
    {
        cout << -1;
        return 0;
    }
    cout << n - (index - 1) ;
}

Measured memory_bytes: 5160