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

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

int main() {
        int n;
        cin >> n;
        int ans = 1;
        while (ans <= n) {
                ans *= 2;
        }
        ans /= 2;
        cout << ans << endl;
        return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n, vector<int>());
  for(int i = 0; i < m; ++i){
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }

  vector<P> dist(n, P(INF, 0)); // dist, num
  queue<int> q;
  dist[0] = P(0, 0);
  q.push(0);
  while(!q.empty()){
    int cur = q.front();
    q.pop();
    for(auto itr : g[cur]){
      if(dist[itr].first != INF) continue;
      dist[itr].first = dist[cur].first + 1;
      dist[itr].second = cur + 1;
      q.push(itr);
    }
  }

  cout << "Yes" << endl;
  for(int i = 1; i < n; ++i){
    cout << dist[i].second << endl;
  }
  return 0;
}

Measured memory_bytes: 10640
#include<cstdio>
#include<cstring>
#define Powered using
#define by namespace
#define Wshine std;
Powered by Wshine

char s;
int count=0,i;
int main()
{
	for(i=0;i<3;i++)
	{
		scanf("%c",&s);
		if(s=='1')
		{
			count++;
		}
	}
	printf("%d",count);
	return 0;
}

Measured memory_bytes: 128
n,k=map(int,input().split())
count=0
l,p=[],[]
for i in range(k):
	d=int(input())
	a=list(map(int,input().split()))
	for i in range(1,n+1):
		if i in a:
			l.append(i)
for i in range(1,n+1):
	if i not in l:
		p.append(i)
print(len(p))


Measured memory_bytes: 9240
#include<bits/stdc++.h>
#define ri register int
using namespace std;
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef vector<int> poly;
#define pb push_back
const int rlen=1<<18|1,inf=0x3f3f3f3f;
const ll Inf=1e18;
char buf[rlen],*ib=buf,*ob=buf;
#define gc() (((ib==ob)&&(ob=(ib=buf)+fread(buf,1,rlen,stdin)),ib==ob)?-1:*ib++)
inline int read() {
  int ans=0;
  bool f=1;
  char ch=gc();
  while(!isdigit(ch)) f^=ch=='-',ch=gc();
  while(isdigit(ch)) ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
  return f?ans:-ans;
}
inline ll readl() {
  ll ans=0;
  bool f=1;
  char ch=gc();
  while(!isdigit(ch)) f^=ch=='-',ch=gc();
  while(isdigit(ch)) ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
  return f?ans:-ans;
}
inline int Read(char*s) {
  int tp=0;
  char ch=gc();
  while(!isdigit(ch)&&!isalpha(ch)) ch=gc();
  while(isdigit(ch)||isalpha(ch)) s[++tp]=ch,ch=gc();
  return tp;
}
namespace modular {
  const int mod=998244353;
  inline int add(int a,int b) { return a+b<mod?a+b:a+b-mod; }
  inline int dec(int a,int b) { return a<b?a-b+mod:a-b; }
  inline int mul(int a,int b) { return (ll)a*b%mod; }
  inline void Add(int&a,int b) { a=a+b<mod?a+b:a+b-mod; }
  inline void Dec(int&a,int b) { a=a<b?a-b+mod:a-b; }
  inline void Mul(int&a,int b) { a=(ll)a*b%mod; }
  inline int ksm(int a,int p) { int ret=1;for(;p;p>>=1,Mul(a,a)) (p&1)&&(Mul(ret,a),1);return ret; }
  inline int Inv(int a) { return ksm(a,mod-2); }
  inline int sqr(int a) { return mul(a,a); }
  inline int cub(int a) { return (ll)a*a%mod*a%mod; }
}
using namespace modular;
template<typename T> inline void ckmax(T&a,T b) { a<b?a=b:0; }
template<typename T> inline void ckmin(T&a,T b) { a>b?a=b:0; }
template<typename T> inline T gcd(T a,T b) { T t;while(b)t=a,a=b,b=t-t/a*a;return a; }
template<typename T> inline T Abs(T x) { return x<0?-x:x; }
const int N=1e6+5;
int n,a[N],top=0;
char s[N];
inline int getc(int n,int m) {
  if(n<2&&m<2) return n>=m;
  return getc(n/2,m/2)*getc(n%2,m%2);
}
inline void check_1(int*a) {
  int res=0;
  for(ri i=1;i<=n;++i) res^=(a[i]&1)*getc(n-1,i-1);
  if(res) cout<<1,exit(0);
}
inline void check_2(int*a) {
  int res=0;
  for(ri i=1;i<=n;++i) res^=(a[i]>0)*getc(n-1,i-1);
  if(res) cout<<2,exit(0);
}
int main() {
  #ifdef ldxcaicai
  freopen("lx.in","r",stdin);
  #endif
  n=read(),Read(s);
  for(ri i=1;i<=n;++i) a[i]=(s[i]^48)-1;
  check_1(a);
  bool f1=0,f2=0;
  for(ri i=1;i<=n;++i) if(a[i]==1) f1=1;else if(a[i]==2) f2=1;
  if(!f1) check_2(a);
  cout<<0;
  return 0;
}

Measured memory_bytes: 5376
using System;
using System.Linq;

