akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define mp make_pair
#define F(i, a, n, b) for(int i=a;i<n;i+=b)
#define REVF(i, a, b, c) for(int i=a;i>=b;i-=c)
#define REP(i, n) F(i, 0, n, 1)
#define REP1(i, n) F(i, 1, n+1, 1)
#define REV(i, n) REVF(i, n, 0, 1)
#define PTR(it, x) for(auto it=x.begin();it!=x.end();++it)
#define REVPTR(it, x) for(auto it=x.rbegin();it!=x.rend();++it)
#define MOD 1000000007

typedef unsigned long long ll;

const int MAX = 2e6 + 5;

int n,mx = 0;
string s;
map<string, int> m;
set<string> ans;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n;
	REP(i,n){
		cin>>s;
		m[s]++;
		if(m[s] > mx)
			mx = m[s];
	}
	PTR(it, m){
		if(it->second == mx)
			ans.insert(it->first);
	}
	PTR(it, ans){
		cout<<*it<<endl;
	}
	return 0;
}

Measured memory_bytes: 33280
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
using namespace std;

int main(){
    string S,T;cin>>S>>T;
    int N=S.size();
    string U=S;
    bool b=false;
    while(true){
        char c=U[N-1];
        U.pop_back();
        U=c+U;
        if(U==T)b=true;
        if(U==S)break;
    }
    if(b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

int main(void) {
    int N, A, B;
    cin >> N >> A >> B;
    
    int ans = 0;
    string i_str;
    for (int i = 1; i <= N; i++) {
        int j = 0;
        int tmp = 0;
        i_str = to_string(i);
        while(i_str[j]){
            tmp += i_str[j] - '0';
            j++;
        }
        if (A <= tmp && tmp <= B)
            ans += i;
    }

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

Measured memory_bytes: 3628
import sys
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

x, y = IL()

if x == y == 1:
  print(1000000)
  exit()

ans = 0
if x == 1:
  ans += 300000
elif x == 2:
  ans += 200000
elif x == 3:
  ans += 100000

if y == 1:
  ans += 300000
elif y == 2:
  ans += 200000
elif y == 3:
  ans += 100000
print(ans)

Measured memory_bytes: 38384
#!/usr/bin/env python

import sys
import argparse
import logging
#import math

logging.basicConfig(filename='logger.log', level=logging.DEBUG)
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)


def f(s: str) -> int:
    '''
    >>> f("SSS")
    0
    >>> f("RRS")
    2
    >>> f("RRR")
    3
    >>> f("RSR")
    1
    '''
    result = 0
    n = 0
    for c in list(s):
        if c == 'R':
            n += 1
        else:
            n = 0
        result = max(result, n)
    return result


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument(
            '--doctest', action='store_true', default=False)
    args = parser.parse_args()
    if args.doctest:
        import doctest
        doctest.testmod(verbose=True)
        sys.exit()

    s = sys.stdin.readline().rstrip()
    print(f(s))

Measured memory_bytes: 11828
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    final String LINE_SPR = System.getProperty("line.separator");
    final int BIG_MOD = 1000000007;

    void run() throws Exception {
        String line;
        PriorityQueue<Integer> nums = new PriorityQueue<Integer>();
        while((line = br.readLine()) != null) 
            nums.add(Integer.parseInt(line) * -1);
        for(int i = 0; i < 3; i++) 
            System.out.println(nums.poll() * -1);

    }


    /*
     * Templates
     */
    void dumpObjArr(Object[] arr, int n) {
        for(int i = 0; i < n; i++) {
            System.out.print(arr[i]);
            if(i < n - 1)
                System.out.print(" ");
        }
        System.out.println("");
    }

    void dumpObjArr2(Object[][] arr, int m, int n) {
        for(int j = 0; j < m; j++) 
            dumpObjArr(arr[j], n);
    }

    int ni() throws Exception {
        return Integer.parseInt(br.readLine().trim());
    }

    long nl() throws Exception {
        return Long.parseLong(br.readLine().trim());
    }

    String ns() throws Exception {
        return br.readLine();
    }

    boolean isPrime(int n) {
        for(int i=2;i<n;i++) {
            if(n%i==0)
                return false;
        }
        return true;
    }

    int getPrime(int n) {
        List<Integer> primes = new ArrayList<Integer>();
        primes.add(2);
        int count = 1;

        int x = 1;
        while(primes.size() < n) {
            x+=2;
            int m = (int)Math.sqrt(x);
            for(int p : primes) {
                if(p > m) {
                    primes.add(x);
                    break;
                }

                if(x % p == 0) 
                    break;
            }
        }

        return primes.get(primes.size() - 1);
    }

    void gcjPrint(String str, int t) {
        System.out.println("Case #" + t + ": " + str);
    }

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

Measured memory_bytes: 16876
#include <bits/stdc++.h>
# define rep(i, n) for (ll i = 0; i < (n); i++)
# define reps(i, n) for (ll i = 1; i <= (n); i++)
# define foreps(i, m, n) for (ll i = (m); i < (n); i++)
# define len(x) ((int)(x).size())
# define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
const long long mod = 1e9 + 7;
const long long inf = 1e18;

int main() {
    ll N; cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    vector<ll> C = A;
    sort(all(C));

    ll range = N / 2 - 1;
    rep(i, N) {
        if (A[i] <= C[range]) cout << C[range + 1] << endl;
        else cout << C[range] << endl;
    }
}

Measured memory_bytes: 6432
N = int(input())
S = list(input())

ans = []
a1 = []
for i in range(N-2):
    if S[i] in a1:continue
    a1.append(S[i])
    a2 = []
    for j in range(i+1,N-1):
        if S[j] in a2:continue
        a2.append(S[j])
        a3 = []
        for k in range(j+1,N):
            if S[k] in a3:continue
            a3.append(S[k])
            ans.append(S[i]+S[j]+S[k])
ans_set = set(ans)
print(len(ans_set))

Measured memory_bytes: 3316
n=int(input())
l=list(map(int,input().split()))
c=0
for i in range(1,n-1):
    m=min(l[i],l[i-1],l[i+1])
    x=max(l[i],l[i-1],l[i+1])
    if(m!=l[i] and x!=l[i]):
        c+=1
print(c)


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

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    long n;
    cin >> n;
    vector<long> h(n);
    int m = 0;
    int c = 0;
    cin >> h[0];
    rep(i, n - 1) {
        cin >> h[i + 1];
        if(h[i + 1] > h[i])
            m = max(m, c), c = 0;
        else
            c++;
    }
    m = max(m, c);

    cout << m << endl;
}

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

const ll INF = 1LL << 60;

const int mod = 1e9 + 7;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

ll N, K;
vector<ll> A;

int main() {
    cin >> N >> K;
    A.resize(N);
    rep(i, N) cin >> A[i];

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

    combination comb(1e5 + 10);

    // 最大と最小を分解する
    mint ans = 0;

    for (int m = 0; m < 2; m++) {
        for (int i = 0; i < N; i++) {
            mint now = comb(i, K - 1); 
            if (m == 1) now = -now;

            ans += now * A[i];
        }

        reverse(A.begin(), A.end());
    }

    cout << ans << endl;
}

Measured memory_bytes: 5432
N = int(input())
A = list(map(int,input().split()))
x = sum(A)//N
y = x+1
tot1 = 0
tot2 = 0
for i in range(N):
    tot1 += (x-A[i])**2
    tot2 += (y-A[i])**2
print(min(tot1,tot2))

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
bool check = 0;
string s, t;
int N = 3;
vector<int> v(N);
int a, b;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  cin >> s;
  sort(s.begin(), s.end());
  if (s == "abc")
    Yes();
  else
    No();
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> company(N, 0);
  for (int i = 0; i < N-1; i++) {
    int tmp;
    cin >> tmp;
    company[tmp-1]++;
  }
  for (int i = 0; i < N; i++) cout << company[i] << endl; 
}


