akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <iostream>
#include <iomanip> 
#include <algorithm>
#include <queue>
#include <list>
#include <numeric>
#include <stack>
#include <unordered_map>
#include <map>
#include <set>
 
using namespace std;
 
#define sz(a) int((a).size())
#define all(x) x.begin(), x.end()
#define pb push_back
#define endl '\n'
#define watch(x) cout << #x << " : " << x << endl;
 
#define FastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
typedef long long ll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef vector<ii> vii;
 
const int N = int(2e5)+10;
const int K = 10005;
// const int MOD = int(1e9)+7;
const int INF = int(1e9)+5;
const ll INF64 = 1e18;

const ll MOD = 1e9+7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

vi path;
vvi cycles;
int a[N],visited[N];
bool visited2[N];
int st,c = 0;

void dfs (int s) {
    path.pb(s);
    // Gray Colour.
    visited[s] = 1;
    int to = a[s];
    if (visited[to] != 2) {
        // Enter a gray vertex, cycle found.
        if (visited[to] == 1) {
            cycles.emplace_back();
            int id = sz(path) - 1;
            while (path[id] != to) {
                cycles.back().pb(path[id]);
                id--;
            }
            cycles.back().pb(to);
        } else {
            dfs(to);
        }
    }
    path.pop_back();
    // Black vertex, done and dusted.
    visited[s] = 2;
}

void dfs2 (int s) {
    if (visited2[s]) return;
    visited2[s] = true;
    c++;
    int to = a[s];
    if (to == st) return;
    dfs2(to);
}

int dfs3 (int s,int k) {
    if (k == 0) return s;
    int to = a[s];
    return dfs3(to,k-1);
}

void solve () {
    int n;cin>>n;
    ll K;cin>>K;
    for (int i=1;i<=n;i++) cin>>a[i];
    dfs(1);
    reverse(all(cycles[0]));
    st = cycles[0][0];
    int sze = sz(cycles[0]);
    // Cycle Starts At 1 Itself.
    if (st == 1) {
        K %= sze;
        int ans;
        for (int i=0;i<=K;i++) ans = cycles[0][i];
        cout<<ans<<endl;
    } else {
        dfs2(1);
        if (K >= c) {
            K -= c;
            K %= sze;
            int ans;
            for (int i=0;i<=K;i++) ans = cycles[0][i];
            cout<<ans<<endl;
        } else {
            cout<<dfs3(1,K)<<endl;
        }
    }
}

int main () {
    FastIO
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    int t;
    // cin>>t;
    t = 1;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 18488
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long K;
  long long ans=0;
  cin >> K;
  for(int a=1;a<=K;a++){
    for(int b=1;b<=K;b++){
      for(int c=1;c<=K;c++){
        	ans+=gcd(gcd(a,b),c);
  	  }
 	}
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::f64::consts::PI;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}

#[allow(unused_macros)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn a() {
    unimplemented!();
}

