akhauriyash/Code-Regression huggingface dataset:
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int l, r;
    cin >> l >> r;
    if(r - l >= 2019){
        cout << 0 << '\n';
        return 0;
    }
    int ans = 2018;
    for(int i = l; i <= r; i++){
        for(int j = i + 1; j <= r; j++){
            ans = min(ans, (int)((ll)i * j % 2019));
        }
    }
    cout << ans << '\n';
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
int mod = 2;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    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 {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=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 {
        mint res(*this);
        return res/=a;
    }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
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];
    }
};

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

    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<mint> b(n);
    combination c(n-1);
    rep(i, n) if (a[i]) {
        // add(1 - (x-i)^(n-1)
        mint pw = 1;
        b[0] += 1;
        for (int j = n - 1; j >= 0; --j) {
            b[j] -= pw*c(n-1, j);
            pw *= -i;
        }
    }
    rep(i, n) {
        cout << b[i].x << endl;
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<math.h>
#include<set>
using namespace std;

void itsvgg() 
{
    ios::sync_with_stdio(0);cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt", "w", stdout);
    #endif
} 

double rolls[301][301][301];


void initialization()
{
		for(int i=0;i<=300;i++)
		for(int j=0;j<=300;j++)
			for(int k=0;k<=300;k++)
				rolls[i][j][k]=0.0;
}	

double prob(int n, int x,int y, int z)
{
	double p1=double(x)/double(n),p2=double(y)/double(n),p3=double(z)/double(n);
	double p0=1-p1-p2-p3;
	double k=1;
	if(x>0)
	{	
		if(rolls[x-1][y][z]==0)
			k+=p1*prob(n,x-1,y,z);
		else
			k+=p1*rolls[x-1][y][z];
	}	
	if(y>0)
	{	
		if(rolls[x+1][y-1][z]==0)
			k+=p2*prob(n,x+1,y-1,z);
		else
			k+=p2*rolls[x+1][y-1][z];
	}	
	if(z>0)
	{	
		if(rolls[x][y+1][z-1]==0)
			k+=p3*prob(n,x,y+1,z-1);
		else
			k+=p3*rolls[x][y+1][z-1];
	}	
	//cout<<x<<" "<<1-p0<<endl;

	if(x!=0 || y!=0 || z!=0)
		rolls[x][y][z]=k/(1-p0);
	else 
		rolls[x][y][z]=0;
	return rolls[x][y][z];	 
	
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);	
    itsvgg();
	initialization();
	int n;
	cin>>n;
	int ones=0,twos=0,threes=0;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		if(x==1)
		{
			ones++;
		}
		else if (x==2)
			twos++;
		else
			threes++;
	}
	//cout<<ones<<twos<<threes<<endl;
	
	//cout<<expected[0][0][0];			
	//cout<<ones<<twos<<threes<<endl;
	cout.precision(10);
	cout<<prob(n,ones,twos,threes);
}


Measured memory_bytes: 216392
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	x := nextInt()
	ans := 0
	for b := 1; b*b <= x; b++ {
		for p := 2; p <= 10; p++ {
			a := pow(b, p)
			if a > x {
				break
			}
			if a > ans {
				ans = a
			}
		}
	}
	puts(ans)
	wt.Flush()
}