Measured memory_bytes: 3992
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void) {
    int W,H,x,y,r;
    scanf("%d%d%d%d%d", &W,&H,&x,&y,&r);
    if (x - r >= 0 && y - r >= 0 && x + r <= W && y + r <= H)printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 2120
def solve():
    from collections import deque
    from sys import stdin
    f_i = stdin
    
    N, u, v = map(int, f_i.readline().split())
    u -= 1
    v -= 1
    adj = [[] for i in range(N)]
    for i in range(N - 1):
        A, B = map(int, f_i.readline().split())
        A -= 1
        B -= 1
        adj[A].append(B)
        adj[B].append(A)
    
    INF = 10 ** 5
    tak_dist = [INF] * N
    tak_dist[u] = 0
    aoki_dist = [INF] * N
    aoki_dist[v] = 0
    
    # BFS takahashi
    q = deque([(u, 0)])
    while q:
        pos, dist = q.popleft()
        dist += 1
        for next_pos in adj[pos]:
            if tak_dist[next_pos] > dist:
                tak_dist[next_pos] = dist
                q.append((next_pos, dist))
    
    # BFS aoki
    q = deque([(v, 0)])
    while q:
        pos, dist = q.popleft()
        dist += 1
        for next_pos in adj[pos]:
            if aoki_dist[next_pos] > dist:
                aoki_dist[next_pos] = dist
                q.append((next_pos, dist))
    
    d = (d2 for d1, d2 in zip(tak_dist, aoki_dist) if d1 < d2)
    print(max(d) - 1)

solve()

Measured memory_bytes: 28780
import java.util.*;
public class Main {
    private static Scanner sc=new Scanner(System.in);
    private static ArrayList<Character> charArray=new ArrayList<Character>();
    public static void main(String[] args){
        int sx=sc.nextInt();
        int sy=sc.nextInt();
        int tx=sc.nextInt();
        int ty=sc.nextInt();
       up(ty-sy);
       right(tx-sx);
       down(ty-sy);
       left(tx-sx+1);
       up(ty-sy+1);
       right(tx-sx+1);
       down(1);
       right(1);
       down(ty-sy+1);
       left(tx-sx+1);
       up(1);
       for(int i=0;i<charArray.size();i++) System.out.print(charArray.get(i));
       System.out.println("");
    }
    private static void up(int x){
        for(int i=0;i<x;i++) charArray.add('U');
    }
    private static void down(int x){
        for(int i=0;i<x;i++) charArray.add('D');
    }
    private static void right(int x){
        for(int i=0;i<x;i++) charArray.add('R');
    }
    private static void left(int x){
        for(int i=0;i<x;i++) charArray.add('L');
    }
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

ull cal(ull n)
{
   ull t_cnt = n * (n - 1) / 2;
   return t_cnt;
}

int main(void)
{
   int n;
   cin >> n;
   vector<string> s(n);
   for (int i = 0; i < n; i++)
   {
      cin >> s.at(i);
      //中の文字列を並び替え
      sort(s.at(i).begin(), s.at(i).end());

      //     cout << s.at(i) << endl;
   }

   //文字列ごと並び替え
   sort(s.begin(), s.end());

   ull cnt = 0;

   //mapを用いて、同じ文字列をカウントしていく
   map<string, ull> ans;
   for (int i = 0; i < n; i++)
   {
      string t = s.at(i);
      ans[t]++;
   }

   for (auto it : ans)
   {

      //   auto key = it.first;
      //   cout << key << endl;
      auto value = it.second;
      if (value >= 2)
         cnt += cal(value);
   }
   cout << cnt << endl;
   return 0;
}


Measured memory_bytes: 13568
#include<iostream>
#include<cstring>
using namespace std;
int good[105];
int main(){
	int n,t,m;
	int i,j,k;
	int a,b,c;
	while(cin>>n>>t){
		if(!n)break;
		memset(good,0,sizeof(good));
		for(i=0;i<n;i++){
			cin>>m;
			for(j=0;j<m;j++){
				cin>>a;
				good[a]++;
			}
		}
		a=0;
		for(i=0;i<105;i++){
			if(good[a]<good[i])a=i;
		}
		if(good[a]<t)cout<<0<<endl;
		else cout<<a<<endl;
	}
}



Measured memory_bytes: 3108
import sys
def main():
    N,M=tuple(map(int,sys.stdin.readline().split()))
    if M%2==1:
        m1,m2=M//2,M//2+1
        for i in range(m1):
            l,r=i+1,M-i
            print(str(l)+' '+str(r))
        for i in range(m2):
            l,r=M+1+i,2*M+1-i
            print(str(l)+' '+str(r))
    else:
        m=M//2
        for i in range(m):
            l,r=i+1,M+1-i
            print(str(l)+' '+str(r))
        for i in range(m):
            l,r=M+2+i,2*M+1-i
            print(str(l)+' '+str(r))
if __name__=='__main__':main()

Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
ll mod=1000000007;
ll n,k,t,m,q,flag=0;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(a) -- no. of elements strictly less than a
// s.find_by_order(i) -- itertor to ith element (0 indexed)
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
int ans[500][500];
int is[500][500];

void update(int x, int y){
    if(x>0){
        if(ans[x-1][y]>ans[x][y]+is[x][y]){
            ans[x-1][y]=ans[x][y]+is[x][y];
            update(x-1,y);
        }
    }
    if(x<n-1){
        if(ans[x+1][y]>ans[x][y]+is[x][y]){
            ans[x+1][y]=ans[x][y]+is[x][y];
            update(x+1,y);
        }
    }
    if(y>0){
        if(ans[x][y-1]>ans[x][y]+is[x][y]){
            ans[x][y-1]=ans[x][y]+is[x][y];
            update(x,y-1);
        }
    }
    if(y<n-1){
        if(ans[x][y+1]>ans[x][y]+is[x][y]){
            ans[x][y+1]=ans[x][y]+is[x][y];
            update(x,y+1);
        }
    }

}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef NOOBxCODER
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #else 
    #define NOOBxCODER 0
    #endif
    //cin>>t;
    t=1;
    while(t--){
        cin>>n;
        //int ans[n][n];
        fo(i,n)fo(j,n){
            ans[i][j]=min(min(i,n-1-i), min(j,n-1-j));
            is[i][j]=1;
        }
        ll p[n*n];
        ll sum=0;
        fo(i,n*n){
            cin>>p[i];
            p[i]--;
            ll x=p[i]/n, y=p[i]%n;
            sum+=ans[x][y];
            is[x][y]=0;
            update(x,y);

        }
        cout<<sum;




        
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 34148
// 2013/11/25 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

const int INF = 100000000;

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

		if(n==0)
			break;

		int T[10][10];
		for(int i=0; i<10; i++){
			for(int j=0; j<10; j++){
				if(i==j){
					T[i][j] = 0;
				}
				else{
					T[i][j] = INF;
				}
			}
		}

		int m = 0;		// 町の総数

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

			T[a][b] = T[b][a] = c;

			if(a+1>m){
				m = a+1;
			}
			if(b+1>m){
				m = b+1;
			}
		}

		for(int k=0; k<m; k++){
			for(int i=0; i<m; i++){
				for(int j=0; j<m; j++){
					T[i][j] = min(T[i][j], T[i][k]+T[k][j]);
				}
			}
		}

		int m_min = -1;
		int s_min = 1000000000;

		for(int i=0; i<m; i++){
			int s = 0;

			for(int j=0; j<m; j++){
				s += T[i][j];
			}

			if(s<s_min){
				m_min = i;
				s_min = s;
			}
		}

		cout << m_min << ' ' << s_min << endl;
	}

	return 0;
}

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