fn b() {
    let n = read!(usize);
    for i in 1..10 {
        for j in 1..10 {
            if i * j == n {
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}

fn c() {
    let n = read!(usize);
    if n == 2 {
        println!("1");
        return;
    }
    if n == 3 || n == 4 {
        println!("2");
        return;
    }
    let mut max_div = 1;
    for i in 1..((n as f64).sqrt() as usize + 1) {
        //        println!("{}", i);
        if n % i == 0 {
            max_div = i;
        }
    }
    let t = n / max_div;

    //    debugln!("{} {}", max_div, t);

    println!("{}", max_div + t - 2);
}

fn d() {
    let (a, b, x) = read!(usize, usize, usize);
    let a = a as f64;
    let b = b as f64;
    let x = x as f64;
    let theta = ((b * b * a) / (2.0 * x)).atan();

    if b * ((PI / 2.0) - theta).tan() <= a {
        println!("{}", theta * 180.0 / PI);
        return;
    }

    let theta = ((2.0 * a * a * b - 2.0 * x) / a.powi(3)).atan();
    println!("{}", theta * 180.0 / PI);
}

fn e() {
    unimplemented!();
}

fn f() {
    unimplemented!();
}

fn main() {
    b();
}


Measured memory_bytes: 4476
#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main() {

	bool k[8] = { 0 };
	int a, b,c,d;
	cin >> a >> b>>c>>d;
	k[a]=true; k[b]=true; k[c]=true; k[d]=true;
	if (k[1] && k[4] && k[9] && k[7]) {
		YES;
	} else{
		NO;
	}
	


	return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define debug(args...){string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
#define endl "\n"

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> ii;
typedef pair <ii, int> iii;

void err(istream_iterator<string> it){}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args){
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max({a*c, a*d, b*c, b*d}) << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define int             long long int
#define pb              push_back
#define se              second
#define mp              make_pair
#define fi              first
#define del(a,vec)      vec.erase(std::remove(vec.begin(), vec.end(), a), vec.end());
#define search(f,l,v)   binary_search(f,l,v)
#define iter(a,b)       vector<int>::iterator a,b
#define lower(v,num)    lower_bound (v.begin(), v.end(), num);
#define upper(v,num)    upper_bound (v.begin(), v.end(), num); 
#define removecopy(a)   unique(a.begin(), a.end()); 
#define vi              vector<int> 
#define pi              pair<int,int>    
#define vpi             vector<pi>      
#define mlbb            ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)    
int mod =1000000007;
namespace Rahul{
    bool isPrime(int n) 
    {if (n <= 1)  return false; if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
    return true; }
    int pow (int x, int n,int mod) {//calculate x^n
    if (n == 0) return 1;

    int res = pow (x, n / 2,mod);

    res = (res * res) % mod;
    if (n % 2) res = (res * x ) % mod;

    return res;
    }
    int _gcd(int a,int b)
    {
        if(a==0)
            return b;
        else    
            return _gcd(b%a,a);
    }
    //s.erase(s.find(2)) where s={1,2,3,3,2}; 
};
using namespace Rahul;
int32_t main()
{
        
     mlbb;   
     int n;
     cin>>n;
     int a[n+1];
     for(int i=0;i<n;i++)   cin>>a[i];
     
     int count=0;
     int ind=1;
     for(int i=0;i<n;i++)   
     {
         if(a[i]==ind)
            ind++;
        else    count++;    
            
            
     }
     if(count==n)
        cout<<-1<<endl;
    else
        cout<<count<<endl;
     
}


Measured memory_bytes: 1920
N, Y = map(int, input().split())
result = 0
flag = False
for i_1man in range(0, N+1):
    for i_5sen in range(0, N+1-i_1man):
        now = 10000 * i_1man + 5000 * i_5sen + 1000 * (N - i_1man - i_5sen)
        if now == Y:
            result = 1
            flag = True
        if flag:
            break
    if flag:
        break
if result == 0:
    print('-1 -1 -1')
else:
    print('{} {} {}'.format(i_1man, i_5sen, (N - i_1man - i_5sen)))

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

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

    ll ans = 0;

    rep(i, 1000)
    {
        string t;
        if(i < 10) t += "00";
        else if(i < 100) t += '0';
        t += to_string(i);
        int p = 0;

        rep(j, s.size())
        {
            if(t.at(p) == s.at(j)){
                if(p == 2)
                {
                    ans++;
                    break;
                }
                p++;
            }
        }
    }

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

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn f(s: &[char]) -> bool {
    let m = s.len();
    for i in 0..m {
        if s[i] != s[m - 1 - i] {
            return false;
        }
    }
    true
}

use std::iter::Iterator;
use std::cmp;

fn main() {
    input! {
        k : i32,
        x : i32,
    }

    let mut min = x - k + 1;
    if min < -1000000 { min = -1000000}

    let mut max = k + x - 1;
    if max > 1000000 { max = 1000000}

    let ans = (min..max + 1).map(|x| x.to_string()).collect::<Vec<_>>().join(" ");

    println!("{}", ans);

}


Measured memory_bytes: 4352
#include<stdio.h>

int main()
{
	int fib1{ 1 }, fib2{ 1 }, n;

	scanf("%d", &n);
	for (int i = 1; i < n; ++i)
	{
		int tmp = fib2;
		fib2 += fib1;
		fib1 = tmp;
	}
	printf("%d\n", fib2);
	return 0;
}


Measured memory_bytes: 2728
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
  double a,b,c,d,e,f;
  while(cin >> a >> b >> c >> d >> e >>f){
    double delta = a*e - d*b;
    double x = (1/delta)*(e*c+(-b)*f)+0;
    double y = (1/delta)*((-d)*c+a*f)+0;
    //cout << x << " " <<y << endl;
    printf("%4.3f %4.3f\n",x,y);
  }
}

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

using namespace std ;

const int MAXN = 19 , MAX = (1 << 19) ;

int arr[MAX] ;
pair<int , int> ans[MAX] ;
int n ;

void Merge(pair<int , int>&p , pair<int , int>p2)
{
	if(p2.first > p.first)
	{
		p.second = p.first , p.first = p2.first ;
		if(p2.second > p.second)
			p.second = p2.second ;
	}
	else if(p2.first > p.second)
		p.second = p2.first ;
	return ;
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	for(int i = 0 ; i < (1 << n) ; ++i)
	{
		cin>>arr[i] ;
		ans[i].first = arr[i] ;
		ans[i].second = 0 ;
	}
	for(int i = 0 ; i < n ; ++i)
	{
		for(int mask = 0 ; mask < (1 << n) ; ++mask)
		{
			if((mask & (1 << i)))
				Merge(ans[mask] , ans[mask ^ (1 << i)]) ;
		}
	}
	for(int i = 1 ; i < (1 << n) ; ++i)
	{
		if(ans[i-1].first + ans[i-1].second > ans[i].first + ans[i].second)
			ans[i] = ans[i-1] ;
		cout<<ans[i].first + ans[i].second<<"\n" ;
	}
	return 0 ;
}		

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

signed main(void)
{
	int n, m, x;
	cin >> n >> m >> x;
	int c[n], a[n][m];
	int ans;
	bool flag;
	rep(i, n)
	{
		cin >> c[i];
		rep(j, m)
		{
			cin >> a[i][j];
		}
	}
	ans = 1e9;
	flag = false;
	for(int bit = 1; bit < (1 << n); bit++)
	{
		vector<int> v;
		rep(i, n)
		{
			if (bit >> i & 1)
			{
				v.push_back(i);
			}
		}
		int sum_c, sum_a[m];
		sum_c = 0;
		rep(i, m) sum_a[i] = 0;
		rep(i, v.size())
		{
			sum_c += c[v[i]];
			rep(j, m)
			{
				sum_a[j] += a[v[i]][j];
			}
		}
		bool ok;
		ok = true;
		rep(i, m)
		{
			if (sum_a[i] < x)
			{
				ok = false;
				break;
			}
		}
		if (ok)
		{
			flag = true;
			ans = min(sum_c, ans);
		}
	}
	if (!flag) ans = -1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <string.h>

#define DEF_ELEM_MAX 100000

typedef long long llong;

int W[DEF_ELEM_MAX];
	int N;
	int K;
/////////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////////
// ?????§????????? P ??? k ??°?????????????????§?????????????????????????????????
int check(int P)
{
	int i = 0;
	int j;
	llong s;

	for ( j = 0; j < K; j++ ) {
		s = 0;
		while( s + W[i] <= P ) {
			s += W[i];
			i++;
			if ( i == N ) return N;
		}
	}
	return i;
}

/////////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////////
int solve()
{
	llong v;
	llong left = 0;
	llong right = 100000 * 10000; // ??????????????° ?? 1????????????????????§??????
	llong mid;

	while ( right - left > 1 ) {
		mid = (left + right) / 2;
		v = check((int)mid); // mid == P ????±??????????????????????????????§??????
		if ( v >= N ) {
			right = mid;
		} else {
			left = mid;
		}
	}

	return (int)right;
}

/////////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////////
int main(void)
{
	int i;
//
	scanf("%d %d", &N, &K);
	for ( i = 0 ; i < N ; i++ ) {
		scanf("%d", &W[i] );
	}

	printf("%d\n", solve());

	return 0;
}

Measured memory_bytes: 984
#include<bits/stdc++.h> 
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
using namespace std;
const int N=2e5+5,inf=1e9;
int n,p[N],q[N],b[N],b2[N],bs1,bs,ans;
int la[N],ne[N*2],to[N*2],l[N*2],h[N],st[N],d[N],js;
bool bz[N];
void link(int x,int y,int z){
//	printf("%d %d\n",x,y);
	ne[++js]=la[x];la[x]=js;to[js]=y;l[js]=z;
	ne[++js]=la[y];la[y]=js;to[js]=x;
}
bool is(){
	fo(i,0,bs+1)st[i]=la[i],h[i]=-1;
	d[1]=0;h[0]=0;
	for(int s=0,t=1,x;x=d[++s],s<=t;)
		for(int i=la[x];i;i=ne[i])if(l[i]&&h[to[i]]==-1)
			h[to[i]]=h[x]+1,d[++t]=to[i];
	return h[bs+1]>-1;
}
int dinic(int x,int su){
	if(x==bs+1)return su;int us=0;
	for(int i=st[x];i;i=ne[i])if(l[i]&&h[to[i]]==h[x]+1){
		st[x]=i;int tt=dinic(to[i],min(su-us,l[i]));
		if(tt){
			l[i]-=tt;l[i^1]+=tt;us+=tt;
			if(us==su)return us;
		}
	}
	h[x]=-1;
	return us;
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	fo(i,1,n)cin>>p[i],++p[i];
	fo(i,1,n)cin>>q[i],++q[i];
	fo(i,1,n)if(!bz[i]){
		int j=i;++bs;
		for(;!bz[j];j=p[j])b[j]=bs,bz[j]=1;
	}
	memset(bz,0,sizeof bz);
	fo(i,1,n)if(!bz[i]){
		int j=i;++bs;
		for(;!bz[j];j=q[j])b2[j]=bs,bz[j]=1;
	}
	js=1;ans=n;
	fo(i,1,n)
		if(p[i]==i){
			if(q[i]==i)--ans;else link(0,b2[i],1);
		}else{
			if(q[i]==i)link(b[i],bs+1,1);
			else{
				link(b[i],b2[i],1);
				if(p[i]==q[i])link(b2[i],b[i],1);
			}
		}
	for(;is();)ans-=dinic(0,inf);
	cout<<ans;
}

Measured memory_bytes: 12928
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v);
#ifndef ONLINE_JUDGE
#define debug(a) cout<<#a<<" --> "<<(a)<<"\n";
#define debug2(a) cout<<#a<<" --> "<<(a)<<" ";
#define HERE cout<<"here - "<<__LINE__<<"\n";
#else
#define debug(a)
#define debug2(a)
#define HERE
#endif
const ll mod = 1e9+7;
const int N = 1e5+5;
typedef pair<int,int> pii;
int h,w,k;
vector<string>v;


bool check(int mask1 , int mask2)
{
    vector<int>r,c;
    for(int i=0;i<h;i++)
    {
        if(mask1&(1<<i))
        {
            r.push_back(i);
        }
    }
    for(int i=0;i<w;i++)
    {
        if(mask2&(1<<i))
        {
            c.push_back(i);
        }
    }
    int cnt= 0;
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            if(binary_search(r.begin(),r.end(),i) || binary_search(c.begin(),c.end(),j))
                continue;
            if(v[i][j]=='#')
            {
                cnt++;
            }
        }
    }
    //debug(cnt);
    return cnt==k;
}

int solve()
{
    int ans =0;
    for(int i=0;i<(1<<h);i++)
    {
        for(int j=0;j<(1<<w);j++)
        {
            ans+= check(i,j);
        }
    }
    return ans;

}

void TEST_CASES(int cas)
{
    cin>>h>>w>>k;
    v.resize(h);
    for(int i=0;i<h;i++)
    {
        cin>>v[i];
    }
    cout<<solve()<<endl;

}


/*

*/

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        TEST_CASES(++cas);
    }
    return 0;
}