namespace _10_A
{
    class Program
    {
        static void Main()
        {
            double[] x = Console.ReadLine().Split().Select(double.Parse).ToArray();
            Console.WriteLine(Math.Sqrt((x[0] - x[2]) * (x[0] - x[2]) + (x[1] - x[3]) * (x[1] - x[3])));
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9628
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=a;i<(b);i++)
using namespace std;
string S;

int main(){
  cin >> S;
  int ng = 0;
  int np = 0;
  int w = 0, l = 0;
  REP(i,S.size()){
    if( np == ng ){ // gを出すしかない
      if( S[i] == 'p' ){
	l++;
      }
      ng++;
    }else{ // pを出せる
      if( S[i] == 'g' ){
	w++;
      }
      np++;
    }
  }
  cout << w - l << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 7;

int main(){
	ios::sync_with_stdio(false); cin.tie(nullptr);
	int a[3]; for(int i = 0; i < 3; ++ i) cin >> a[i];
	sort(a, a + 3);
	bool bl = false;
	if(a[0] == a[1] && a[1] != a[2]) bl = true;
	if(a[2] == a[1] && a[1] != a[0]) bl = true;
	bl ? cout << "Yes\n" : cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		int x=sc.nextInt();
		ArrayList<Integer> a=new ArrayList<Integer>();
		for (int i=1;i<=m;i++){
			a.add(sc.nextInt());
		}
		int before=0;
		int after=0;
		
		for (int i=0;i<m;i++){
			if (a.get(i)<x){
				before+=1;
			}else{
				after+=1;
			}
		}
		System.out.println(Math.min(before,after));
	}
}

Measured memory_bytes: 21972
x = input()
y = input()
    
a = len(x)
b = len(y)
dp = [[1000000000]*(b+1) for _ in range(a+1)]
for i in range(a+1):
    dp[i][0] = i
for j in range(b+1):
    dp[0][j] = j

for i in range(a):
    for j in range(b):
        if x[i] == y[j]:
            dp[i+1][j+1] = min(dp[i][j] , dp[i][j+1]+1 , dp[i+1][j]+1)
        else:
            dp[i+1][j+1] = min(dp[i][j]+1 , dp[i][j+1]+1 , dp[i+1][j]+1)
            
print(dp[a][b])


Measured memory_bytes: 41960
/*why so serious?*/
#include<bits/stdc++.h>
using namespace std;
#define   int      long long
#define   fast()   ios_base::sync_with_stdio(0);cin.tie(0)
#define   all(x)   x.begin(),x.end()
#define   pb       push_back
#define   F        first
#define   S        second

int32_t main()
{int i,j,n,m,c,p,cnt=0,x;
 cin>>n>>m>>c;
 int a[m],b[m];
 for(i=0;i<m;++i)
 cin>>b[i];
 for(i=0;i<n;++i)
 {for(j=0,p=0;j<m;++j)
  {cin>>x;
   p+=b[j]*x;
  }
  if(p+c>0)
  ++cnt;
 }
 cout<<cnt;
}







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

int main() {
	int n;
	cin >> n;
	ll ans = 0;
	for(int i = 1; i <= n; i++) {
		if(i%3 != 0 && i%5 != 0) ans += i;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = (int)1e9 + 7;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;

    cout << a + b/2 << endl;
}

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

int main(){
	int n;
	cin>>n;
	vector<int> c(n);
	vector<int> s(n);
	vector<int> f(n);
	
	for(int i=0;i<n-1;i++)cin>>c[i]>>s[i]>>f[i];
	
	for(int i=0;i<n;i++){
		int np=0;
		for(int j=i;j<n-1;j++){
			if(s[j]<np){
				if(np%f[j]==0){
					np/=f[j];
					np*=f[j];
				}else{
					np/=f[j];
					np++;
					np*=f[j];
				}
			}else{
				np=s[j];
			}
			np+=c[j];
		}
		cout<<np<<endl;
	}
}

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

const int N = 55555 + 5;
int n;

int prime[N], vis[N];
//线性筛
void gen_prime_linear(int n){
    //sieve 2 to n prime talbe, vis==1 means not prime
    memset(vis, 0, sizeof(vis));
    int cnt = 0;
    for(int i = 2;i <= n; i++){
        if(!vis[i]) prime[cnt++] = i;//没筛掉说明它是素数
        for(int j = 0; j < cnt; ++j){
            if(i * prime[j] > n) break;//剪枝
            vis[i*prime[j]] = 1;
            if(i%prime[j] == 0) break;//保证用且只用最小的质因子把它筛去
        }
    }
}


int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n;
    int k = 55555;
    gen_prime_linear(k);
    
    int cnt[5];
    
    vector<int> ans;
    for (int i = 2; i <= k; i++){
        if(vis[i] == 0){
            if(i%5==1)ans.push_back(i);
            if (ans.size()==n)break;
        }
    }
    
    for (int i = 0; i < n; i++){
        cout<<ans[i]<<" \n"[i==n-1];
    }
    
    
    
    
    return 0;
}



Measured memory_bytes: 512
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
using namespace std;
int a[100000];
int n, sum, p;
char c[100000];
int main() {
	while (true) {
		cin >> n;
		if (n == 0) { break; }
		for (int i = 0; i < n; i++) {
			cin >> c[i];
			sum = 0;
			for (int j = 0; j < n - 1; j++) {
				cin >> p;
				if (p == 0) { sum += 10000; }
				if (p == 2) { sum += 100; }
			}
			sum += (20 - i);
			a[i] = sum;
		}
		sort(a, a + n);
		for (int i = n - 1; i >= 0; i--) {
			cout << c[20 - (a[i] % 100)] << endl;
		}
	}
}

Measured memory_bytes: 1176
#include <iostream>

using namespace std;

int a,b,c,d;

int main(){
    int input;
    while (cin >> input) {
int count(0);
        for (int a = 0; a < 10; ++a){
            for (int b = 0; b < 10; ++b){
                for (int c = 0; c < 10; ++c){
                    for(int d = 0; d < 10; ++d){
                        count+=a+b+c+d==input;
                    }
                }
            }
        }
        cout << count << endl;
    }
}

Measured memory_bytes: 3072
import math


def resolve():
    import sys
    input = sys.stdin.readline
    # row = [int(x) for x in input().rstrip().split(" ")]
    # n = int(input().rstrip())
    h = int(input().rstrip())