hash = {}
for bit in range(1 << n):
    red, blue = "", ""
    for i in range(n):
        if (bit & (1 << i)) > 0:
            red += s[i]
        else:
            blue += s[i]
    hash[(red, blue)] = hash.get((red, blue), 0)+1

t = s[n:][::-1]
cnt = 0
for bit in range(1 << n):
    red, blue = "", ""
    for i in range(n):
        if (bit & (1 << i)) > 0:
            red += t[i]
        else:
            blue += t[i]
    cnt += hash.get((blue, red), 0)

print(cnt)


Measured memory_bytes: 126172
package main

import (
	"fmt"
	"math"
)

func main() {
	var r float64
	if _, err := fmt.Scan(&r); err != nil {
		panic(err)
	}

	area := r * r * math.Pi
	circumference := 2 * r * math.Pi
	fmt.Printf("%.6f %.6f\n", area, circumference)
}



Measured memory_bytes: 1152
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;

int p[1000000];
int main()
{
	for (int i = 2; i < 1000; ++i)
	{
		if (!p[i])
		{
			for (int j = i+i; j < 1000000; j += i)
				p[j] = 1;
		}
	}

	int n;
	while (scanf("%d", &n), n)
	{
		int ans = 0;
		for (int i = 3; i <= n/2; ++i)
			(p[i] | p[n-i]) || ++ans;
		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 0
N = int(input())
num_list = list(map(int,input().split()))
num_sum = []

joker = 0

for i in range(N):
    joker += num_list[i]

for i in range(N-1):
    joker -= num_list[i]
    num_sum.append(num_list[i]*joker)
    
print(sum(num_sum)%(10**9+7))

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

int swap(int *a, int *b){
  int x = a[0];
  a[0] = b[0];
  b[0] = x;
}

void quick_a(int *s, int m){
  int i, j, k=1, p=1;
  int a = s[0];
  for(; k<m; k++){
    if(a < s[k]){
      a = s[k];
      p = k;
      break;
    }else if(a > s[k]){
      p = k-1;
      break;
    }else if(k+1==m){
      break;
    }
  }
  if(k<m-1){
    i = p;
    j = m-1;
    do{
      while(s[i]< a && i!=j){
        i++;
      }
      if(i==j)    {break; }
      while(s[j]>=a && i!=j){
        j--;
      }
      if(i==j)    {break; }
      if(s[i]>s[j]){
        swap(&s[i], &s[j]);
      }
    }while(i+1!=j);
    quick_a(&s[0],   j);
    quick_a(&s[j], m-j);
  }else if(p==k-1 && s[0]>s[k]){
    swap(&s[0], &s[k]);
  }
}

void quick_d(int *s, int m){
  int i, j, k=1, p=1;
  int a = s[0];
  for(; k<m; k++){
    if(a > s[k]){
      a = s[k];
      p = k;
      break;
    }else if(a < s[k]){
      p = k-1;
      break;
    }else if(k+1==m){
      break;
    }
  }
  if(k<m-1){
    i = p;
    j = m-1;
    do{
      while(s[i]> a && i!=j){
        i++;
      }
      if(i==j)    {break; }
      while(s[j]<=a && i!=j){
        j--;
      }
      if(i==j)    {break; }
      if(s[i]<s[j]){
        swap(&s[i], &s[j]);
      }
    }while(i+1!=j);
    quick_d(&s[0],   j);
    quick_d(&s[j], m-j);
  }else if(p==k-1 && s[0]<s[k]){
    swap(&s[0], &s[k]);
  }
}

int main(void){
  int n, m, i, j;
  scanf("%d %d", &n, &m);
  int x[m];
  for(i=0; i<m; i++){
    scanf("%d", &x[i]);
  }

  if(n>=m){
    printf("0\n");
  }else{
    quick_a(&x[0], m);
    int s[m-1];
    for(i=0; i<m-1; i++){
      s[i] = x[i+1]-x[i];
    }
    quick_d(&s[0], m-1);
    int sum = 0;
    for(i=0; i<n-1; i++){
      sum += s[i];
    }
    printf("%d", x[m-1]-x[0]-sum);
  }

  return 0;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

using namespace std;

int main() {
    int sum = 0;

    REP(i, 3) {
        char c;
        cin >> c;
        if (c == '1') sum++;
    }

    cout << sum << endl;

    return 0;
}


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

#define FOR(i,m,n) for(ll i=(m);i<(n);++i)
typedef vector<int> vi;
inline int in() { int x; cin >> x; return x; }
int MOD = 1000000007;

void solve() {
	int N = in(), M = 0;
	vi v(N); for (auto &i : v) i = in();
	FOR(i,0,60) {
		int odd = 0, even = 0;
		for (auto j : v) (((j>>i)&1) ? odd : even)++;
		int K = (int)1 << i;
		K %= MOD;
		K *= (odd*even) % MOD;
		M += K;
		M %= MOD;
	}
	cout << M << endl;
}

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


Measured memory_bytes: 2560
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

int x[3] , y[3];
db d[3];

int main(){
  rep(i,0,3) scanf("%d%d",x+i,y+i);
  rep(i,0,3) {
    db dx=x[i]-x[(i+1)%3];
    db dy=y[i]-y[(i+1)%3];
    d[i] = sqrt(dx*dx+dy*dy);
  }
  db a = d[0] , b = d[1] , c = d[2];
  db p = (a + b + c) / 2;
  db area = sqrt(p * (p - a) * (p - b) * (p - c));
  db r = area / p;
  db D = max(max(a , b) , c);
  // (1 - x / r) * D = 2 * x
  // D = (2 + D / r) * x
  db ans = D / (2 + D / r);
  printf("%.12f\n",ans);
  return 0;
}


Measured memory_bytes: 256
int main(int argc, const char * argv[]) {
    int h=0,w=0,i=0,j=0;
    while(1){
        scanf("%d %d",&h,&w);
        if(h==0 && w==0){
            break;
        }
            for(i=0; i<h; i++){
                for(j=0; j<w; j++){
                    if(i%2==0){
                        if(j%2==0){
                            printf("#");
                        }else{
                            printf(".");
                        }
                    }else if(i%2==1){
                        if(j%2==0){
                            printf(".");
                        }else{
                            printf("#");
                        }
                    }
                }
                printf("\n");
            }
            printf("\n");
    }
    return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n;
  string s, t;
  cin >> n;
  cin >> s >> t;
  rep(i, n) { cout << s[i] << t[i]; }
  cout << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var n int
	con.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		con.Scan(&a[i])
	}
	var sumP, sumN, movP, movN int
	for i := 0; i < n; i++ {
		sumP += a[i]
		sumN += a[i]
		if i&1 == 0 {
			if sumP <= 0 {
				movP += 1 - sumP
				sumP = 1
			}
			if sumN >= 0 {
				movN += sumN + 1
				sumN = -1
			}
		} else {
			if sumP >= 0 {
				movP += sumP + 1
				sumP = -1
			}
			if sumN <= 0 {
				movN += 1 - sumN
				sumN = 1
			}
		}
	}
	if movP < movN {
		con.Println(movP)
	} else {
		con.Println(movN)
	}
	return nil
}


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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  long long total = 0;
  range(i, 0, n) {
    cin >> a[i] >> b[i];
    total += max(0, b[i] - a[i]);
  }
  vector<int> id(n);
  iota(id.begin(), id.end(), 0);
  sort(id.begin(), id.end(), [&](int i, int j){return max(a[i], b[i]) < max(a[j], b[j]);});
  vector<int> _a(n), _b(n);
  range(i, 0, n) {
    _a[i] = a[id[i]];
    _b[i] = b[id[i]];
  }
  swap(a, _a); swap(b, _b);
  vector<long long> pref(n);
  range(i, 0, n) {
    pref[i] = max(a[i], b[i]);
    if(i > 0) pref[i] += pref[i - 1];
  }
  long long u = 0, v = 1;
  range(i, 0, n) {
    if(b[i] < a[i]) total += b[i] - a[i];
    long long sum = 0;
    int p = upper_bound(pref.begin() + i, pref.end(), total + max(a[i], b[i])) - pref.begin();
    if(p == i) {
      if(i > 0) p = upper_bound(pref.begin(), pref.begin() + i, total) - pref.begin();
      sum = (p > 0 ? pref[p - 1] : 0);
    } else {
      sum = pref[p - 1] - max(a[i], b[i]);
      p--;
    }
    // sum + x * a[i] <= total - x * (b[i] - a[i])
    // sum + x * b[i] <= total
    // x <= (total - sum) / b[i]
    // x <= 1;
    long long su = min(total - sum, 1LL * b[i]);
    long long sv = b[i];
    su += sv * p;
    if(su / sv > u / v || (su / sv == u / v && (su % sv) * v > (u % v) * sv)) {
      u = su;
      v = sv;
    }
    if(b[i] < a[i]) total += a[i] - b[i];
  }
  v *= n;
  long long g = __gcd(u, v);
  u /= g; v /= g;
  cout << u << " " << v;
  return 0;
}


Measured memory_bytes: 3072
#define _CRT_SECURE_NO_WARNINGS
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cctype>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int, int> PII;
const ll mod = 1000000007;
const double eps = 1e-6;
const double PI = acos(-1);
ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
const int iadd[] = {0, 1, 0, -1}, jadd[] = {1, 0, -1, 0};
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 5;
char str[maxn];

void solve(){
	for(int i = 0; str[i]; i++) if((i & 1) == 0) printf("%c", str[i]);
	puts("");
}
int main(){
	scanf("%s", str);
	solve();
}



Measured memory_bytes: 384
import heapq


def dijkstra(n: int, s: int, g: int, Graph) -> int:
    INF = float('inf')
    dis = [[INF, INF, INF] for _ in range(n)]
    dis[s][0] = 0
    hq = []
    heapq.heappush(hq, (0, s, 0))

    while hq:
        c, n, idx = heapq.heappop(hq)
        for i in Graph[n][idx]:
            to, idx, weight = i
            if dis[to][idx] > c + weight:
                dis[to][idx] = c + weight
                if to == g and idx == 0:
                    return dis[to][idx]//3
                heapq.heappush(hq, (dis[to][idx], to, idx))
    return -1


N, M = map(int, input().split())

graph = [[[], [], []] for _ in range(N)]
for _ in range(M):
    frm, to = map(int, input().split())
    graph[frm-1][0].append((to-1, 1, 1))
    graph[frm-1][1].append((to-1, 2, 1))
    graph[frm-1][2].append((to-1, 0, 1))

S, T = map(int, input().split())
dis = dijkstra(N, S-1, T-1, graph)
print(dis)


Measured memory_bytes: 97124
// @author PraveenKumarRana

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define int long long int
#define vi vector<int>
#define pi pair<int, int>
#define IOS std::ios_base::sync_with_stdio(false);
#define all(x) x.begin(), x.end()
#define f(i, a, n) for (int i = a; i < n; i++)
#define fr(i, n, a) for (int i = n - 1; i >= a; --i)

const int mod = 1e9 + 7;
const int inf = 1e16 + 7;

void SOLVE() {
    // Write your code here ?
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    f(i, 0, n) cin >> s[i];

    sort(all(s));

    f(i, 0, n) cout << s[i];
    cout << endl;
}

int32_t main() {
    IOS;
    SOLVE();
    return 0;
}


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

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  int N;
  cin>>N;
  vector<int> H(N);
  for(int i=0;i<N;i++) cin>>H.at(i);

  int low=H.at(0);

  for(int i=1;i<N;i++){
    if(H.at(i)>low) low=H.at(i);
    if(H.at(i)<=low-2){
      cout<<"No"<<endl;
      return 0;
    }
    
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

const ll mod = 998244353;
ll n, m, k;
ll powe(ll x, ll y)
{
    if(!y) return 1;
    ll ret = powe(x, y>>1);
    ret = ret * ret % mod;
    if(y&1) ret = ret * x % mod;
    return ret;
}
ll inv(ll x){return powe(x, mod-2);}
ll fact[200010], invf[200010];
void prep()
{
    fact[0] = invf[0] = 1;
    Forn(i, 200005)
    {
        fact[i] = fact[i-1] * i % mod;
        invf[i] = invf[i-1] * inv(i) % mod;
    }
}
ll C(ll x, ll y)
{
    if(y>x) return 0;
    return fact[x] * invf[y] % mod * invf[x-y] % mod;
}

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    prep();
    cin >> n >> m >> k;
    if(n==1)
    {
        cout << m << endl;
        return 0;
    }
    ll ans = 0;
    for(int i=0; i<=k; i++)
    {
        ll add = m * powe(m-1, n-i-1) % mod * C(n-1, i) % mod;
        //cout << i << " " << add << endl;
        ans = (ans + add) % mod;
    }
    cout << ans << endl;
}


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  string s1,s2;cin>>s1>>s2;
  if(s1[0]==s2[2]&&s1[1]==s2[1]&&s1[2]==s2[0]){
    puts("YES");
  }else{
    puts("NO");
  }


  return 0;
}


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