//os.order_of_key(v): returns how many elements strictly less than v
//os.find_by_order()

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v)
{
    for(auto i:v)
    {
        os<<"Key : "<<i.first<<" , Value : "<<i.second<<endl;
    }
    return os;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
  ll n, a[1005000], ans;

int main(){
  
  cin >> n;
  for(int i=1;i<=n;i++){
    cin >> a[i];
  }ll cnt = 0;
  for(int i=1;i<=n;i++){
    if(a[i] == 0){
      ans += cnt / 2;
      cnt = 0;
      continue;
    }
    cnt += a[i];
  }
  if(cnt > 0)ans += cnt / 2;
  cout << ans;
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a));reverse(all(a))
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (ll)(a.size())
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl;
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) rep(ghf,SZ(a)){rep(kjh,SZ(a[ghf])){cout<<(a[ghf][kjh]<10?" ":"")<<a[ghf][kjh]<<" ";}ENDL;}
#define out(a) cout<<(a)<<endl
#define fi first
#define se second
#define Vec vector
#define P pair
typedef long long ll;
typedef string str;
typedef vector<ll> V;
typedef pair<ll,ll> Pi;
typedef vector<Pi> VP;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int max(int a,int b){if(a>b)return a; return b;}
int min(int a,int b){if(a>b)return b; return a;}
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

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

  int d=m/n;
  for(int x=d;1;x--){
    if(m%x==0){
      cout<<x<<endl;
      return 0;
    }
  }
  
  return 0;
}



