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

#define DEBUG(C) cerr << #C << " = " << C << endl

using namespace std;

string S;
int dp[555][555];
bool f(int l, int r) { //[l, r)
//  cerr << dp[l][r] << endl;
//  cerr << l << " " << r << endl;
  if (dp[l][r] != -1) {
    return dp[l][r];
  }
  if (l == r) {
    return dp[l][r] = 1;
  }
  if (S[l] != 'm' || S[r - 1] != 'w') {
    return dp[l][r] = 0;
  }
  bool res = false;
  for (int i = l + 1; i < r - 1; i++) {
    if (S[i] == 'e') {
      res |= (f(l + 1, i) && f(i + 1, r - 1));
    }
  }
  return dp[l][r] = res;
}

int main() {
  cin >> S;
  memset(dp, -1, sizeof(dp));
  cout << (f(0, S.length()) ? "Cat" : "Rabbit") << endl;
  return 0;
}

Measured memory_bytes: 4400
#include <bits/stdc++.h>
using namespace std;
 
long long a,b,l,n;
string s;
int main() {
	
  cin >> n;
  
  int a[n];
  
  for (int i=0; i<n; i++){
    	cin >> a[i];
  	}
  
  int l=0,k=0;
 
  for (int i=0; i<n; i++){
  	  if (a[i]!=l+1){
        l--;
        k++;
      }
 
      l++;
  }
  
  if (k==n)
    cout << -1 << endl;
  else
    cout << k << endl;
    
}

Measured memory_bytes: 1024
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var read = Console.ReadLine();
                var temp_string = read.Split(' ');

                int n = int.Parse(temp_string[0]), x = int.Parse(temp_string[1]),count=0;

                if (n == 0 && x == 0)
                {
                    break;
                }

                for (int i = 1; i <= n-2;i++ )
                {
                    for(int j=i+1;j<=n-1;j++)
                    {
                        for(int k=j+1;k<=n;k++)
                        {
                            if(i+j+k==x)
                            {
                                count++;
                            }
                        }
                    }
                }

                Console.WriteLine(count);

            }

        }
    }
}

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

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

    string ans = "";
    rep(i, s.size()) {
        if (i % 2 == 0) ans += s[i];
    }

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


Measured memory_bytes: 512
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int c1, c5, c10, c50, c100, c500;
  cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
  int sum = c1 + (c5 * 5 ) + (c10 * 10) + (c50 * 50) +  (c100 * 100) +(c500 * 500);
  if(sum >= 1000) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
}



Measured memory_bytes: 3160
#include<stdio.h>
#include<stdbool.h>
int main(void)
{
    int n,i,num1,num2,num4;
    bool objective;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++)
        scanf(" %d",&a[i]);
    num1=num2=num4=0;
    for(i=0;i<n;i++)
        if(a[i]%4)
            if(a[i]%2) num1++;
            else num2++;
        else
            num4++;
    if(num1==0) objective=true;
    else if(num4==0) objective=false;
    else if(num2==0)
        if(num4>=num1-1) objective=true;
        else objective=false;
    else
        if(num4>=num1) objective=true;
        else objective=false;
    if(objective)
        printf("Yes");
    else
        printf("No");
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
	string s;
	long long k;
	cin>>s>>k;
	int one=0;
	for(int i=0;i<s.length();i++)
		if(s[i]=='1')
			one++;
		else
			break;
	if(one>=k)
		printf("1\n");
	else
		printf("%d\n",(int)s[one]-'0');
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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


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

    int n; cin >> n;
    map<int, int> ma;
    rep(i, n) {
        int a; cin >> a;
        ma[a]++;
    }
    int cnt = 0;
    for(auto itr = ma.begin(); itr != ma.end(); ++itr) {
        if(itr->second % 2) {
            cnt++;
        }
    }
    COUT(cnt);

}

Measured memory_bytes: 4992
#include<stdio.h>
int main(void){
    int a,b,c[100000],d;
    scanf("%d %d",&a,&b);
    for(int i=0;i<a;i++){
        scanf("%d",&c[i]);
    }
    d=a-b;
    if(a/2<b) {
        if(a==b)printf("1");
        else    printf("2");
    }
    else if(d%(b-1)==0) printf("%d\n",1+d/(b-1));
    else if(d%(b-1)!=0) printf("%d\n",2+d/(b-1));
    return 0;
}


Measured memory_bytes: 512
s = input()
s_n = len(s)
a = 0
z = 0
for i in range(s_n):
    if s[i] == 'A':
        a += i
        break
for i in range(s_n - 1, 0, -1):
    if s[i] == 'Z':
        z += i
        break
print(z - a + 1)

Measured memory_bytes: 3516
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#include <bitset>
#include <complex>
#include <cassert>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define GI(i) (scanf("%d",&i))
#define GLL(i) (scanf("%lld",&i))
#define GD(i)  (scanf("%lf",&i))
#define PB          push_back
#define MP          make_pair
#define MT          make_tuple
#define GET0(x)     (get<0>(x))
#define GET1(x)     (get<1>(x))
#define GET2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       (1LL<<60)
#define LLMIN       -(1LL<<60)
#define IMAX        (1<<30)
#define IMIN        -(1<<30)
typedef long long LL;
using namespace std;