typedef vector<int> vec;
typedef vector<vec> mat;

int H, W, N;

bool check(vector<string> &v) {
    for (int i = 0; i < H; i++)
        for (int j = 0; j < W; j++)
            if (v[i][j] != '.') return false;
    return true;
}

void fall(vector<string> &v) {
    for (int i = 0; i < W; i++) {
        for (int j = H - 1; j > -1; j--) {
            if (v[j][i] == '.') {
                int k = 1;
                while (j - k > -1 && v[j - k][i] == '.') k++;
                if (j - k > -1) {
                    v[j][i] = v[j - k][i];
                    v[j - k][i] = '.';
                }
            }
        }
    }
}

bool solve(vector<string> &v) {
    fall(v);
    if (check(v)) return true;

    mat cw(H, vec(W, 0));
    auto ch = cw;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W - 1; j++) {
            if (v[i][j] != '.') cw[i][j]++;
            if (v[i][j] == v[i][j+1]) cw[i][j+1] += cw[i][j];
        }
        if (v[i][W-1] != '.') cw[i][W-1]++;
    }

    for (int j = 0; j < W; j++) {
        for (int i = 0; i < H - 1; i++) {
            if (v[i][j] != '.') ch[i][j]++;
            if (v[i][j] == v[i+1][j]) ch[i+1][j] += ch[i][j];
        }
        if (v[H-1][j] != '.') ch[H-1][j]++;
    }

    bool changed = false;
    for (int i = 0; i < H; i++) {
        for (int j = W - 1; j >= N - 1; j--) {
            if (cw[i][j] >= N) {
                changed = true;
                for (int k = cw[i][j] - 1; k > -1; k--) {
                    v[i][j - k] = '.';
                    cw[i][j - k] = 0;
                }
            }
        }
    }

    for (int i = 0; i < W; i++) {
        for (int j = H - 1; j > -1; j--) {
            if (ch[j][i] >= N) {
                changed = true;
                for (int k = ch[j][i] - 1; k > -1; k--) {
                    v[j - k][i] = '.';
                    ch[j - k][i] = 0;
                }
            }
        }
    }

    fall(v);

    if (!changed) return false;
    return solve(v);
}