Measured memory_bytes: 256
while 1:
    q=int(input())
    if q==-1:break
    xn=lambda x,q:x-(x**3-q)/3/(x**2)
    x=xn(q/2,q)
    while 1:
        x=xn(x,q)
        if abs(x**3-q)<0.00001*q:break
    print(x)



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

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

int MOD = 1e9 + 7;
ll INF = 1e18;

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int main(){
    int p; cin>>p;
    int ans=0;
    while(ans <= p-10000) ans += 10000;
    while(ans <= p-5000) ans += 5000;
    while(ans <= p-1000) ans += 1000;
    while(ans <= p-500) ans += 500;
    cout << ans << endl;
}


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

int main() {
	int a,b,c; cin >> a >> b >> c;
	if(a>b*c) cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 3592
n=int(input())
ans=float("INF")
for i in range(n+1):
  d=0
  temp=i
  while (temp>0):
    d+=temp%6
    temp//=6
  temp=n-i
  while(temp>0):
    d+=temp%9
    temp//=9
  ans=min(d,ans)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=100005;
vector<int>g[N];

void dfs(int u,vector<bool>&vis,vector<int>&dp){
	vis[u]=true;
	for(auto v:g[u]){
		if(!vis[v]){
			dfs(v,vis,dp);
		}
		dp[u]=max(dp[u],1+dp[v]);
	}
}

int main(){
	ll n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		g[x].push_back(y);
	}
	vector<bool>vis(n+1,false);
	vector<int>dp(n+1,false);
	for(int i=1;i<=n;i++){
		if(!vis[i])
		dfs(i,vis,dp);
	}
  	int mx=0;
	for(int i=1;i<=n;i++)
      mx=max(mx,dp[i]);
  	cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 9600
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
	
	int a[100];
	
	int n;
	cin>>n;
	for(int i=0 ; i<n ; i++){
		cin>>a[i];
	}
	for(int i=0 ; i<n ; i++){
		cout<<a[i];
		if(i < n-1) cout<<" ";
	}
	cout<<endl;
	
	for(int i=1 ; i<n ; i++){
		int v = a[i];
		int j = i-1;
		while(j>=0 && a[j]>v){
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = v;
		for(int i=0 ; i<n ; i++){
			cout<<a[i];
			if(i < n-1) cout<<" ";
		}
		cout<<endl;
	}
	


	return 0;
}

Measured memory_bytes: 1164
import sys

input = sys.stdin.readline


def main():
    S = input().rstrip()

    # AKIHABARA
    correct_list = [
        "AKIHABARA",
        "KIHABARA",
        "AKIHBARA",
        "AKIHABRA",
        "AKIHABAR",
        "KIHBARA",
        "KIHABRA",
        "KIHABAR",
        "AKIHBRA",
        "AKIHBAR",
        "AKIHABR",
        "KIHBRA",
        "KIHBAR",
        "KIHABR",
        "AKIHBR",
        "KIHBR",
    ]

    is_correct = False
    for correct in correct_list:
        if S == correct:
            is_correct = True
            break

    if is_correct:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
int main(){
    int n;
    cin>>n;
    map<string,int> li;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        li[s]++;
    }
    cout<<li.size()<<endl;
}

