akhauriyash/Code-Regression huggingface dataset:
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define mod 1000000007
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define ret return puts("-1"),0;
#define N 500055
#define int ll
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,ans,sum[N],f[N],a[N],r[N],l[N];
struct xx{
	int x,v;
}z[N];
bool cmp(xx a,xx b){return a.x<b.x;}
int _get(int x){
	//找到第一个>=x的
	if (a[n]<x) return n+1;
	int l=1,r=n;
	while (l<r){
		int mid=(l+r)>>1;
		if (a[mid]>=x) r=mid;
		else l=mid+1; 
	}
	return l;
}
inline void add(int &x,int k){
	x+=k;x-=(x>=mod)?mod:0;x+=(x<0)?mod:0;
}
bool cmp2(xx a,xx b){return a.v<b.v;}
signed main(){
	n=read();
	F(i,1,n){z[i].x=read();a[i]=z[i].v=read();}
	sort(z+1,z+n+1,cmp2);F(i,1,n) z[i].v=i;
	sort(z+1,z+n+1,cmp);sort(a+1,a+n+1);
	F(i,1,n) r[i]=max(r[i-1],z[i].v);
	l[n+1]=inf;D(i,n,1) l[i]=min(l[i+1],z[i].v);
	sort(z+1,z+n+1,cmp);
	f[0]=sum[0]=1;z[0].x=z[0].v=0;
	int l1=0;
	F(i,1,n){
		while (r[l1]<l[i]-1&&l1<=i-1) l1++;
		if (l1<=i-1) add(f[i],sum[i-1]-sum[l1-1]);
		if (r[i]==n) add(ans,f[i]);
		sum[i]=(sum[i-1]+f[i])%mod;
	}
	wrn(ans);
	return 0;
}
/*
4
1 1
2 2
3 4
4 5
*/

Measured memory_bytes: 24960
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
#define repi(i,a,b) for(lint i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) tsort(v); reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_1
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

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

    lint n, m, in[2];cin>>n>>m;
    vector<lint> c, a;
    rep(i,m){
        cin>>in[0]>>in[1];
        if(in[0]==1)c.push_back(in[1]);
        else if(in[1]==n)a.push_back(in[0]);
    }
    tsort(a);tsort(c);
    rep(i,siz(c)){
        if(binary_search(all(a),c[i])){
            co("POSSIBLE");
            return 0;
        }
    }
    co("IMPOSSIBLE");
}

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

using namespace std;