func pow(a, n int) int {
	ret := 1
	for n > 0 {
		if n&1 == 1 {
			ret *= a
		}
		a *= a
		n >>= 1
	}
	return ret
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

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

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

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

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

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

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

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

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


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
//ll ar[500009],br[500009];

ll modPow(ll a, ll x, ll p)
{
    //calculates a^x mod p in logarithmic time.
    ll res = 1;
    while(x > 0)
    {
        if( x % 2 != 0)
        {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

ll modInverse(ll a, ll p)
{
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}
ll modBinomial(ll n, ll k, ll p)
{
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++)
    {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++)
    {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
ll Bigmod(ll base,ll pow,ll mod)
{
    ll res=1;
    while(pow!=0)
    {
        if(pow%2==1)
        {
            res=((res%mod)*(base%mod))%mod;
        }
        base=((base%mod)*(base%mod))%mod;
        pow=pow/2;
    }
    return res;
}
int main()
{
    ll g,f,h,q,b,c,j;

    cin>>q>>b>>c;

    g=((Bigmod(2,q,1000000007)));
    h=modBinomial(q,b,1000000007);
    f=modBinomial(q,c,1000000007);

    j=(g-h-f-1)%1000000007;
    j=(j+1000000007)%1000000007;
    cout<<j;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
char a[50][50];
int check(int x,int y){
   int vx[4]={0,0,1,-1};
   int vy[4]={1,-1,0,0};

   bool c=true;
   for(int i=0;i<4;i++){
      if(a[x+vx[i]][y+vy[i]]=='#'){
         c=false;
         a[x+vx[i]][y+vy[i]]='#';
         a[x][y]='#';
         break;
      }
   }
   if(c==true) return -1;
   else return 1;
}

int main(){
   int h,w;
   cin>>h>>w;

   

   rep(i,h){
      rep(j,w){
         cin>>a[i][j];
      }
   }
   bool f=true;

   rep(i,h){
      rep(j,w){
         if(a[i][j]=='#'){
            int x=check(i,j);
            if(x==-1) {
               f=false;
               cout<<"No";
               return 0;
            }
         }
      }
   }
   cout<<"Yes";

   
   

   
return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
deque<int> q;
int32_t main()
{
	int n=in();
	int x;
	for(int i=0;i<n;i++)
	{
		x=in();
		if(i&1)q.push_front(x);
		else q.push_back(x);
	}
	vector<int> a;
	while(!q.empty())
	{
		a.push_back(q.front());
		q.pop_front();
	}
	if(n&1)reverse(all(a));
	for(auto i:a)cout<<i<<' ';
}

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

int main(){
	int n;
	cin >> n;
	vector<int> a(100010, 0);
	int ans=0;
	
	for(int i = 0; i < n; i++)
	{
		int b;
		cin >> b;
		a[b]++;
	}
	
	for(int i = 0; i < 100000; i++)
	{
		ans = max(ans, a[i]+a[i+1]+a[i+2]);
	}
	
	
	
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
n,m = map(int,input().split())

div = 2
L = []
i = 1
while div <= int(m**0.5)+1:
    while m%div == 0:
        m //=div
        L.append(div)
    div +=1
if m!= 1:
    L.append(m)
#L.append(1)

from collections import Counter
L = Counter(L)

cnt = 1
for k,v in L.items():
    cnt *=k**(v//n)
print(cnt)

Measured memory_bytes: 9556
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
	char a[4];
	cin>>a[1]>>a[2]>>a[3];
	int ans=700;
	for(int i=1;i<=3;i++)if(int(a[i])=='o')ans+=100;
	cout<<ans<<endl;
	return 0;
 } 

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

int main() {
  int N, M; 
  cin >> N >> M;
  tuple<int, int, int> data[M]; // <Y[i], P[i], i>
  for (int i = 0; i < M; i++) {
    int P, Y;
    cin >> P >> Y;
    data[i] = make_tuple(Y, P, i);
  }

  sort(data, data + M); // Y[i]の昇順

  vector<pair<int, int>> id(M); // <P[i], P[i]の中でx番目に誕生>
  vector<int> cnt(N + 1); // 県P[i]に属する市の数

  for (int i = 0; i < M; i++) {
    int y, p, idx;
    tie(y, p, idx) = data[i];
    cnt[p]++;
    id[idx] = make_pair(p, cnt[p]);
  }

  for (int i = 0; i < M; i++) {
    cout << setw(6) << setfill('0') << id[i].first;
    cout << setw(6) << setfill('0') << id[i].second << endl;
  }
  return 0;
}

Measured memory_bytes: 3840
def main():
    s = input()
    if len(s) == 0:
        print(0)

    one_counter = 0
    for i in range(len(s)):
        if s[i] == '1':
            one_counter += 1
    zero_counter = len(s) - one_counter
    print(2 * min(zero_counter, one_counter))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100010];
ll b[100010];
ll c[100010];
ll ans=0;
bool cmp(ll a,ll b){return a>b;}
int main()
{
    int x,y,A,B,C;
    cin>>x>>y>>A>>B>>C;
	for(int i=1;i<=A;i++)  scanf("%lld",&a[i]);
	sort(a+1,a+1+A,cmp);
    for(int i=1;i<=B;i++)  scanf("%lld",&b[i]);
    sort(b+1,b+1+B,cmp);
    for(int i=1;i<=C;i++)  scanf("%lld",&c[i]);
    sort(c+1,c+1+C,cmp);
    
    int p1,p2,p3;
    p1=p2=p3=1;
    
	while(p1+p2+p3-3<x+y)
    {
    	if(p1<=x && a[p1]>=b[p2] && a[p1]>=c[p3])
    	{
    		ans+=a[p1];
    		p1++;
    		if(p1>x)   a[p1]=0;
		}
		else if(p2<=y && b[p2]>=c[p3] && b[p2]>=a[p1])
    	{
    		ans+=b[p2];
    		p2++;
    		if(p2>y)   b[p2]=0;
		}
		else if(p3<=C && c[p3]>=b[p2] && c[p3]>=a[p1])
    	{
    		ans+=c[p3];
    		p3++;
		}
		
	//	cout<<p1<<" "<<p2<<" "<<p3<<endl;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6028
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


int main(){
    
    long long int D, N;
    cin >> D >> N;
    
    long long int p = pow(100, D);
    if (N <= 99)
        cout << p * N << endl;
    else
        cout << p * 101 << endl;
    
    return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
s_list = []  # h, w
dp_dict = {}
for i in range(h):
    s = input()
    temp_list = []
    for temp in s:
        if temp == "#":
            temp_list.append(1)
        else:
            temp_list.append(0)
    s_list.append(temp_list)


def search(x, y, black):
    res = 0
    if (x, y, black) in dp_dict:
        return dp_dict[(x, y, black)]
    if x == w-1 and y == h-1:
        if s_list[y][x] == 1:
            if black:
                res = 0
            else:
                res = 1
        else:
            res = 0
    elif x == w-1:
        if s_list[y][x] == 1:
            if black:
                res = search(x, y+1, True)
            else:
                res = search(x, y+1, True)+1
        else:
            res = search(x, y+1, False)
    elif y == h-1:
        if s_list[y][x] == 1:
            if black:
                res = search(x+1, y, True)
            else:
                res = search(x+1, y, True)+1
        else:
            res = search(x+1, y, False)
    else:
        if s_list[y][x] == 1:
            if black:
                res = min([search(x+1, y, True), search(x, y+1, True)])
            else:
                res = min([search(x+1, y, True), search(x, y+1, True)])+1
        else:
            res = min([search(x+1, y, False), search(x, y+1, False)])
    dp_dict[(x, y, black)] = res
    return res


print(search(0, 0, False))


Measured memory_bytes: 5244
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int main(){
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	cout << *max_element(a.begin(), a.end()) - *min_element(a.begin(), a.end()) << endl;
}

Measured memory_bytes: 256
n, m = map(int,input().split())
X = list(map(int,input().split()))
X.sort()

dist = []
for i in range(m-1):
    dist.append(X[i+1]-X[i])
dist.sort()
    
ans = 0
for i in range(max(m-n,0)):
    ans += dist[i]

print(ans)

Measured memory_bytes: 90876
N = int(input())
A = list(map(int,input().split()))
S = [0]
for i in range(N):
  temp = S[-1]+A[i]
  S.append(temp)
total = sum(A)
target = total//2
INF = float("inf")
ans = INF

for i in range(N-1): #0からN-1
  temp = abs(total-2*S[i+1])
  ans = min(ans,temp)
print(ans)

Measured memory_bytes: 101480
s = int(input())

end_flg = False
i = 1
suuretsu = [0,s]

while end_flg == False:
    i += 1
    if suuretsu[i-1] % 2 == 0:
        elem = suuretsu[i-1] / 2
    else:
        elem = 3*suuretsu[i-1]+1
    if elem in suuretsu:
        print(i)
        end_flg = True
    else:
        suuretsu.append(elem)

Measured memory_bytes: 3060
class UnionFind:
    def __init__(self, size: int):
        self.__root = [-1 for _ in range(size)]

    def find(self, v: int) -> int:
        if self.__root[v] < 0:
            return v
        self.__root[v] = self.find(self.__root[v])
        return self.__root[v]

    def size(self, v: int) -> int:
        r = self.find(v)
        return -self.__root[r]

    def unite(self, u: int, v: int):
        ur, vr = self.find(u), self.find(v)
        if ur == vr:
            return

        if self.size(ur) < self.size(vr):
            ur, vr = vr, ur

        self.__root[ur] += self.__root[vr]
        self.__root[vr] = ur

    def connected(self, u: int, v: int):
        return self.find(u) == self.find(v)


def decayed_bridges(N: int, M: int, edges: list) -> list:
    ret = [0 for _ in range(M)]
    uf = UnionFind(N)

    current = N*(N-1)//2
    for m in range(M-1, -1, -1):
        ret[m] = current

        u, v = edges[m]
        u, v = u-1, v-1

        if not uf.connected(u, v):
            n1, n2 = uf.size(u), uf.size(v)
            current -= n1 * n2
            uf.unite(u, v)

    return ret


if __name__ == "__main__":
    N, M = [int(s) for s in input().split()]
    edges = []
    for _ in range(M):
        a, b = [int(s) for s in input().split()]
        edges.append((a, b))

    answers = decayed_bridges(N, M, edges)

    for a in answers:
        print(a)


Measured memory_bytes: 22932
N,K = map(int,input().split())

L = []
for count in range(N):
    L.append(0)

for count in range(K):
    d = int(input())
    Alist = list(map(int,input().split()))
    for count2 in range(len(Alist)):
        L[Alist[count2]-1] = 1

ans = 0
for count in range(N):
    if L[count] == 0:
        ans = ans + 1

print(ans)


Measured memory_bytes: 9200
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>


using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string s; cin >> s;
	vector<vector<int>> to(60, vector<int>(s.size()));
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'L') {
			to[0][i] = i - 1;
		}
		else {
			to[0][i] = i + 1;
		}
	}
	for (int i = 1; i < 60; i++) for (int j = 0; j < s.size(); j++) to[i][j] = to[i - 1][to[i - 1][j]];

	vector<int> cnt(s.size());
	for (int i = 0; i < s.size(); i++) cnt[to[59][i]]++;

	for (int i = 0; i < s.size(); i++) cout << cnt[i] << " \n"[i + 1 == s.size()];
	return 0;
}

Measured memory_bytes: 27496
#include <bits/stdc++.h>
using namespace std;
#define fr(i,n) for (int i=0;i<n;i++)
#define rep(i,a,b) for (int i=a;i<=b;i++)
#define per(i,a,b) for (int i=a;i>=b;i--)
#define all(cont) cont.begin(), cont.end()
#define unique(a)  sort(all(a)) , (a).erase(unique((a).begin(), (a).end()),(a).end())
#define rall(cont) cont.rbegin(), cont.rend()
#define sz(x) (int)(x).size()
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define f first
#define s second
#define mset(m,v) memset(m,v,sizeof(m))
#define mod 1000000007
const int N = 2e5 + 5;
#define PI acos(-1.0)
long double EPS = 1e-9;
typedef long long ll;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
#define pqll_max priority_queue<ll> // max heap. push(),pop(),top(),size(),empty()
#define pqll_min priority_queue<ll,vector<ll>,greater<ll> >
#define lb(v,val)   lower_bound(v.begin(),v.end(),val) //first equal to or lower than [------------
#define ub(v,val)   upper_bound(v.begin(),v.end(),val) //first greater than ------------)
#define bs(v,x) binary_search(v.begin(),v.end(),x)
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x; }
inline ll sub(ll a, ll b) { if (a < b)swap(a, b); return (((a%mod) - (b%mod) + mod) % mod); }
inline ll mul(ll x, ll y) { return (x%mod * 1ll * y%mod) % mod; }
inline ll pwr(ll a, ll b) { ll x = 1 % mod; while (b) { if (b & 1) x = mul(x, a); a = mul(a, a); b >>= 1; }return x % mod; }
inline ll inv(ll a) { return pwr(a, mod - 2) % mod; }
ll gcd(ll a, ll b) { if (!a)return b % mod; return gcd(b%a, a) % mod; }
#define debug(x) cout << #x << " = " << x << endl;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#define in(container) for (auto &it : container) cin>>it;
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
void pre() {
}
void solve() {
	int n;
	cin >> n;
	cout << 2 * PI*n << endl;
}
signed main()
{
	fastio;
	cout<<fixed<<setprecision(15);
	//clock_t begin = clock();
	//pre();
	int tc;
	tc = 1;
	//cin >> tc;
	while (tc--) {
		solve();
	}
	//clock_t end = clock();double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;cerr << elapsed_secs;
}


Measured memory_bytes: 3760
def main():
    _ = int(input())
    B = list(map(int, input().split()))
    A = []
    A.append(B[0])
    A.append(min(B[0:2]))
    
    for i in range(1, len(B[:-1])):
        A.append(min(B[i], B[i+1]))
    if len(B) > 1:
        A.append(B[-1])

    print(sum(A))

    
if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define mem0(s) memset(s,0,sizeof(s))
#define meminf(s) memset(s,0x3f,sizeof(s))
#define mp_insert(a,b,c) mp.insert(map<pair<int,int>,int>::value_type(make_pair(a,b),c))
double pi=acos(-1);
typedef long long ll;
typedef unsigned long long ull;
inline ll lowbit(ll x){return x&(-x);}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll max(ll a,ll b){return a>b?a:b;}
const ll INF=4223372036854775807,max_n=300005,mod=0x7f7f7f7f7f;
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
inline ll pow(ll a,ll b,ll mod){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;}
struct Node{int a,b,c,d;};Node data1[105];bool cmp(Node a,Node b){return a.d>b.d;}
int main()
{
	ll a,b,n;cin>>a>>b>>n;
	if(n>=b)
	{
		//b-1;
		cout<<(a*(b-1))/b;
	}
	else
	{
		//n
		cout<<(a*n)/b;
	}

	return 0;
}

Measured memory_bytes: 3672
hash = Hash.new
('a'..'z').each do |ch|
  hash[ch] = 0
end
while true do
  begin
  gets.gsub(/[^A-Za-z]/, '').downcase.each_char do |ch|
    hash[ch] += 1
  end
  rescue
    break;
  end
end
hash.sort.each do |val|
  puts "#{val[0]} : #{val[1]}"
end

Measured memory_bytes: 6104
n = int(input())
a = [int(x) for x in input().split()]
sum = 0

d = {}
d_sum = {}
dd_sum = {}

for aa in a:
    if aa not in d:
        d[aa] = 0
    d[aa] += 1

for dd in d.keys():
    sum += d[dd] * (d[dd]-1) // 2
    d_sum[dd] = d[dd] * (d[dd]-1) // 2

for i in range(len(a)):
    buf = a[i]
    tmp = sum
    tmp -= d_sum[buf]
    tmp += (d[buf] - 1) * (d[buf] - 2) // 2
    print(tmp)


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

#define For(i, j, k) for (int i = j; i <= k; i++)

using namespace std;

const int N = 38;

char S[N];
int n;
map<string, int> M[N];

int main() {

	scanf("%d%s", &n, S);
	For(i, 0, (1 << n) - 1) {
		char T[20];
		int l = 0, r = n;
		For(j, 0, n - 1) if (i & (1 << j)) T[l++] = S[j]; else T[--r] = S[j];
		T[n] = '\0';
		M[l][string(T)]++;
	}

	long long ans = 0;
	For(i, 0, (1 << n) - 1) {
		char T[20];
		int l = 0, r = n;
		For(j, 0, n - 1) if (i & (1 << j)) T[l++] = S[2 * n - 1 - j]; else T[--r] = S[2 * n - 1 - j];
		T[n] = '\0';
		ans += M[l][string(T)];
	}
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 65792
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def solve(c):
    max_length = max(c)
    for i in range(max_length, max_length // 2, -1):
        if c[i] < 2:
            return False

    if max_length % 2 == 0:
        if c[max_length // 2] != 1:
            return False
    else:
        if c[max_length - max_length // 2] != 2:
            return False

    return True


def main():
    N = int(input())
    c = Counter(list(map(int, input().split())))
    print("Possible" if solve(c) else "Impossible")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

class Solver {
public:
    void solve();
};

void Solver::solve() {
    using namespace std;
    int n, m, c;
    std::cin >> n >> m >> c;
    std::vector<int> b = std::vector<int>();
    for (std::size_t i = 0; i < m; ++i) {
        int t;
        std::cin >> t;
        b.push_back(t);
    }

    int count = 0;
    for (size_t i = 0; i < n; ++i) {
        int result = 0;
        for (size_t j = 0; j < m; ++j) {
            int a;
            cin >> a;
            result += a * b[j];
        }
        if ((result + c) > 0)
            count++;

    }
    cout << count << endl;


}


int main() {
    Solver solver = Solver();
    solver.solve();
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	int x[100];
	for(int i=0; i < n; i++) cin >> x[i];
	int min = 10000000;
	for(int p=1; p <=100; p++){
		int sum = 0;
		for(int i =0; i < n; i++){
			int tmp = x[i] -p;
			sum += (int)pow(tmp, 2);
		}
		if(sum < min) min = sum;
	}
	cout << min << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e17;
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    int tab[n];
    long long mini[n];
    for(int i =0; i < n; i++){
        cin >> tab[i];
        mini[i]=INF;
    }
    mini[0] = 0;
    int h = min(n, k);
    
    for(int i = 1; i < h; i++){
        for(int j = 1; j <= i; j++){
            mini[i] =min(mini[i], mini[i-j]+abs(tab[i]-tab[i-j]));
        }
    }
    
    for(int i = k; i < n; i++){
        for(int j =1; j <= k; j++){
            mini[i] = min(mini[i],mini[i-j]+abs(tab[i]-tab[i-j]) );
        }
        
    }
  
    cout << mini[n-1];
    return 0;
}



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

using namespace std;

int main(){
	
	int s;
	cin>>s;
	map<int,int> m;
	m[s]++;
	int count=1;
	while(m[s]<2){
		if(s%2==0){
			s= s/2;
			}
			else{
				s = 3*s+1;
				}
			count++;	
			m[s]++;	
		}
		cout<<count;
	return 0;
	}


Measured memory_bytes: 256
N = int(input())
W = [input() for _ in range(N)]
if len(set(W)) == len(W):
    flag = True
    for i in range(len(W) - 1):
        if W[i][-1] != W[i+1][0]:
            flag = False
            break
    print('Yes' if flag == True else 'No')
else:
    print('No')

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

using namespace std;
inline int read()
{
	int ck=0;
	char fu=1;
	char c;
	for(;!isdigit(c);c=getchar())
		if(c=='-')
			fu=-1;
	for(;isdigit(c);c=getchar())
		ck=ck*10+c-'0';
	return fu*ck;
}
long long x,y,ans,anz;
int main()
{
   	cin>>x>>y;
    ans=((long long)(y/x));
    while(ans>=1){
    	ans=ans/2;
		anz++;	
    }
    cout<<anz<<endl;
	return 0;
}



Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    n = I()
    a = LI()
    for i in range(n):
        a[i] -= i+1
    a.sort()
    b = sum(a)//n
    ans = 0
    for i in range(n):
        ans += abs(a[i]-b)
    ans2 = 0
    b += 1
    for i in range(n):
        ans2 += abs(a[i]-b)
    ans3 = 0
    b = a[n//2]
    for i in range(n):
        ans3 += abs(a[i]-b)
    print(min(ans,ans2,ans3))

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 78928
#include <iostream>
#include <queue>
#include <utility>
using namespace std;
 
#define N 1000000
#define INF 1000000

typedef pair<string, int> Proc;
 
int main(void){
  int n, quant, now;
  queue<Proc> que;
  
  cin >> n >> quant;
  for (int i=0; i<n; i++){
    string s;
    int t;
    cin >> s >> t;
    que.push(make_pair(s,t));
  }
  now = 0;
  while (que.size()){
    Proc tmpProc;
    tmpProc = que.front();
    que.pop();
    if (tmpProc.second > quant){
      que.push(make_pair(tmpProc.first, tmpProc.second-quant));
      now += quant;
    } else {
      now += tmpProc.second;
      cout << tmpProc.first << " " << now << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 6336
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<iomanip>
#include<map>
using namespace std;
typedef pair<int, pair<int, int> >PP;
typedef long long ll;
typedef pair<ll, ll>P;
typedef vector<int>vec;
int inf=-1;
ll mod = pow(10, 9) + 7;

int main() {
	int n,d;cin>>n>>d;
	d*=2;d+=1;
	int ans=n/d;
	if(n%d!=0){
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	vl a(n);
	FOR(i,0,n) cin >> a[i];

	map<ll,ll> cnt;
	FOR(i,0,n) cnt[a[i]]++; 
	
	vector<pll> b(all(cnt));
	n = sz(b);

	ll ii = 0, sum = 0;
	FOR(i,1,n) {
		sum += b[i-1].xx*b[i-1].yy;
		if (2*sum < b[i].xx) ii = i;
	}
	ll res = 0;
	FOR(i,ii,n) res += b[i].yy;
	cout << res << endl;

}



Measured memory_bytes: 8832
public class Main {
  
  static char[] arr = ("abcdefghijklmnopqrstuvwxyz").toCharArray(); 
  
  public static void main(String[] args){
    long N = new java.util.Scanner(System.in).nextLong();

    System.out.println(getName(N, ""));
  }
  
  private static String getName(long n, String str) {
    long syo = n / 26L;
    int yo = (int)(n % 26L);
    
    if (yo == 0) {
      yo = 26;
      syo -= 1;
    }

    str = String.valueOf(arr[yo - 1]) + str;
    
    if (syo == 0) {
      return str;
    }
    return getName(syo, str);
  }
}


Measured memory_bytes: 39704
<?php
$a = fgets(STDIN);
$b = fgets(STDIN);
$c = fgets(STDIN);
$x = fgets(STDIN);

$result = 0;
for($fiveH = 0; $fiveH <= $a; $fiveH++) {
    for($hund = 0; $hund <= $b; $hund++) {
        for($fifty = 0; $fifty <= $c; $fifty++) {
            if(500 * $fiveH + 100 * $hund + 50 * $fifty == $x) {
           		$result++;
            }
        }
    }
}
echo($result);

Measured memory_bytes: 4728
def framod(n,mod):
    a=1
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n,r,mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod
    
def comb(n,k,mod):
    if n<0 or k<0 or n<k: return 0
    if n==0 or k==0: return 1
    a=framod(n,mod)
    b=framod(k,mod)
    c=framod(n-k,mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

n,m=map(int, input().split())
pf={}
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pf[i]=pf.get(i,0)+1
        m//=i
if m>1:pf[m]=1

mod=10**9+7   
ans=1
for i in pf:
    ans=(ans * comb(pf[i]+n-1,pf[i],mod)) % mod
print(ans)

Measured memory_bytes: 3316
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

class program
{
    static public int mod = 1000000007;
    static void Main()
    {
        var kn = inta();
        int k = kn[0], n = kn[1];
        var a = inta();
        var mx =  k - a[n - 1] + a[0];
        var sum = k - a[n - 1] + a[0];
        for(int i = 0; i < n-1; i++)
        {
            int diff = a[i + 1] - a[i];
            sum += diff;
            if(diff > mx)
                mx = diff;            
        }
        Write(sum - mx);            
    }

    static int pow(int a, int b) { string binary = Convert.ToString(b, 2); int bileng = binary.Length; long a_power = a; long value = 1; for (int i = bileng - 1; i >= 0; i--) { if (binary[i] == '1') { value = value * a_power % mod; } a_power = a_power * a_power % mod; } return (int)value; }
    static string rstr() { return ReadLine(); }
    static int rint() { return int.Parse(ReadLine()); }
    static long rlong() { return long.Parse(ReadLine()); }
    static string[] stra() { return ReadLine().Split(' '); }
    static char[] chara() { string[] a = stra(); string b = ""; for (int i = 0; i < a.Length; i++) { b += a[i]; } return b.ToCharArray(); }
    static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; }
    static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; }
    static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = double.Parse(read_str_array[countup_i]); } return return_double_array; }
    static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } }
    static long LCM(long a, long b) { return a * b / GCD(a, b); }
    static void WriteArray2(int[,] a, int b, int c) { for (int i = 0; i < b; i++) { for (int j = 0; j < c; j++) { if (j != 0) Write(" "); Write(a[i, j]); } WriteLine(); } }
    static void WriteArray(int[] a, int b) { for (int i = 0; i < b; i++) { Write(" "); Write(a[i]); } WriteLine(); }
}


Measured memory_bytes: 43056
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long f(long n){
    if(n <= 1){
        return 1;
    }else{
        return  1 + 2 * f(n / 2);
    }
}
int main(void){
    long n;
    cin >> n;
    long ans = 0;
    ans = f(n);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <bitset>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;
using ll=long long;
using vint=vector<int>;
using pint=pair<int,int>;

const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

#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 SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

void solve(){
	int N, L; cin >> N >> L; vector<int> a(N); rep(i,N) cin >> a[i];
	int pos = -1;
	rep(i, N-1){
		if(a[i] + a[i+1] >= L){
			pos = i;
			break;
		}
	}

	if(pos + 1){
		cout << "Possible" << endl;
		rep(i, pos){
			cout << i+1 << endl;
		}
		for(int i = N-1; i > pos; i--)
			cout << i << endl;
	}else{
		cout << "Impossible" << endl;
	}
}

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

Measured memory_bytes: 1152
#include <cstdio>

int main(){
    int m, n;
    int total = 0, num = 0, row = 0;
    while( scanf("%d,%d\n", &m, &n) != EOF ){
        total += m * n; //ÌàzÌvÉÁZ
        num += n;       //ÌÌÊÌÉÁZ
        row++;          //üÍÌsðâ·
    }
    int ans = (int)(num / (double)row + 0.5); //ÌÊÌ½Ï(lÌÜü·é)
    printf("%d\n%d\n", total, ans );
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}

int n,m;
int cnt[100];

int main(){
	cin >> n >> m;
	rep(i,n){
		int k;
		cin >> k;
		rep(j,k){
			int num;
			cin >> num;
			num--;
			cnt[num]++;
		}
	}
	int ans = 0;
	rep(i,m){
		ans += (cnt[i] == n);
	}
	cout << ans << endl;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,m,l,a,b,c,q,s,t,memo[300][300],ans[300][300];

signed main() {
    rep(i,300) rep(j,300) if (i^j) memo[i][j] = ans[i][j] = INF/10;
    cin >> n >> m >> l;
    rep(i,m) {
        cin >> a >> b >> c;
        --a, --b;
        memo[a][b] = c;
        memo[b][a] = c;
    }
    rep(k,n) rep(i,n) rep(j,n) memo[i][j] = min(memo[i][j], memo[i][k]+memo[k][j]);
    rep(i,n) rep(j,n) if (memo[i][j] <= l) ans[i][j] = 1;
    rep(k,n) rep(i,n) rep(j,n) ans[i][j] = min(ans[i][j], ans[i][k]+ans[k][j]);
    cin >> q;
    rep(i,q) {
        cin >> s >> t;
        --s, --t;
        if (ans[s][t] == INF/10) cout << -1 << endl;
        else cout << ans[s][t]-1 << endl;
    }
}



Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a;
    cin>>n;
    set<int> myset;
    for(int i=0;i<n;i++)
    { 
        cin>>a;
        myset.insert(a);
    }
    
    cout<<myset.size()<<"\n";
    return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        int h;
        cin >> h;
        if (h >= k)
        {
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;


public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int target = s.nextInt(),n = s.nextInt();
        int arr[] = new int[n];
        int freq[] = new int[102];

        for(int i=0;i<n;i++){
            arr[i] = s.nextInt();
            freq[arr[i]]++;
        }



        int ans = 0,min = Integer.MAX_VALUE;

       

        for(int i=0;i<=101;i++){
            if(freq[i]==0&&Math.abs(target-i)<min){
                min = Math.abs(target-i);
                ans = i;
            }
        }
        System.out.println(ans);

    }
}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

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

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

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25176
N = int(input())
a = list(map(int,input().split()))
s = [0] * 30
t = [1] * 30
for i in range(29):
    t[i + 1] = t[i] * 2
ss = a[0]
for j in range(N - 1):
    ss = ss ^ a[j + 1]
for j in range(N):
    print(a[j] ^ ss,end = " ")
print()

Measured memory_bytes: 31420
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

using namespace std;
typedef long long ll;


int main(){
	ll n;
	char s[100001][1];
	ll count = 1;
	cin >> n;

	cin >> s[0][0];
	for (int i = 1; i < n; i++){
		cin >> s[i][0];
		if (s[i - 1][0] != s[i][0]) count++;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 384
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, c = map(int, readline().split())

    if a == b == c:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 66304
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x&&x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS*max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x*x + y*y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;

#if 1

const ll MOD = 1e9 + 7;

ll weightLen(const vector <ll>& a)
{
	int n = SZ(a);

	ll ret = 0;

	for (int i = 0; i < n-1; ++i)
	{
		ll tmp = (a[i+1]-a[i]);
		tmp %= MOD;
		tmp *= (i+1);
		tmp %= MOD;
		tmp *= (n-i-1);
		tmp %= MOD;

		ret += tmp;
		ret %= MOD;
	}

	return ret;

}

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

	vector <ll> x(n);
	vector <ll> y(m);

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

	for (int i = 0; i < m; ++i)
	{
		cin >> y[i];
	}


	ll ans = weightLen(x);
	ans %= MOD;
	ans *= weightLen(y);
	ans %= MOD;

	cout << ans << endl;


	return 0;
}


#else

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

	int minFreq[256] = {};
	for (int i = 0; i < 256; ++i)
	{
		minFreq[i] = BIG;
	}

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

		int freq[256]={};
		for (int k = 0; k < SZ(s); ++k)
		{
			freq[s[k]]++;
		}

		for (int i = 0; i < 256; ++i)
		{
			amin(minFreq[i], freq[i]);
		}
	}

	string ans;
	for (int i = 'a'; i <= 'z'; ++i)
	{
		ans += string(minFreq[i], i);
	}

	cout << ans << endl;




	return 0;
}

#endif



Measured memory_bytes: 1792
S = input()
S = S.replace("BC", "D")
segs = []
prev = "a"
for c in S:
    if c in "AD":
        if prev not in "AD":
            segs.append([c])
        else:
            segs[-1].append(c)
    prev = c

ans = 0
for seg in segs:
    pos = []
    for i in range(len(seg)):
        if seg[i] == "D":
            pos.append(i)
    for i, p in enumerate(pos):
        ans += p - i

print(ans)


Measured memory_bytes: 14288