    def process(num: int):
        if num == 1:
            return 1
        else:
            count = 2 * process(num // 2)+1

        return count

    print(process(h))



if __name__ == "__main__":
    resolve()


Measured memory_bytes: 61944
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
ll mo=1000000007;
int main() 
{ 
	ll t1=1;
	//cin>>t1;
	while(t1)
	{
		ll arr[5];
		for(ll i=0;i<5;i++)cin>>arr[i];
		for(ll i=0;i<5;i++)
		{
			if(arr[i]==0)
				{
					cout<<i+1<<endl;
					break;
				}	
		}	
		t1--;
    }
    return 0; 
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,a[2][110];
int s[2][110];

int main(){
	cin >> n;
	REP(i,0,2) REP(j,0,n) cin >> a[i][j];
	
	REP(i,0,n) s[0][i+1] = s[0][i] + a[0][i];
	reverse(a[1], a[1]+n);
	REP(i,0,n) s[1][i+1] = s[1][i] + a[1][i];
	
	int ma = 0;
	REP(i,0,n){
		ma = max(ma, s[0][i+1] + s[1][n-i]);
	}
	
	cout << ma << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b)
#define chmin(a, b) (a)=min(a, b)
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/


int main(void) {
  ll i, j, k;

  ll N, M;
  cin >> N >> M;
  ll h[MAX];
  ll f[MAX]={};
  
  for(i=0; i<N; i++) cin >> h[i];
  
  for(i=0; i<M; i++) {
    ll a, b;
    cin >> a >> b;
    a--; b--;
    if(h[a]>=h[b]) f[b]=1;
    if(h[b]>=h[a]) f[a]=1;
  }
  
  ll ans=0;
  for(i=0; i<N; i++) ans+=!f[i];
  pt(ans);
  
}
 
 


Measured memory_bytes: 5124
#include<bits/stdc++.h>
#include<unordered_map>
/*
*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
*    ▀▀       ▀▀▀▀▀▀    ▀     ▀▀▀▀▀▀      ▀    ▀
*   ▀  ▀      ▀         ▀     ▀            ▀  ▀
*  ▀    ▀     ▀ ▀ ▀     ▀     ▀ ▀ ▀         ▀
* ▀ ▀▀▀▀ ▀    ▀         ▀     ▀             ▀
*▀        ▀   ▀         ▀     ▀             ▀
*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
*/
using namespace std;
void afify()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
#define ll long long
#define ld long double
#define mk make_pair
#define loop(i,intial,n)  for(int i=int(intial);i<n;i++)
#define loopn(j,n) for(int j=int(n);j>=0;j--)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(v) v.begin(),v.end()
///////////////////////////////////////
#define SCD(a) scanf("%d",&a)
#define SCD2(a,b) scanf("%d %d",&a,&b)
#define SCLL(a) scanf("%lld",&a)
#define SCLL2(a,b) scanf("%lld %lld",&a,&b)
#define PRD(a) printf("%d\n",a)
#define PRLL(a) printf("%lld\n",a)
///////////////////////////////////////
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <vi> vvi;
typedef vector <vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<vpii> vvpii;
typedef stringstream ss;
const ll oo = (ll) 10e9+7;
const double EPS = 1e-4;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
//ifstream ifs("input.txt");
//ofstream ofs("output.txt");

int main()
{
	afify();
	int n,m;
	cin>>n>>m;
	vi v(n);
	loop(i,0,m){
		int x,y;
		cin>>x>>y;
		v[x-1]++;
		v[y-1]++;
	}
	loop(i,0,n){
		cout<<v[i]<<endl;
	}
	return 0;
}

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

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

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main()
{
  int R, G;
  cin >> R >> G;
  cout << R + 2 * (G - R) << endl;
  return 0;
}


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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<vector<char>> A, B;
    for (int i = 0; i < N; i++)
    {
        vector<char> tmp;
        for (int j = 0; j < N; j++)
        {
            char n;
            cin >> n;
            tmp.push_back(n);
        }
        A.push_back(tmp);
    }
    for (int i = 0; i < M; i++)
    {
        vector<char> tmp;
        for (int j = 0; j < M; j++)
        {
            char n;
            cin >> n;
            tmp.push_back(n);
        }
        B.push_back(tmp);
    }
    bool judge = false;
    for (int i = 0; i <= N - M; i++)
    {
        for (int j = 0; j <= N - M; j++)
        {
            bool match = true;
            for (int k = 0; k < M; k++)
            {
                for (int n = 0; n < M; n++)
                {
                    if (A[i + k][j + n] != B[k][n])
                    {
                        match = false;
                    }
                }
            }
            if (match)
            {
                judge = true;
            }
        }
    }
    if (judge)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.rbegin(), a.rend());
	int sumA = 0, sumB = 0;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			sumA += a[i];
		} else {
			sumB += a[i];
		}
	}
	cout << sumA - sumB << '\n';	
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

int main(){
    int x,y,z,k; cin >> x >> y >> z >> k;
    vector<ll> a(x),b(y),c(z);
    for (int i = 0; i < x; i++){ cin >> a[i];}
    for (int i = 0; i < y; i++){ cin >> b[i];}
    for (int i = 0; i < z; i++){ cin >> c[i];}
    vector<ll> d(0),ans(0);

    for (int i = 0; i < x; i++){
        for (int j = 0; j < y; j++){
            ll tmp = a[i]+b[j];
            d.push_back(tmp);
        }
    }
    sort(d.begin(),d.end());
    reverse(d.begin(),d.end());

    for (int i = 0; i < min(k,x*y); i++){
        for (int j = 0; j < z; j++){
            ll tmp = d[i] + c[j];
            ans.push_back(tmp);
        }
    }
    sort(ans.begin(),ans.end());
    reverse(ans.begin(),ans.end());
    for (int i = 0; i < k; i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 43368
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<string.h>
#include<stack>
#include<vector>
using namespace std;
int main()
{
	int c[26]={0};
	char a[30]={0};
	scanf("%s",a);
	for(int i=0;a[i];i++)
	{
		c[a[i]-'a']++;
		if(c[a[i]-'a']>1)
		{printf("no");return 0;}
	}
	printf("yes");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair
using namespace std;

int inf = 1e18;
const int N = 5e5+5;

int mod = 1e9+7;
//int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}


signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
        int n,m;
        cin>>n>>m;
        if(n==m)
            cout<<"Yes"<<el;
        else
            cout<<"No"<<el;
    }


        return 0;
    }


Measured memory_bytes: 256
#!/usr/bin/env ruby
# require 'pry'

n = gets.chomp.to_i
ary = []
1.upto(9) do |n1|
  1.upto(9) do |n2|
    ary << n1*n2
  end
end
puts (ary.include?(n)) ? 'Yes' : 'No'


Measured memory_bytes: 1788
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long int ll;
static const int MAX_K = 2000;
static const int MAX_N = 2000;
static const ll MOD = 998244353;

int K, N;
ll nCr[MAX_K + MAX_N + 1][MAX_N + 1];

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

void init(){
	for(int i = 0; i <= N + K; i++){
		for(int j = 0; j <= K; j++){
			if(i == 0 && j == 0) nCr[i][j] = 1;
			else if(i == 0) nCr[i][j] = 0;
			else if(j == 0) nCr[i][j] = nCr[i - 1][j];
			else nCr[i][j] = nCr[i - 1][j - 1] + nCr[i - 1][j];
			nCr[i][j] %= MOD;
		}
	}
	return ;
}

ll binomial(int n, int r){
	if(n < 0 || r < 0 || r > n) return 0;
	else return nCr[n][r];
}

int main(){
	scanf("%d %d", &K, &N);
	init();
	for(int i = 2; i <= 2 * K; i++){
		if(i % 2 == 1){
			ll sum = 0;
			int num = (i > K + 1 ? (2 * K - i + 1) / 2 : (i - 1) / 2);
			for(int j = 0; j <= num; j++){
				ll cnt = mod_pow(2, num - j);
				cnt *= binomial(num, num - j);
				cnt %= MOD;
				cnt *= binomial(N - (num - j) + (K - 2 * j - (num - j) - 1), K - 2 * j - (num - j) - 1);
				cnt %= MOD;
				sum += cnt;
				sum %= MOD;
			}
			printf("%lld\n", sum);
		}else{
			ll sum = 0;
			int num = (i > K + 1 ? (2 * K - i + 1) / 2 : (i - 1) / 2);
			for(int j = 0; j <= num; j++){
				ll cnt = mod_pow(2, num - j);
				cnt *= binomial(num, num - j);
				cnt %= MOD;
				cnt *= binomial(N - (num - j) + (K - 2 * j - (num - j) - 2), K - 2 * j - (num - j) - 2);
				cnt %= MOD;
				sum += cnt;
				sum %= MOD;
				cnt = mod_pow(2, num - j);
				cnt *= binomial(num, num - j);
				cnt %= MOD;
				cnt *= binomial(N - 1 - (num - j) + (K - 2 * j - (num - j) - 2), K - 2 * j - (num - j) - 2);
				cnt %= MOD;
				sum += cnt;
				sum %= MOD;
			}
			printf("%lld\n", sum);
		}
	}
	return 0;
}


Measured memory_bytes: 62720
import java.util.Arrays;
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int a[] = new int[n];
        for (int i=0; i<n; ++i) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int q = sc.nextInt();
        int flag = 0;
        int m = 0;

        int[] sum = new int[1 << n];

        for (int i=0; i<q; ++i) {
            m = sc.nextInt();
            flag = 0;
            for (int j=0; j<Math.pow(2, n); ++j) {
                if (sum[j] == 0) {
                    for (int k=0; k<n; ++k) {
                        if (((j >> k) & 1) == 1) {
                            sum[j] += a[k];
                        }
                    }
                }
                if (sum[j] == m) {
                    flag = 1;
                    break;
                }
            }
            System.out.println(flag == 1 ? "yes" : "no");
        }

    }
}