int main() {
    cin >> H >> W >> N;
    vector<string> v(H);
    for (auto &i : v) {
        cin >> i;
    }


    bool res = false;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W - 1; j++) {
            auto v_ = v;
            v_[i][j] = v[i][j+1];
            v_[i][j+1] = v[i][j];
            res |= solve(v_);
        }
    }

    if (res) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 3400
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

pair<char, int> v[1111111];
char s[1111111];

int main(void)
{
	int n, i, ans = 0, cnt = 0;

	scanf("%s" ,&s[1]);
	n = strlen(&s[1]);

	for (i = 1; i <= n; i++)
		if (s[i] == s[i - 1])
			v[cnt].second++;
		else
			v[++cnt] = make_pair(s[i], 1);

	for (i = 1; i <= cnt - 2; i++)
		if (v[i].first == 'J' && v[i + 1].first == 'O' && v[i + 2].first == 'I')
			if (v[i + 1].second <= v[i].second && v[i + 1].second <= v[i + 2].second)
				ans = max(ans, v[i + 1].second);

	printf("%d\n" ,ans);
	return 0;
}


Measured memory_bytes: 12412
n = int(input())
t = [0]
x = [0]
y = [0]
text = 'Yes'
for i in range(1,n+1):
  tt, xt, yt = map(int, input().split())
  t.append(tt)
  x.append(xt)
  y.append(yt)
  if abs(x[i] - x[i-1]) + abs(y[i]-y[i-1]) > t[i] - t[i-1]:
    text = 'No'

  if (t[i]-t[i-1] - abs(x[i]-x[i-1]) - abs(y[i]-y[i-1]))%2 != 0:
    text = 'No'