double rast(double x1,double y1,double x2, double y2)
{
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}



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

    int n;
    cin >> n;
    int ans=0;
    for (int i=1;i<=n;i++)
    {
        int x=i;
        int kol=0;
        while (x)
        {
            x/=10;
            kol++;
        }

        if (kol%2==1)
            ans++;
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";}

// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
typedef long long ll;
typedef double ld;
#define pll pair<ll,ll>
#define pii pair<int, int>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
   
const ll Mod = 1e9 + 7;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
    int n;
    cin >> n;
    int A[n];
    for(int i = 0 ;i < n; i++)
        cin >>  A[i];
    
    int cnt = 0;
    for(int i = 1 ;i < n-1 ; i++){
        if(A[i] < A[i-1] && A[i] >  A[i+1] || A[i] > A[i-1] && A[i] < A[i+1])
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

int main(){
  int H[1010] ;
  int N,T,A,h ;
  double abs_temperature[1010] ;

  int i,j ;

  cin >> N ;
  cin >> T >> A ;

  for(i=0; i<N; i++){
    cin >> H[i] ;
  }

  for(i=0; i<N; i++){
    abs_temperature[i] = fabs(A- T + 0.006*H[i]) ;
  }

  j=0 ;

  for(i=0; i<N; i++){
    if(abs_temperature[j]>abs_temperature[i]) j = i ;
  }

  cout << j+1 << endl;
}


Measured memory_bytes: 888
#include <cstdio>
#include <vector>
void erase(std::vector<int> &vec, int val) { vec.erase(std::lower_bound(vec.begin(), vec.end(), val)); }
int ans[200005];
char str[200005];
std::vector<int> vec_00, vec_01, vec_10, vec_11;
int main()
{
	// freopen("B.in", "r", stdin);
	int n, cur = 0;
	scanf("%d%s", &n, str + 1);
	str[0] = str[n << 1] = '1';
	for (int i = 0; i < n << 1; i++)
	{
		if (str[i] == '0')
			(str[i + 1] == '0' ? vec_00 : vec_01).push_back(i);
		else
			(str[i + 1] == '0' ? vec_10 : vec_11).push_back(i);
	}
	int m = vec_11.size();
	if (m & 1)
	{
		puts("No");
		return 0;
	}
	if (m & 3)
	{
		int a = 0;
		while (a <= n << 1 && str[a] == '1')
			a++;
		if (a > n << 1)
		{
			puts("No");
			return 0;
		}
		while (true)
		{
			while (a < n << 1 && str[a + 1] == '0')
				a++;
			if (a >= n << 1)
			{
				puts("No");
				return 0;
			}
			if (a + 2 <= n << 1 && str[a + 2] == '1')
				break;
			a += 2;
		}
		int b = a + 1;
		while (b <= n << 1 && str[b] == '1')
			b++;
		if (b > n << 1)
		{
			puts("No");
			return 0;
		}
		int pos = 0;
		while (pos < m && vec_11[pos] > a && vec_11[pos] < b - 1)
			pos++;
		if (pos >= m)
		{
			puts("No");
			return 0;
		}
		while (pos + 1 < m && vec_11[pos + 1] < a)
			pos++;
		int x = a, y = b - 1, z = a + 1, w = vec_11[pos];
		ans[x] = ans[y] = cur++;
		erase(vec_01, x);
		erase(vec_10, y);
		ans[z] = ans[w] = cur++;
		erase(vec_11, z);
		erase(vec_11, w);
	}
	for (int i = 0; i < vec_01.size(); i++)
		ans[vec_01[i]] = ans[vec_10[i]] = cur++;
	for (int i = 0; i < vec_00.size(); i += 2)
		ans[vec_00[i]] = ans[vec_00[i + 1]] = cur++;
	for (int i = 0; i < vec_11.size(); i += 4)
	{
		ans[vec_11[i]] = ans[vec_11[i + 2]] = cur++;
		ans[vec_11[i + 1]] = ans[vec_11[i + 3]] = cur++;
	}
	puts("Yes");
	for (int i = 0; i < n << 1; i++)
		printf("%d%c", ans[i] + 1, " \n"[i + 1 == n << 1]);
	return 0;
}


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

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

  for(int i=A; i<=B; i++){
    int two_digits = i % 100;
    int r_two = (two_digits % 10) * 10 + two_digits / 10;
    if(i / 1000 == r_two){
//      cout << i << "\n";
      count++; 
    }
  }
  
  cout << count << "\n";
}


Measured memory_bytes: 3520
s=input()
t=input()
lt=len(t)
ls=len(s)
differ=ls-lt
ans=[]
for i in range(0,differ+1,1):
  cnt=0
  st=differ-i
  s_cont=s[st:]
  for a in range(lt):
    if s_cont[a]==t[a]:
      cnt+=1
    ans.append(lt-cnt)
print(min(ans))
   

Measured memory_bytes: 14372
#include"bits/stdc++.h"
using namespace std;
int n,N=1e6;
int main()
{
    vector<int> v(N);
    cin>>n;
    int x;
    while(n--)
    {
        cin>>x;
        v[x]++;
    }
    
    int ans=0;
    for(int i=1;i<=N;i++)
    {
        if(v[i])
        {
           if(v[i]==1)ans++;
            
            for(int j=i+i;j<=N;j+=i)
            {
                v[j]=0;
            }
            
        }
        
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 7012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;
const int MAX_N = 2e5;

int d, c[26], s[365][26], t[365], last[26];
int u;
ll point;
int test(int k, int i){
  ll res = 0;
  rep(j, 26){
    if(j == k) continue;
    res -= c[j] * last[j];
  }
  
  return res + s[i][k];
}

int main(){
  cin >> d;
  rep(i, 26) cin >> c[i];
  rep(i, d){
    rep(j, 26){
      cin >> s[i][j];
    }
  }
  
  point = 0;
  fill(last, last+26, 0);
  rep(i, d){
    rep(i, 26) last[i]++;
    int res = -INF;
    
    rep(k, 26){
      if(res < test(k, i)){
        u = k;
        res = test(k, i);
      }
    }
    last[u] = 0;
    t[i] = u;
  }
  rep(i, d) cout << t[i]+1 <<endl;
}

Measured memory_bytes: 3680
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    cunt1=0
    cunt2=0
    for ss in s:
        if ss=='1':cunt1+=1
        else:cunt2+=1
    print(min(cunt1,cunt2)*2)

if __name__=='__main__':
    main()

Measured memory_bytes: 39408
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.Unboxed            as AU
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.Int
import qualified Data.IntMap                   as IM
import qualified Data.Map                      as M
import           Data.List
import qualified Data.Set                      as S
import           Data.Maybe
import           Data.Ord
import           Data.Time
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readString = map BS.unpack . BS.words <$> BS.getLine
readStrings n = replicateM n $ BS.unpack <$> BS.getLine
toPair [x, y] = (x, y)

main = do
  nums <- map read . words <$> getLine
  putStrLn $ solve nums

solve :: [Int] -> String
solve nums | length (group $ sort nums) == 2 = "Yes"
           | otherwise                       = "No"


Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

using ipair = pair<ll,ll>;

ll INF = 1e16+7;

bool operator>(const ipair a,const ipair b){return a.first > b.first;}


int N, M, Q;
vector<tuple<int, int, int, int>> question;

ll calc(vector<int> vect){
  // rep(i, N) cout << vect[i] << " ";
  // cout << endl; 

  ll ret = 0;

  rep(i, Q){
    tuple<int, int, int, int> t = question[i];
    int a = get<0>(t);
    int b = get<1>(t);
    int c = get<2>(t);
    int d = get<3>(t);

    if(vect[b] - vect[a] == c){
      ret += d;
    }
  }

  return ret;
}

ll dfs(int depth, int m, vector<int> vect){
  if(depth == N){
    return calc(vect);
  }

  ll ret = 0;

  for(int j=m; j <= M; j++){
    vector<int> next_vect(N);
    rep(i, N) next_vect[i] = vect[i];
    next_vect[depth] = j;
    ret = max(ret, dfs(depth+1, j, next_vect));
  }

  return ret;
}

int main(){

  cin >> N >> M >> Q;

  rep(i, Q){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--; b--;
    question.emplace_back(a, b, c, d);
  }

  vector<int> tmp(N);
  rep(i, N) tmp[i] = 1;

  cout << dfs(0, 1, tmp) << endl;

  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){
	int n, a, max = -1000000, min = 1000000;
	long long sum=0;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a;
		sum =sum+ a;
		if (max < a){
			max = a;
		}
		if (min > a){
			min = a;
		}
	}
	cout << min <<" "<< max <<" "<< sum << endl;
}


Measured memory_bytes: 3112
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))
const int MOD = 1e9 + 7;

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

