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

int main() {
    int b1, b2, b3; cin >> b1 >> b2 >> b3;
    
    if (b1==1 && b2==1 && b3==0) {
        cout << "Open" << endl;
    }
    else if (b1==0 && b2==0 && b3==1) {
        cout << "Open" << endl;
    }
    else {
        cout << "Close" << endl;
    }
}


Measured memory_bytes: 3112
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<58;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
vi a;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		int A;
		cin>>A;
		if(!i||a.back()!=A) a.push_back(A);
	}
	if(a.size()==1){
		cout<<1<<endl;
		return 0;
	}
	int res=1,I=1,S=a.size();
	bool b=a[1]>a[0];
	for(int i=2;i<S;i++){
		if(a[i]>a[i-1]^b){
			res=max(res,i-I+1);
			b=!b;
			I=i;
		}
	}
	res=max(res,S-I+1);
	cout<<res<<endl;
	
}

Measured memory_bytes: 3424
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> v;
int n,a[100000],ans;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i]--;
    }
    for(int i=0;i<n;i++){
        if(i==a[a[i]])ans++;
    }
    cout<<ans/2<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
using ll = long long;

using namespace std;



int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int ans = n;
    int j = 1;
    rep(i,n) {
        if(a[i] == j) {
            --ans;
            ++j;
        }
    }
    if(j == 1) ans = -1;
    cout<< ans << endl;

    return 0;
}


Measured memory_bytes: 4044
#include <stdio.h>

int main(void){

        long long int N,i,Ai;
        int count[300000];
        scanf("%lld",&N);

        for(i=0;i<N-1;i++){
                scanf("%lld",&Ai);
                count[Ai-1]++;
        }   

        for(i=0;i<N;i++){
                printf("%d\n",count[i]);
        }   
return 0;
}


Measured memory_bytes: 2520
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <bitset>
#include <vector>
#include <string>
#include <assert.h>
#include <algorithm>

using namespace std;
#define ll long long

int main()
{
	int N,K;
  string S;
	cin >> N >> K;
  cin >> S;
  S[K-1] = tolower(S[K-1]);
  cout << S;
	return 0;
}


Measured memory_bytes: 256
/**
*    author:  Taichicchi
*    created: 09.09.2020 20:25:15
**/

#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

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

    ll ans = 0;

    for(ll i=1;i<=N;++i) {
        if((i % 3 != 0) & (i % 5 != 0)) {
            ans += i;
        }
    }

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

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

typedef long long ll;
const ll inf = 1e15;
ll mod = 1000000007;

int main() {
    int n;
    scanf("%d",&n);
    vector<ll> h(n,0);
    for (int i = 0; i < n; i++) scanf("%lld",&h[i]);
    int ans = 0;
    for (int i = 0; i < n - 1; i++) {
        int res = 0;
        while (h[i] >= h[i + 1]) {
            res++;
            i++;
            if (i > n - 2) break;
        }
        ans = max(ans,res);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mn=2e5+10;
const ll mod=998244353;
ll num[mn];
ll po(ll a,ll b){
    ll ans=1;
    for(;b;b>>=1,a=a*a%mod)if(b&1)ans=ans*a%mod;
    return ans;
}
int main(){
    int n,i,x;
    scanf("%d",&n);
    ll ans=1;
    for(i=0;i<n;i++){
        scanf("%d",&x);
        if(i==0&&x!=0)ans=0;
        if(i!=0&&x==0)ans=0;
        num[x]++;
    }
    for(i=1;i<n;i++)ans=ans*po(num[i-1],num[i])%mod;
    printf("%lld",ans);
}

Measured memory_bytes: 1024
n=int(input())
happiness=[list(map(int,input().split())) for _ in range(n)]
dp=[[0 for _ in range(3)] for _ in range(n)]
dp[0][0],dp[0][1],dp[0][2]=happiness[0][0],happiness[0][1],happiness[0][2]
for i in range(1,n):
    for j in range(3):
        dp[i][j]=max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3])+happiness[i][j]
print(max(dp[-1]))

Measured memory_bytes: 50140
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int x = 0, y = 0, sum = 0;
		for(int i = 1 ; i <=  N ; i++) {
			x += 800;
			if(i % 15 == 0) {
				y += 200;
			}
		}
		sum = x - y;
		System.out.println(sum);
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define M_PI 3.14159265358979323846
#define MOD 1000000007
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> ipair;
typedef pair<ll, ll> llpair;

/*
    Author: Koushik Sahu
    Created: 29 August 2020 Sat 17:19:12
*/

double d, t, s;

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    cin>>d>>t>>s;
    if(t>=(d/s)) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 3748
a = int(input())
b = a // 1000
c = a // 100 - b*10
d = a // 10 - b*100 - c*10 
e = a - b*1000 - c*100 - d*10
if b == c or c == d or d == e:
  print('Bad')