print(text)


Measured memory_bytes: 11816
#include <bits/stdc++.h> 
#define int long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define mc map<char, int>
#define ms map<string, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
#define mod 1000000007LL
//#define mod 998244353 
using namespace std;
int power(int x, int y) ;
int gcd(int a, int b) ;
#define pi 3.141592653589

signed main() {
    quickie
    int k, a, b ;
    cin >> k >> a >> b ;
    rep1(i, a, b) {
        if(i%k == 0) {
            cout << "OK\n" ;
            return 0 ;
        }
    }
    cout << "NG\n" ;
}

int power(int x, int y) {
    int res = 1; x %= mod;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}

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

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}


int main()
{
  ll n ;
  cin >> n ;
  ll m ;
  
  vector<ll> num(n) ;
  
  REP(i,n){
    cin >> num.at(i) ;
  }
  
  REP(i,n-1){
    m = gcd(num.at(i),num.at(i+1)) ;
    num.at(i+1) = m ;
  }
  
  cout << m <<endl ;
  


  return 0 ;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
//#define hell        1000000007
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.000000001
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e7+1;
const long long mod = (long long) 998244353;
const long long hell = (long long) 1000000007;

using namespace std;
#include <stdio.h>
ll m;
ll power(ll x,ll y)
{
  ll res=1;
  while(y>0)
  {
    if(y%2) res=(x%hell*res%hell)%hell;
    x=(x%hell*x%hell)%hell;
    y=y/2;
  }
  return res;
}

ll modinv(ll x){
  return power(x,hell-2);
}

void solve();


void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/

void solve(){
  int test;
  //cin>>test;
  test=1;
  while(test--){
        int n;
        cin>>n;
        string s;
        cin>>s;
        int ans=0;
        for(int i=0;i<n-2;i++){
            if(s[i]=='A' and s[i+1]=='B' and s[i+2]=='C')
            ans++;
        }  
        cout<<ans;
  }    
}    




/*bool issafe(int x,int y){
  return (x>=0 && y>=0 && x<n && y<m);
}*/

///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll x,ll y){
  if(x==0)
  return y;
  else
  return gcd(y%x,x);
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1))*k);
  else
  return ((pw(k,x/2))*(pw(k,x/2)));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
