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

using ll = long long;
#define repi(n) for (int i = 0; i < n; i++)
#define repj(n) for (int j = 0; j < n; j++)
#define repk(n) for (int k = 0; j < n; k++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (auto i = a; i < b; i++)
#define repv(itr) for (auto&& v : itr)
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}

bool comp(string a, string b) {
  return a.size() > b.size() || (a.size() == b.size() && a > b);
}
string dp[10010];
bool canuse[10];
const int usecount[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int main() {
  int n, m;
  cin >> n >> m;
  repi(m) {
    int x;
    cin >> x;
    canuse[x] = true;
  }
  dp[0] = "0";
  repi(n) {
    if (dp[i] == "") continue;
    string moto = dp[i] == "0" ? "" : dp[i];
    repr(j, 1, 10) {
      if (!canuse[j]) continue;
      string ns = (char)(j + '0') + moto;
      if (comp(ns, dp[i + usecount[j]])) dp[i + usecount[j]] = ns;
      ns = moto + (char)(j + '0');
      if (comp(ns, dp[i + usecount[j]])) dp[i + usecount[j]] = ns;
    }
  }
  // repi(n + 1) cout << "dp[" << i << "]:" << dp[i] << endl;
  cout << dp[n] << endl;
}


Measured memory_bytes: 33536
#include<iostream>
#include<algorithm>
#include<string.h>

using namespace std;

char S[2][2000];
int length[2];//length[a] == b ?????? S[a][b] == *""
int changed = 0;
int dp[1500][1500];

int main()
{
	cin >> S[0];
	cin >> S[1];

	for (int a = 0; a < 1000; a++)
	{
		if (S[0][a] == 0)
		{
			length[0] = a;
			break;
		}
	}

	length[0] = strlen(S[0]);
	length[1] = strlen(S[1]);

	for (int a = 0; a < 1000; a++)
	{
		if (S[1][a] == 0)
		{
			length[1] = a;
			break;
		}
	}

	for (int a = 0; a < length[0]+1; a++)
	{
		dp[0][a] = a;
	}
	for (int a = 0; a < length[1]+1; a++)
	{
		dp[a][0] = a;
	}

	for (int a = 1; a < length[0]+1; a++)
	{
		for (int b = 1; b < length[1]+1; b++)
		{
			if (S[0][a-1] == S[1][b-1])
			{
				dp[b][a] = min(dp[b - 1][a - 1], min(dp[b - 1][a] + 1, dp[b][a - 1] + 1));
			}
			else
			{
				dp[b][a] = min(dp[b - 1][a - 1], min(dp[b - 1][a], dp[b][a - 1])) + 1;
			}
		}
	}

	cout << dp[length[1]][length[0]] << endl;

	return 0;
}

Measured memory_bytes: 7288
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll=long long;
using P=pair<int,int>;
const int INF=1001001001;
int main(){
   int x; cin>>x;
   if(x==3||x==5||x==7) cout<<"YES"<<endl;
   else cout<<"NO"<<endl;
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
const int MINF=-2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/*---------------------template----------------------*/
/*----------------------end--------------------------*/
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
signed main(){
  string S;cin>>S;
  string K="keyence";
  int A=6;
  for(int i=S.size()-1;i>=0;i--){
    if(K[A]==S[i]){
      K.pop_back();
      A--;
    }
    else break;
  }
  if(S.substr(0,A+1)==K)puts("YES");
  else puts("NO");
}


Measured memory_bytes: 3604
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <time.h>
#define ll long long
#define mod 1000000007
int main(){
    int i,j,n,flag=0,d[112][2]={{}};
    scanf("%d",&n);
    for(i=0; i<n; i++){
        scanf("%d %d",&d[i][0],&d[i][1]);
        if(d[i][0]==d[i][1])flag++;
        else flag=0;
        if(flag==3){
            printf("Yes");
            return 0;
        }
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 1728
N = input()
n = len(N)
N = int(N)
s = ["1","7","5","3"]
ans = 0
for i in range(4**n):
    st = "0"
    while i != 0:
        st = st + s[i%4]
        i = i//4
    if "1" in st:
        b = False
    else:
        b = True
    for j in s[1:]:
        if not j in st:
            b = False
    if b and int(st) <= N:
        ans += 1
print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()
bool comparator(P a, P b) {
	return a.first / a.second < b.first / b.second;
}

int main() {
	double a, b;
	double k;
	cin >> k >> a >> b;
	if (((int)a) % ((int)k) == 0 || ((int)b) % ((int)k) == 0) {
		cout << "OK" << endl;
		return 0;
	}
	if ((int)(a / k) != (int)(b / k)) {
		cout << "OK" << endl;
		return 0;
	}
	cout << "NG" << endl;
}


Measured memory_bytes: 3196
#include <iostream>
#include <vector>

using namespace std;

typedef long long INT;

static INT MOD = 1000000007;

int main(void) {
    INT N, M;
    cin >> N >> M;

    vector<INT> S(N), T(M+1);

    for(INT i=0; i<N; ++i) {
	cin >> S[i];
    }
	
    for(INT i=0; i<M; ++i) {
	cin >> T[i];
    }

    vector<INT> X(N+1, 0);
    X[0] = 1;

    for(INT m=0; m<M; ++m) {
	INT t = T[m], x = 1;
	
	for(INT n=0; n<N; ++n) {
	    INT s = S[n], prevX = X[n+1];

	    if (t == s) {
		X[n+1] = (X[n+1] + x)%MOD;
	    }

	    x =  (x + prevX)%MOD;
	}
    }

    INT sum = 0;
    for(INT i=0; i<N+1; ++i) {
	sum = sum + X[i];
    }

    cout << sum%MOD << endl;
}



Measured memory_bytes: 384
def solve():
    H, W = map(int, input().split())
    row = [False for _ in range(H)]
    column = [False for _ in range(W)]
    a = [['' for _ in range(W)] for _ in range(H)]
    for i in range(H):
        a[i] = input()
        for j in range(W):
            if a[i][j] == '#':
                row[i] = True
                column[j] = True

    for i in range(H):
        if row[i]:
            for j in range(W):
                if column[j]:
                    print(a[i][j], end='')
            print()


if __name__ == "__main__":
    solve()


Measured memory_bytes: 9184
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 07/15/20 19:44:33
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

template <typename M>
class segment_tree {
 private:
  size_t size_;
  std::vector<M> tree_;

 public:
  explicit segment_tree(size_t size) : size_(size), tree_(size*2) {}

  template <typename Iter>
  explicit segment_tree(Iter begin, Iter end) : segment_tree(end-begin) {
    for (auto it = begin; it != end; ++it)
      tree_[size_ + it - begin] = *it;
    for (size_t i = size_-1; i > 0; i--)
      tree_[i] = tree_[i * 2] * tree_[i * 2 + 1];
  }

  M operator[](size_t index) const {
    return tree_[size_ + index];
  }

  void set(size_t index, M val) {
    auto i = size_ + index;
    tree_[i] = val;
    i >>= 1;
    while (i > 0) {
      tree_[i] = tree_[i*2] * tree_[i*2+1];
      i >>= 1;
    }
  }

  M query(size_t l, size_t r) const {
    M lhs,rhs;
    for (auto _l = l+size_, _r = r+size_; _l < _r; _l>>=1, _r>>=1) {
      if (_l&1) lhs = lhs * tree_[_l++];
      if (_r&1) rhs = tree_[--_r] * rhs;
    }
    return lhs * rhs;
  }

};

constexpr int MINF = -2e9;

struct Max {
  int x;
  Max(int x=MINF) : x(x){}
  Max operator*(const Max& r) const {return max(x,r.x);}
  Max& operator*=(const Max& r) {return *this = *this * r;}
};

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

  int n; cin>>n;
  vector<pair<int,int>> LR(n);
  map<int,int> ps;
  ps[MINF]=0;
  int max_r = MINF;
  for (int i = 0; i < n; i++) {
    int x,l; cin>>x>>l;
    LR[i] = {x-l, x+l};
    ps[x-l]=0;
    ps[x+l]=0;
    max_r = max(max_r, x+l);
  }
  int id = 0;
  for (auto& [p,k]:ps) {
    k = id++;
  }
  sort(LR.begin(), LR.end());
  segment_tree<Max> rmq(ps.size());
  rmq.set(ps[MINF], 0);
  for (auto [l,r]:LR) {
    assert(ps.count(l) and ps.count(r));
    int c = rmq.query(ps[MINF], ps[l]+1).x;
    rmq.set(ps[r], c+1);
  }
  cout << rmq.query(0, ps[max_r]+1).x << endl;

  return 0;
}


Measured memory_bytes: 15084
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        while(true){
            int s[]=new int[5];
            int s1=sc.nextInt();
            int s2=sc.nextInt();
            if(s1+s2==0){
                break;
            }
            s[0]=s1+s2;
            int max=s[0];
            int maxs=0;
            for(int i=1;i<5;i++){
                s1=sc.nextInt();
                s2=sc.nextInt();
                s[i]=s1+s2;
                if(max<s[i]){
                    max=s[i];
                    maxs=i;
                }
            }
            String str;
            if(maxs==0){
                str="A";
            }else if(maxs==1){
                str="B";
            }else if(maxs==2){
                str="C";
            }else if(maxs==3){
                str="D";
            }else{
                str="E";
            }
            System.out.println(str+" "+max);
        }
    }
}


Measured memory_bytes: 29452
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

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


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18+9;

string s,t;
int main() {
    cin>>s>>t;
    string ans="No";
    REP(i,0,s.size()){
        string ss=s.substr(i,s.size()-i)+s.substr(0,i);
        if(t==ss){
            ans="Yes";
            break;
        }
    }
    p(ans);
    return 0;
}

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

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

    string ans;

    int len = s.length();
    int cou = 0;

    for(int i = 0; i < len; i++){
        if(s[i] != 'B'){
            ans += s[i];
            cou++;
        }else{
            if(cou != 0){
                ans.erase(cou - 1, 1);
                cou--;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <sys/time.h>

using namespace std;

typedef long long ll;

vector<ll> createPrime ( const ll num )
{
	vector<ll> v;
	bool isPrime[num+1];
	
	memset(isPrime, true, sizeof(isPrime));
	
	for (ll i = 2; (i*i) <= num; ++i)
	{
		if (isPrime[i])
		{
			for (ll j = i+i; j <= num; j += i)
			{
				isPrime[j] = false;
			}
		}
	}
	for (ll i = 2; i <= num; ++i)
	{
		if (isPrime[i]) { v.push_back(i); }
	}
	return v;
}

ll LCM ( const vector<ll> &primes, const vector<ll> &nums )
{
	ll lcm = 1;
	for (int i = primes.size()-1; i >= 0; --i)
	{
		ll p = primes[i];
		ll count = 0;
		
		for (int j = 0, jlen = nums.size(); j < jlen; ++j)
		{
			ll n = nums[j], cnt = 0;
			
			while ((n % p) == 0)
			{
				n /= p;
				++cnt;
			}
			count = max(count, cnt);
		}
		
		lcm *= (ll)pow(p, count);
	}
	return lcm;
}

int main ( void )
{
	const int N = 3;
	vector<ll> prime;
	ll a[N], m[N];
	
	prime = createPrime(pow(2, 15)+1);

	while (cin >> a[0] >> m[0] >> a[1] >> m[1] >> a[2] >> m[2], 
		a[0] | m[0] | a[1] | m[1] | a[2] | m[2])
	{
		vector<ll> count(N, 0);

		for (int i = 0; i < N; ++i)
		{
			ll xyz = 1;
			do
			{
				xyz = a[i] * xyz % m[i];
				++count[i];
			} while (xyz != 1);
		}

		ll answer = LCM(prime, count);

		cout << answer << endl;
	}
	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

ll solve(vector<pair<ll, ll>> A, const int N) {
  sort(ALL(A));
  reverse(ALL(A));
  // pv(ALL(A));

  ll res = 0;
  priority_queue<ll> pq;

  int j = 0;
  for (int i = N; i >= 1; i--) {
    while (j < A.size() && A[j].first >= i) {
      pq.push(A[j].second);
      j++;
    }
    if (!pq.empty()) {
      res += pq.top();
      pq.pop();
    }
  }
  return res;
}

int main2() {
  int N = nextLong();

  ll base = 0;
  vector<pair<ll, ll>> A, B;
  REP(i, N) {
    int K = nextLong();
    int L = nextLong();
    int R = nextLong();
    if (L == R) base += L;
    else if (K == N) base += L;
    else if (L > R) {
      base += R;
      A.push_back({K, L - R});
    }
    else if (L < R) {
      base += L;
      B.push_back({N-K, R - L});
    }
  }

  sort(ALL(A));
  sort(ALL(B));

  ll ans = base + solve(A, N) + solve(B, N);
  cout << ans << endl;
  return 0;
}

int main() {
  int t = nextLong();
  while (t--)
    main2();
  return 0;
}

Measured memory_bytes: 9916
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <fstream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <complex>

using namespace std;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

constexpr int MAXN = 100005;
constexpr ll INF = 1e18;
struct dijkstra {
    using edge = pair<ll, int>;

    int n;
    vector<vector<edge>> graph;

    dijkstra(int n): n(n) {
        graph.assign(n, vector<edge>());
    }

    void add_edge(int u, int v, ll w) {
        graph[u].emplace_back(w, v);
        graph[v].emplace_back(w, u);
    }

    // dists, previous. change return type if you only need one.
    vector<ll> run(int src) {
        vector<ll> dist(n, INF);
        priority_queue<edge, vector<edge>, greater<edge>> pq;

        dist[src] = 0LL;
        pq.emplace(0LL, src);

        ll cur_dist;
        int u;
        while (!pq.empty()) {
            tie(cur_dist, u) = pq.top();
            pq.pop();
            if (dist[u] != cur_dist)
                continue;

            // printf("dist[%d] = %lld\n", u, cur_dist);
            for (auto& e : graph[u]) {
                ll w = e.first;
                int v = e.second;
                if (dist[u] + w < dist[v]) {
                    dist[v] = dist[u] + w;
                    pq.emplace(dist[v], v);
                }
            }
        }

        return dist;
    }
};

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

    int n, m, s, t;
    scanf(" %d %d %d %d", &n, &m, &s, &t);

    --s; --t;
    dijkstra d1(n), d2(n);

    int u, v, a, b;
    for (int i = 0; i < m; ++i) {
        scanf(" %d %d %d %d", &u, &v, &a, &b);
        --u; --v;
        d1.add_edge(u, v, a);
        d2.add_edge(u, v, b);
    }

    vector<ll> dist0 = d1.run(s);
    vector<ll> dist1 = d2.run(t);

    vector<ll> ans(n);
    ll base = 1e15;
    for (int i = 0; i < n; ++i) {
        ans[i] = base - dist0[i] - dist1[i];
    }

    for (int i = n - 2; i >= 0; --i) {
        ans[i] = max(ans[i], ans[i + 1]);
    }

    for (ll x : ans) {
        printf("%lld\n", x);
    }

    return 0;
}

Measured memory_bytes: 19016
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <queue>
#include <iomanip>
#include <iterator>

// #define MOD 1000000007
// #define INF 1000000001

using namespace std;
// typedef unsigned long long ull;
typedef long long ll;


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}

int main(int argc, char const *argv[]) {
    int N;
    cin >> N;

    vector<int> x4, x2, x1;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        if (a % 4 == 0) {
            x4.push_back(a);
        } else if (a % 2 == 0) {
            x2.push_back(a);
        } else {
            x1.push_back(a);
        }
    }

    int i4 = 0, i2 = 0, i1 = 0;
    int state = 4;
    vector<int> a_sorted;
    while (true) {
        // print("state =", state);
        if (state == 4 && i1 < x1.size()) {
            a_sorted.push_back(x1[i1]);
            state = 1;
            i1 += 1;
        } else if ((state == 2 || state == 4) && i2 < x2.size()) {
            a_sorted.push_back(x2[i2]);
            state = 2;
            i2 += 1;
        } else if (i4 < x4.size()) {
            a_sorted.push_back(x4[i4]);
            state = 4;
            i4 += 1;
        } else {
            break;
        }
    }
    // print(a_sorted);
    if (a_sorted.size() == N) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 1404
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8
from heapq import *

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((b1[:, :], i8, i8, i8, i8), cache=True)
def main(wall, Sx, Sy, Tx, Ty):
    INF = 1 << 30
    H, W = wall.shape
    S = Sx * W + Sy
    T = Tx * W + Ty
    dist = np.full(H * W, INF, np.int64)
    q = [(0,S)]
    while q:
        dv, v = heappop(q)
        if dv > dist[v]:
            continue
        vx, vy = divmod(v, W)
        # そのままあるく
        for dx, dy in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            wx, wy = vx + dx, vy + dy
            if not (0 <= wx < H):
                continue
            if not (0 <= wy < W):
                continue
            if wall[wx, wy]:
                continue
            w = wx * W + wy
            if dist[w] <= dv:
                continue
            dist[w] = dv
            heappush(q, (dv, w))
        # ワープする
        for dx in range(-2, 3):
            for dy in range(-2, 3):
                wx, wy = vx + dx, vy + dy
                if not (0 <= wx < H):
                    continue
                if not (0 <= wy < W):
                    continue
                if wall[wx, wy]:
                    continue
                w = wx * W + wy
                if dist[w] <= dv + 1:
                    continue
                dist[w] = dv + 1
                heappush(q, (dv+1, w))
    ans = dist[T]
    if ans == INF:
        ans = -1
    return ans

H, W = map(int, readline().split())
Sx, Sy = map(lambda x: int(x) - 1, readline().split())
Tx, Ty = map(lambda x: int(x) - 1, readline().split())
wall = np.frombuffer(read(), 'S1').reshape(H, -1)[:, :W] == b'#'

print(main(wall, Sx, Sy, Tx, Ty))


Measured memory_bytes: 114828
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

ll solveA(){
    ll res = 0;
    ll A,B; cin >> A >> B;
    res = A*B - A - B + 1;
    return res;
}

// nの約数を列挙する
vector<ll> getdivisor(ll n){
    vector<ll> res;
    for(ll i = 1; i*i <= n;i++){
        if(n%i == 0) {
            res.push_back(i);
            if(n/i != i) res.push_back(n/i);
        }
    }
    sort(res.begin(),res.end());
    return res;
}
ll solveB(){
    ll res = 0;
    ll N; cin >> N;
    for(int i = 1; i <= N;i++){
        if(i%2 == 0) continue;
        if(getdivisor(i).size() == 8) res++;
    }
    return res;
}

ll solveC(){
    ll res = 0;
    string S; cin >> S; ll K; cin >> K;
    res = 1;
    for(int i = 0; S.length();i++){
        if(S[i] == '1') continue;
        else{
            res = S[i] - '0';
            break;
        }
    }
    return res;
}

ll solveD(){
    ll res = 0;
    ll N,M,Q; cin >> N >> M >> Q;
    vector<ll> L(M),R(M);
    vector<vector<ll>> G(N);
    for(int i = 0; i < M;i++){
        cin >> L[i] >> R[i]; L[i]--; R[i]--;
        G[L[i]].push_back(R[i]);
    }
    for(int i = 0; i < N;i++){
        sort(G[i].begin(),G[i].end());
    }
    while(Q--){
        ll p,q; cin >> p >> q;
        p--; q--;
        
        ll Ans = 0;
        for(ll x = p; x <= q;x++){
            Ans += (upper_bound(G[x].begin(), G[x].end(), q) - G[x].begin());
        }
        cout << Ans << endl;
    }
    return 0;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    //cout << solveA() << endl;
    cout << solveB() << endl;
    //cout << solveC() << endl;
    //solveD();
    return 0;
}


Measured memory_bytes: 256
// Java program For handling Input/Output 
import java.io.*;
import java.util.*;
import java.math.*;
//import java.awt.*;

public class Main {
    BufferedReader br;
    StringTokenizer st;

    int max = -1;
    final long P = 998244353;

    HashSet<String> set = new HashSet<>();
    HashMap<String, Integer> map = new HashMap<>();

    // actual logic
    void solve() throws IOException {
        String s = ns();
        if (Character.isUpperCase(s.charAt(0))) {
            pl("A");
        } else {
            pl("a");
        }
    }

    // constructor
    Main() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                System.out.println(e);
            }
        } catch (Exception e) {
            System.out.println(e);
        }
    }

    Main(String s) {
        try {
            br = new BufferedReader(new FileReader(s));
            st = new StringTokenizer(br.readLine());
        } catch (Exception e) {
            System.out.println(e);
        }
    }

    // main metohd
    public static void main(String[] args) throws IOException {
        new Main().solve();
    }

    // Utility methods

    String ns() {
        if (!st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                System.out.println(e);
            }
        }
        return st.nextToken();

    }

    int ni() {
        return Integer.parseInt(ns());
    }

    long nl() {
        return Long.parseLong(ns());
    }

    double nd() {
        return Double.parseDouble(ns());
    }

    void pl(String s) {
        System.out.println(s);
    }

    void pl(long s) {
        System.out.println(s);
    }
}


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

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define ll long long
#define pii pair<ll, ll>
#define is insert
#define er erase