Measured memory_bytes: 31824
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int,int> pii;
typedef long long ll;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

string yes = "Yes";
string no = "No";

int T;
ll A, B, C, D;

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

int main(){


    cin >> T;
    for(int ite = 0; ite < T; ite++){
        cin >> A >> B >> C >> D;
        if(A < B){
            cout << no << endl;
        }
        else if(D < B){
            cout << no << endl;
        }
        else if(B - 1 <= C){
            cout << yes << endl;
        }
        else{
            ll d = D % B;
            ll g = gcd(d, B);
            ll a = A % B;
            if(a > C){
                cout << no << endl;
            }
            else{
                // a + g * n > C
                ll n = (C - a) / g + 1;
                if(a + g * n < B){
                    cout << no << endl;
                }
                else{
                    cout << yes << endl;
                }
            }
        }
    }

    return 0;
}


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

ll n,c;
ll a[100005];
ll b[100005];

int main(){
    cin >> n >> c;
    for(ll i=0;i<n;i++){
        ll s,t,cc;
        cin >> s >> t >> cc;
        a[s]++;
        a[t+1]--;
    }
    ll memo=0;
    for(ll i=0;i<100004;i++){
        b[i+1]=b[i]+a[i];
        memo=max(memo,b[i+1]);
    }
    memo=min(memo,c);
    cout << memo << endl;
}


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