#define INF           1e9
#define INFL          static_cast<lint>(INF)
#define REP(i,n)      for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)     for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)     for(lint i=n-1;i>=0;--i)
#define REPR1(i,n)    for(lint i=n;i>0;--i)
#define REPI(i,ini,n) for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPC(i,obj)   for(auto i:obj)
#define R_UP(a,b)     (((a)+(b)-1)/(b))
#define ALL(obj)      (obj).begin(),(obj).end()
int main()
{
	int n = in();
	int maximum = -INFL;
	int minimum = in();
	REPI(i, 1, n)
	{
		int r = in();
		maximum = max(maximum, r - minimum);
		minimum = min(minimum, r);
	}
	cout << maximum << endl;
}


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

int main() {
	const int MAX_N = 50 + 10;
    int N, X[MAX_N], Y[MAX_N];
    cin >> N;
    for (int i = 0; i < N; ++i){
    	cin >> X[i] >> Y[i];
    }

    int ans = N;
    for (int i = 0; i < N; ++i){
    	for (int j = i+1; j < N; ++j){
    		int p = X[i]-X[j];
    		int q = Y[i]-Y[j];
    		int cost = N;
    		for (int s = 0; s < N; ++s){
    			for (int t = s+1; t < N; ++t){
    				if   ((X[s] - p == X[t] && Y[s] - q == Y[t])
    					||(X[s] + p == X[t] && Y[s] + q == Y[t])){
    					cost--;
    				}
    			}
    		}
    		ans = min(ans, cost);
    	}
    }

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

Measured memory_bytes: 256
// Anve$hi $hukla
#include <bits/stdc++.h>
using namespace std;
struct ${$(){ios_base::sync_with_stdio(false);cin.tie(NULL);}}$;

typedef long long LL;
const int Maxn = 200005;

int a[Maxn];

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


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

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a + b > c + d) {
		cout << "Left" << endl;
	}
	else if (a + b < c + d) {
		cout << "Right" << endl;
	}
	else
		cout << "Balanced" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int t, a, b, l, r, ans, len;