using namespace std;

int solve();

#define TASK ""

int main()
{
    #ifdef DEBUG
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
        //freopen(TASK".in", "r", stdin);
        //freopen(TASK".out", "w", stdout);
    #endif // DEBUG
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

ll n;
ll p;

int solve()
{
    cin >> n >> p;
    ll p1 = p;
    vector<pii> vec;
    for (ll i = 2; i * i <= p1; ++i)
    {
        ll i1 = p / i;
        if (p % i == 0)
        {
            ll cnt = 0;
            while (p % i == 0)
            {
                cnt++;
                p /= i;
            }
            vec.pb(mp(i, cnt));
        }
    }
    if (p > 1)
    {
        vec.pb(mp(p, 1));
    }
    ll ans = 1;
    for (pii it : vec)
    {
        ll k = it.Y / n;
        //cout << it.X << endl;
        ll cur = 1;
        for (ll i = 0; i < k; ++i)
        {
            cur *= it.X;
        }
        ans *= cur;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
S=gets.chomp
X=[*1...S.size].map{|i|S[i]==S[i-1]?true:false}
minc=S.size
(S.size-1).times{|i|
  if !X[i] then
    minc=[minc,[i+1,S.size-i-1].max].min
  end
}
p minc

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

int	main(void)
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		if (i % 3 == 0)
		{
			cout << ' ' << i;
			i++;
		}
		if (i <= n)
		{
			int x = i;
			while (x)
			{
				if (x % 10 == 3)
				{
					cout << ' ' << i;
					break;
				}
				x /= 10;
			}
		}
	}
	cout << endl;
}



Measured memory_bytes: 3104
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
A = MAP()

amin = min(A)
amax = max(A)

ans = 10**19
for num in range(amin, amax+1):
	cnt = 0
	for a in A:
		cnt += (a-num)**2
	ans = min(ans, cnt)
	
print(ans)

Measured memory_bytes: 38512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=9e18+1;
const int inf=2e9;
const ll lnf=9e18;

ll C[1001][1001]; // C[n][k] -> nCk
void comb_table(int N){
  for(int i=0;i<=N;++i){
    for(int j=0;j<=i;++j){
      if(j==0 or j==i) C[i][j]=1ll;
      else C[i][j]=(C[i-1][j-1]+C[i-1][j]);
    }
  }
}

int main(){
  cout << fixed << setprecision(15);
  itn n,a,b; cin >> n >> a >> b;
  comb_table(1e3);
  vector<ll> v(n);
  rep(i,n) cin >> v[i];
  rsort(v);
  ld mx=0;
  rep(i,a){
    mx+=v[i];
  }
  mx/=a;
  cout << mx << endl;
  ll kagen=v[a-1];
  int cnt1=0;
  int cnt2=0;
  rep(i,n){
    if(v[i]>kagen) cnt1++;
    if(v[i]==kagen) cnt2++;
  }
  //cout << cnt1 << endl;
  //cout << cnt2 << endl;
  if(cnt1){
    cout << C[cnt2][a-cnt1] << endl;
    return 0;
  }
  ll ans=0;
  for(int i=a;i<=b;i++){
    ans+=C[cnt2][i-cnt1];
  }
  cout << ans << endl;
}

Measured memory_bytes: 10616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))