int main(void){
    int N;
    int ans=0, last=-1, nlast=1;
    GI(N);
    REP(i,N){
        int c;GI(c);
        if(last == c)
            nlast++;
        else{
            ans += nlast/2;
            last=c;
            nlast = 1;
        }
    }
    ans += nlast/2;
    printf("%d\n",ans);
    return 0;
}

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

int main() {
  	int r, g, b;
  	cin >> r >> g >> b;
  	if((r * 100 + g * 10 + b) % 4 == 0) cout << "YES" << endl;
  	else cout << "NO" << endl;
  	return 0;
}


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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  int N,K;
  cin>>N>>K;
  if(K>(N-1)*(N-2)/2) cout<<-1<<endl;
  else{
    int t = 0;
    vector<vector<int>> v(K,vector<int>(2));
    for(int i = 1;i < N-1; i++){
      for(int j = i+1; j < N; j++){
        if(t==K) break;
        v[t]={i,j};
        t++;
      }
      if(t==K)break;
    }
    int cnt = 0;
    cout<<N*(N-1)/2-K<<endl;
    for(int i = 0; i < N-1;i++){
      for(int j = i+1; j<N; j++){
        if(cnt<K&&v[cnt][0]==i&&v[cnt][1]==j){
          cnt++;
          continue;
        }
        cout<<i+1<<" "<<j+1<<endl;
      }
    }
  }
}

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


int main(){
	/*input*/
	vector<int> a(5);
    for(int i = 0; i < 5; i++){
    	cin >> a[i];
    }

    /*calc*/
    int  ans = 0;

    /*arrival time*/
    for(int i = 0; i < 5; i++){
    	ans += a[i];
    	if(a[i] % 10 == 0)  a[i] = 10;
    	else{ a[i] %= 10;}
    }

    sort(a.rbegin(),a.rend());

    /*waiting time
     * 待ち時間が最大のものは
     * 最後に注文
     * */
    for(int i = 0; i < 4; i++){
    	if(a[i] != 10 )  ans += 10 - a[i];
    }

    /*output*/
	   	cout<< ans <<endl;
    return 0;
}


Measured memory_bytes: 256
//
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <array>
#include <numeric>
#include <functional>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <complex>

using namespace std;

#define REP(i,m,n) for(int i=m;i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define ALL(x) (x).begin(),(x).end()

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

const ll inf = INT_MAX;
const double eps = 1e-10;
const double pi = acos(-1.0);
const int di[][2] = {{1,0},{0,1},{-1,0},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}};

int main(){

	double a,b;
	cin >> a>>b;
	double x = 1/a + 1/b;
	printf("%f\n", 1/x);
	return 0;
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

VI edge[100010];
bool used[100010];
int lvCnt[100010];
int childCnt[100010];
ll ans = 1;
ll k;
void dfs(int node, int lv){
  used[node] = true;
  lvCnt[lv]++;
  for(int x: edge[node]){
    if(used[x] == false){
      dfs(x,lv+1);
      childCnt[node]++;
    }
  }
}
bool flag = false;
void dfs2(int node){
  used[node] = true;
  for(int x: edge[node]){
    if(used[x] == false){
      int col = k-2;
      ans *= (COM(col,childCnt[x]) * fac[childCnt[x]] )  % MOD;
      ans %= MOD;
      dfs2(x);
    }
  }
}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  COMinit();
  int n;
  cin >> n >> k;
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    a--,b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }

  dfs(0,0);
  memset(used,false,sizeof(used));
  // cout << "COM" << 1+ childCnt[0] << " " << k << endl;
  ans *= COM(k,1+childCnt[0]) * fac[childCnt[0]+1];
  dfs2(0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 22016
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <math.h>
#include <unordered_map>
#include <unordered_set>
//#define local
#ifdef local
#include "dbg-macro/dbg.h"
#endif
//#define hacks
#ifdef hacks
#include <boost/multiprecision/cpp_int.hpp>
#endif
#define p std::pair
#define ll long long
#define ull unsigned long long
#define pi (acos(-1))
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
#define vec std::vector
#define oreq |=
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
ll extgcd(ll a, ll b, ll &x, ll &y);
ll nCr(ll n, ll r);
void stat();
constexpr ll mod = 1000000000 + 7;
int main()
{
    stat();
    int n, k;
    cin >> n >> k;
    ll ans=k;
    rep(i,n-1){
	    ans*=(k-1);
    }
    cout<<ans<<endl;
    return 0;
}
ll extgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) { is_prime[i] = true; }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++)
    {
        if (is_prime[i])
        {
            for (unsigned ll j = 2 * i; j <= N; j += i) { is_prime[j] = false; }
            P.emplace_back(i);
        }
    }
    return P;
}

