akhauriyash/Code-Regression huggingface dataset:
/**
 * File    : JOI_2005_triangle_types.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-3-8 21:20:52
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int cnt[3] = {0, 0, 0};

int main()
{
  int a[3];
  while (cin >> a[0] >> a[1] >> a[2])
  {
    sort(a, a + 3);
    if (a[0] + a[1] <= a[2])
    {
      cout << cnt[0] + cnt[1] + cnt[2] << " "
           << cnt[1] << " " << cnt[0] << " " << cnt[2] << endl;
      return 0;
    }
    int s = a[0] * a[0] + a[1] * a[1];
    int t = a[2] * a[2];
    if (s < t)
    {
      cnt[2]++;
    }
    else if (s == t)
    {
      cnt[1]++;
    }
    else
    {
      cnt[0]++;
    }
  }
}


Measured memory_bytes: 3180
#include<cstdio>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

const int maxn=1e5+5;

int n,m;

int tot,go[2*maxn],next[2*maxn],f1[maxn];
void ins(int x,int y)
{
	go[++tot]=y;
	next[tot]=f1[x];
	f1[x]=tot;
}

bool bz[maxn];
int fro[maxn];
int dfs(int k)
{
	for(int p=f1[k]; p; p=next[p]) if (!bz[go[p]])
	{
		bz[go[p]]=1;
		fro[go[p]]=k;
		return dfs(go[p]);
	}
	return k;
}

int d10,d1[maxn],d20,d2[maxn];
int main()
{
	int a,b;
	
	scanf("%d %d",&n,&m);
	fo(i,1,m)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		ins(x,y), ins(y,x);
		if (i==1) a=x, b=y;
	}
	
	bz[a]=bz[b]=1;
	int st=dfs(a), en=dfs(b);
	for(int i=st; i!=a; i=fro[i]) d1[++d10]=i;
	for(int i=en; i!=b; i=fro[i]) d2[++d20]=i;
	
	printf("%d\n",d10+2+d20);
	fo(i,1,d10) printf("%d ",d1[i]);
	printf("%d %d ",a,b);
	fd(i,d20,1) printf("%d ",d2[i]);
}

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

public class Main{
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        FastReader s = new FastReader();
        int k = s.nextInt();
        System.out.println("ACL".repeat(k));
    }

}


Measured memory_bytes: 32540
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;


ll COMB(int n, int r) {
  std::vector<std::vector<long long>> v(n + 1,std::vector<long long>(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++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v[n][r];
}

int main(){
    int n;cin>>n;
    vector<int>a(n);
    map<ll,ll>mp;
    rep(i,n){
        cin>>a[i];
        mp[a[i]]++;
    }
    vector<ll>comb(200005);
    ll sum = 0;
    for(auto m : mp){
        if(m.second<2)continue;
        comb[m.first] = m.second*(m.second-1)/2;
        sum += comb[m.first];
    }
    rep(i,n){
        ll res;
        if(mp[a[i]]<2)res = sum;
        else res = sum-comb[a[i]]+(comb[a[i]]*(mp[a[i]]-2)/mp[a[i]]);
        cout<<res<<endl;
    }
}



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

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

int main() {
    string s;
    int start = 200005, goal = 0;
    cin >> s;
    rep(i, s.size()) {
        if (s[i] == 'A') {
            start = min(i, start);
        } 
        if (s[i] == 'Z') {
            goal = max(i, goal);
        }
    }
    cout << abs(start-goal) + 1 << endl;

    return 0;
}


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

int main(void)
{
    int N,K;
    ll ans = 1;
    cin >> N >> K;

    ans *= K;
    rep(i, N-1){
        ans *= K-1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3536
// 7以上が出るまでの累積和は
// 1 3 6 10 でi=4 それ以下のはどうとでも構築できる
// つかそう思えばビットが立ってるとこだけでいい気がするが
// -> そんなことありませんでした
// 予め10^7以下となるまでの累積和を用意して大きい順？にひいていく？
// ちがうわ 累積したらそこまでに不要なのが1つだけ出てくる...
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	idx := 1
	tmp := 1
	ruisekis := []int{idx}
	for tmp < N {
		idx++
		tmp += idx
		ruisekis = append(ruisekis, idx)
	}
	for _, a := range ruisekis {
		if a != tmp-N {
			fmt.Println(a)
		}
	}
}


Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	vector<long long> a(n, 0);
	long long sum = 0;
	long long sum2 = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
		if (i % 2 == 1) {
			sum2 += a[i] * 2;
		}
	}

	vector<int> mountain(n, 0);
	mountain[0] = sum - sum2;
	for (int i = 1; i < n; i++) {
		mountain[i] = 2 * a[i - 1] - mountain[i - 1];
	}

	for (int i = 0; i < n; i++) {
		if (i != 0) {
			cout << " ";
		}
		cout << mountain[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 2432
#include <iostream>

using namespace std;

int gcd(int a, int b) {return b? gcd(b,a%b) : a;};
int lcm(int a, int b) {return a / gcd(a,b) * b;};

int main() {
    int n;
    cin >> n;
    cout << lcm(2,n) << endl;
}

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

int main() {
  uint64_t n;
  std::cin >> n;

  uint64_t count = 1;
  uint64_t before;
  uint64_t mod = 1000000007;
  std::vector<uint64_t> c(200001, 0);

  std::cin >> before;
  c[before] = count;
  for (uint64_t i = 1; i < n; i++) {
    uint64_t tmp;
    std::cin >> tmp;

    if (c.size() < tmp + 1) {
      c.resize(tmp + 1, 0);
    }

    if (before == tmp) {
      continue;
    } else {
      count += c[tmp];
      count %= mod;
      c[tmp] = count;
    }
    before = tmp;
  }
  std::cout << count << std::endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int p[n];
  for(int i=0; i<n; i++) {
    cin >> p[i];
  }
  int cnt = 0;
  for(int i=1; i<n-1; i++) {
    if(p[i]>p[i-1] && p[i+1]>p[i]) {
      cnt++;
    }
    if(p[i]>p[i+1] && p[i-1]>p[i]) {
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

int n, h, w;

int main(){
	scanf("%d %d %d", &n, &h, &w);
	return !printf("%d\n", (n - h + 1) * (n - w + 1));
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long n,ans;
long long pt(int x)
{
    long long ret=2;
    for(int i=1;i<=x;i++)
    {
        ret*=5;
    }
    return ret;
}
int main()
{
    scanf("%lld",&n);
    if(n%2)
    {
        printf("0");
        return 0;
    }
    for(long long i=1;i<=26;i++)
    {
        ans+=n/pt(i);
    }
    printf("%lld",ans);
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)

def get_root(s):
    if s != root[s]:
        root[s] = get_root(root[s])
        return root[s]
    return s

def unite(s, t):
    root_s = get_root(s)
    root_t = get_root(t)
    if not root_s == root_t:
        if rank[s] == rank[t]:
            root[root_t] = root_s
            rank[root_s] += 1
        elif rank[s] > rank[t]:
            root[root_t] = root_s
        else:
            root[root_s] = root_t

def same(s, t):
    if get_root(s) == get_root(t):
        return True
    else:
        return False

n, m = map(int, input().split())
root = [i for i in range(n)]
rank = [1 for _ in range(n)]
size = [1 for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    if not same(a - 1, b - 1):
        unite(a - 1, b - 1)
x = [0] * n
ans = 0
for i in range(n):
    j = get_root(i)
    x[j] += 1
    ans = max(ans, x[j])
print(ans)
"""

from collections import deque

def bfs(s):
    q = deque()
    q.append(s)
    visit[s] = 1
    cnt = 1
    while q:
        p = q.popleft()
        for j in G[p]:
            if visit[j] == 0:
                q.append(j)
                visit[j] = 1
                cnt += 1
    global ans
    ans = max(ans, cnt)
    return

n, m = map(int, input().split())
G = [[] for _ in range(n + 1)]
for _ in range(m):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)
visit = [0] * (n + 1)
ans = 0
for i in range(1, n + 1):
    if visit[i] == 0:
        bfs(i)
print(ans)
"""

Measured memory_bytes: 103100
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;

int main() {
    string s; cin >> s;
    auto rec = [&](auto &&rec, int i, ll n, ll m) -> ll {
        if (i == s.size()) return n+m;
        int a = s[i] -'0';
        ll ret = rec(rec, i+1, n+m, a);
        if (i) ret += rec(rec, i+1, n, m*10+a);
        return ret;
    };
    cout << rec(rec, 0, 0, 0) << endl;
}

Measured memory_bytes: 256
#include <iostream>


int main() {
	int y, m, d, s;
	while (std::cin >> y >> m >> d) {
		s  = y; s *= 100;
		s += m; s *= 100;
		s += d;

		if (18680908 <= s && s <= 19120729) {
			std::cout << "meiji ";
			y -= 1867;
		}
		else if (19120730 <= s && s <= 19261224) {
			std::cout << "taisho ";
			y -= 1911;
		}
		else if (19261225 <= s && s <= 19890107) {
			std::cout << "showa ";
			y -= 1925;
		}
		else if (19890108 <= s) {
			std::cout << "heisei ";
			y -= 1988;
		}
		else {
			std::cout << "pre-meiji" << std::endl;;
			continue;
		}
		std::cout << y << " " << m << " " << d << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3020
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

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

ll mod = 1e9 + 7;


int main(){
	int a,b;
	cin >> a >> b;
	cout << max(0, a-2*b) << endl;
	return 0;
}


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

using namespace std;

void solve(vector<int> A) {
  int ans = min({abs(A[0] - A[1]) + abs(A[0] - A[2]),
                 abs(A[1] - A[0]) + abs(A[1] - A[2]),
                 abs(A[2] - A[0]) + abs(A[2] - A[1])});
  printf("%d\n", ans);
}

int main() {
  vector<int> A(3);
  for (int i = 0; i < 3; i++) {
    cin >> A[i];
  }
  solve(A);
  return 0;
}


Measured memory_bytes: 256
import math
n,d = map(int,input().split())
positions = [list(map(int,input().split())) for _ in range(n)]
ans = 0
for i in range(n):
    for j in range(n):
        pre = 0
        if i == j:
            continue
        for k in range(d):
            pre += abs(positions[j][k]-positions[i][k])**2
            # if i == 0 and j == 2:
                # print(pre)
        pre = math.sqrt(pre)
        if pre % 1 == 0:
            pre = int(pre)
        # print(i,j,pre)
        if isinstance(pre,int):
            ans += 1
print(ans//2)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define Pr(a) (#a)<<"="<<(a)<<" "
#define pr1(a) cerr<<Pr(a)<<endl;
#define pr2(a,b) cerr<<Pr(a)<<Pr(b)<<endl;
#define pr3(a,b,c) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<endl;
#define pr4(a,b,c,d) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<endl;
#define pr5(a,b,c,d,e) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<endl;
#define pr6(a,b,c,d,e,f) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<Pr(f)<<endl;
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


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

  int n;
  cin>>n;
  vector<P> A(n);
  for(int i=0;i<n;i++) cin>>A[i].first, A[i].second = i;
  sort(A.begin(),A.end());

  vector<int> ans(n);
  int m = (n - 1) / 2;
  for(int i=0;i<n;i++){
    int l = i;
    int r = n - 1 - i;
    int idx;
    if(l > m) idx = m;
    else idx = i+1+m - l;
    ans[A[i].second] = A[idx].first;
  }

  for(int i=0;i<n;i++)cout<<ans[i]<<endl;
  

  return 0;
}


Measured memory_bytes: 6912
//Author: Mohammad Faisal
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n,k;
  cin >> n >> k;
  int * arr = new int [n+1];
   arr[0] = 0;
  int count=0;
  if(arr[0]<=k)
    count++;
  for(int i=1;i<=n;i++)
  {
    int x;
    cin >> x;
    arr[i] = arr[i-1] + x;
    if(arr[i]<=k)
      count++;
  }
  cout<<count<<endl;
  return 0;
  }

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

#define MAX 10

int main()
{
	int n, a;
	char s[MAX];
	int count=0;

	scanf("%d",&n);

	for(int i=1; i<=n; i++){
		snprintf(s,MAX,"%d",i);
		a=strlen(s);
		if(a%2==1)
			count++;
	}

	printf("%d\n",count);

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>
int main(){
	int i=0,j;
	double x[21],y[21],s=0;
    //値の読み込み
    
    while(scanf("%lf,%lf\n",&x[i],&y[i]) !=EOF) {
    		//scanf("%lf%lf",&x[i],&y[i]);
    		i++;
    	}
    	j=i;
    	for(i=0;i<j-1;i++){
    		s+=(x[i]*y[i+1]-x[i+1]*y[i]);
    	}
        s+=(x[i]*y[0]-x[0]*y[i]);
    	printf("%.6lf\n",(fabs(s))/2.0);
    
    return 0;
}



Measured memory_bytes: 1980
#include <iostream>
using namespace std;
typedef long long ll;

int main(void){
    int n;
    cin >> n;
    
    int t[n], x[n], y[n];
    
    for(int i = 0; i < n; i++){
        cin >> t[i] >> x[i] >> y[i];
    }
    
    int nowX = 0;
    int nowY = 0;
    bool ok = true;
    for(int i = 0; i < n; i++){
        int distance = abs(nowX - x[i]) + abs(nowY - y[i]);
        int needTime;
        if(i == 0){
            needTime = t[i];
        } else {
            needTime = t[i] - t[i - 1];
        }
        if(needTime < distance){
            ok = false;
            break;
        }
        if(needTime % 2 == 0 && distance % 2 != 0){
            ok = false;
            break;
        }
        if(needTime % 2 != 0 && distance % 2 == 0){
            ok = false;
            break;
        }
        
        nowX = x[i];
        nowY = y[i];
    }
    
    if(ok){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    for (auto &c:s) {
        int a = c - 'A';
        a = (a + n) % 26;
        c = 'A' + a;
    }
    cout << s << '\n';
    return 0;
}

Measured memory_bytes: 256
n=int(input())
start_end_map={}
for i in range(1,n+1):
    char=str(i)
    start=char[0]
    end=char[-1]
    if end=="0":
        continue
    if (start,end) not in start_end_map:
        start_end_map[(start,end)]=0
    if (end,start) in start_end_map:
        start_end_map[(start,end)]+=1
        if start!=end and start_end_map[(end,start)]==0:
            start_end_map[(end,start)]=1
    
counter=0
for key,value in start_end_map.items():
    if value==0:
        continue
    start,end=key
    if (end,start) in start_end_map:
        counter+=start_end_map[(start,end)]*start_end_map[(end,start)]
print(counter)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<deque>
#include<string>
#include<iomanip>
using namespace std;
int main(){
  int n, a; cin >> n;
  vector<int> b(0);
  long s;

  for(int i = 0; i < n; i++){
    cin >> a;

    if((n + i) % 2 == 0){
      b.push_back(a);
    } else {
      b.insert(b.begin(), a);
    }
  }

  for(int i = 0; i < n; i++){
    cout << b[i] << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC targett("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(ll i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 4e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time"<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//_______________________________________________________________________________
int main()
{
       ll a,b,c,d;
       cin>>a>>b>>c>>d;
       ll ans = b*d;
       ans = max(ans,(a*c));
       ans = max(ans,(a*d));
       ans = max(ans,(b*c));
       cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890
#define MOD 998244353
#define de(x) if(x!=0 && MODE==x)
#define MODE 1
using namespace std;

int D[100007];
int chart[100007]={};

int main()
{
    int i,j;
    int N;

    scanf("%d", &N);
    int maxi = 0;
    for( i=0; i<N; i++)
    {
        scanf("%d", &D[i]);
        chart[D[i]]++;
    }
    if( !(chart[0] == 1 && D[0]==0))
    {
        printf("0\n");
        return 0;
    }
    sort( D, D+N);
    LLI ans = 1;
    for( i=1, j=-1; i<N; i++)
    {
        if( D[i] != D[i-1] && D[i] != D[i-1]+1)
        {
            ans = 0;
            break;
        }

        if( D[i] == D[i-1]+1)
        {
            j++;
        }
        ans *= chart[j];
        ans %= MOD;
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>

using namespace std;

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

typedef vector<string> vs;
typedef vector<vs> vvs;

typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;

typedef map<string, int> msi;

typedef pair<int, int> pii;
typedef pair <ll, ll> pll; // note 'single' ls

#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++)

#define pb \
push_back

#define ff \
first

#define ss \
second

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

	vll A;

	for (int i = 0; i < N; i++)
	{
		ll a;
		cin >> a;
		A.pb(a);
	}

	sort(A.begin(), A.end());

	ll n = A.back();
	
	ll min_dis = abs(n - (2 * A[0]));
	ll r = A[0];

	for (auto a : A)
	{		
		if (abs(n - (2*a)) < min_dis)
		{
			min_dis = abs(n - (2 * a));
			r = a;
		}

		//cout << "For " << a << ", distance is" << abs((2 * n) - a) << endl;
	}

	cout << n << " " << r << endl;

	cin >> n;
	return 0;
}

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

int main(){
  int width, height;

  cin >> height >> width;

  char mapin[height][width];
  int neighbors[3] = {-1, 0, 1};

  for (int i = 0; i < height; i++){
    for (int j = 0; j < width; j++){
      cin >> mapin[i][j]; 
    }
  }
  
  int count;
  int vref, href;
  for (int i = 0; i < height; i++){
    for (int j = 0; j < width; j++){
      count = 0;
      if (mapin[i][j] == '#'){
        cout << '#'; 
      } else {
        for (int k = 0; k < 3; k++){
          for (int l = 0; l < 3; l++){
            vref = i + neighbors[k];
            href = j + neighbors[l];
           // cout << vref << ' ' << href << ' ';
            if (-1 < vref && vref < height){
              if (-1 < href && href < width){
	        if (mapin[vref][href] == '#') count++;
              }
            }
          }
        }
        cout << count;
      }
      if (j == width - 1) cout << endl;
    }
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        int m, f, r;
        while((m = load()) >= 0 | (f = load()) >= 0 | (r = load()) >= 0) {
            System.out.println(judge(m, f, r));
        }
    }
    
    private static int load() {
        return scn.nextInt();
    }
    
    private static String judge(int m, int f, int r) {
        String rslt;
        int sum;
        if(m < 0 || f < 0 || (sum = m + f) < 30) {
            rslt = "F";
        } else if(sum > 79) {
            rslt = "A";
        } else if(sum > 64) {
            rslt = "B";
        } else if(sum > 49 || r > 49) {
            rslt = "C";
        } else {
            rslt = "D";
        }
        return rslt;
    }
}

Measured memory_bytes: 26176
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")

#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
const string s1="CODEFESTIVAL2016";
string s;
int ans;
int main()
{
	fast;
	cin>>s;
	for (int i=0;i<=s.size()-1;i++)
	   if (s[i]!=s1[i])
	      ans++;
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;

int main(){
  string s;
  cin >> s;
  int ans = 0;
  int n;
  n = s.size();
  for(int i=0; i<n; i++){
    int count = 0;
    for(int j=i; j<n; j++){
      if(s[j] == 'A') count++;
      else if(s[j] == 'G') count++;
      else if(s[j] == 'C') count++;
      else if(s[j] == 'T') count++;
      else break;
    }
    ans = max(count, ans);
  }
  cout << ans <<endl;

  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    print(max(A + B, A - B, A * B))


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <cstdio>

using namespace std;

int N;
int A[200000];

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; i++) 
		scanf("%d", &A[i]);
	int now = -1;
	int t = 0;
	long sum = 0;
	for (int i = 0; i < N; i++) {
		for (now++;now < N; now++) {
			if ((t & A[now]) == 0)
				t ^= A[now];
			else break;
		}
		now--;
		sum += now - i + 1;
		t ^= A[i];
	}
	printf("%ld\n", sum);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
#define mod 1000000007
#define pub(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x,y,z;
    cin>>x>>y;
    cout<<(x^y^1^2^3);
   
    return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1e9+7,n,a,b;
ll qpow(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1) res=res*a%mod;
        b/=2;
        a=a*a%mod;
    }
    return res%mod;
}
int main(){
    cin>>n>>a>>b;
    ll ans=qpow(2,n)-1;
    ll x=1,y=1;
    for(ll i=1;i<=a;i++){
        x=x*i%mod;
    }
    for(ll i=n;i>=n-a+1;i--){
        y=y*i%mod;
    }
    ans-=y%mod*qpow(x,mod-2)%mod;
    x=1,y=1;
    for(ll i=1;i<=b;i++){
        x=x*i%mod;
    }
    for(ll i=n;i>=n-b+1;i--){
        y=y*i%mod;
    }
    ans-=y%mod*qpow(x,mod-2)%mod;
    cout<<(ans+mod+mod)%mod<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
 //   string a,b,c;
    //int ap=0,bp=0,cp=0;
// int al=a.size(),bl=b.size(),cl=c.size();
    char a[4][110];
    scanf("%s",&a[0]);
    scanf("%s",&a[1]);
    scanf("%s",&a[2]);
    int al = strlen(a[0]);
    int bl = strlen(a[1]);
    int cl = strlen(a[2]);

    int now=0,ap=0,bp=0,cp=0;

    if(a[0][0]=='a')now=0;
    else if(a[0][0]=='b')now=1;
    else if(a[0][0]=='c')now=2;
    int p=0;
    while(true)
    {
   //     cout<<a[now][p]<<" ";
         if(ap==al+1)
        {
            printf("A\n");
            return 0;
        }
        else  if(bp==bl+1)
        {
            printf("B\n");
            return 0;
        }
        if(cp==cl+1)
        {
            printf("C\n");
            return 0;
        }

        if(a [now][p]=='a') now=0;
        else if(a[now][p]=='b')now=1;
        else if(a[now][p]=='c')now=2;

        if(now==0)p=ap++;
        else if(now==1)p=bp++;
        else p=cp++;

    }
}


Measured memory_bytes: 256
# import numpy as np
import math
import sys
input = sys.stdin.readline

X = int(input())

def is_prime(x):
    if x <= 1:
        return False
    for i in range(2,int(math.sqrt(x))+1):
        if x % i == 0:
            return False
    return True

while not is_prime(X):
    X += 1

print(X)


Measured memory_bytes: 3060
import sys

with sys.stdin as f:
    s_input = f.read()

    s_args = s_input.splitlines()
    n = int(s_args[0])
    dx = s_args[1].split()
    d = int(dx[0])
    x = int(dx[1])
    an = [int(sa) for sa in s_args[2:]]

    res = x
    for ai in an:
        res += (d-1) // ai + 1

    print(res)
        
sys.exit(0)


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
using namespace std;
#define ll long long
ll ans;
int a[8];
int main()
{
	for(int i=1;i<=7;++i)scanf("%d",&a[i]);
	ans+=a[2];ans+=2*(a[1]>>1);ans+=2*(a[4]>>1);ans+=2*(a[5]>>1);
	if((a[1]&1)&&(a[4]&1)&&(a[5]&1))ans+=3;
	else if((a[1]&1)&&(a[4]&1)&&(!(a[5]&1))&&a[5])ans+=1;
	else if((a[1]&1)&&(!(a[4]&1))&&(a[5]&1)&&a[4])ans+=1;
	else if((!(a[1]&1))&&(a[4]&1)&&(a[5]&1)&&a[1])ans+=1;
	cout<<ans<<endl;
	return 0;
}


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

typedef long long ll;

/* メモリ食い過ぎ注意 */
#define int ll
#define ALL(v) v.begin(), v.end()
#define _REP(i, n) for (int i = 0; i < n; i++)
#define REP(n) _REP(i, n)

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n, m;
    int a[50], b[50];
    cin >> n >> m;
    for (int i = 0; i < m; i++)
        cin >> a[i] >> b[i];

    deque<int> dq;
    for (int i = 2; i <= n; i++)
        dq.push_back(i);

    int cnt = 0;
    do
    {
        bool f = true;
        dq.push_front(1);
        for (int i = 1; i < dq.size(); i++)
        {
            int j;
            for (j = 0; j < m; j++)
            {
                if ((a[j] == dq[i - 1] && b[j] == dq[i]) || (a[j] == dq[i] && b[j] == dq[i - 1]))
                {
                    // ok.
                    break;
                }
            }
            if (j == m)
            {
                f = false;
                break;
            }
        }
        if (f)
            cnt++;
        dq.pop_front();
    } while (next_permutation(dq.begin(), dq.end()));

    cout << cnt << endl;
}

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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int e[101] = {};
  e[a]++, e[b]++, e[c]++, e[d]++;
  int f = 0;
  rep(i, 0, 101) {
    if(e[i]) f++;
    if(e[i] == 3) f++;
  }
  if(f <= 2) cout << "yes" << endl;
  else cout << "no" << endl;
}