int main(){
	ll a[3] = {};
	ll ans = 1;
	int N,A;
	cin >> N;
	FOR(i,0,N){
		cin >> A;
		int cnt = 0;
		FOR(j,0,3){
			cnt += A==a[j];
		}
		(ans*=cnt)%=MOD;
		FOR(j,0,3){
			if(A==a[j]){
				a[j]++;
				break;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pl;
typedef queue<ll> ql;
typedef set<ll> sl;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll &a, ll &b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll &b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX = 500010;
ll num, M, N, ans=0, count=0;

sl move(sl set, ll m, ll flg) {
  sl S;
  for(ll i: set) {
    S.insert(i+m);
    if(flg>=1) S.insert(i-m);
  }
  return S;
}

int main() {
  string s;
  cin >> s;
  ll x, y, m=1, flg=0;
  cin >> x >> y;
  
  sl set_x={0}, set_y={0};
  rep(i, s.size()) {
    if(s[i] == 'T') flg++;
    else if(s[i] == 'F' && s[i+1] == 'F') m++;
    else {
      if(flg%2==0) set_x = move(set_x, m, flg);
      else set_y = move(set_y, m, flg);
      m=1;
    }
  }
  
  for(ll i: set_x) if(x==i) ans++;
  for(ll i: set_y) if(y==i) ans++;
  
  if(ans==2) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int m,n;
	cin>>m>>n;
	int m1,n1;
	cin>>m1>>n1;
	cout<<m*n-(m1*n+n1*m-m1*n1)<<endl;
	return 0;
}

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

int main(void) {
  int A, B, C;
  cin >> A >> B >> C;
  int ma = max({A, B, C});
  int da = ma - A, db = ma - B, dc = ma - C;
  if ((da + db + dc) % 2 == 0) {
    cout << (da + db + dc) / 2 << endl;
  } else {
    cout << (da + db + dc + 3) / 2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
s = input("")
t = input("")

ans = 10000

for i in range(len(s)-len(t)+1):
    cnt = 0
    S = s[i:i+len(t)]
    for j in range(len(t)):
        if S[j] != t[j]:
            cnt += 1
    ans = min(ans,cnt)
    
print(ans)

Measured memory_bytes: 8940
#include <bits/stdc++.h>
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;

ll r, d, x, xx;
int main()
{
    IOS
    //freopen("planet.in", "r", stdin);
    cin >> r >> d >> x;

    for (int i = 0; i < 10; ++i) {
        xx = r * x - d;
        cout << xx << endl;
        x = xx;
    }


    return 0;
}


Measured memory_bytes: 256
l=[]
for i in range(0,1001):
    l.append(i**5)
n=int(input())
for i in range(0,1001):
    if((l[i]-n) in l):
        print(i,l.index(l[i]-n))
        break
    elif((n-l[i]) in l):
        print(i,-l.index(-l[i]+n))
        break

        
    

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

int main(){
  int N;
  cin>>N;
  vector<float>v(N);
  for(int i=0;i<N;i++){
    cin>>v[i];
  }
  
  //要素を昇順にソート
  sort(v.begin(),v.end());
  
  v[0]*=2;
  for(int i=0;i<N;i++){
    for(int j=0;j<i+1;j++){
      v[j]/=2;
    }
  }
  float ans=0.0;
  for(int i=0;i<N;i++){
    ans+=v[i];
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {
  public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int n = sc.nextInt();
   int x = sc.nextInt();
   int t = sc.nextInt();

   int calc = n / x;
   if (n % x > 0) {
     calc++;
   }
   System.out.println(calc * t);
  }
}


Measured memory_bytes: 35436
#include <bits/stdc++.h>
using namespace std;
const int maxn=2010;
const double pi=acos(-1.0);
struct point {
    double x,y;
    int id;
}p[maxn],ch[maxn];
typedef point Vector;
double ans[maxn];
int top;
Vector operator - (Vector A,Vector B) {
    Vector e;
    e.x=A.x-B.x;
    e.y=A.y-B.y;
    return e ;
}
double dot(Vector A,Vector B)
{
    return A.x*B.x+A.y*B.y;
}
double cross(Vector A,Vector B)
{
    return A.x*B.y-A.y*B.x;
}
double len(point A,point B)
{
    return sqrt(dot(A-B,A-B));
}
int cmp(point a,point b)
{
    if (a.x==b.x) return a.y<b.y;
    else return a.x<b.x;
}
double normal(double x)
{
    //if (x>(pi/2)) x=pi-x;
    return pi-x;
}
void gethull(point p[],int n)
{
    int i,k;
    sort(p,p+n,cmp);
    top=0;
    for (i=0;i<n;i++) {
        while (top>1&&cross(ch[top-1]-ch[top-2],p[i]-ch[top-2])<0) top--;
        ch[top++]=p[i];
    }
    k=top;
    for (i=n-2;i>=0;i--) {
        while (top>k&&cross(ch[top-1]-ch[top-2],p[i]-ch[top-2])<0) top--;
        ch[top++]=p[i];
    }
    if (n>1) top--;
}
int main()
{
    //freopen("text.in","r",stdin);
    int i,n;
    double a;
    point p1,p2;
    scanf("%d",&n);
    for (i=0;i<n;i++) {
        scanf("%lf%lf",&p[i].x,&p[i].y);
        p[i].id=i;
    }
    gethull(p,n);
    /*for (i=0;i<top;i++) {
        printf("%lf %lf\n",ch[i].x,ch[i].y);
    }
    printf("\n\n");*/
    memset(ans,0,sizeof(ans));
    for (i=0;i<top;i++) {
        p1=ch[(i-1+top)%top]; p2=ch[(i+1)%top];
        a=acos(dot(p1-ch[i],p2-ch[i])/(len(p1,ch[i])*len(p2,ch[i])));
        //printf("a=%lf %lf    %lf %lf\n",a,dot(p1-p[i],p2-p[i]),p1.x-p[i].x,p1.y-p[i].y);
        a=normal(a);
         //printf("a2=%lf\n",a);
        ans[ch[i].id]=a/(2*pi);
    }
    for (i=0;i<n;i++) {
        printf("%.20lf\n",ans[i]);
    }
    return 0;
}


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

#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define sz(c) int(c.size())
#define clr(v, d)   memset(v, d, sizeof(v))
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define INF             INT64_MAX
#define NINF            INT64_MIN
#define ROW 1001
#define COL 1001

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<pll> vll;
typedef vector<ll> vl;
int alpha[26];

int k;
long long compute_hash(string const& s) {
    const int p = 31;
    const int m = 1e9 + 9;
    long long hash_value = 0;
    long long p_pow = 1;
    for (char c : s) {
        hash_value = (hash_value + (c - 'a' + 1) * p_pow) % m;
        p_pow = (p_pow * p) % m;
    }
    return hash_value;
}
vector<vector<int>> group_identical_strings(vector<string> const& s) {
    int n = s.size();
    vector<pair<long long, int>> hashes(n);
    for (int i = 0; i < n; i++)
        hashes[i] = {compute_hash(s[i]), i};

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

    vector<vector<int>> groups;
    for (int i = 0; i < n; i++) {
        if (i == 0 || hashes[i].first != hashes[i-1].first)
            groups.emplace_back();
        groups.back().push_back(hashes[i].second);
    }
    return groups;
}
int count_unique_substrings(string const& s,int *freq) {
    int n = s.size();

    const int p = 31;
    const int m = 1e9 + 9;
    vector<long long> p_pow(n);
    p_pow[0] = 1;
    for (int i = 1; i < n; i++)
        p_pow[i] = (p_pow[i-1] * p) % m;

    vector<long long> h(n + 1, 0);
    for (int i = 0; i < n; i++)
        h[i+1] = (h[i] + (s[i] - 'a' + 1) * p_pow[i]) % m;

    int cnt = 0;
    for (int l = 1; l <= n; l++) {
        set<long long> hs;
        for (int i = 0; i <= n - l; i++) {
            long long cur_h = (h[i + l] + m - h[i]) % m;
            cur_h = (cur_h * p_pow[n-i-1]) % m;
            string tmp=s.substr(i,l);
            if(freq[i+l]-freq[i]<=k){
                pair<set<long long>::iterator,bool> set_out;
                set_out=hs.insert(cur_h);
//                if(set_out.second)
//                    cout<<tmp<<endl;
            }
        }
        cnt += hs.size();

    }

    return cnt;
}
int main(void){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt=0;
    range(i,0,s.size()-3)
    {

       if((s[i]=='A')&&(s[i+1]=='B')&&(s[i+2]=='C'))
       {
           cnt++;
           i+=2;
       }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int S, h, m, s;

  0 <= S < 86400;
 
  scanf("%d",&S);
  printf("%d:%d:%d\n", S / 3600, (S % 3600) / 60, (S % 3600) % 60);
  return 0;
}

Measured memory_bytes: 592
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define mod 1000000007
#define INF2 1000000000000000000


const int INF = 1 << 29;        // 十分大きい値にする, INT_MAX にしないのはオーバーフロー対策

								// 入力
int N;

// DPテーブル
int dp[61][100010];

int main() {
	cin >> N;
	vector<int> v;
	int tmp = 1;
	rep(i, 5) v.push_back(tmp);
	rep(i, 6) {
		tmp *= 6;
		rep(j, 5) {
			v.push_back(tmp);
		}
	}
	tmp = 1;
	rep(i, 5) {
		tmp *= 9;
		rep(j, 5) {
			v.push_back(tmp);
		}
	}




	// 一旦すべて INF に
	for (int i = 0; i < 61; ++i) for (int j = 0; j < 100010; ++j) dp[i][j] = INF;
	dp[0][0] = 0;                // dp[0][0] だけ 0 に

	for (int i = 0; i < 60; ++i) {
		for (int j = 0; j <= N; ++j) {
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
			if (j >= v[i]) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + 1);
			// cout << "dp[" << i + 1 << "][" << j << "] = " << dp[i + 1][j] << endl;
		}
	}

	cout << dp[60][N] << endl;
}

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

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

    int N;
    cin >> N;
    string S;
    cin >> S;
    for (auto s : S) {
        s += N;
        if (s > 'Z') s -= 26;
        cout << s;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> d(n);
    rep(i, n) cin >> d[i];
    map<ll, ll> cnt;
    rep(i, n) cnt[d[i]]++;
    cnt[0]++;
    ll ans1 = LONG_LONG_MAX;
    for(auto x : cnt) {
        if (x.second >= 3) {
            cout << 0 << endl;
            return 0;
        }
        if (x.second == 2) {
            ans1 = min(ans1, x.first);
            ans1 = min(ans1, 24 - x.first * 2);
        }
    }
    ll ans2 = LONG_LONG_MIN;
    if ((cnt[0] >= 2) || (cnt[12] >= 2)) {
        cout << 0 << endl;
        return 0;
    }
    rep(i, 1LL << 13) {
        ll dist = LONG_LONG_MAX;
        rep(ii, 13) {
            rep(iii, 13) {
                if ((ii == iii) || (cnt[ii] == 0) || (cnt[iii] == 0)) continue;
                if ((cnt[ii] == 1) && (cnt[iii] == 1)) {
                    ll d1 = ((i & (1LL << ii)) == 0) ? ii : (24 - ii);
                    ll d2 = ((i & (1LL << iii)) == 0) ? iii : (24 - iii);
                    dist = min(dist, min(abs(d1 - d2), 24 - abs(d1 - d2)));
                }
                else if (cnt[ii] == 2) {
                    ll d1 = ((i & (1LL << iii)) == 0) ? iii : (24 - iii);
                    dist = min(dist, min(abs(d1 - ii), 24 - abs(d1 - ii)));
                    dist = min(dist, min(abs(d1 - (24 - ii)), 24 - abs(d1 - (24 - ii))));
                }
                else if (cnt[iii] == 2) {
                    ll d1 = ((i & (1LL << ii)) == 0) ? ii : (24 - ii);
                    dist = min(dist, min(abs(d1 - iii), 24 - abs(d1 - iii)));
                    dist = min(dist, min(abs(d1 - (24 - iii)), 24 - abs(d1 - (24 - iii))));
                }
                else {
                    dist = min(dist, min(abs(ii - iii), 24 - abs(ii - iii)));
                    dist = min(dist, min(abs(ii - (24 - iii)), 24 - abs(ii - (24 - iii))));
                    dist = min(dist, min(abs((24 - ii) - iii), 24 - abs((24 - ii) - iii)));
                    dist = min(dist, min(abs((24 - ii) - (24 - iii)), 24 - abs((24 - ii) - (24 - iii))));
                }
            }
        }
        if (dist != LONG_LONG_MAX) ans2 = max(ans2, dist);
    }
    cout << min(ans1, ans2) << endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
//#include<ctype.h>
//#define pi acos(-1.0)
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define S(type,x) fscanf(stdin,"%"#type,x)
//#define MAX(a,b) a>b?a:b
//#define MIN(a,b) a<b?a:b

int main() {
	int a, b, c, f;
	for (; ~fscanf(stdin, "%d%d%d", &a, &b, &c),a; P(d, f)){
		int d[201] = {},
			i,e=0;
		for (i = 0; i < a; i++)S(d, d + i);
		for (i = b; i <= c; i++)
			if (e <= d[i - 1] - d[i])e = d[i - 1] - d[i], f = i;
	}
	return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<cstdio>
using namespace std;
int a[13][11];
int main(){
	int b,f,r,v,n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d%d%d",&b,&f,&r,&v);
		a[(b-1)*3+f][r]+=v;
	}
	for(int i=1;i<=12;i++){
		if(i!=1&&(i-1)%3==0){
			for(int j=0;j<20;j++) printf("#");
			printf("\n");
		}
		for(int j=1;j<=10;j++){
			printf(" %d",a[i][j]);
		}
		printf("\n");
		
	}
	return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n, m; cin >> n >> m;
	if(n == m) {
		cout << "Yes" << endl;	
	} else {
		cout << "No" << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
float PHI = 1.6180339;
//const float  PI_F=3.14159265358979f;
#define MAX 100000 
#define endl "\n"    
//typedef long long float;
#define int long long
//#define float unsigned long long

vector<int>v;

void SieveOfEratosthenes(int n) 
{ 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 

    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          v.push_back(p);
} 

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(9);

    int n;
    cin>>n;
    SieveOfEratosthenes(1000000);
/*     for(int i=0;i<v.size();i++)
    cout<<v[i]<<endl; */
    vector<int>::iterator ans;
    ans=lower_bound(v.begin(),v.end(),n);
    cout<<v[ans-v.begin()]<<endl;

}

    
    

Measured memory_bytes: 2424