using namespace std;

typedef long long ll;

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

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

int solve(const string &X, const string &Y) {
    const int xlen = (int) X.size();
    const int ylen = (int) Y.size();
    vector<vector<int>> dp(xlen + 1, vector<int>(ylen + 1, 0));

    for (int i = 1; i <= xlen; i++) {
        for (int j = 1; j <= ylen; j++) {
            if (X[i - 1] == Y[j - 1]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            } else {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }

    return dp[xlen][ylen];
}

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

    for (int i = 0; i < N; i++) {
        string X, Y;
        cin >> X >> Y;
        cout << solve(X, Y) << endl;
    }

    return 0;
}



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

int main()
{
  int n;
  cin >> n;
  vector<int> w(n);
  int i, j;
  for(i = 0; i < n; i++)
  {
    cin >> w.at(i);
  }
  int sum1, sum2;
  int sumdis = 1000000;
  for(i = 0; i < n-1; i++)
  {
    sum1 = 0;
    sum2 = 0;
    for(j = 0; j < n; j++)
    {
      if(j <= i)
      {
        sum1 += w.at(j);
      }
      else
      {
        sum2 += w.at(j);
      }
    }
    if(abs(sum1-sum2) < sumdis)
    {
      sumdis = abs(sum1-sum2);
    }
  }
  cout << sumdis << endl;
}

Measured memory_bytes: 256
import sys

N,K=map(int,sys.stdin.readline().split())
S=sys.stdin.readline().rstrip()

befores='N'
happiness=0
noCounter=0
for s in S:
  if befores==s:
    happiness+=1
  else:
    noCounter+=1
  befores=s

happiness+=min(K,noCounter)*2
print(min(happiness,N-1))
  

Measured memory_bytes: 39408
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
int main(){
    int r;
    cin>>r;
    if(r<1200){
        cout<<"ABC"<<endl;return 0;
    }
    if(r<2800){
        cout<<"ARC"<<endl;return 0;
    }
    cout<<"AGC"<<endl;
    return 0;
}


Measured memory_bytes: 256
s,k = input(),int(input())

chrs = []
prev = 0
cnt = 0
for c in s:
    if c==prev: cnt+=1
    else: chrs.append(cnt);cnt=1
    prev = c
chrs.append(cnt)

ans = 0
for i in chrs: ans += i//2
ans *= k
if s[0]==s[-1]: ans += (chrs[1]%2 and chrs[-1]%2) * (k-1)

if len(set(s))==1: ans = len(s)*k//2

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
	int a, b, c, k, max, sum;

	cin >> a >> b >> c >> k;

	max = a;

	if(max < b || max < c)
	{
		max = b;
		if(max < c)
		{
			max = c;
		}
	}

	sum = a + b + c - max + max * pow(2, k);

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define M  2005
#define LL long long
using namespace std;
vector<int>edge[M];
int cnt[M];
int dis[M][M],n;
bool mark[M]={0}; 
void BFS(int k){
	int x=k;
	int Q[M],L=0,R=0;
	for(int i=1;i<=n;i++)mark[i]=0;
	Q[R++]=x;dis[k][x]=0;
	while(L<R){
		int x=Q[L++]; 
		for(int i=0;i<edge[x].size();i++){
			int y=edge[x][i];
			if(!mark[y]){
				dis[k][y]=dis[k][x]+1;
				mark[y]=1;
				Q[R++]=y;
			}
		}
	}
}
int main(){
	int x,y;
	cin>>n>>x>>y;
	edge[x].push_back(y);
	edge[y].push_back(x);
	for(int i=1;i<n;i++){
		edge[i].push_back(i+1);
		edge[i+1].push_back(i);
	}
	
	for(int i=1;i<n;i++){
		BFS(i);
		for(int j=i+1;j<=n;j++)
			cnt[dis[i][j]]++;
	}
	for(int i=1;i<n;i++)printf("%d\n",cnt[i]);
	return 0;
}

Measured memory_bytes: 16000
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>

using namespace std;


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

	int tmp = 0;
	for (int i = 1; i < n; i++) {
		if (s[i] == 'E')tmp++;
	}

	int ans = tmp;

	for (int i = 1; i < n; i++) {
		if (s[i] == 'E')tmp--;
		if (s[i - 1] == 'W')tmp++;
		if (ans > tmp) ans = tmp;
	}

	cout << ans << endl;

	return 0;
}

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