Measured memory_bytes: 3152
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);
function main(){
  var n = next();
  var a = nexts(n);
  var set = new Set();
  for(var i = 0; i < n; i++){
    if(set.has(a[i]))return "NO";
    set.add(a[i]);
  }
  return "YES";
}

Measured memory_bytes: 45268
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, L: "List[int]", R: "List[int]"):
    diff = min(R) - max(L)
    if diff < 0:
        print(0)
    else:
        print(diff + 1)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    L = [int()] * (M)  # type: "List[int]"
    R = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        L[i] = int(next(tokens))
        R[i] = int(next(tokens))
    solve(N, M, L, R)


if __name__ == '__main__':
    main()


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;

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

  vector<int> l(N);
  REP(i,N)cin >> l[i];

  sort(l.begin(), l.end());

  int ans = 0;
  for(int i = N - 1; i >= 0; i--){
    for(int j = i - 1; j >= 0; j--){
//      printf("%d %d\n", l[i], l[j]);
      int a = l.end() - upper_bound(l.begin(), l.end(), l[i] - l[j]) - (N-j);
//      cout << a << endl;
      if(a>0)ans+=a;
    }
  }

  cout << ans << endl;

}



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

int main() {
  string s; cin >> s;
  if(s[0] == s[2]){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 3624
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

const BIG: usize = 1000000007;

fn factrial(n: usize) -> usize {
    let mut sum = 1;
    for i in 1..n+1 {
        sum *= i;
        sum %= BIG;
    }
    sum
}

fn abs(a: usize, b: usize) -> usize {
    if a > b {
        a - b
    } else {
        b - a
    }
}

fn main() {
    input! {
        n: usize,
        m: usize,
    }
    if n == m {
        println!("{}", (factrial(n) * factrial(m) * 2) % BIG);
    } else if abs(m, n) == 1 {
        println!("{}", (factrial(n) * factrial(m)) % BIG);
    } else {
        println!("{}", 0);
    }
}

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

int main(){
   int a[100001],N,res=0;
   cin >>N;
   for(int i=0;i<N;i++)cin>>a[i];

   for(int i=0;i<N;i++)if(a[i]%2)res++;
   if(res%2)
      cout  << "NO" <<endl;
    else
       cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>

int main(void) {
	int n, b[101], a[101], count;

  if(scanf("%d", &n) == 1);
	count = n;

	for(int i = 1; i <= n; i++) {
		if(scanf("%d", &b[i]) == 1);
	}

	for(int i = n; i > 0; i--) {
		if(i == b[i]) {
			a[n] = i;
			for(int j = i; j < n; j++) {
				b[j] = b[j + 1];
			}
			n--;
			i = n + 1;
		}
	}

	if(n == 0) {
		for(int i = 1; i <= count; i++) {
			printf("%d\n", a[i]);
		}
	} else {
		printf("-1");
	}

  return 0;
}


Measured memory_bytes: 128
def main():
    n, m = map(int, input().split())

    ans = [None for _ in range(m)]
    used = set()
    a = 1
    b = n
    good = True
    for i in range(m):
        if b - a == n - (b - a):
            a += 1
            b -= 1
        ans[i] = (a, b)
        if (b - a) in used:
            good = False
            break
        else:
            used.add(b - a)
        if (n - (b - a)) in used:
            good = False
            break
        else:
            used.add(n - (b - a))
        a += 1
        b -= 1

    if not good:
        ans = [None for _ in range(m)]
        used = set()
        a = 1
        b = n-1
        good = True
        for i in range(m):
            if b - a == n - (b - a):
                a += 1
                b -= 1
            ans[i] = (a, b)
            if (b - a) in used:
                good = False
                break
            else:
                used.add(b - a)
            if (n - (b - a)) in used:
                good = False
                break
            else:
                used.add(n - (b - a))
            a += 1
            b -= 1

    if not good:
        ans = [None for _ in range(m)]
        used = set()
        a = 1
        b = n
        good = True
        dec = False
        for i in range(m):
            if b - a == n - (b - a):
                b -= 1
            if not dec and ((b - a) in used or (n - (b - a)) in used):
                b -= 1
            ans[i] = (a, b)
            if (b - a) in used:
                good = False
                break
            else:
                used.add(b - a)
            if (n - (b - a)) in used:
                good = False
                break
            else:
                used.add(n - (b - a))
            a += 1
            b -= 1


    for i in range(m):
        print(ans[i][0], ans[i][1])

if __name__ == '__main__':
    main()


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

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

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

  string s; cin >> s;
  auto n = s.size();
  ll ans = 0;
  ll a = 0;
  rep(i, n) {
    if (s[i] == 'A') {
      a++;
    } else if (s[i] == 'B') {
      if (i+1<n && s[i+1]=='C') {
        ans += a;
        i++;
      } else {
        a = 0;
      }
    } else {
      a = 0;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(string S, string T){
	cout << T+S << endl;
}

int main(){	
	string S;
	string T;
	cin >> S;
	cin >> T;
	solve(S, T);
	return 0;
}



Measured memory_bytes: 256
#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))
INF = float("inf")

#処理内容
def main():
	H, W = getlist()
	L = []
	for i in range(H):
		l = list(input())
		L.append(l)

	DP = [[INF] * W for i in range(H)]
	#初期化
	if L[0][0] == "#":
		DP[0][0] = 1
	else:
		DP[0][0] = 0

	for i in range(1, H):
		DP[i][0] = 0
	for i in range(1, W):
		DP[0][i] = 0

	for i in range(1, H):
		if L[i][0] != L[i - 1][0]:
			DP[i][0] += DP[i - 1][0] + 1
		else:
			DP[i][0] += DP[i - 1][0]

	for i in range(1, W):
		if L[0][i] != L[0][i - 1]:
			DP[0][i] += DP[0][i - 1] + 1
		else:
			DP[0][i] += DP[0][i - 1]

	for i in range(1, H):
		for j in range(1, W):
			if L[i][j] != L[i - 1][j]:
				DP[i][j] = min(DP[i][j], DP[i - 1][j] + 1)
			else:
				DP[i][j] = min(DP[i][j], DP[i - 1][j])

			if L[i][j] != L[i][j - 1]:
				DP[i][j] = min(DP[i][j], DP[i][j - 1] + 1)
			else:
				DP[i][j] = min(DP[i][j], DP[i][j - 1])

	# print(DP)

	ans = int((DP[-1][-1] + 1) // 2)
	print(ans)


if __name__ == '__main__':
	main()

Measured memory_bytes: 41584
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{  
    int n,m;
    cin >> n >> m;
    n = n-1;
    m = m-1;
    cout << n * m << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
  	string S,T,A="";
  	cin>>N>>S>>T;
  		for(int i=0;i<2*N;i++){
          if(i%2==0) A+=S[i/2];
          else A+=T[(i-1)/2];
        }
  cout<<A<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first) {
        return a.first < b.first;
    } else {
        return a.second < b.second;
    }
}
const int MAX = 2000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k) {
    if(n < k)
        return 0;
    if(n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int N;
    cin >> N;
    vector<vector<int>> G(N);
    vector<pair<int, int>> pp;
    rep(i, 0, N - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
        pp.emplace_back(a, b);
    }
    int K = 0;
    map<pair<int, int>, int> I;
    vector<int> cs(N, 0);

    vector<int> used(N, 0);
    queue<int> que;
    used[0] = 1;
    que.emplace(0);
    while(!que.empty()) {
        int v = que.front();
        que.pop();
        if(K < (int)G[v].size()) {
            K = G[v].size();
        }
        int cur = 1;
        for(int u : G[v]) {
            if(used[u])
                continue;
            if(cur == cs[v])
                cur++;
            cs[u] = I[make_pair(u, v)] = I[make_pair(v, u)] = cur++;
            used[u] = 1;
            que.emplace(u);
        }
    }

    cout << K << endl;
    for(auto p : pp)
        cout << I[p] << endl;
    return 0;
}

Measured memory_bytes: 20084
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
	string s;
	string t;
	cin>>s>>t;
	ll n=s.size();
	ll c=0;
	for(ll i=0;i<n;i++)
	{
	    if(s[i]!=t[i])
	    c++;
	    else
	    continue;
	}
   cout<<c<<endl;
    
}

Measured memory_bytes: 3832
#include<bits/stdc++.h>
#include <string> 
using namespace std;
using int64 = long long;
typedef long long ll;
int main()
{

  ll N;
  ll A[3][100010];
  ll DP[3][100010]{};
  cin>>N;
  for(ll i=0;i<N;i++){
    cin>>A[0][i]>>A[1][i]>>A[2][i];
  }
  
  for(ll i=0;i<N;i++){
    for(ll j=0;j<3;j++){
      for(ll k=0;k<3;k++){
        if(j==k)continue;
        DP[j][i+1]=max(DP[k][i]+A[j][i],DP[j][i+1]);
      }
    }
  }
  
  ll ans=max(DP[0][N],max(DP[1][N],DP[2][N]));
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4992
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
using pll = pair<ll,ll>;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
using mat = vector<vector<ll>>;
using vec = vector<ll>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;



int main(){
int N;
cin>>N;
int A[N],table[1000001];
rep(i,N)cin>>A[i];
memset(table,0,sizeof(table));
rep(i,N){
    if(table[A[i]]!=0)table[A[i]]++;
    else {
        for(int j=1;A[i]*j<=1000000;j++){
        table[A[i]*j]++;
    }
    }
}
int count=0;
rep(i,N)if(table[A[i]]==1)count++;
cout<<count<<endl;
return 0;
}

Measured memory_bytes: 8308