else:
  print('Good')

Measured memory_bytes: 2940
import sys
input=sys.stdin.readline
sys.setrecursionlimit(1000000000)
n=int(input())
a=list(map(int,input().split()))
b=[0]
for i in a:b.append(i+b[-1])
dp=[n*[10**15]for _ in range(n)]
def dfs(l,r):
  if dp[l][r]!=10**15:return dp[l][r]
  if l==r:return 0
  dp[l][r]=b[r+1]-b[l]+min(dfs(l,i)+dfs(i+1,r)for i in range(l,r))
  return dp[l][r]
print(dfs(0,n-1))

Measured memory_bytes: 48220
#include<stdio.h>

int main(void)
{
    int a,i = 0;
    int tem[10]={0};

    while(scanf("%d",&a) != EOF){
        if(a!=0){
            tem[i]=a;
            i++;
        } else {
            i--;
            printf("%d\n",tem[i]);
        }
    }
    return 0 ;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl;
#define CNO cout<<"No"<<endl;

typedef long long LL;
typedef long double LD;

int main(){
  while(1){
    int n;
    cin >> n;
    if(n==0) return 0;
    vector<vector<bool>> e(n,vector<bool>(n,false));
    rep(i,n){
      int m;
      cin >> m;
      int x;
      rep(j,m){
        cin >> x;
        e[i][x-1]=true;
      }
    }
    int k,x;
    cin >> k;
    vector<int> r(k);
    rep(i,k){
      cin >> r[i];
      r[i]--;
    }
    vector<int> ans;
    rep(i,n){
      rep(j,k){
        if(!e[i][r[j]]){
          goto next;
        }
      }
      ans.push_back(i);
      next:;
    }
    if(ans.size()==1){
      cout << ans[0]+1 << endl;
    }else{
      cout << -1 << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3168
A, B, C, X, Y = map(int, input().split())
a, b, c = 0, 0, 0
if(A + B >= C * 2):
    c += min(X, Y) * 2
    X -= c / 2
    Y -= c / 2
if(A >= C * 2):
    c += X * 2
else:
    a += X
if(B >= C * 2):
    c += Y * 2
else:
    b += Y
print(int(a*A+ b*B +c*C))

Measured memory_bytes: 3064
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
string S,T;
int main() {
	cin>>S>>T;

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

	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    static FastScanner in;
    static PrintWriter out;
    static final long MOD = 1000000007;

    public static void main(String[] args) throws IOException {
        //        Scanner in = new Scanner(new File("input.txt"));
        //        Scanner in = new Scanner(System.in);
        //        System.setOut(new PrintStream(new BufferedOutputStream(new FileOutputStream("output.txt")), true));
        out = new PrintWriter(System.out);
        in = new FastScanner(System.in);
        //        in = new FastScanner("input.txt");
        char s[] = in.next().toCharArray();
        s[3] = '8';
        out.println(String.valueOf(s));
        out.close();
    }
}

class Rect {
    int left;
    int right;
    int top;
    int bottom;

    public Rect(int left, int right, int top, int bottom) {
        this.left = left;
        this.right = right;
        this.top = top;
        this.bottom = bottom;
    }
}

class Pair {
    public double first; //first member of pair
    public double second; //second member of pair

    public Pair(double first, double second) {
        this.first = first;
        this.second = second;
    }

    public Pair() {

    }

    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (!(o instanceof Pair))
            return false;
        Pair p = (Pair) o;
        return first == p.first && second == p.second;
    }

    @Override
    public int hashCode() {
        int result = (int) first;
        result = 31 * result + (int) second;
        return result;
    }
}

class PairComparable implements Comparator<Pair> {

    @Override
    public int compare(Pair o1, Pair o2) {
        if (o1.second < o2.second)
            return -1;
        else if (o1.second > o2.second)
            return 1;
        else {
            return 0;
        }
    }
}

class FastScanner {

    BufferedReader br;
    StringTokenizer tokenizer;

    FastScanner(String fileName) throws FileNotFoundException {
        this(new FileInputStream(new File(fileName)));
    }

    FastScanner(InputStream is) {
        br = new BufferedReader(new InputStreamReader(is));
    }

    String nextLine() throws IOException {
        tokenizer = null;
        return br.readLine();
    }

    String next() throws IOException {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            String line = br.readLine();
            if (line == null) {
                return null;
            }
            tokenizer = new StringTokenizer(line);
        }
        return tokenizer.nextToken();
    }

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

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

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

    char nextChar() throws IOException {
        return next().charAt(0);
    }
}

Measured memory_bytes: 22484
#include <stdio.h>

int main(){
  int s[10];
  int ret;
  char bin;
  int num = 0;
  while(1){
    ret = scanf("%c",&bin);
    if(ret == EOF || bin == '\n') break;
    s[num] = bin - '0';
    num++;
  }
  long answer = 0;
  int pow2[10] = {1};
  int pow10[10] = {1};
  for(int i = 1; i < 10; ++i){
    pow2[i] = 2 * pow2[i-1];
    pow10[i] = 10 * pow10[i-1];
  }
  long var;
  for(int i = 0; i < num; ++i){
    if(i == num - 1){
      answer += (long) s[i] * pow2[num-1];
    }else{
      var = 0;
      for(int j = 0; j < num - i - 1; ++j){
        var += (long) s[i] * pow2[num-2-i-j] * pow10[j];
      }
      var += (long) s[i] * pow10[num - 1 - i];
      answer += var * pow2[i];
    }
  }
  printf("%ld\n",answer);
  return 0;
}

Measured memory_bytes: 128
n=int(input())
i=1

while i<=n:
    a,b,c=map(int, input().split())
    if a<b:
        a,b=b,a
    if a<c:
        a,c=c,a
    if a**2==b**2+c**2:
        print("YES")
    else:
        print("NO")
    
    i+=1


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
      std::ios::sync_with_stdio(false);
      long long n;
      cin >> n;
      long long sum=0;
      for (long long i=1; i<=n; i++)
      {
            if (!(i%3==0||i%5==0))
                  sum+=i;
      }cout << sum << endl;
     return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

unsigned GetDigit(unsigned num){
    if(num == 0)return 1;
    return log10(num)+1;
}

int main(){
    LL n;cin >> n;
    double N = sqrt(n);
    LL lim = N;
    LL A=0,B=0;
    LL ans = INF;

    for(int i = 1;i <= lim;i++){
        if(i == 0)continue;
        if(n % i == 0){
            A = GetDigit(i);
            LL big = n/i;
            B = GetDigit(big);
            ans = min(ans,max(A,B));
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 512
import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
# from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var): sys.stdout.write(' '.join(map(str, var)) + '\n')
def out(var): sys.stdout.write(str(var) + '\n')
from decimal import Decimal
# from fractions import Fraction
# sys.setrecursionlimit(100000)
mod = int(1e9) + 7
INF=float('inf')

n=int(data())
ans=0
for i in range(1,n):
    ans+=n//i
    if n%i==0:
        ans-=1
out(ans)

Measured memory_bytes: 77316
#include <bits/stdc++.h>
#define mod 998244353
#define int long long
using namespace std;
const int N=3100;
int a,b,c,d,dp[N][N][2];
signed main()
{
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	if (a==c && b==d)
	{
		printf("1\n");
		return 0;
	}
	if (a==c)
	{
		int ans=1;
		for (int i=b;i<d;i++) ans=(ans*a)%mod;
		printf("%lld\n",ans);
		return 0;
	}
	if (b==d)
	{
		int ans=1;
		for (int i=a;i<c;i++) ans=(ans*b)%mod;
		printf("%lld\n",ans);
		return 0;
	}
	dp[c][d][0]=dp[c][d][1]=1;
	for (int i=c;i>=a;i--)
	{
		for (int j=d;j>=b;j--)
		{
			dp[i-1][j][0]=(dp[i-1][j][0]+dp[i][j][1])%mod;
			dp[i-1][j][1]=(dp[i-1][j][1]+(dp[i][j][1]*j)%mod)%mod;
			dp[i][j-1][0]=(dp[i][j-1][0]+(dp[i][j][0]*i)%mod)%mod;
			dp[i][j-1][1]=(dp[i][j-1][1]+(dp[i][j][0]*i)%mod)%mod;
		}
	}
	int ans=0;
	ans=(ans+dp[a][b+1][0]*a)%mod;
	ans=(ans+dp[a+1][b][1]*b)%mod;
	printf("%lld\n",ans);
}


Measured memory_bytes: 148928
from collections import defaultdict
from bisect import bisect

N, M = map(int, input().split())
p = [tuple(map(int, input().split())) for _ in range(M)]
a = defaultdict(list)
for x, y in sorted(p):
    a[x] += [y]

for x, y in p:
    z = bisect(a[x], y)
    print("%06d%06d"%(x, z))


Measured memory_bytes: 40044
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 300030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;

int main(){
 ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
ll n;
cin>>n;
ll x=0;
ll prev=0;
ll sum=0;
ll arr[n];
rep(i,0,n)
{
	cin>>arr[i];
	sum+=arr[i];
}
x=n*(n+1)/2;
if(sum%x)
{
	cout<<"NO";
	return 0;
}
x=sum/x;

rep(i,1,n)
{
	ll y=arr[i]-arr[i-1];
	ll z=x-y;

	if(z%n||z<0)
	{
		cout<<"NO";
		return 0;
	}

}

cout<<"YES";


}





Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pl;

#define sl(x) scanf("%lld",&x)
#define pl(x) printf("%lld\n",x)
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define F first
#define S second
#define f(i,n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)

const ll mod = 1000000007;
const ll inf = (ll)5e16;
const ld eps = 1e-12;
const ll N = 100005;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}
ll n;
int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    string s[2];
    cin >> s[0] >> s[1];
    ll ans;
    if(s[0][0] == s[1][0])
    {
        ans = 3;
        ll i = 1;
        ll pre = 0;
        while(i < n)
        {
            if(s[0][i] != s[1][i])
            {
                if(pre == 0) ans = mul(ans, 2);
                else ans = mul(ans, 3);
                i += 2;
                pre = 1;
            }
            else
            {
                if(pre == 1)
                {

                }
                else
                {
                    ans = mul(ans, 2);
                }
                i++;
                pre = 0;
            }
        }
    }
    else
    {
        ans = 6;
        ll i = 2;
        ll pre = 1;
        while(i < n)
        {
            if(s[0][i] != s[1][i])
            {
                if(pre == 0) ans = mul(ans, 2);
                else ans = mul(ans, 3);
                i += 2;
                pre = 1;
            }
            else
            {
                if(pre == 1)
                {

                }
                else
                {
                    ans = mul(ans, 2);
                }
                i++;
                pre = 0;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 3e5+10;
const int mod = 998244353;

int n,a,b,k;
int g[N],rev[N];

long long binpow(int a,int x)
{
 
	long long res;
	if(x == 0) return 1;
	res = binpow(a,x/2) % mod;
	if(x % 2 == 0) return res*res % mod;
	else return ((a*res) % mod * res) % mod;
}

void add(long long &x, long long y) { x = (x + y) % mod; }

long long tohop(int k,int n)
{
	if(k < 0 || n < 0 || k > n) return 0;
	int val = g[n-k]*g[k] % mod;
	return (g[n] * binpow(val,mod-2)) % mod;
}

signed main()
{
	int ans = 0;
	cin>>n>>a>>b>>k;
	g[0] = 1;
	for(int i=1;i<N;i++)
	{
		g[i] = ((g[i-1] % mod) * (i % mod)) % mod;
	}

	for(int i=0;i<=n;i++)
	{
		if((k - a*i) % b == 0)
		{
			int j = (k-a*i)/b;
			int val = tohop(i,n) * tohop(j,n) % mod;
				add(ans, val);
		}
	}

	cout<<ans;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n-1); i >= 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main() {
	int n; cin >> n;
	vint l(n);
	rep(i,n) cin >> l[i];
	sort(be(l));
	reverse(be(l));
	int a=0;
	rrep(i,1,n) a+=l[i];
	if(a>l[0]) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3640
n,k=map(int,input().split())
P=[0]+list(map(int,input().split()))
C=[0]+list(map(int,input().split()))


def cycle(v):
    check=[False for _ in range(n+1)]
    check[v]=True
    while True:
        v=P[v]
        if check[v]:
            return v
        else:
            check[v]=True

ans=-1*float("inf")
for v in range(1,n+1):
    point=0
    tans=-1*float("inf")
    m=0
    st=cycle(v)

    while v!=st and m<k:
        m+=1
        v=P[v]
        point+=C[v]
        tans=max(tans,point)

    if m==k:
        ans=max(ans,tans)
        continue
       
    c_point=0
    t=0
    while True:
        t+=1
        v=P[v]
        c_point+=C[v]
        if v==st:
            break
    cp=0
    cpmax=-1*float("inf")
    if 2*t>k-m:
        v=st
        for _ in range(k-m):
            v=P[v]
            cp+=C[v]
            cpmax=max(cpmax,cp)
        tans=point+cpmax
        ans=max(ans,tans)
 

    elif c_point>0:
        l=(k-m)//t
        mv=k-m-(l-1)*t
        cp=c_point*(l-1)
        v=st
        for _ in range(mv):
            v=P[v]
            cp+=C[v]
            cpmax=max(cpmax,cp)
        tans=point+cpmax
        ans=max(ans,tans)

    else:
        v=st
        for _ in range(t):
            v=P[v]
            cp+=C[v]
            cpmax=max(cpmax,cp)
        tans=point+cpmax
        ans=max(ans,tans)
print(ans)

Measured memory_bytes: 78660
#include<stdio.h>
#include<ctype.h>
#include<string.h>
main(){
  int a=0;
  int b=0;
  int c=0;
  int d=97;
  int e=0;
  char A;
  int B[26]={0};
  while(scanf("%c",&A)!=EOF){
    a=A-'a';
    if(a<0){
      a=a+32;
    }
    B[a]=B[a]+1;
  }
  for(c=0;c<26;c++){
  printf("%c : %d\n",d,B[c]);
  d=d+1;
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector< tuple < string, int , int >> p(N);
  for (int i = 0; i < N; i++) {
    string a ;
    int b ;
    cin >> a >> b;
    
    p.at(i) = make_tuple(a, -1*b , i+1); 
  }

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

  for (int i = 0; i < N; i++) {
    string  a ; 
    int b;
    int c ;
    tie(a, b , c ) = p.at(i);  
    cout << c << endl;
  }
}

Measured memory_bytes: 3616
s=list(input())
n=len(s)

p=['1']
q=['0']

for x in range(1,n):
  if p[x-1]=='0':
    p.append('1')
  else:
    p.append('0')
    
  if q[x-1]=='0':
    q.append('1')
  else:
    q.append('0')
  
ans=0
ans1=0
for i in range(n):
  if s[i]!=p[i]:
    ans+=1
  if s[i]!=q[i]:
    ans1+=1
    
print(min(ans,ans1))

Measured memory_bytes: 11348
#include <iostream>
#include <climits>
#define ll long
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int n, k;
    int arr[100005]; 
    ll score=INT_MIN, pref[100005], pos[100005], maxi=0;
    cin >> n >> k;
    pref[0]=0;
    pos[0]=0;
    
    for(int i=1; i<=n; i++){
        cin >> arr[i];
        pref[i]=pref[i-1]+arr[i];
        pos[i]=pos[i-1];
        if(arr[i]>0){
            pos[i]+=arr[i];
        }
    }
    for(int l=0; l<=n-k; l++){
        int r=l+k;
        maxi = max(pref[r]-pref[l]+pos[n]-pos[r]+pos[l], pos[n]-pos[r]+pos[l]);
        if(score<maxi){
            score = maxi;
        }
    }
    cout << score << endl;
    return 0;
}

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

int main(){
  int l,r;	cin >> l >> r;
  int right=min(l+2018,r);
  
  int ans=2019;
  for(int i=l;i<=right;i++){
    for(int j=i+1;j<=right;j++){
      int a=i%2019;
      int b=j%2019;
      ans=min(ans,(a*b)%2019);
    }
  }
  cout << ans;
}

Measured memory_bytes: 3600
fn main() {
    let n = read::<usize>();
    let s = read::<String>();
    let s: Vec<char> = s.chars().into_iter().collect();
    let mut ret = 0;
    for i in 0..n {
        if i == 0 {
            ret += 1;
            continue;
        }

        if s[i-1] == s[i] {
            continue;
        }

        ret += 1;
    }

    println!("{}", ret);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}



Measured memory_bytes: 4352
import java.io.*;

class Main
{
   public static void main(String[] args) throws IOException
   {

      BufferedReader br =
       new BufferedReader(new InputStreamReader(System.in));

      String str = br.readLine();
      int x = Integer.parseInt(str);

      System.out.println( (int)Math.pow(x,3) );

   }
}

Measured memory_bytes: 24288
x = int(input())

if x <= 6:
    print(1)
    exit()
elif x <= 11:
    print(2)
    exit()
else:
    if x % 11 == 0:
        print(int(x/11)*2)
        exit()
    else:
        if x <= 11 * (x//11) + 6:
            print(((x//11)*2)+1)
            exit()
        else:
            print(((x//11)*2)+2)
            exit()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define N 100005
#define m 1000000007
#define dd double
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
int32_t main() 
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	if(n%1000)
	{
		cout<<1000-(n%1000);
	}
	else cout<<"0";
}


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

const int maxn=1e5+7;
int p[maxn],b[maxn];
long long ans;

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n+1;++i) scanf("%d",p+i);
	for(int i=1;i<=n;++i) scanf("%d",b+i);
	for(int i=1;i<=n;++i) {
		if(p[i]<=b[i]) ans+=p[i],b[i]-=p[i];
		else ans+=b[i],b[i]=0;
		if(b[i]) {
			if(p[i+1]>=b[i]) ans+=b[i],p[i+1]-=b[i];
			else ans+=p[i+1],p[i+1]=0;
		}
	}
	printf("%lld",ans);
}

Measured memory_bytes: 1024
import copy
import sys
N = int(input())
H = list(map(int,input().split()))
C = 0

if sorted(H) == H:
	print("YES")
	sys.exit()

for i in range(0,N-1):
	for j in range(1,N):
		L = copy.copy(H)
		L[i],L[j] = L[j],L[i] 
		if L == sorted(H):
			print("YES")
			sys.exit()
print("NO")

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define     ll           long long
#define     sf(n)        scanf("%lld",&n)
#define     pf(n)        printf("%lld\n",&n)
#define     ct(p)        cout<<p<<endl
#define     mem(a)       memset(a,0,sizeof a)
#define     yes          cout<<"YES"<<endl
#define     no           cout<<"NO"<<endl
ll a[10000000],b[1000000];
map<ll,ll>mp;

///......................................///

int main()
{
    cin.sync_with_stdio(false);
    ll i,j,k,l,c,v,b[1000],aa[1000],bb[10000],n,m,r,t;
    // ll bb[10][10];
    ll x1,x2,y1,y2,x3,x4,x5,x6;
    string s,s1,s2,s3,ss[10000];
    s1="CODEFORCES";

    while(cin>>n)
    {
        c=100000000;
        for(i=0; i<n; i++)
        {
            cin>>m;
            j=0;
            while(m%2==0)
            {
                j++;
                m=m/2;

            }
            //j++;
           c= min(j,c);
        }
        cout<<c<<endl;
    }
}






Measured memory_bytes: 384
/*

    author : s@if

*/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			1e9
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> new_data_set;

//*find_by_order(k)  gives the kth element;
//order_of_key(item)   gives the index(number of element strictly less than item) of item;


inline int in() {int x; scanf("%d", &x); return x; }
bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};    // King's move
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hx[]={-2,-2,-1,+1,+2,+2,-1,+1};    // Knight's move
int hy[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)2e5+9;


int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    int i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    string s;
    cin>>s;

    if(s[2]==s[3] && s[4]==s[5])
        cout<<"Yes\n";
    else
        cout<<"No\n";

   // main();

    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)



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

using namespace std;
#define N 1500000
#define int long long
int arr1[N];
int arr2[N];
int n;
int k;
bool cmp(int a,int b){
	return a>b;
}
int ok(int m){
	int sum=0;
	for(int i=1;i<=n;i++){
	 	if(arr1[i]*arr2[i]<=m){
	 		continue;
		 }else{
		 	int temp=arr1[i]*arr2[i];
		 	int cha=temp-m;
		 	 sum+=cha/arr2[i];
		 	if (cha%arr2[i]){
		 		sum++;
			}
			if(sum>k){
				return false;
			}
		 }
	 }
	 return true;
}
signed main(){
	int add=0;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		scanf("%lld",&arr1[i]);
		add+=arr1[i];
	}
	for(int i=1;i<=n;i++)
		scanf("%lld",&arr2[i]); 
	if(add<=k){
		printf("0\n");
		return 0;
	}
	sort(arr1+1,arr1+1+n,cmp);
	sort(arr2+1,arr2+1+n);
	int l=0;
	int r=arr1[1]*arr2[n];
	int ans=0;
    ans=r;
	while(l<=r){
		int mid=(l+r)/2;
		if(ok(mid)){
			r=mid-1;
			ans=min(ans,mid);
		}else{
			l=mid+1;
		}
	}
	cout<<ans;
	return 0;
} 


Measured memory_bytes: 5888
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main (){
    int a, b, c, d;
    cin >> a >> b >> c >>d;
    if(fabs(a-c)<=d){
        cout << "Yes";
    }else if(fabs(b-a)<=d && fabs(c-b)<=d){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

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

signed main() {
	ll N, K;
	scanf("%lld%lld", &N, &K);
	vector<ll> A(N, 0);
	for(ll i=0; i<N; i++){
		scanf("%lld", &A[i]);
	}

	vector<ll> S(N+1,0);
	for(ll i=0; i<N; i++){
		S[i+1]=S[i]+A[i];
	}

	ll ans = 0;
	map<ll,ll> m;
	for(ll i=0; i<N+1; i++){
		ll j=i-K;
		if(j>=0){
			ll s=(S[j]-j)%K;
			m[s]--;
		}
		ll t=(S[i]-i)%K;
		if(m[t]>0){
			ans+=m[t];
		}
		m[t]++;
	}

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


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;

signed main() {
  ll N;
  cin >> N;
  ll ans = 0;
  rep(i, N) {
    ll num = i + 1;
    if (num % 3 == 0 || num % 5 == 0) {
      continue;
    }
    //  else if (num % 3 == 0) {
    //   continue;
    // } else if (num % 5 == 0) {
    //   continue;
    // }
    // debug(num);
    ans += num;
  }

  COUT(ans);
  return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,a,b,c;
  cin >> s;
  a = "Sunny", b = "Cloudy", c = "Rainy";
  if(s == a)
    cout << b << endl;
  else if(s == b)
    cout << c << endl;
  else
    cout << a << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define X real()
#define Y imag()
const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

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

P reflection(const L &l, const P &p) {
  return p + P(2, 0) * (projection(l, p) - p);
}

int main() {
  int x0, y0, x1, y1, Q;
  cin >>x0 >>y0 >>x1 >>y1;
  L l = L(P(x0, y0), P(x1, y1));
  cin >>Q;
  REP(q, Q){
    int x, y; cin >>x >>y;
    P p = P(x, y), ans = reflection(l, p);
    printf("%.10lf %.10lf\n", ans.X, ans.Y);
  }
  return 0;
}

Measured memory_bytes: 1244
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>

using namespace std;
 
int main(void)
{
	int n, t;
	int dsum = 0;

	cin >> n;

	t = n;
	while (t > 0)
	{
		dsum += (t % 10);
		t /= 10;
	}
	
	if (n%dsum == 0)
	{
		cout << "Yes" << '\n';
	}

	else
	{
		cout << "No" << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using pib = pair<int,bool>;
using ll = long long;
using ld = long double;
#define all(x) (x).begin(),(x).end()
#ifdef fread_unlocked
#define fread fread_unlocked
#define fwrite fwrite_unlocked
#endif
#define mp make_pair
#define lc ind<<1
#define rc ind<<1|1
const int MN = 1e6+5, MOD = 1e9+7, BASE = 31, MASK = (1 << 10) - 1;
int cnt[MN], a[MN];
int main () {
	int n;
	scanf ("%d",&n);
	for (int i = 1; i <= n; i++) scanf ("%d",a+i), cnt[a[i]]++;
	for (int i = MN-1; i; i--) {
		for (int j = i*2; j < MN; j += i) cnt[j] += cnt[i];
	}
	int ret = 0;
	for (int i = 1; i <= n; i++) if (cnt[a[i]] == 1) ++ret;
	printf ("%d\n",ret);
	return 0;
}


Measured memory_bytes: 8332
#include <iostream>
#include <set>
using namespace std;
int main(void)
{
	int n,q,k=0,num;
	set<int> set;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> num;
		set.insert(num);
	}
	cin >> q;
	for(int i=0;i<q;i++){
		cin >> num;
		if(set.find(num)!=set.end()) k+=1;
	}
	cout << k << endl;
	return 0;
}

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    vector<vector<ll>> dp(N + 1, vector<ll>(5, 1LL << 60));
    dp[0][0] = 0;
    // 0, 偶数, 奇数, 偶数, 0
    for (int i = 0; i <= N; i++) {
        for(int j = 0; j < 4; j++) {
            dp[i][j + 1] = min(dp[i][j + 1], dp[i][j]);
        }
        if (i < N) {
            dp[i + 1][0] = min(dp[i + 1][0], dp[i][0] + A[i]);
            dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + ((A[i] == 0) ? 2 : (A[i] % 2)));
            dp[i + 1][2] = min(dp[i + 1][2], dp[i][2] + (1 - A[i] % 2));
            dp[i + 1][3] = min(dp[i + 1][3], dp[i][3] + ((A[i] == 0) ? 2 : (A[i] % 2)));
            dp[i + 1][4] = min(dp[i + 1][4], dp[i][4] + A[i]);
        }
    }
    cout << dp[N][4] << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

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

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

ll ans;
int N,tmp, maxv, secondmaxv;
vi As,inp;

void solve(){
    rep(i,inp.size()){
        if(inp[i] == maxv)
            cout << secondmaxv << endl;
        else
            cout << maxv << endl;
    }
}

int main(){
    cin >> N;

    rep(i,N){
        cin >> tmp;
        inp.push_back(tmp);
        As.push_back(tmp);
    }

    sort(As.begin(),As.end());
    reverse(As.begin(),As.end());

    maxv = As[0];
    secondmaxv = As[1];

    solve();
}


Measured memory_bytes: 3436
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong(), min=Long.MAX_VALUE;
		long city[] = new long[5];
		for(int i=0; i<5; i++) {
			city[i]=sc.nextLong();
			min=Math.min(min, city[i]);
		}
		System.out.println((long)Math.ceil((double)n/min)-1+5);
	}
}

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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const int MOD = (int) 998244353;
const int maxn = (int) 200000 + 20;
const int maxm = (int) 1000000 + 20;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL m = MOD) {LL res = 1; for(; n; n >>= 1, a = a * a % m) if(n & 1) res = res * a % m; return res;}

int n;
string s;

void work()
{
    cin >>n >>s;
    int cnt = 0;
    for(int i = 0; i < s.size() - 2; i++)
    {
        if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') cnt++;
    }
    cout <<cnt <<endl;
}

int main()
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


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

typedef long long ll;
typedef long double ld;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
const ll N=210;

int main()
{
    fast();
    ll n,d,x;
    cin>>n>>d>>x;

    vector<ll> arr(n);
    for(ll i=0;i<n;i++)
        cin>>arr[i];

    ll ans = x;
    for(ll i=0;i<n;i++)
        for(ll j=0; (j*arr[i])+1 <=d ;j++ )
            ans++;

    cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>
#include <cctype>
#include <climits>
#include <list>
#include <queue>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

template<typename T>
T combinations2(T n, T r) {
  T a = 1;
  for (T d = 1; d <= r; ++d) {
    a *= n--;
    a /= d;
  }
  return a;
}

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

  ll N; cin>>N;
  vector<ll> A(N);
  for(int i=0; i<N; i++) {
    cin>>A[i];
  }

  vector<ll> acc(N+1);
  acc[0] = A[0];
  acc[N] = 0; // stopper
  for(int i=1; i<N; i++) {
    acc[i] = acc[i-1] + A[i];
  }
  sort(acc.begin(), acc.end());

  ll ans = 0;
  map<ll,ll> dict;
  for(int i=0; i<=N; i++) {
    dict[acc[i]]++;
  }
  for(auto p: dict) {
    ans += combinations2(p.second, (ll)2);
  }

  cout << ans << endl;
}


Measured memory_bytes: 15872
n = int(input())
a = [i for i in map(int, input().split())]
 
if a.count(0) != 0:
  print(0)
else:
  result = 1
  for i in range(n):
    result *= a[i]
    if result > (10**18):
      print(-1)
      break
    else:
      continue
  else:
    print(result)

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

int main(void)
{
    int N;
    cin >> N;
    map<int, int> a_map;
    int a;
    for (int i = 0; i < N; i++)
    {
        cin >> a;
        if (0 < a_map.count(a))
        {
            a_map[a] = a_map[a] + 1;
        }
        else
        {
            a_map[a] = 1;
        }
    }
    int count = 0;
    for(auto x: a_map)
    {
        if(x.second %2 == 1)
        {
            count++;
        }
    }
    cout << count << endl;
}

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

string s;
int cnt[26];

int main() {
    cin >> s;
    long long ans = 1;
    for (char c : s) {
        for (int i = 0; i < 26; i++) {
            if (c ^ (i + 'a')) ans += cnt[i];
        }
        cnt[c - 'a']++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(len(A)-1):
    if A[i] <= A[i + 1]:
        continue
    else:
        ans += A[i] - A[i + 1]
        A[i+1] = A[i]
print(ans)

Measured memory_bytes: 32364
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
// #include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
// #define MOD 1000000007
#define MOD 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int n;cin>>n;
  vector<int> vec (n,0);
  vector<int> pos (n+1,0);
  for (int i = 0; i < n; i++)
  {
    cin>>vec[i];
    pos[vec[i]] = i;
  }
  multiset<int> st = {-1,-1,n,n};
  int res = 0;
  for (int i = n; i > 0; i--) 
  {
    st.insert(pos[i]);
    auto itr = st.lower_bound(pos[i]);
    auto l1 = prev(itr);//(前に小さい数のイテレーター)
    auto l2 = prev(l1);
    auto r1 = next(itr);//(次に大きい数のイテレーター)
    auto r2 = next(r1);
    res += ((*l1 - *l2)*(*r1 - pos[i]) + (*r2 - *r1)*(pos[i] - *l1))*vec[pos[i]];
    // DEBUG(res,"\n");
  }
  cout<<res<<endl;
  

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

int main(void)
{
	ll N,W; cin>>N>>W;
    ll V[N+1][W+1];
    rep(i,W+1) V[0][i]=0;
    vector<ll> v(N),w(N);
    rep(i,N) cin>>v[i]>>w[i];
    rep(i,N){
        rep(j,W+1){
            if(j<w[i]) V[i+1][j]=V[i][j];
            else V[i+1][j]=max(V[i][j],V[i][j-w[i]]+v[i]);
        }
    }
    cout<<V[N][W]<<endl;
	return 0;
}


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

long long A[100005];
long long B[100005];

int main(void){
    int N; cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }
    
    int ans = 0;
    long long s = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] < B[i]) {
            s += B[i] - A[i];
            ans += 1;
        }
    }
    
    vector<long long> diff(N);
    for (int i = 0; i < N; i++) {
        diff[i] = A[i] - B[i];
    }
    sort(diff.begin(), diff.end(), greater<long long>());
    int idx = 0;
    for (int i = 0; diff[i] > 0 && s > 0; i++) {
        s -= diff[i];
        ans++;
    }
    if (s <= 0) {
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }
}


Measured memory_bytes: 2560
### ----------------
### ここから
### ----------------

import sys
import math
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n=int(readline())

    to=int(math.sqrt(n))+1
    ans=n-1
    for i in range(2,to+1):
        if n%i==0:
            j=n//i
            if ans>0:
                ans=min(ans,i+j-2)
            else:
                ans=i+j-2
    print(ans)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 5576