ll mypow(ll a, ll p){
	if(p <= 0) return 1;
	if(p == 1) return (a % MOD);
	if(p & 1) return ((a % MOD) * (mypow(a, p - 1) % MOD)) % MOD;
	ll x = mypow(a, p / 2) % MOD;
	return (x * x) % MOD;
}

ll inv(ll base){
	return mypow(base, MOD - 2);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	string s;
	cin >> s;
	int n = s.size();
	int q = 0;
	rep(i, n) if(s[i] == '?') q++;
	ll ans = 0;
	ll ar = 0, br = 0;
	rep(i, n){
		if(s[i] == 'A') (ar += mypow(3, q)) %= MOD;
		if(s[i] == 'B') (br += ar) %= MOD;
		if(s[i] == 'C') (ans += br) %= MOD;
		if(s[i] == '?'){
			(ans += br * inv(3)) %= MOD; //in a third of cases
			(br += ar * inv(3)) %= MOD; //in a third it is a B
			(ar += mypow(3, q - 1)) %= MOD; //in a third it is an
		}
		//debug(ans);
		//debug(ar);
		//debug(br);
		//cout << "-----" << endl;
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "



int main(){
    int n,l;cin>>n>>l;
    int absmin=1e9;
    int sum = 0;
    for(int i=0;i<n;++i){
        sum+=(l+i);
        if(abs(absmin)>abs(l+i))absmin=l+i;
    }
    co(sum-absmin);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cctype>
#include <map>
using namespace std;
 
map<char, char> sym;
 
void init() {
  sym['i'] = 'i';
  sym['w'] = 'w';
  sym['('] = ')';
  sym[')'] = '(';
}
 
int main() {
  init();
   
  string str;
  getline(cin, str);
   
  int n = str.size();
  int cnt = 0;
  if(str == "") goto fin;
  for(int i=0; i<n/2+1; i++) {
    if(sym[str[i]] != str[n-i-1]) cnt ++;
    str[n-i-1] = sym[str[i]];
  }
 fin:
  cout << cnt << endl;
   
  return 0;
}

Measured memory_bytes: 1188
N, M = map(int, input().split())
mod_ = 10 ** 9 + 7

nA = 1

for i in range(N):
  nA *= M - i
  nA %= mod_

dp = [0 for i in range(N+1)]
dp[1] = M-N
if N == 1:
  print( nA * dp[N] % mod_ )  
else:
  dp[2] = M - N + 1 + (M - N)*(M - N)
  dp[1] %= mod_
  dp[2] %= mod_
  for i in range(3, N+1):
    dp[i] = dp[i-1] * (M - N + i - 1) + dp[i-2] * (i-1)
    dp[i] %= mod_
  print( nA * dp[N] % mod_ )

Measured memory_bytes: 102396
x, n = gets.chomp.split(" ").map(&:to_i)
nums = gets.chomp.split(" ").map(&:to_i).sort

if n == 0 then
    puts x
    exit
end

plus_queue = [x]
minus_queue = [x]
ans = -1

while true do
    minus = minus_queue.shift
    plus = plus_queue.shift
    unless nums.include?(minus) then
        ans = minus
        break
    end
    unless nums.include?(plus) then
        ans = plus
        break
    end
    plus_queue << plus + 1
    minus_queue << minus - 1
end

puts ans

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

int main(){
    int q; cin >> q;
    multiset<int> a;
    decltype(a)::iterator itr1;
    decltype(a)::iterator itr2;
    rep(i ,q){
        int m , x , y;
        cin >> m >> x;
        switch (m)
        {
        case 0: 
            a.insert(x);
            cout << a.size() << endl; 
            break;
        case 1:
            cout << a.count(x) << endl;
            break;
        case 2:
            a.erase(x);
            break;
        case 3:
            cin >> y;
            if(a.empty()) break;
            else { 
                set<int>::iterator itr1,itr2;
                itr1 = a.lower_bound(x);
                itr2 = a.upper_bound(y);
                set<int>::iterator it = itr1;
                while(it != itr2){
                    cout << *(it++) << endl;
                }
            }
            break;
        }
    }
}


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

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>

using namespace std;
typedef long long ll;
int main(){

	int a,b,c;
	int k,total=0;
	int s=0;

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

	s=0;

	if(a<=b&&c<=b){
		s=b;
		total+=a+c;
	}else if(a>=b&&c<=a){
		s=a;
		total+=b+c;
	}else if(a<=c&&c>=b){
		s=c;
		total+=a+b;
	}

	for(int i=1; i<k+1; i++){
		s=s*2;
	}
	total+=s;

	cout<<total<<endl;


	return 0;
}


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

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

int w,n;
int ans[50];
int a,b;

int main(){
	cin>>w>>n;
	rep(i,w){
		ans[i+1] = i+1;
	}
	rep(i,n){
		char t;
		int tmp;
		cin>>a>>t>>b;
		tmp = ans[a];
		ans[a] = ans[b];
		ans[b] = tmp;
	}
	rep(i,w){
		cout<<ans[i+1]<<endl;
	}
	return 0;
}

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

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̒萔 (10��9��)
const int mod = 1000000007;

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

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int> > a(n, vector<int> (n));
    vector<vector<int> > b(m, vector<int> (m));
    rep(i, n) {
        string s;
        cin >> s;
        rep(j, s.size()) {
            a[i][j] = s[j];
        }
    }
    rep(i, m) {
        string s;
        cin >> s;
        rep(j, s.size()) {
            b[i][j] = s[j];
        }
    }

    rep(i, n - m + 1) {
        rep(j, n - m + 1) {
            int flag = 0;
            rep(k, m) {
                rep(l, m) {
                    if (a[k + i][l + j] == b[k][l])
                        flag++;
                }
            }
            if (flag == m * m) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main(void){
  int A;
  cin >> A;
  if(A / 100 == 7){
    cout << "Yes";
  } else if((A % 100) / 10 == 7){
    cout << "Yes";
  } else if((A % 10) == 7){
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h> 
using namespace std; 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    string s;
    int flag = 0;
    cin>>s;

    int n = s.length();

    string str = s.substr(0, (n-1)/2);
    string str1 = s.substr((((n+3)/2) - 1), n);

    string copy = s;
    string copy1 = str;
    string copy2 = str1;

    reverse(s.begin(), s.end());
    reverse(str.begin(), str.end());
    reverse(str1.begin(), str1.end());

    if((s == copy) && (str == copy1) && (str1 == copy2))
    flag++;

    if(flag > 0)
    cout<<"Yes\n";

    else 
    cout<<"No\n";

   



	return 0; 
} 


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>
#include <vector>
#include <list>
#include <iterator>

#include <cmath>

#define DIM 2
#define EPS (5*10e-4)

typedef std::vector<double> Vec;
typedef std::vector<Vec> Mat;
typedef std::pair<Mat,Vec> Eq;

void removeMinusZero(double& x){
	if ( fabs(x)< EPS ){
		x = 0.0;
	}
}

int main(void){
	using namespace std;
	cout << fixed << setprecision(3);

	list<Eq> input;
	double a,b,c,d,e,f;

	while(cin >> a >> b >> c >> d >> e >> f){
		Vec m1, m2;
		m1.push_back(a);
		m1.push_back(b);
		m2.push_back(d);
		m2.push_back(e);

		Vec vec;
		vec.push_back(c);
		vec.push_back(f);

		Mat mat;
		mat.push_back(m1);
		mat.push_back(m2);

		Eq eq = make_pair(mat,vec);

		input.push_back(eq);
	}

	for(auto itr = input.begin(); itr!=input.end(); ++itr){
		auto mat = itr->first;
		auto vec = itr->second;

		auto det = mat[0][0] * mat[1][1] - mat[0][1] * mat[1][0];

		mat[0][1] = -mat[0][1];
		mat[1][0] = -mat[1][0];
		swap(mat[0][0],mat[1][1]);

		Vec output(DIM);
		for (int i=0; i<DIM; i++){
			output[i] = inner_product(vec.begin(), vec.end(), mat[i].begin(), 0);
		}
		transform(output.begin(), output.end(),output.begin(), std::bind2nd(divides<double>(),det));
		for_each(output.begin(), output.end(), [](double& x) -> void { if(abs(x)< EPS){ x=0.0; } });
		cout << output[0] << " " << output[1] << endl;
	}
}

Measured memory_bytes: 1304
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int out = 2;
        if(n == out){
            System.out.println(2);
            return;
        }
        while(out <= n){
            out *= 2;
        }
        System.out.println(out / 2);
        scan.close();
    }
}


Measured memory_bytes: 26320
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define SREP(s,i,m) for(unsigned int i = s; i < m; ++i)
#define REP(i,m) SREP(0,i,m)

using namespace std;
#ifdef _MSC_VER
using LONG = __int64;
using ULONG = unsigned __int64;
#else
using LONG = long long int;
using ULONG = unsigned long long int;
#endif

int dfs(int initPos, int pos, vector<bool> &visited, vector<vector<int>> &edges, vector<int> &ans) {
	visited[pos] = true;
	ans.push_back(pos);
	for(auto node : edges[pos]) {
		if (!visited[node]) {
			if (dfs(initPos, node, visited, edges, ans)) return true;
		}
	}

	bool ok = true;
	for (auto node : edges[initPos]) {
		if (!visited[node]) {
			ok = false; break;
		}
	}
	for (auto node : edges[pos]) {
		if (!visited[node]) {
			ok = false; break;
		}
	}
	if (ok) return true;

	ans.erase(ans.end() - 1);
	return false;
}

int main(void) {
	int N, M;
	cin >> N >> M;
	vector<pair<int, int>> E;
	vector<vector<int>> edges(N);
	REP(i, M) {
		int a, b;
		cin >> a >> b;
		E.push_back({ a, b });
		a--; b--;
		edges[a].push_back(b);
		edges[b].push_back(a);
	}
	vector<pair<int, int>> edgeCount;
	REP(i, N) {
		edgeCount.push_back({edges[i].size(), i});
	}
	sort(edgeCount.begin(), edgeCount.end());
	vector<int> initPositions;
	vector<bool> added(N, false);
	initPositions.push_back(edgeCount[0].second);
	added[edgeCount[0].second] = true;
	for (int i = 1; i < edgeCount.size(); i++) {
		if (edgeCount[i - 1] != edgeCount[i]) break;
		initPositions.push_back(edgeCount[i].second);
		added[edgeCount[i].second] = true;
	}
	int limit = initPositions.size();
	for (int i = 0; i < limit; i++) {
		for (auto node : edges[initPositions[i]]) {
			if (!added[node]) {
				added[node] = true;
				initPositions.push_back(node);
			}
		}
	}
	for (auto initPos : initPositions) {
		vector<bool> visited(N, false);
		vector<int> ans;
		bool ok = dfs(initPos, initPos, visited, edges, ans);
		if (ok) {
			cout << ans.size() << endl;
			REP(i, ans.size()) ans[i]++;
			for (int i = 0; i < ans.size() - 1; i++) {
				cout << ans[i] << " ";
			}
			cout << ans[ans.size() - 1] << endl;
			return 0;
		}
	}
	throw runtime_error("ERROR");
	return 0;
}

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

int main() {
	int n;
	int table[128][128];
	for(int i = 0; i < 128; i++) {
		for(int j = 0; j < 128; j++)
			table[i][j] = 10000;
		table[i][i] = 0;
	}

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

		cin >> s;
		cin >> k;
		for(int j = 0; j < k; j++) {
			int d;
			cin >> d;
			table[s][d] = 1;
		}
	}

	for(int i = 0; i < 128; i++)
		for(int j = 0; j < 128; j++)
			for(int k = 0; k < 128; k++)
				table[j][k] = min(table[j][k], table[j][i] + table[i][k]);

	int p;
	cin >> p;

	for(int i = 0; i < p; i++) {
		int s, d, v;
		cin >> s >> d >> v;
		int tmp = table[s][d] + 1;
		if(v < tmp)
			cout << "NA" << endl;
		else
			cout << tmp << endl;
	}
}

Measured memory_bytes: 1228
n, k = map(int, input().split())
mod = 10**9 + 7

SIZE = 2 * 10 ** 5 + 1
fact = [0] * SIZE
inv = [0] * SIZE
finv = [0] * SIZE
fact[0], fact[1] = 1, 1
inv[1] = 1
finv[0], finv[1] = 1, 1
for i in range(2, SIZE):
    fact[i] = fact[i - 1] * i % mod
    inv[i] = mod - inv[mod % i] * (mod // i) % mod
    finv[i] = finv[i - 1] * inv[i] % mod


def nCr(n, r):
    if n < 0 or r < 0 or n < r:
        return 0
    return fact[n] * (finv[r] * finv[n - r] % mod) % mod


ans = 1
limit = min(k+1, n)
for i in range(1, limit):
    vacant = i
    fill = n-i
    add = i
    pattern = nCr(n, vacant) * nCr(add+fill-1, add)
    ans = (ans + pattern) % mod

print(ans)

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

int main() {
    char s[102], t[102];
    fgets(s, 102, stdin);
    fgets(t, 102, stdin);
    int len_s = strlen(s) - 1;
    s[len_s] = '\0';
    t[len_s] = '\0';
    for (int i=0; i<len_s; i++) {
        if (s[i] == t[0]) {
            char buf[len_s+1];
            for (int j=0; j<len_s; j++) {
                if (j+i < len_s) buf[j] = s[j+i];
                else buf[j] = s[j+i-len_s];
            }
            buf[len_s] = '\0';
            if (!strcmp(t, buf)) {
                printf("Yes");
                return 0;
            }
        }
    }
    printf("No");
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>
 
int main (int argc, char const *argv[])
{
    intmax_t N, A, B, C, D;
    char S[200000 + 1];
    intmax_t ans = 0;
 
    scanf("%jd%jd%jd%jd%jd", &N, &A, &B, &C, &D);
    scanf("%s", S);
 
    A--;
    B--;
    C--;
    D--;
 
    // #が並んでいると飛び越えれない
    for (int i = A; i < (D - 1); i++) {
        if (S[i] == '#' && S[i + 1] == '#') {
            puts("No");
            return 0;
        }
    }
 
    // C < Dだと、ふぬけくんを先にゴールさせとけばいい
    if (C < D) {
        puts("Yes");
        return 0;
    }
 
    // C > Dだと、すぬけくんがふぬけくんを飛び越えられればいい
    for (int i = B; i <= D; i++) {
        if (S[i] == '#') continue;
        if (S[i - 1] == '.' && S[i + 1] == '.') {
            puts("Yes");
            return 0;
        }
    }
 
    puts("No");
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) (vec).begin(),(vec).end()
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int h,w,m,row,col,rh[300100],ch[300100],ret,unt[300100];
vector<int> vec[300100];
vector<pair<int,int> > roh,coh;
map<pair<int,int>,int> exi;
int rvc[300100];
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>h>>w>>m;
	while(m--){
		cin>>row>>col;
		rh[row]++;
		ch[col]++;
		exi[make_pair(row,col)]=1;
		vec[row].push_back(col);
	}
	for(int i=1;i<=h;i++) roh.push_back(make_pair(rh[i],i));
	for(int i=1;i<=w;i++) coh.push_back(make_pair(ch[i],i));
	sort(roh.begin(),roh.end());reverse(roh.begin(),roh.end());
	sort(coh.begin(),coh.end());reverse(coh.begin(),coh.end());
	for(int i=0;i<w;i++) rvc[coh[i].second]=i;
	for(int i=1;i<=h;i++){
		if(!vec[i].size()){
			unt[i]=0;
			continue;
		}
		int lst=-1;
		for(int j=0;j<vec[i].size();j++){
			vec[i][j]=rvc[vec[i][j]];
		}
		sort(vec[i].begin(),vec[i].end());
		unt[i]=-1;
		for(int j=0;j<vec[i].size();j++){
			if(vec[i][j]>(lst+1)){
				unt[i]=lst+1;
				break;
			}
			lst=vec[i][j];
		}
		if(unt[i]==-1){
			if(vec[i][vec[i].size()-1]<(w-1))
				unt[i]=vec[i][vec[i].size()-1]+1;
			else unt[i]=-1;
		}
	}
	for(int i=0;i<h;i++){
		ret=max(ret,roh[i].first+coh[0].first-exi[make_pair(roh[i].second,coh[0].second)]);
		if(unt[roh[i].second]==-1) continue;
		ret=max(ret,roh[i].first+coh[unt[roh[i].second]].first);
	}
	cout<<ret<<endl;
	return 0;
}


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

int main(){
  int X,X_const,fX ;
  
  cin >> X ;
  X_const = X ;
  
  fX=0 ;
  
  while(1){
    if(X == 0){break ;}
    fX = fX + X % 10 ;
    X = (X - X%10)/10 ;
  }

  if(X_const % fX == 0) cout << "Yes" << endl;
  else cout << "No" << endl ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,a[205],sum=0;
   cin>>n;
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
   }
   for(int i=0;;i++)
   {
       bool f=1;
       for(int j=0;j<n;j++)
       {
            if(a[j]%2==1) f=0;
            a[j]/=2;
       }
       if(f==0) break;
       sum++;
   }
   cout<<sum;
}


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

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

	int dp[n][3];
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];

	for (i = 1; i < n; i++) {
		dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = b[i] + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = c[i] + max(dp[i - 1][0], dp[i - 1][1]);
	}

	int ans = 0;
	ans = max(max(dp[n - 1][0], dp[n - 1][1]), dp[n - 1][2]);

	cout << ans << endl;

	return 0;
}

int32_t main() {

	solve();
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll dp1[200200][2];
ll dp2[200200][2][2];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  ll n;
  cin >> n;
  vector<ll>a(n);
  rep(i,n) cin >> a[i];
  rep(i,n){
    dp1[i][0]=dp1[i][1]=-INF;
    dp2[i][0][0]=dp2[i][1][0]=dp2[i][0][1]=dp2[i][1][1]=-INF;
  }
  ll m=n/2;
  if(n%2==0){
    dp1[1][0]=a[0];
    dp1[1][1]=a[1];
    for(int i=1;i<m;i++){
      rep(j,2){
        if(j==0)dp1[i+1][0]=max(dp1[i+1][0],dp1[i][0]+a[2*i]);
        dp1[i+1][1]=max(dp1[i+1][1],dp1[i][j]+a[2*i+1]);
      }
    }
    cout << max(dp1[m][0],dp1[m][1]) << endl;
  }
  
  else{
    dp1[1][0]=a[0];
    dp1[1][1]=a[1];
    for(int i=1;i<m;i++){
      rep(j,2){
        if(j==0)dp1[i+1][0]=max(dp1[i+1][0],dp1[i][0]+a[2*i]);
        dp1[i+1][1]=max(dp1[i+1][1],dp1[i][j]+a[2*i+1]);
      }
    }
    dp2[1][0][0]=a[0]+a[n-1];
    dp2[1][1][0]=a[1]+a[n-1];
    dp2[1][0][1]=a[n-1];
    for(int i=1;i<n/2;i++){
      rep(j,2){
        rep(k,2){
          if(k==0){
            dp2[i+1][0][1]=max(dp2[i+1][0][1],dp2[i][j][k]);
          }
          if(j==0){
            dp2[i+1][0][k]=max(dp2[i+1][0][k],dp2[i][0][k]+a[2*i]);
          }
          if(i!=m-1){
            dp2[i+1][1][k]=max(dp2[i+1][1][k],dp2[i][j][k]+a[2*i+1]);
          }
        }
      }
    }
    cout << max({dp1[m][0],dp1[m][1],dp2[m][0][1],dp2[m][1][1]});
  }
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<bool> vb;

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}

#define deb(x) cout << '>' << #x << ':' << x << endl;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define END '\n'
#define inf 9e18
#define ff first
#define ss second
#define pb push_back

constexpr ll modu = 1e9 + 7;

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

void solve(){
    int n;
    cin >> n;
    vi A(n), cnt(n, 0);
    cin >> A;
    for (int i = 0; i < n; ++i) ++cnt[A[i]];
    if (cnt[0] >= 2) {
        cout << "0\n";
        return;
    } else if (cnt[0] == 1) {
        bool ok = true;
        for (int i = 2; i < n; i += 2) {
            if (cnt[i] != 2) {
                ok = false;
                break;
            }
        }
        if (ok) {
            cout << binpow(2, n / 2, modu);
            return;
        } else cout << "0\n";
    } else {
        bool ok = true;
        for (int i = 1; i <= n; i += 2) {
            if (cnt[i] != 2) {
                ok = false;
                break;
            }
        }
        if (ok) {
            cout << binpow(2, n / 2, modu);
        } else cout << "0";
    }
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3944
#include<bits/stdc++.h>
#define int long long
#define MOD 1000000007
#define MP make_pair
#define EPS (1e-10)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define rep(i,n)for(long long i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int a[100000];
signed main() {
	int n, x; scanf("%lld%lld", &n, &x);
	rep(i, n)scanf("%lld", &a[i]);
	int cnt = 0;
	rep(i, n - 1) {
		if (a[i] + a[i + 1] > x) {
			int d = (a[i] + a[i + 1] - x);
			if (a[i + 1] < d) {
				cnt += a[i + 1];
				d -= a[i + 1];
				a[i + 1] = 0;
				cnt += d;
				a[i] -= d;
			}
			else {
				a[i + 1] -= d;
				cnt += d;
			}
		}
	}
	printf("%lld\n", cnt);
}

Measured memory_bytes: 1024
n, k = map(int, input().split())
A = []
for _ in range(n):
    t, d = map(int, input().split())
    A.append((d, t))
A.sort(reverse=True)
X = []
Y = []
st = set()
for i in range(k):
    d, t = A[i]
    if t in st:
        X.append(d)
    else:
        Y.append(d)
        st.add(t)
x = sum(X)
y = sum(Y)
v = len(Y)
ans = x + y + v ** 2
for i in range(k, n):
    if not X:
        break
    d, t = A[i]
    if t in st:
        continue
    st.add(t)
    x -= X.pop()
    y += d
    v += 1
    ans = max(ans, x + y + v ** 2)
print(ans)


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

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

  ll ans = 0;
  for (int i=0; i<N-2; i++) {
    if (S[i]=='A' && S[i+1]=='B' && S[i+2]=='C') ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input()) // 2
ns = list(map(int, input().split()))

a = [ns[i] for i in range(len(ns)) if i % 2 == 0]
b = [ns[i] for i in range(len(ns)) if i % 2 == 1]
#ca = sorted([(a.count(s), s) for s in sa])[::-1]
#cb = sorted([(b.count(s), s) for s in sb])[::-1]  # [(出た回数, num)]
# countが遅かったので
da = {}
db = {}
for s in a:
    da[s] = da.get(s, 0) + 1
for s in b:
    db[s] = db.get(s, 0) + 1
ca = sorted([(v, k) for k, v in da.items()])[::-1]
cb = sorted([(v, k) for k, v in db.items()])[::-1]

if ca[0][1] != cb[0][1]:
    print(n-ca[0][0] + n-cb[0][0])
else:
    if len(ca) == 1 and len(cb) == 1:
        print(n)
    elif len(ca) == 1 and len(cb) > 1:
        print(n-ca[0][0] + n-cb[1][0])
    elif len(ca) > 1 and len(cb) == 1:
        print(n-ca[1][0] + n-cb[0][0])
    else:
        print(min(n-ca[1][0] + n-cb[0][0], n-ca[0][0] + n-cb[1][0]))  # ?

Measured memory_bytes: 22168
//#pragma comment(linker, "/STACK:1024000000,1024000000")
/* vim: set fdm=marker */
//{{{
#define __ return
int ATTENTION() {
	/* pls IGNORE this function and go down and HACK me
	 * read this AFTER contest
	 * this function is empty and it will not be called !
	 */

	http://codeforces.com/group/Pmz2A2x7ES
	/* I created a group there.
	 * I hope with the group, people can finish
	 * past contests, which is important for 
	 * increasing rating.
	 * I am still getting familiar with this function.
	 */
	 __ 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int iinf = 0x7fffffff;
const ll linf = ~(1LL<<63);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;
template<typename T>
inline T gcd(T a, T b) {
	if(a < 0) return gcd(-a, b);
	if(b < 0) return gcd( a,-b);
	if(a < b) return gcd(b, a);
	if(b == 0) return a;
	return gcd(b, a%b);
}

ll qpow(ll a, ll n, ll mod) {
	a %= mod;
	ll ans = 1LL;
	while(n) {
		if(n & 1) ans = (ans*a % mod);
		a = (a*a % mod);
		n >>= 1;
	}
	return ans;
}

inline ll rev(ll a, ll p) {
	return qpow(a, p - 2, p);
}

#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define rep(x, st, en) for(int x = st; x < en; x++)
#define rer(x, st, en) for(int x = st; x >= en; x--)
#define pb push_back
#define mp make_pair
#define dbgm(msg, var) cerr<<#msg<<" "<<#var<<" = "<<var<<endl; 
#define dbg(var) cerr<<#var<<" = "<<var<<endl;
#define X first
#define Y second
// build prefix sum
template<typename T>
inline void BPS(T* DST, T* SRC, int N, int s = 0) {
	DST[s] = SRC[s];
	rep(i, 1, N) DST[s + i] = DST[s + i - 1] + SRC[s + i];
}
inline int in() { int x; cin>>x; return x; }
#ifdef ALNDBG
namespace alndbg {
	clock_t s, e;
}
#endif

inline void tic() {
#ifdef ALNDBG
	alndbg::s = clock();
#endif
}

inline void toc() {
#ifdef ALNDBG
	alndbg::e = clock();
	cerr<<1000.0 * (alndbg::e - alndbg::s) / CLOCKS_PER_SEC<<" ms"<<endl;
#endif
}



//}}}

// -------------------- Spliters ------------------------
// BFS求最短路小心vis可能访问过
const int maxn = 1;

int main() {
	ios::sync_with_stdio(0);
  string s; cin>>s;
  s[3] = '8';
  cout<<s<<endl;
	return 0;
}
// --USE C++11
// *-USE O2


Measured memory_bytes: 256
# -*- coding:utf-8 -*-
from fractions import gcd

def lcm(a, b):
    """ aとbの最小公倍数を返す """
    return a*b // gcd(a, b)

def f(a, x, y):
    """ a以下で、xでもyでも割り切れないものの数"""
    return a - (a//x + a//y - a//lcm(x,y))

def solve():
    A,B,C,D = list(map(int, input().split()))
    ans = f(B, C, D) - f(A-1, C, D)
    print(ans)

if __name__ == "__main__":
    solve()


Measured memory_bytes: 5076
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<vector<int>> g(n);
	vector<P> rec(n - 1);
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
		rec[i] = P(a, b);
	}
	int ans1 = 0;
	rep(i, n) maxs(ans1, (int)g[i].size());
	vector<bool> used(n);
	map<P, int> mp;
	function<void(int, int)> Dfs = [&](int v, int prev) {
		used[v] = true;
		queue<int> que;
		rep(i, (int)g[v].size()) if (i + 1 != prev) que.push(i + 1);
		for (int c : g[v]) {
			if (used[c]) continue;
			mp[P(v, c)] = que.front();
			mp[P(c, v)] = que.front();
			Dfs(c, que.front());
			que.pop();
		}
	};
	rep(i, n) if (!used[i]) Dfs(i, -1);
	cout << ans1 << endl;
	rep(i, n - 1) cout << mp[rec[i]] << endl;
	return 0;
}


Measured memory_bytes: 62336
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define lld long long
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int a,b; cin>>a>>b;
    int z=b*10;
    int flag=0;
    for(int j=z;j<b*1000;j++)
    {
    	int ll=(int)(j*.08);
    	int mm=(int)(j*.1);
    	if(ll==a&&mm==b)
    	{
    		cout<<j;
    		return 0;
    	}
    }
    cout<<-1;
}

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

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

    ll ans=0;
    ll count=1;
    while(H>0){
        ans += count;
        if(H==1){
            H=0;
        }else{
            H/=2;
            count*=2;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        int ret = 0;

        ret += Math.max(Math.max(A, B), C) * 10;

        ret += A + B + C - ret/10;

        System.out.println(ret);

    }
}

Measured memory_bytes: 22740
using System;
using System.Linq;
using static System.Console;

class Program
{
    public static void Main(string[] args)
    {
        var v = ReadLine().Split(' ').Select(x=>int.Parse(x)).ToArray();
        var o = v.OrderBy(x=>x).ToArray();
        WriteLine(v[2] == o[1] ? "Yes" : "No");
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
	int sum=0;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		sum+=(s[i]-'0');
		sum%=9;
	}
	if(sum)cout<<"No\n";
	else cout<<"Yes\n";
    return 0;
}



Measured memory_bytes: 3776
a,b,c = map(int, input().split())

for i in range(100):
    if a%2==1 or b%2==1 or c%2==1:
        break
    a, b, c = (a+b)//2,(b+c)//2,(c+a)//2
ans = i
if i == 99:
    ans = -1
print(ans)


Measured memory_bytes: 2940
#include <stdio.h>

int judgeOf(int,int);

int main(){
int i,a,b,temp,result;

scanf("%d%d",&a,&b);
if(a<b){
temp=a;
a=b;
b=temp;
}
result=judgeOf(a,b);
printf("%d\n",result);

}

int judgeOf(int a,int b){
    int r;
    r=a%b;
while(r!=0){
    a=b;
    b=r;
    r=a%b;
}
return b;
}



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

using namespace std;

typedef long long ll;
ll graph[55][55][55];

int main()
{
    ll N;
    cin>>N;
    ll a[N],b[N];
    vector<ll> c[N];
    for(ll i=0; i<N; i++){
        cin>>a[i];
        c[i].push_back(a[i]);
    }
    for(ll i=0; i<N; i++){
        cin>>b[i];
    }

    for(ll i=0; i<55; i++){
        for(ll j=0; j<55; j++){
            graph[i][i][j] = 1;
        }
    }


    for(ll k=1; k<55; k++){
        for(ll i=0; i<55; i++){
            for(ll j=0; j<55; j++){
                if(graph[i%k][j][k-1]==1 || graph[i][j][k-1]==1)
                    graph[i][j][k] = 1;
            }
        }
    }


    for(ll i=0; i<N; i++){
        if(graph[a[i]][b[i]][50]==0){
            cout<<-1<<endl;
            return 0;
        }
    }

    ll ans = 0;
    for(ll k=50; k>0; k--){
        bool check = true;
        for(ll i=0; i<N; i++){
            bool test = false;
            for(ll j=0; j<c[i].size(); j++){
                if(graph[c[i][j]][b[i]][k-1]==1){
                    test = true;
                }
            }
            if(!test)
                check = false;

        }
        if(!check){
            ans+= (1ll<<k);
            for(ll i=0; i<N; i++){
                vector<ll> carry;
                ll poss[55];
                for(ll j=0; j<55; j++)
                    poss[j] = 0;
                for(ll j=0; j<c[i].size(); j++){
                    poss[c[i][j]] = 1;
                    poss[c[i][j]%k] = 1;
                }
                for(ll j=0; j<55; j++){
                    if(poss[j]==1)
                        carry.push_back(j);
                }
                c[i] = carry;
            }

        }

    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1024