void stat() {
#ifdef local
    rep(i, 2) {std::cout << "local enable" << std::endl;
}
#endif
#ifdef hacks
rep(i, 2) { std::cout << "boost enable" << std::endl; }
#endif
}

ll nCr(ll n, ll r)
{
    ll num = 1;
    for (ll i = 1; i <= r; i++) { num = num * (n - i + 1) / i; }
    return num;
}


Measured memory_bytes: 3612
#include <iostream>
using namespace std;
int main() {
   string S,T,U;
   int A,B;
   cin>>S>>T;
   cin>>A>>B;
   cin>>U;
if (A>=1 && A<=10 && B>=1&& B<=10){
     if (S==U){
         A=A-1;
         cout<<A<<' '<<B;
     }
     if (T==U){
        B=B-1;
        cout<<A<<' '<<B;
     }
}

   }


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

int main(){
  int N,count;
  cin >> N;
  for(int i=1;i<=N;i++){
    int p;
    cin >> p;
    if(p!=i) count++;
  }
  if(count==0||count==2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<utility>
#include<set>
#include<bitset>
#include<vector>
#include<functional>
#include<deque>
#include<cctype>
#include<climits>
#include<complex>
#include<bits/stdc++.h>
#include<ctime>

using namespace std;

typedef long long LL;
typedef double DB;
typedef pair<int,int> PII;
typedef pair<DB,DB> PDD;
typedef complex<DB> CP;
typedef vector<int> VI;

#define mmst(a,v) memset(a,v,sizeof(a))
#define mmcy(a,b) memcpy(a,b,sizeof(a))
#define fill(a,l,r,v) fill(a+l,a+r+1,v)
#define re(i,a,b)  for(i=(a);i<=(b);i++)
#define red(i,a,b) for(i=(a);i>=(b);i--)
#define fi first
#define se second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define two(k) (1<<(k))
#define SZ(x) (int(x.size()))
#define all(x) (x).begin(),(x).end()
#define ire(i,v,x) for(i=0,v=i<SZ(x)?x[i]:0;i<SZ(x);v=x[++i])
#define ls (rt<<1)
#define rs (rt<<1|1)
#define MID ((l+r)>>1)

template<class T>inline T sqr(T x){return x*x;}
template<class T>inline void upmin(T &t,T tmp){if(t>tmp)t=tmp;}
template<class T>inline void upmax(T &t,T tmp){if(t<tmp)t=tmp;}

inline int sgn(DB x){if(fabs(x)<1e-9)return 0;return(x>0)?1:-1;}
const DB Pi=acos(-1.0);

int gint()
  {
		int res=0;bool neg=0;char z;
		for(z=getchar();z!=EOF && z!='-' && !isdigit(z);z=getchar());
		if(z==EOF)return 0;
		if(z=='-'){neg=1;z=getchar();}
		for(;z!=EOF && isdigit(z);res=(res<<3)+(res<<1)+z-'0',z=getchar());
		return (neg)?-res:res;
	}
LL gll()
  {
  	LL res=0;bool neg=0;char z;
		for(z=getchar();z!=EOF && z!='-' && !isdigit(z);z=getchar());
		if(z==EOF)return 0;
		if(z=='-'){neg=1;z=getchar();}
		for(;z!=EOF && isdigit(z);res=res*10+z-'0',z=getchar());
		return (neg)?-res:res;
	}
int gdb()
  {
  	string s;
  	cin>>s;
  	size_t p=s.find('.');
  	if(p==string::npos)
  	  s+="000";
  	else
  	  {
  	  	int d=s.length()-p-1;
  	  	s=s.substr(0,p)+s.substr(p+1);
  	  	while(d<3)s+="0",d++;
  	  }
  	istringstream is(s);
  	int res=0;
  	is>>res;
  	return res;
  }

const int maxn=2100;

int n,m;
char s[maxn][maxn];
int a[maxn][maxn],b[maxn][maxn];

int sta[maxn],top;
int ld[maxn],rd[maxn];

int solve(int *b,int m)
  {
  	int i;
  	b[sta[top=1]=0]=-1;
  	re(i,1,m)
  	  {
  	  	while(top && b[sta[top]]>=b[i])top--;
  	  	ld[i]=sta[top];
  	  	sta[++top]=i;
  	  }
  	b[sta[top=1]=m+1]=-1;
  	red(i,m,1)
  	  {
  	  	while(top && b[sta[top]]>=b[i])top--;
  	  	rd[i]=sta[top];
  	  	sta[++top]=i;
  	  }
  	int res=0;
  	re(i,1,m)if(b[i]) upmax(res,(rd[i]-ld[i])*(b[i]+1));
  	return res;
  }

int main()
  {
  	/*freopen("F.in","r",stdin);
  	freopen("F.out","w",stdout);*/
  	int i,j;
  	n=gint();m=gint();
  	re(i,1,n)scanf("%s",s[i]+1);
  	re(i,1,n-1)re(j,1,m-1)a[i][j]=(s[i][j]=='#')^(s[i+1][j]=='#')^(s[i][j+1]=='#')^(s[i+1][j+1]=='#');
  	re(i,1,n-1)re(j,1,m-1)b[i][j]=a[i][j]?0:b[i-1][j]+1;
  	int ans=max(n,m);
  	re(i,1,n-1)upmax(ans,solve(b[i],m-1));
  	cout<<ans<<endl;
  	return 0;
  }

  	

Measured memory_bytes: 38784
#include <stdio.h>


#define SIZE 200000


int main()
{
  int n, m, i, a, b;
  int aa[SIZE]={0}, bb[SIZE]={0};
  int flag=1;

  scanf("%d %d", &n, &m);
  for (i=0; i<m; i++){
    scanf("%d %d", &a, &b);
    if (a == 1) aa[b] = 1;
    if (b == n) bb[a] = 1;
  }

  for (i=0; i<SIZE; i++){
    if (aa[i] == 1 && bb[i] == 1){
      printf("POSSIBLE\n");
      flag--;
      break;
    }
  }

  if (flag) printf("IMPOSSIBLE\n");

  return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    string s;
    cin >> s;
    int n = s.size() - 1;
    if (s[n] == 's') {
        cout << s << "es\n";
    } else {
        cout << s << "s\n";
    }
}

Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC optimize("Ofast")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <random>
#include <cassert>
#include <complex>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef complex <LD> cld;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

/////////////////////////////////////////////////////////////////////

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

template <typename T1, typename T2>
T2 sum_mod(T1 x, T2 MOD) {
	if (x < 0)
		x += MOD;
	if (x >= MOD)
		x -= MOD;
	return x;
}

template <typename T1, typename T2>
T2 mul_mod(T1 x, T2 MOD) {
	if (x < 0)
		return (abs(x) % MOD == 0 ? 0 : MOD - abs(x) % MOD);
	return x % MOD;
}

template <typename T>
bool uax(T& a, const T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T>
bool uin(T& a, const T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

mt19937_64 gen_rand;

const int N = (int)1e5 + 7;
const int LOG = 20;
const int N_ = (int)8e2 + 7;
const int MAXN = (int)5e5 + 7;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9 + 7;
const int CONST = 300;
const LL LINF = (i64)2e15;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1e-6;

/////////////////////////////////////////////////////////////////////

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
	gen_rand.seed(0);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	gen_rand.seed(time(0));
#endif

	int n; cin >> n;
	string s; cin >> s;
	int ans = 0;
	for (int i = 0; i < n - 2; i++) {
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
			ans++;
	}
	cout << ans;

#ifdef _DEBUG 
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

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

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

    if (a <= 5) {
        cout << 0 << endl;
    } else if(a >= 6 && a <= 12) {
        cout << b / 2 << endl;
    } else {
        cout << b << endl;
    }
}


Measured memory_bytes: 256
using System;

public class MainAppB
{
    static public void Main(string[] args)
    {
        var k = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();
        if(s.Length <= k) {
            Console.WriteLine(s);
        }
        else {
            var s2 = s.Substring(0, k) + "...";
            Console.WriteLine(s2);
        }
    }
}



Measured memory_bytes: 17636
#include<iostream>

using namespace std;

int main(void) {
	int n, r;
	int p = 0;

	cin >> n;
	r = n;

	while (n != 0) {
		p += n % 10;
		n /= 10;
	}

	if (r%p == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<map>
#include<queue>
#define N 3
#define N2 9
using namespace std;

struct Puzzle{
  int f[N2];
  int space;
  string path;
  bool operator < (const Puzzle &p)const{
    for(int i=0;i<N2;i++){
      if(f[i]==p.f[i])continue;
      return f[i]>p.f[i];
    }
    return false;
  }
};

static const int dx[4]={-1,0,1,0};
static const int dy[4]={0,-1,0,1};
static const char dir[4]={'u','l','d','r'};

bool isTarget(Puzzle p){
  for(int i=0;i<N2;i++)
    if(p.f[i]!=(i+1))return false;
  return true;
}

string bfs(Puzzle s){
  queue<Puzzle>Q;
  map<Puzzle,bool>V;
  Puzzle u,v;
  s.path="";
  Q.push(s);
  V[s]=true;
  
  while(!Q.empty()){
    u=Q.front();
    Q.pop();
    if(isTarget(u))return u.path;
    int sx=u.space/N;
    int sy=u.space%N;
    for(int r=0;r<4;r++){
      int tx=sx+dx[r];
      int ty=sy+dy[r];
      if(tx<0||ty<0||tx>=N||ty>=N)continue;
      v=u;
      swap(v.f[u.space],v.f[tx*N+ty]);
      v.space=tx*N+ty;
      if(!V[v]){
	V[v]=true;
	v.path+=dir[r];
	Q.push(v);
      }
    }
  }
  return "unsolvable";
}

int main(){
  Puzzle in;
  for(int i=0;i<N2;i++){
    scanf("%d",&in.f[i]);
    if(in.f[i]==0){
      in.f[i]=N2;
      in.space=i;
    }
  }
  string ans=bfs(in);
  printf("%lu\n",ans.size());
  return 0;
}

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

using namespace std;

typedef long long ll;

const int maxn = 2e5 + 10;
int n, a[maxn];
ll par[maxn];

int main(){	
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		a[i] -= i + 1;
	}
	sort(a, a + n);
	for (int i = 0; i < n; ++i)
		par[i + 1] = par[i] + a[i];
	ll ans = 1e18;
	for (int i = 0; i < n; ++i) {
		ll k = ll(i - (n - i - 1)) * a[i] - par[i];
		k += par[n] - par[i + 1];
		ans = min(ans, k);
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 2560
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

N = ii()
nums = [0 for _ in range(5)]
ans = 0

for _ in range(N):
  s = input()
  if s[0] == 'M':
    nums[0] += 1
  elif s[0] == 'A':
    nums[1] += 1
  elif s[0] == 'R':
    nums[2] += 1
  elif s[0] == 'C':
    nums[3] += 1
  elif s[0] == 'H':
    nums[4] += 1

for i, j, k in combinations(range(5), 3):
  ans += nums[i] * nums[j] * nums[k]

print(ans)




Measured memory_bytes: 41836
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define x first
#define y second
#define PII pair < int , int >
#define PLL pair < ll , ll >
#define MOD 1000000007
#define rc(x) return cout << x, 0

using namespace std;

ll n, a[55];
ll cnt, rs;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    while (1){
        sort(a+1, a+n+1, [&](ll a, ll b){return a > b;});
        if (a[1] < n) return cout << rs, 0;
        cnt = a[1] / n;
        rs += cnt;
        a[1] %= n;
        for (int i = 2; i <= n; i++) a[i] += cnt;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define inf 99999999

long long dist[205][205] ;
long long solve(int last,vector<int> r,int done,long long ans ){
 int bit = r.size() ;
 if(done == (1<<bit)-1) { return ans ;}
 long long tor = inf ;
 for(int i = 0  ; i< bit ; i++){
    if(!(done&(1<<i))) tor = min(tor,solve(r[i],r,(done|(1<<i)),ans+dist[last][r[i]])) ;
 }
 return tor ;
}

int main()
{
   int n,m,r ;
   cin>>n>>m>>r ;
   vector<int> des ;
   long long graph[n+1][n+1] ;
   for(int i = 0 ; i< n+1 ; i++){
    for(int j = 0 ; j< n+1 ; j++){
        graph[i][j] = inf ;
        dist[i][j] = inf ;
    }
    dist[0][i] = 0 ; dist[i][0] = 0 ;
   }
   for(int i = 0 ; i< r ; i++){
    int c ; cin>>c ;
    des.push_back(c) ;
   }
   for(int i = 0 ; i< m ; i++){
    int x,y ; long long c ;
    cin>>x>>y>>c ;
    graph[x][y] = c ;
    graph[y][x] = c ; dist[y][x] = c ;
    dist[x][y] = c ;
   }
   bool vis[r+1] ;
   for(int i = 0 ; i<= r ; i++)vis[i] = false ;
   for (int k = 1; k <= n; k++)
    {
        for (int i = 1; i <= n; i++)
        {
            for (int j = 1; j <= n; j++)
            {
                if (dist[i][k] + dist[k][j] < dist[i][j])
                    dist[i][j] = dist[i][k] + dist[k][j];
            }
        }
    }
    long long ans = solve(0,des,0,0) ;
    cout<<ans<<endl ;

    return 0;
}


Measured memory_bytes: 896
#include<stdio.h>
#include<math.h>

typedef struct point{
    double x;
    double y;
}Point;

void koch(int n,Point a,Point b){
    if(n==0)
        return;
    
    Point s,t,u;
    double th;
    
    th=M_PI*60.0/180.0;
    
    s.x=(2.0*a.x+1.0*b.x)/3.0;
    s.y=(2.0*a.y+1.0*b.y)/3.0;
    t.x=(1.0*a.x+2.0*b.x)/3.0;
    t.y=(1.0*a.y+2.0*b.y)/3.0;
    u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
    u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;
    
    koch(n-1,a,s);
    printf("%.8f %.8f\n",s.x,s.y);
    koch(n-1,s,u);
    printf("%.8f %.8f\n",u.x,u.y);
    koch(n-1,u,t);
    printf("%.8f %.8f\n",t.x,t.y);
    koch(n-1,t,b);
}

int main(){
    Point a,b;
    int n;
    
    scanf("%d",&n);
    
    a.x=0;
    a.y=0;
    b.x=100;
    b.y=0;
    
    printf("%.8f %.8f\n",a.x,a.y);
    koch(n,a,b);
    printf("%.8f %.8f\n",b.x,b.y);
    
    return 0;
}





Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, X;
  cin >> N >> X;
  int count = 1, now = 0, a;
  for(int i = 0; i < N; i++){
    cin >> a;
    if(X >= a + now){
      count++;
      now += a;
    } else break;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import math

a, b = map(int, input().split())

a_min = math.ceil(a / 0.08)
a_max = math.ceil((a + 1) / 0.08)

b_min = math.ceil(b / 0.10)
b_max = math.ceil((b + 1) / 0.10)

if (b_min < a_max and a_min < b_max):
    print(max(a_min, b_min))
else:
    print(-1)


Measured memory_bytes: 3064
import sys,queue,math,copy,itertools,bisect,collections
from heapq import *

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**5
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    N,M = LI()
    root = [[] for _ in range(N)]
    for i in range(M):
        a,b,c = LI()
        root[a-1].append((b-1,c,i))
        root[b-1].append((a-1,c,i))

    rest = [1] * M
    q = []
    heapify(q)

    for i in range(N):
        node = [INF] * N
        heappush(q,(0,i,-1))
        while q:
            d,v,m = heappop(q)
            if node[v] < d: continue
            if m >= 0: rest[m] = 0
            for u,c,n in root[v]:
                if d + c < node[u]:
                    node[u] = d + c
                    heappush(q,(d+c,u,n))
    print(sum(rest))




if __name__ == '__main__':
    main()

Measured memory_bytes: 51032
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }

int k[10];
int s[10][10];
int p[10];

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

  int n, m; cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    cin >> k[i];
    for (int j = 0; j < k[i]; ++j) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < m; ++i) cin >> p[i];
  
  int ans = 0;

  for (int i = 0; i < (1<<n); ++i) {
    int switch_on = 0;
    for (int j = 0; j < m; ++j) {
      int cnt = 0;
      for (int bit = 0; bit < n; ++bit) {
        for (int l = 0; l < k[j]; ++l) {
          if (i & (1<<bit) && (bit + 1) == s[j][l]) {
            ++cnt;
          }
        }
      }
      switch_on += (cnt % 2 == p[j]);
    }
    ans += switch_on == m;
  }

  print(ans);

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=1e9+5;
const int N=2e5+5;
const ll oo=1e18+5;
const ll mod=1e9+7;

vector<int> v[N];
vector<int> sizee;
vector<int> cnt;
vector<int> c;
vector<map<int,int>> dp;
vector<vector<ll>> res;

void dfs(int u,int par){
	for(int x:v[u]){
		if(x==par) continue;
		dfs(x,u);
		cnt[u]+=cnt[x];
		int tmpcnt=cnt[x];
		if(dp[x].count(c[x])) tmpcnt-=dp[x][c[u]];
		res[c[u]].push_back(tmpcnt);
		if((int)dp[u].size()<(int)dp[x].size()) swap(dp[u],dp[x]);
		for(auto& xx:dp[x]) dp[u][xx.first]+=xx.second;
	}
	++cnt[u];
	dp[u][c[u]]=cnt[u];
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	sizee.resize(n);
	cnt.resize(n);
	c.resize(n);
	res.resize(n);
	dp.resize(n);
	for(int& x:c) cin>>x,--x;
	for(int i=0;i<n-1;++i){
		int x,y;
		cin>>x>>y;
		--x;
		--y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs(0,-1);
	for(int i=0;i<n;++i) res[i].push_back(n-dp[0][i]);
	vector<ll> ans(n,1ll*n*(n+1)/2);
	for(int i=0;i<n;++i){
		for(ll x:res[i]) ans[i]-=x*(x+1)/2;
		cout<<ans[i]<<" ";
	}
	return 0;
}


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

int main() {
	string S;
	cin >> S;
	string check = "No";
	if (S.size() % 2 == 0) {
		check = "Yes";
		for (int i = 0;i < S.size();i += 2) {
			if (S.at(i) != 'h' || S.at(i + 1) != 'i') {
				check = "No";
			}
		}
	}
	cout << check << endl;
	return 0;
}

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

using namespace std;

int main(){
    long long n;
    cin >> n;
    vector<long long> a(n), b(n), c, d;
    for(long long i = 0; i < n; i++){
        cin >> a[i];
    }
    for(long long i = 0; i < n; i++){
        cin >> b[i];
    }
    long long ans = 0;
    for(long long i = 0; i <= 28; i++){
        c = a;
        d = b;
        long long m = 1;
        m = m << (i + 1);
        for(long long j = 0; j < n; j++){
            c[j] %= m;
            d[j] %= m;
        }
        sort(d.begin(), d.end());
        long long t = m >> 1;
        long long cnt = 0;
        for(long long j = 0; j < n; j++){
            long long l1 = lower_bound(d.begin(), d.end(), t - c[j]) - d.begin();
            long long r1 = lower_bound(d.begin(), d.end(), 2 * t - c[j]) - d.begin();
            long long l2 = lower_bound(d.begin(), d.end(), 3 * t - c[j]) - d.begin();
            long long r2 = lower_bound(d.begin(), d.end(), 4 * t - c[j]) - d.begin();
            cnt += r1 - l1 + r2 - l2;
        }
        ans += cnt % 2 * t;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8576
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

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

int n;
ll a[100010][3] ,dp[100010][3];

int main(void){
    cin >> n;
    REP(i, n) REP(j, 3) cin >> a[i][j];

    REP(i, n){
        REP(j, 3){
            REP(k, 3){
                if(j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    ll ans = 0;
    REP(i, 3) chmax(ans, dp[n][i]);
    cout << ans << endl;
}

Measured memory_bytes: 4992
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        
        int a = scan.nextInt();
        int b = scan.nextInt();
        
        System.out.printf(a/b + " " + a%b + " %.10f", (double)a/(double)b);
    }
}


Measured memory_bytes: 26572
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,a[200005];
map<ll,ll>m;
map<ll,ll>viz;
map<ll,ll>val;
int32_t main(){
CODE_START;
cin>>n;
for(ll i=0;i<n;i++)
{
    cin>>a[i];
    m[a[i]]++;
}
ll ans=0;
for(ll i=0;i<n;i++)
{
    if(viz[a[i]]==0){
              val[a[i]]=m[a[i]];
    m[a[i]]=m[a[i]]*(m[a[i]]-1)/2;
    }
    if(viz[a[i]]==0){
    ans=ans+m[a[i]];
    viz[a[i]]=1;
    }
}
for(ll i=0;i<n;i++)
{
    ll x=ans-m[a[i]];
    cout<<x+((val[a[i]]-1)*(val[a[i]]-2)/2)<<endl;
}
}


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

using namespace std;

int main()
{
    vector<int> W,K;
    int temp;

    for(int i=0; i<10; ++i) {
        cin >> temp;
        W.push_back(temp);
    }

    for(int i=0; i<10; ++i) {
        cin >>temp;
        K.push_back(temp);
    }

    sort(W.rbegin(),W.rend());
    sort(K.rbegin(),K.rend());

    cout << W[0]+W[1]+W[2] << " " << K[0]+K[1]+K[2] << endl;

    return 0;
}

Measured memory_bytes: 3144
import java.util.*;
public class Main{
    public static void main(String[] args) {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        int length = a.length();

        String afterA = a;

        for(int i=0; i<length; i++){
            char charA = afterA.charAt(length-1);
            afterA = charA + afterA.substring(0,length-1);
            if(afterA.equals(b)){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}


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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()


void solve(long long N, std::vector<std::string> S){
    sort(all(S));
    i64 ans = 1;
    rep(i, 1, S.size()){
        if(S[i] != S[i - 1]) ++ans;
    }
    cout << ans << endl;
}

struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  int L,R;
  L = A+B;  
  R = C+D;
  
  if (L > R) {
    cout << "Left" << endl;
  }
  else if (L == R) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" <<endl;
  }
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,c,k;
	cin>>n>>c>>k;
	vi in(n);
	rep(i,n)cin>>in[i];
	sort(all(in));
	int out=0;
	int co=0;
	rep(i,n){
		if(in[i]-in[i-co]<=k)co++;
		else co=c+1;
		if(co>=c){
			co-=c;
			out++;
		}
	}
	if(co)out++;
	cout<<out<<endl;
}








Measured memory_bytes: 1024
//waz
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))
 
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;
 
#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))
 
int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

int n, a[100010];

int main() 
{
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", a + i);
	sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1);
	for (int i = 1; i <= n; ++i)
	{
		if (i + 1 > a[i + 1])
		{
			int j = i + 1, ans = 0;
			for (; a[j] == i; ++j) ans ^= 1;
			if ((ans || ((a[i] - i) & 1))) puts("First");
			else puts("Second");
			break;
		}
	}
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ALL(s)  (s).begin(),(s).end()

int main() {
	int N, L;
	cin >> N >> L;
	
	vector<int> a(N);

	for (int i = 0; i < N; i++) {
		a[i] = L + i;
	}

	int sum = 0;
	for (int i = 0; i < N; i++) {
		sum += a[i];
	}

	int tmp = sum;
	int min = 10000;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		sum = tmp;
		sum -= a[i];
		if (abs(tmp - sum) < min) {
			min = abs(tmp - sum);
			ans = sum;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
//doaremon,squirtle is love
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define testcase ll t;cin>>t;while(t--)
#define input(x) ll x;cin>>x;
#define output(x) cout<<x<<endl;//to print (-1)
#define inputarray() ll n;cin>>n;ll arr[n];rep(0,n)cin>>arr[i];
#define deb(a) cout<<" :: "<<#a<<" = "<<a<<endl
#define deb2(a,b) cout<<" :: "<<#a<<" = "<<a<<" :: "<<#b<<" = "<<b<<endl
#define setbit(x)  __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<long long int,long long int>
#define ub upper_bound // '>'
#define lb lower_bound // '>='
//erase,count,find,make_unique
#define len(arr) (sizeof(arr)/sizeof(arr[0]))
#define sz(x) ((long long)x.size())
#define make_unique(arr) arr.erase(unique(arr.begin(),arr.end()),arr.end()) //Makes a sorted array unique
#define rep(a,b) for(int i=a;i<b;i++)
#define updiv(a,b) (ceil)((a)*(1.0)/(b))
#define printarray(arr) cout<<"PRINT ARRAY"<<endl; rep(0,len(arr)) cout<<arr[i]<<" "; cout<<endl;
#define printvector(vect) cout<<"PRINT VECTOR"<<endl; for(auto x:vect) cout<<x<<" "; cout<<endl;
#define rev(x) reverse(all(x))
//LLONG_MAX, ULLONG_MAX INT_MAX
typedef long long int ll;
typedef unsigned long long int ull;
#define M 1000000007
using namespace std;
int main()
{
    fast


        ll n,k,a,b;
    cin>>n>>k;
    n=(n%k);
      if(n<k)
    {
        a=n;
        b=k-n;}

cout<<min(a,b)<<endl;

}










Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>


#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

void add_reverse(string& s, string& t) {
	FOR_LT(i, 0, t.size()) {
		s += t[t.size() - i - 1];
	}
}

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

	string s; cin >> s;
	int n; cin >> n;

	string sb, se;
	bool t = 0;
	FOR_LT(i, 0, n) {
		int sn; cin >> sn;
		if (sn == 1) t = 1 - t;
		if (sn == 2) {
			int m; cin >> m;
			char c; cin >> c;
			bool tn = (t ^ (m - 1));
			if (!tn) {
				sb += c;
			}
			else {
				se += c;
			}
		}
	}

	string ans;
	if (!t) {
		add_reverse(ans, sb);
		ans += s;
		ans += se;
	}
	else {
		add_reverse(ans, se);
		add_reverse(ans, s);
		ans += sb;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1428
import math


def resolve():
    A, B = map(int, input().split())

    for i in range(10000):
        tmp_8 = math.floor(i * 0.08)
        tmp_10 = math.floor(i * 0.1)

        if (tmp_8 > 0 and tmp_10 > 0 and tmp_8 == A and tmp_10 == B):
            print(i)
            return

    print(-1)


resolve()

Measured memory_bytes: 3060
n = int(raw_input())
 
d = [0 for i in range(n)]
f = [0 for i in range(n)]
G = [0 for i in range(n)]
M = [[0 for i in range(n)] for j in range(n)]
st = [0 for i in range(n)]
t = [0]
 
def DFS_visit(s):
    st[s] = 1
    t[0] += 1
    d[s] = t[0]
    for e in range(n):
        if M[s][e] == 1 and st[e] == 0:
            DFS_visit(e)
    st[s] == 2
    t[0] += 1
    f[s] = t[0]
 
def DFS():
    for s in range(n):
        if st[s] == 0:
            DFS_visit(s)
    for s in range(n):
        print'{0} {1} {2}'.format(s+1, d[s], f[s])
     
for i in range(n):
    G = map(int, raw_input().split())
    for j in range(G[1]):
        M[G[0]-1][G[2+j]-1] = 1
 
DFS()

Measured memory_bytes: 6592
fun main(arg: Array<String>) {
    val K = nextInt()
    val ans = IntArray(K) { Int.MAX_VALUE }
    val visit = BooleanArray(K)
    val deque = java.util.LinkedList<Int>()
    ans[1] = 1
    deque.addLast(1)
    while (!deque.isEmpty()) {
//System.err.println(deque.asIterable().joinToString())
        val e = deque.pollFirst()!!
        if (visit[e]) continue
        visit[e] = true
        if (ans[e] < ans[(e * 10) % K]) {
            ans[(e * 10) % K] = ans[e]
            deque.addFirst((e * 10) % K)
        }
        if (ans[e] + 1 < ans[(e + 1) % K]) {
            ans[(e + 1) % K] = ans[e] + 1
            deque.addLast((e + 1) % K)
        }
    }
    println(ans[0])
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt(d: Int = 0) = listOfString().map { Integer.parseInt(it) + d }
fun listOfLong() = listOfString().map(String::toLong)


Measured memory_bytes: 40552
import math
a,b,h,m = map(int, input().split())

ans = 0
a_a = (h+m/60)/12*2*math.pi
a_b = m/60*2*math.pi

ans = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(abs(a_a-a_b)))
print(ans)


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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll a, b;
  while(cin >> a >> b) {
    cout << to_string(a + b).size() << endl;
  }
	return 0;
}


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

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  string s;
  cin >> s;

  int sum=0;
  if(s[0]=='1') sum++;
  if(s[1]=='1') sum++;
  if(s[2]=='1') sum++;

  cout<<sum<<endl;

}

Measured memory_bytes: 256