Measured memory_bytes: 19224
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    cin>>k;
    string s;
    cin>>s;
    int len=s.size();
    if(len<=k)
        cout<<s<<endl;
    else
    {
        string s1=s.substr(0,k);
        s1+="...";
        cout<<s1<<endl;
    }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 1001001001001001;
const double EPS = 1e-10;

struct edge{ll to,cost;};

int n;
ll a[333][333],d[333][333],na[333][333];
vector<edge> g[333];

bool check(){
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(a[i][j]!=na[i][j])return false;
        }
    }
    return true;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=0;i<n;i++)for(int j=0;j<n;j++){
        cin>>a[i][j];
        if(i==j)d[i][j]=0;
        else d[i][j]=1;
        if(i==j)na[i][j]=0;
        else na[i][j]=INF;
    }
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(a[i][j]==a[i][k]+a[k][j]){
                    d[i][j]=max(d[i][j],d[i][k]+d[k][j]);
                }
            }
        }
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(d[i][j]==1){
                g[i].push_back((edge){j,a[i][j]});
                g[j].push_back((edge){i,a[j][i]});
                ans+=a[i][j];
                na[i][j]=na[j][i]=a[i][j];
            }
        }
    }
    ans/=2;
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                na[i][j]=min(na[i][j],na[i][k]+na[k][j]);
            }
        }
    }

    if(check())cout<<ans<<endl;
    else cout<<-1<<endl;
}

/*
d[i][j] = d[i][k] + d[k][j];
*/

Measured memory_bytes: 10116
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l; i<(int)(r); i++)
#define rep_eq(i,l,r) for(int i=l; i<=(int)(r); i++)
#define all(vec) vec.begin(),vec.end()
using namespace std;

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; }

using ll=long long;

using vb=vector<bool>;
using vs=vector<string>;
using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;

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

  int N; ll K; cin >>N >>K;
  vi A(N+1);
  rep(i,1,N+1) {cin >>A[i];}

  vll l(N+1,-1);
  vll tmp;
  ll pos=1;
  ll cnt=0;

  while (true) {
    if (l[pos]!=-1) {
      ll t=cnt-l[pos];
      if (K<cnt) {
        cout <<tmp[K] <<'\n';
      } else {
        cout <<tmp[l[pos]+(K-cnt)%t] <<'\n';
      }
      break;
    }
    l[pos]=cnt++;
    tmp.push_back(pos);
    pos=A[pos];
  }

  return 0;
}


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

int main(){

 int i, x, n;

 cin >> n;

 for (i = 1; i <= n; i++) {
  x = i;
  if (x % 3 == 0) cout << " " << i;
  else {
   while(x) {
    if (x % 10 == 3) {
     cout << " " << i;
     break;
    }
    x /= 10;
   }
  }
 }
 cout << endl;

 return 0;
}

Measured memory_bytes: 1164
def main():
    K = int(input())
    # ルンルン数
    # 1,2,3,4,5,6,7,8,9,(9通り)
    # => 1ケタ:9通り
    # 10,11,12,(3)
    # 21,22,23,(3)
    # ...
    # 87,88,89,(3)
    # 98,99,(2)
    # => 2ケタ:3*9-1=26通り

    lun = [1,2,3,4,5,6,7,8,9]
    tmp = lun
    count = 9
    while count<K:
        add = []
        for l in tmp:
            k = l%10
            a = l*10+k
            if k==0:
                add.extend([a,a+1])
            elif k==9:
                add.extend([a-1,a])
            else:
                add.extend([a-1,a,a+1])
        count += len(add)
        tmp = add
        lun.extend(add)
    print(lun[K-1])