bool chk(int t) {
	int cntb = max(t - 1, 0ll) / ans, cnta = t;
	cnta = a - cnta; cntb = b - cntb;
	if (ans * (cnta + 1) >= cntb) return 1;
	else return 0;
}

char getit(int p) {
	if (p <= len) return p % (ans + 1) ? 'A' : 'B';
	else {
		p -= len;
		int cntb = len / (ans + 1), cnta = len - cntb;
		cnta = a - cnta; cntb = b - cntb;
		int w = cntb - ans * cnta;
		if (p <= w) return 'B';
		p -= w; cntb -= w;
		return p % (ans + 1) == 1 ? 'A' : 'B';
	}
}

void solve() {
	scanf("%lld%lld%lld%lld", &a, &b, &l, &r);
	if (a < b) ans = b / (a + 1) + !!(b % (a + 1));
	else ans = a / (b + 1) + !!(a % (b + 1));
	int ls = 0, rs = a;
	while (ls != rs) {
		int mid = (ls + rs + 1) >> 1;
		if (chk(mid)) ls = mid;
		else rs = mid - 1;
	}
	len = ls + (ls - 1) / ans;
	for (int i = l; i <= r; ++i)
		printf("%c", getit(i));
	printf("\n");
}

signed main() {
	scanf("%lld", &t);
	while (t--) solve();
}


Measured memory_bytes: 384
import java.util.*;
import java.util.Arrays;

public class Main{
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int p=0;
		for(int i=a;i<=b;i++){
			if(i%k==0){
				p = 1;
				break;
			}
		}
		if(p==1){
			System.out.println("OK");
		}
		else{
			System.out.println("NG");
		}


		

	}
}











Measured memory_bytes: 27084
x,k,d=list(map(int,input().split()))

l=0
if x==0:
    if k%2==0:
        
        print(0)
    else:
        print(d)
elif x<0:
    if x+d*k>=0:
        x=abs(x)
        a=x%d
        b=d-a
        e=x//d
        if e&1==k&1:
            print(a)
        else:
            print(b)
    else:
        print(abs(x+d*k))
        
        
else:
    if x-d*k<=0:
        a=x%d
        b=d-a
        e=x//d
        if e&1==k&1:
            print(a)
        else:
            print(b)
    else:
        print(x-d*k)
        
    

Measured memory_bytes: 61752
#include<bits/stdc++.h>
using namespace std;
#define sync ios::sync_with_stdio(false); cin.tie(NULL); cerr.tie(NULL);

int main(){
  sync;
  string s,t;
  cin >> s >> t;
  if(s.length()!=t.length()) cout << "No\n";
  else if(s==t) cout << "Yes\n";
  else{
    int flag=0;
    for(int i=0;i<s.length();i++){
      string p="";
      for(int j=0,temp=i;j<s.length();j++,temp++){
        p+=s[temp%s.length()];
      }
      if(p==t){
        flag=1;
        break;
      }
    }
    if(flag==0) cout << "No\n";
    else cout << "Yes\n";
  }
  return 0;
}


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

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

	if (B == 1) {
		cout << 0 << endl;
		return 0;
	}
	int sum = 1;
	int plg = A;
	while (true) {
		if (B <= plg) {
			break;
		}
		sum++;
		plg += A - 1;
	}
	cout << sum << endl;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;

int MOD = 1000000007;

signed main(){
    int n;
    cin >> n;
    int ans = 0;
    int mx = 0;
    rep(i,n){
        int a;
        cin >> a;
        ans += a;
        if(a > mx)mx = a;
    }
    cout << ans - mx/2 << endl;
    
    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

Measured memory_bytes: 256
N = int(input())
list = list(map(int,input().split()))

list_c = [list[i]-(i+1) for i in range(N)]
list_c.sort()

med = list_c[len(list_c)//2]

ans = 0

for i in range(N):
    ans += abs(list[i]-(med+(i+1)))

print(ans)

Measured memory_bytes: 26128