int board[9][9];
bool ok[9][9];

void check() {
    int cnt[10] = {};
    for(int i=0; i<9; ++i) {
        memset(cnt, 0, sizeof(cnt));
        for(int j=0; j<9; ++j) cnt[board[i][j]]++;
        for(int j=0; j<9; ++j)
            if(cnt[board[i][j]] > 1) ok[i][j] = false;

        memset(cnt, 0, sizeof(cnt));
        for(int j=0; j<9; ++j) cnt[board[j][i]]++;
        for(int j=0; j<9; ++j)
            if(cnt[board[j][i]] > 1) ok[j][i] = false;
    }

    for(int i=0; i<3; ++i)
        for(int j=0; j<3; ++j) {
            memset(cnt, 0, sizeof(cnt));
            for(int k=0; k<3; ++k)
                for(int l=0; l<3; ++l)
                    cnt[board[i*3+k][j*3+l]]++;

            for(int k=0; k<3; ++k)
                for(int l=0; l<3; ++l)
                    if(cnt[board[i*3+k][j*3+l]] > 1) ok[i*3+k][j*3+l] = false;
        }
}

int main() {
    int n;
    bool first = true;
    cin>>n;
    while(n--) {
        if(!first) cout<<endl;
        first = false;

        for(int i=0; i<9; ++i)
            for(int j=0; j<9; ++j)
                cin>>board[i][j];
        memset(ok, true, sizeof(ok));
        check();

        for(int i=0; i<9; ++i) {
            for(int j=0; j<9; ++j)
                cout<<((ok[i][j])?" ":"*")<<board[i][j];
            cout<<endl;
        }
    }
}