main()


Measured memory_bytes: 19116
import java.util.Scanner;

public class Main {

	private static Scanner sc=new Scanner(System.in);

	public static void main(String[] args) {
		char[] df = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
		
		
		
		
		
		while (sc.hasNextInt()) {
			int n =sc.nextInt();
			if(n==0)break;
			int[] key = new int[n];
			for (int i = 0; i < n; i++) {
				key[i] = sc.nextInt();
			}
			char[] a = sc.next().toCharArray();





			for (int i = 0; i < a.length; i++) {
				int temp;
				if ('a' <= a[i] && a[i] <= 'z') {
					temp = a[i] - 'a' + 52;
				} else {
					temp = a[i] - 'A' + 78;
				}
				temp -= (key[i % n]);
				a[i] = df[temp % 52];
			}
			
			
			
			
			
			
			String ans=new String(a);
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 25496
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * Christmas Party
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		int N = parseInt(br.readLine());
		int[] points = new int[N + 1];

		int M = parseInt(br.readLine());
		int[] targets = new int[M];

		StringTokenizer st = new StringTokenizer(br.readLine());
		for (int i = 0; i < M; i++) {
			targets[i] = parseInt(st.nextToken());
		}

		for (int i = 0; i < M; i++) {
			st = new StringTokenizer(br.readLine());
			for (int j = 0; j < N; j++) {
				int a = parseInt(st.nextToken());
				if (a == targets[i]) {
					points[j + 1]++;
				} else {
					points[targets[i]]++;
				}
			}
		}

		StringBuilder sb = new StringBuilder();
		for (int i = 1; i < N + 1; i++) {
			sb.append(points[i]).append("\n");
		}
		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 26524
open Printf
open Scanf

let n = sscanf (read_line ()) "%d" (fun n -> n);;
let array = Array.make n 0;;
Array.iteri (fun x _ -> array.(x) <- read_int()) array;;

let ans_tuple = (0,Array.make 200000 (-1));;

let isOK index key array_tuple =
    let (size, array) = array_tuple in
    if (array.(index) > key) then true
    else false;;

let binary_search key array_tuple =
    let (size, array) = array_tuple in
    let left = ref (-1) in
    let right = ref (size) in
    while (!right - !left > 1) do
        let mid = !left + (!right - !left) / 2 in
        if isOK mid key array_tuple then
        right := mid
        else
        left := mid
    done;
    !right;;

let array_update key array_tuple =
let (size, target) = array_tuple in
let index = binary_search key array_tuple in
if size = 0 then
    (*let _ = printf("size:0 key = %d, index = %d\n") key index in*)
    let _ = target.(0) <- key in
    (size + 1, target)
else if index = size then
   (*let _ = printf("index=size key = %d, index = %d\n") key index in*)
    if key < target.(index-1) then
        let _ = target.(index-1) <- key in
        (size, target)
    else
        let _ = target.(index) <- key in
        (size + 1, target)
else
(*let _ = printf("replace key = %d, index = %d\n") key index in *)
    let _ = target.(index) <- key in
    (size, target);;

let rec solve n array_tuple =
    let (size, target) = array_tuple in
    if n < 0 then size
    else
        let l = array_update array.(n) array_tuple in
        solve (n-1) l;;

printf ("%d\n") (solve (n-1) ans_tuple);;

Measured memory_bytes: 6400
N, L = map(int, input().split())

total = 0
for i in range(N):
    apple = L + i
    total += apple

min_diff = 1000
min_taste = 0
for i in range(N):
    apple = L + i
    diff = abs(apple)
    if min_diff > diff:
        min_diff = diff
        min_taste = total - apple

print(min_taste)


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

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

   cout << n * n - a << endl; 
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
using namespace std;
const int maxd = (1<<19)+10;
int arr[maxd],n,m,que[maxd],p;
multiset<int> s;
bool cmp(int x,int y)
{
    return x > y;
}
int main()
{
    // freopen("a.in","r",stdin);
    // freopen("k.out","w",stdout);
    scanf("%d",&n);m = 1 << n;
    for(int i=1;i<=m;i++) scanf("%d",&arr[i]);
    sort(arr+1,arr+1+m,cmp);
    for(int i=2;i<=m;i++) s.insert(-arr[i]);
    s.insert(1); que[++p] = -arr[1];
    int now = 1;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=now;j++)
        {
            set<int>::iterator it;
            it = s.upper_bound(que[j]);
            //printf("%d %d\n",que[j],*it);
            if(*it==1)
            {
                printf("No\n");
                return 0;
            }
            que[++p] = *it;
            s.erase(it);
        }
        now*=2;
    }
    printf("Yes\n");
    return 0;
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};

Vi d(5);

int main(){
   REP(i, 5) cin >> d[i];
   SORT(d);

   ll ans = INF;
   do{
      ll temp = 0;
      REP(j, 4){
         temp += (d[j] + 9) / 10 * 10;
      }
      temp += d[4];
      chmin(ans, temp);
   } while (next_permutation(d.begin(), d.end()));
   cout << ans << endl;

   
}


Measured memory_bytes: 256
from collections import Counter

N, T = map(int, input().split())
A = list(map(int, input().split()))

maxA = [0 for _ in range(N + 1)]
minA = [float('inf') for _ in range(N + 1)]

for i, a in enumerate(A):
    minA[i + 1] = min(minA[i], a)
for i, a in enumerate(reversed(A)):
    maxA[-1 - i] = max(maxA[-1 - (i - 1)], a)

maxProfit = 0
for i in range(1, N):
    if maxProfit < maxA[i + 1] - minA[i]:
        maxProfit = maxA[i + 1] - minA[i]

pairs = set([])
for i in range(1, N):
    if maxProfit == maxA[i + 1] - minA[i]:
        pairs.add((minA[i], maxA[i + 1]))

ans = len(pairs)
print(ans)

Measured memory_bytes: 14736
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main()
{
  ll H ,N;
  cin >> H >> N;
  vector <int> A(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
    H-=A.at(i);
  }
  if(H <= 0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 640
N, K = map(int,input().split())
A= list((map(int, input().split())))
an = (K*(K+1))//2
a = ((K-1)*K)//2
au =0
al = 0
for i in range(N):
  for j in range(N):
    au += 1 if A[i]<A[j] and i>j else 0
    al += 1 if A[i]<A[j] and i<j else 0
print((au*an+al*a)%(10**9+7))

Measured memory_bytes: 41836
#include <iostream>
#include <sstream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

struct rule {
  bool k;
  string s,d;
};
struct packet {
  string s,d,m;
};

bool eq(const string &a, const string &b) {
  REP(i, 8) {
    if (b[i] != '?' && a[i] != b[i]) return 0;
  }
  return 1;
}

int main() {
  int n,m;
  while(cin >> n >> m, n || m) {
    rule r[n];
    packet p[m];
    REP(i, n) {
      string a,b,c;
      cin >> a >> b >> c;
      r[i] = (rule){a=="permit",b,c};
    }
    REP(i,m) {
      string a,b,c;
      cin >> a >> b >> c;
      p[i] = (packet){a,b,c};
    }
    reverse(r, r+n);
    vector<packet> v;
    
    REP(i,m) {
      int ok = 0;
      REP(j,n) {
        if (eq(p[i].s, r[j].s) && eq(p[i].d, r[j].d)) {
          if (r[j].k) {
            ok = 1;
            break;
          } else break;
        }
      }
      if (ok) {
        v.push_back(p[i]);
      }
    }
    cout << v.size() << endl;
    FOR(it, v)
      cout << it->s << " " << it->d << " " << it->m << endl;
  }
}

Measured memory_bytes: 1092
#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(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  string s;
  ll k;

  cin >> s;
  cin >> k;

  for(ll i=0; i < min(k, (ll)s.size()); i++){
    if(s[i]!='1'){
      cout << s[i] << endl;
      exit(0);
    }
  }
  cout << 1 << endl;
}



Measured memory_bytes: 256
/*

                              Jai Shree Krishna !!
                                 Radhe Radhe !!
                                 
             उद्यमेन हि सिद्ध्यन्ति कार्याणि न मनोरथैः। नहि सुप्तस्य सिंहस्य मुखे प्रविशन्ति मृगाः।।
             
*/
   
   
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
typedef long long ll;
#define loop(i,n)  for(int i=0;i<n;i++)
#define read(a) int a; cin >>a;
#define readarr(a,n) int a[n] ; for(int i=0;i<n;i++) cin >> a[i];
#define readmat(a,n,m) int a[n][m]; for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin >> a[i][j];
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define pi pair<int,int>
#define vvi vector<vector<int>>
#define sti set<int>
#define vpi vector<pair<int,int>>
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define printmat(a,n,m) for(int i=0;i<n;i++) {for(int j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define endl "\n"
#define mp make_pair
#define ins insert
#define rep(i,s,e)  for(int i=s;i<=e;i++)
#define repd(i,s,e)  for(int i=e;i>=s;i--)
#define vb vector<bool>
#define read2(n,m) int n,m; cin >> n >> m;
#define range(v) v.begin(),v.end()
#define sortd(v) sort(v.begin(),v.end(),greater<int>())
#define sorti(v) sort(v.begin(),v.end())

const ll inf = 1e18;
const ll mod = 1e9 + 7;
 
signed main()
{
 
    fast;
    int n ; cin >> n;
    string s ; 
    cin >> s;
    int c=0;
    rep(i,0,n-3){
    	string k=s.substr(i,3);
    	if(k=="ABC") c++;
    }
    cout<<c<<endl;
    return 0;
}

/* Pooja Yadav */

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s1,s2,s3,ss;
	cin>>s1;
	cin>>s2;
	cin>>s3;
	ss+=s1[0];
	ss+=s2[1];
	ss+=s3[2];
	cout<<ss;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int gcd(int a, int b);
int lcm(int a, int b);

int main(void)
{
  int a, b;
  while (scanf("%d %d", &a, &b) == 2) {
    printf("%d %d\n", gcd(a, b), lcm(a, b));
  }
  return (0);
}

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

int lcm(int a, int b)
{
  return (a / gcd(a, b) * b);
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
typedef long long ll;
using namespace std;
#define nummax 220000

int drop(int n, int N, int Q, string s, char t[], char d[])
{
	int i, posi = n;
	
	for (i = 1; i <= Q; i++)
	{
		if (s[posi - 1] == t[i])
		{
			if (d[i] == 'R')
			{
				posi++;
				if (posi > N)
					return 1;
			}
			else
			{
				posi--;
				if (posi < 1)
					return -1;
			}
		}
	}
	return 0;
}

int main() 
{
	int i, N, Q, LL, LR, RL, RR, LM, RM, ans;
	char t[nummax], d[nummax];
	string s;
	cin >> N >> Q;
	cin >> s;
	for (i = 1; i <= Q; i++)
	{
		cin >> t[i] >> d[i];
	}
	LL = 0;
	RL = 0;
	LR = N + 1;
	RR = N + 1;
	while (1)
	{
		LM = (LL + LR) / 2;
		if (drop(LM, N, Q, s, t, d) == -1)
			LL = LM;
		else LR = LM;
		if (LR - LL == 1)
			break;
	}
	while (1)
	{
		RM = (RL + RR) / 2;
		if (drop(RM, N, Q, s, t, d) == 1)
			RR = RM;
		else RL = RM;
		if (RR - RL == 1)
			break;
	}
	ans = RR - LR;
	cout << ans << endl;
}

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

int main() {
  int a, c, e, ans = 0;
  int b[100005] = {0};
  int d[5];
  cin >> a;
  for(int i = 0; i < a; i++) {
    cin >> c;
    b[c]++;
  }

  for(int i = 1; i < 100001; i++) {
    while(b[i] >= 3) {
      b[i] -= 2;
    }
  }

  for(int i = 1; i < 100001; i++) {
    if(b[i] == 2) {
      b[i] = 1;
      d[e] = i;
      e++;
      if(e >= 3) {
        e = 1;
        b[d[0]] = 1;
        b[d[1]] = 1;
        d[0] = i;
        d[1] = 0;
      }
    }
  }

  if(e == 1) ans--;

  for(int i = 0; i < 100001; i++) {
    if(b[i] == 1) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<set>

using namespace std;

typedef long long ll;
typedef double db;

const int maxn=(int)2e5+9;
const db eps=1e-6;
const int mp=72;

int a[maxn];
int n;
int k;

void init(){
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
}

int rs[maxn];
set<int> s;

int main(){
	init();
	rs[0]=1;
	int ans=0;
	int mx=0;
	for(int i=1;i<n;i++){
		if(a[i]>a[i-1]){
			rs[i]=rs[i-1]+1;
		}
		else{
			rs[i]=1;
		}
		mx=max(rs[i],mx);
	}
	if(mx>=k){
		ans++;
	}
	int fl=0;
	s.clear();
	for(int i=0;i<k;i++){
		s.insert(a[i]);
		if(*s.rbegin()!=a[i]){
			fl=1;
		}
	}
	if(fl)ans++;
	for(int i=k;i<n;i++){
		int fl=0;
		if(*s.begin()!=a[i-k]){
			fl=1;
		}
		s.erase(a[i-k]);
		s.insert(a[i]);
		if(*s.rbegin()!=a[i]){
			fl=1;
		}
		if(fl&&rs[i]<k)ans++;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 11136
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll K, N;
ll A[201010];
ll diff[201010];

int main()
{
    cin >> K >> N;
    rep(i, 0, N)
    {
        cin >> A[i];
    }
    diff[0] = (K - A[N - 1]) + A[0];
    rep(i, 1, N)
    {
        diff[i] = A[i] - A[i - 1];
    }
    sort(diff, diff + N);
    cout << K - diff[N - 1] << endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <unordered_set>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1LL << 50;
static const int NIL = -1;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
 
struct edge{
    int from, to; ll cost;
};

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

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,even=0,count=0;
  cin>>n;
  int a[n];
 
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]%2==0){
      even++;
      if(a[i]%3==0||a[i]%5==0){
      count++;
    }
    }
    
  }
  
  if(even != count)
     cout<<"DENIED"<<endl;
  else
     cout<<"APPROVED"<<endl;
}

Measured memory_bytes: 3584