Measured memory_bytes: 0
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
int  a[100006];
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	if (n % 3 == 0) {
		if (a[0] == a[n / 3 - 1] && a[n / 3] == a[n * 2 / 3 - 1] && a[n * 2 / 3] == a[n - 1]&&(a[0]^a[n/3])==a[n*2/3]) {
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
	else {
		if (a[0] == a[n - 1] && a[n - 1] == 0)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}


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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int ans = 0;
int l;
int N;
void dfs(vector<int> &A) {
    if (A.size()==l) {
        int tmp = 0;
        bool t = false;
        bool h = false;
        bool t3,t5,t7;
        t3 = t5 = t7 = false;
        rep(i,A.size()) {
            if (t&&A[i]==0) h = true;
            if (A[i]>0) t = true;
            if (A[i]==3) t3 = true;
            if (A[i]==5) t5 = true;
            if (A[i]==7) t7 = true;
            tmp = tmp*10+A[i];

        }
        if (h || tmp>N) return;
        else if (t3 && t5 && t7) ans++;
        return;
    }
    else {
        int d[4] = {0,3,5,7};
        rep(i,4) {
            A.push_back(d[i]);
            dfs(A);
            A.pop_back();
        }
    }
    return;
}


int main(){
    cin >> N;
    int t = N;
    while(t>10) {
        t/=10;
        l++;
    }
    l++;
    vector<int> A;
    dfs(A);
    cout << ans << endl;
}


Measured memory_bytes: 3592
import random


def gcd(a, b):
    if a == 0:
        return b
    return gcd(b % a, a)


def lcm(a, b):
    return (a * b) / gcd(a, b)



#a = list(map(int, input().split()))
n,d= map(int, input().split())
c=0
for _ in range(n):
    x,y=map(int, input().split())
    if (x*x+y*y)**0.5<=d:
        c+=1
print(c)

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

int main()
{
    int n;
    cin >> n;
    int a = n / 100;
    int b = (n - a * 100) / 10;
    int c = n % 10;
    if (a == 7 || b == 7 || c == 7) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;

    }
    return 0;
}

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

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


Measured memory_bytes: 3916
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
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 <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >> p.second;
	return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
	rep(i, v.size()) { is >> v[i]; }
	return is;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);int main(){
	int n;
	ll ans=0LL;
	cin >>n;
	V a(n);
	cin >> a;
	rep(i, n) { 
		if(i!=0){
			if(a[i-1]==1 and a[i]>=1){
				ans++;
				a[i - 1]--;
				a[i]--;
			}
		}
		ans += a[i] / 2;
		a[i] %= 2;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3948
#include <iostream>
#include <algorithm>
#include <cassert>
#include <climits>
using namespace std;

typedef long long lli;

int n;
lli a[10000];

int main() {
  while(cin >> n && n) {
    for(int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    sort(a, a+n);
    lli res = 0;
    for(int i = 0; i < n; ++i) {
      res += a[i] * (n-i-1);
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
long long INF = (long long)1E17;
//#define i_7 (long long)(1E9+7)
#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}

//typedef long long ll;
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

//配列のSIZEは問題ごとに定義する必要がある。
const int SIZE = 200010;
long long inv[SIZE+1];//各iの逆元を格納する配列。
long long kai[SIZE+1];//i!のmodを格納する配列。
long long invkai[SIZE+1];//各i!の逆元を格納する配列。
const int MOD=i_7;
void invinit(){//上の配列を初期化する関数。
    inv[1]=1;
    for(int i=2;i<=SIZE;i++){
        inv[i] = MOD - ((MOD/i)*inv[MOD%i])%MOD;
    }
    
    kai[0]=invkai[0]=1;
    for(int i=1;i<=SIZE;i++){
        kai[i]=(kai[i-1]*i)%MOD;
        invkai[i]=(invkai[i-1]*inv[i])%MOD;
    }
}

long long comb(long long a, long long b){
    if(b<0 || a<b){
        return 0;
    }
    return mod(kai[a]*mod(invkai[b]*invkai[a-b]));
}

int main(){
  invinit();
  using namespace std;
  long long n, m, k;
  cin>>n>>m>>k;
  long long ans = 0;
  for(long long i = 0; i <= k; i++){
    long long c = comb(n - 1, i);
    long long t = m * po(m - 1, n - i - 1);
    t = mod(t);
    ans += mod(c * t);
    ans = mod(ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8328
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;


int main()
{
    IOS
    ll n;
    cin>>n;
    ll a[n-1];
    ll b[n];
    multiset<pll>st;
    for(ll i=0;i<n-1;i++)
    {
        b[i]=-1;b[i+1]=-1;
        cin>>a[i];
        st.insert({a[i],i});
    }
    ll cnt=0;
    while(!st.empty())
    {
        pll top=*(st.begin());
        st.erase(st.begin());
        ll ind=top.second;
        ll val=top.first;
        if(b[ind]==-1)
        {
            b[ind]=val;
        }
        if(b[ind+1]==-1)
        {
            b[ind+1]=val;
        }
    }
    ll ans=0;
    for(ll x:b)
    {
        ans+=x;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
typedef long long ll;
int a[2500000],b[2500000];
ll M,N,m0,md,n0,nd,ans=1e18,sa[2500001],sb[2500001];
ll val(ll i,ll j){
	return (M-i)*(N-j)+sa[i]+sb[j];
}
int main(){
	cin>>M>>N>>m0>>md>>n0>>nd;
	a[0]=m0;
	rep(i,M-1) a[i+1]=(a[i]*58+md)%(N+1);
	b[0]=n0;
	rep(i,N-1) b[i+1]=(b[i]*58+nd)%(M+1);
	sort(a,a+M);
	sort(b,b+N);
	rep(i,M) sa[i+1]=sa[i]+a[i];
	rep(i,N) sb[i+1]=sb[i]+b[i];
	ll j=N,now=sb[N];
	rep(i,M+1){
		while(j>0&&val(i,j)>val(i,j-1)){
			j--;
		}
		ans=min(ans,val(i,j));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 59764
import sys

def resolve():
    input = sys.stdin.readline
    N=int(input().rstrip())
    S=input().rstrip()

    count=0
    buf2=""
    buf1=""
    for i in range(N):
        buf0=S[i]

        if buf2=="A" and buf1=="B" and buf0=="C":
            count+=1
        buf2=buf1
        buf1=buf0
        
    print(count)

import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """10
ZABCDBABCQ"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """19
THREEONEFOURONEFIVE"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """33
ABCCABCBABCCABACBCBBABCBCBCBCABCB"""
        output = """5"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Measured memory_bytes: 6364
#include <iostream>
#include <queue>
using namespace std;
int dx[] = { -1, 0, 1, 0 };
int dy[] = { 0, -1, 0, 1 };

int main(){
	int W, H;
	while( cin >> W >> H, W, H ){
		char room[20][20];
		queue< pair<int, int> > xy;
		for( int i = 0; i < H; i++ ){
			for( int j = 0; j < W; j++ ){
				cin >> room[i][j];
				if( room[i][j] == '@' ){
					xy.push(pair<int, int>(i, j));
					room[i][j] = '#';
				}
			}
		}
		//cout << xy.front().first << ' ' << xy.front().second << endl;
		int sum = 1;
		while( !xy.empty() ){
			for( int i = 0; i < 4; i++ ){
				int x = xy.front().second + dx[i];
				int y = xy.front().first + dy[i];
				//cout << room[y][x];
				if( 0 <= x && x < W && 0 <= y && y < H && room[y][x] == '.' ){
					room[y][x] = '*';
					xy.push(pair<int, int>(y, x));
					sum++;
				}
			}
			//cout << endl;
			xy.pop();
		}
		/*for( int i = 0; i < H; i++ ){
			for( int j = 0; j < W; j++ ){
				cout << room[i][j];
			}
			cout << endl;
		}*/
		cout << sum << endl;
	}
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

const ll inf = 1<<29;
vector<int> G[100005];
vector<int> fromFennek(100005, inf), fromSnuke(100005, inf);

void dfs(int from, int now, int dist, int type){
    if(type==1) fromFennek[now]=dist;
    else fromSnuke[now]=dist;

    for(auto to:G[now]){
        if(from==to) continue;
        dfs(now, to, dist+1, type);
    }
}

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

    int n; cin >> n;
    rep(i, n-1){
        int a, b; cin >> a >> b;
        --a; --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    dfs(-1, 0, 0, 1);
    dfs(n, n-1, 0, 2);
    
    int Fscore=0, Sscore=0;
    rep(i, n){
        if(fromFennek[i]<=fromSnuke[i]) ++Fscore;
        else ++Sscore;
    }

    if(Fscore>Sscore) cout << "Fennec\n";
    else cout << "Snuke\n";

    return 0;
}

Measured memory_bytes: 12800
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a * b % 2 == 0) {
            System.out.println("Even");
        } else {
            System.out.println("Odd");
        }
    }
}


Measured memory_bytes: 22996
/*
 * =====================================================================================
 *
 *       Filename:  atcoder.cpp
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  2018年05月17日 16时23分38秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  XIAN WU (wuxian), sysuwuxian@gmail.com
 *   Organization:  
 *
 * =====================================================================================
 */

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



int main()
{
  int a[3];
  for(int i = 0; i < 3; i++)
    scanf("%d", &a[i]);
  
  sort(a, a + 3);

  int ans = 0;
  ans += a[2] - a[1];

  int re = a[1] - a[0];
  ans += (re % 2 == 0) ? re / 2 : re / 2 + 2;

  cout<<ans<<endl;

  return 0;

}


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

int main(){
    int a, b;
    cin>>a >>b;
    if(a>b){
        cout<<"a > b"<<endl;
    }else if(a<b){
        cout<<"a < b"<<endl;
    }else{
        cout<<"a == b"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3044
N, M = map(int, input().split())
a = []
flag = True
for i in range(M):
    a.append(int(input()))

a = [-1] + a + [N+1] #add beginning and end

# list of steps between broken steps
s1=[]
for i in range(len(a)-1):
    if a[i+1]-a[i]-2<0:
        flag = False
        break
    s1.append(a[i+1]-a[i]-2) 

if flag==False:
    print(0)    
else:     
    # possibile ways for steps
    s2 = [1, 1, 2]
    while len(s2) < N+1:
        s2.append(s2[-2]+s2[-1])
    
    # possible ways for all
    s3 = 1 
    for j in s1:
        s3 = s3 * s2[j] 
        
    s4 = s3 % 1000000007 
    print(s4)

Measured memory_bytes: 462488
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll long long
int main(){
  ll a,b,c,ans=0;
  cin>>a>>b>>c;
  if(a+b>=c){
    ans=b+c;
  }
  else{
    ans=b+c-(c-a-b)+1;
  }
  cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    ll t=1,h,w,n,x=0,y=0,z=0,min=100000000000,k,ans=0;
    string s1,s2,s3;
    VS s(3);
    cin >> s[0] >> s[1] >> s[2];
    int turn = 0, next;
    while(!s[turn].empty()){
        next = s[turn][0] - 97; //'a'は10進数で97を表す
        s[turn].erase(s[turn].begin());
        turn = next;
    }
    cout << (char)( turn + 65 ) <<endl;  //'A'は10進数で65である。
    return 0;
}


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

int main(){
    string S;  cin >> S;
    if(S == "Sunny") cout << "Cloudy" << endl;
    if(S == "Cloudy") cout << "Rainy" << endl;
    if(S == "Rainy") cout << "Sunny" << endl;
}

Measured memory_bytes: 256
# B - String Palindrome
# https://atcoder.jp/contests/abc159/tasks/abc159_b

import sys

S = input()
N = len(S)

def is_palindrome(s):
    return s == s[::-1]

if not is_palindrome(S):
    print("No")
    sys.exit()

if not is_palindrome(S[:(N-1)//2]):
    print("No")
    sys.exit()

if not is_palindrome(S[(N+3)//2-1:]):
    print("No")
    sys.exit()

print("Yes")

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

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

const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int N;
int a[112345];

int main() {
	cin >> N;
	REP(i, N) scanf("%d", a + i);
	
	bool ans = true;
	
	if (*max_element(a, a + N) - *min_element(a, a + N) >= 2) ans = false;
	
	map<int, int> mm;
	REP(i, N) mm[a[i]]++;
	
	vector<pii> v;
	for (map<int, int>::iterator it = mm.begin(); it != mm.end(); ++it)
		v.push_back(pii(*it));
	sort(ALL(v));
	
	if (v.size() == 1) {
		if (v[0].fi + 1 == v[0].se) ans = true;
		else if (v[0].fi * 2 > N) ans = false;
	}
	else {
		int cnt = v[1].fi - v[0].se;
		
		if (cnt <= 0 || cnt > v[1].se / 2) ans = false;
	}
	
	puts(ans ? "Yes" : "No");
	
	return 0;
}


Measured memory_bytes: 6520
import collections

def resolve():
  N = int(input())
  A = [int(x) for x in input().split(" ")]
  setA = set(A)
  listA = sorted(list(setA))
  collectionA = collections.Counter(A)

  result = listA[-1]
  collectionA[listA[-1]] -= 1

  if collectionA[listA[-1]] == 0:
    listA.pop()

  for list_a in listA:
    collectionA[list_a] *= 2

  for i in range(N - 2):
    result += listA[-1]
    collectionA[listA[-1]] -= 1
    if collectionA[listA[-1]] == 0:
      listA.pop()

  print(result)


if __name__ == "__main__":
  resolve()

Measured memory_bytes: 48132
n=int(input())
a=list(map(int,input().split()))
a.sort()
if n==2:
    print(a[-1])
else:
    su=a[-1]
    d=1
    for i in range(n-2,-1,-1):
        su+=2*a[i]
        d+=2
        if d==n-1:
            break
        elif d>n-1:
            su-=a[i]
            break
    print(su)

Measured memory_bytes: 94316