akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cctype>
#define qmin(x,y) (x=min(x,y))
#define qmax(x,y) (x=max(x,y))
using namespace std;

inline char gc() {
//  static char buf[100000],*p1,*p2;
//  return (p1==p2)&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
    return getchar();
}

template<class T>
int read(T &ans) {
    ans=0;char ch=gc();T f=1;
    while(!isdigit(ch)) {
        if(ch==EOF) return -1;
        if(ch=='-') f=-1;
        ch=gc();
    }
    while(isdigit(ch))
        ans=ans*10+ch-'0',ch=gc();
    ans*=f;return 1;
}

template<class T1,class T2>
int read(T1 &a,T2 &b) {
    return read(a)!=EOF&&read(b)!=EOF?2:EOF;
}

template<class T1,class T2,class T3>
int read(T1 &a,T2 &b,T3 &c) {
    return read(a,b)!=EOF&&read(c)!=EOF?3:EOF;
}

typedef long long ll;
const int Maxn=3100000;
const int inf=0x3f3f3f3f;
const ll mod=1000000007;

int tl[Maxn],tr[Maxn],n,m;
ll tn[Maxn],flag[Maxn];

void build(int root,int l,int r) {
    tl[root]=l;tr[root]=r;
    int mid=l+r>>1;
    if(l==r) return;
    build(root<<1,l,mid);
    build((root<<1)|1,mid+1,r);
}

inline void update(int root) {
    tn[root]=max(tn[root<<1],tn[(root<<1)|1]);
}

void pushdown(int root) {
    if(flag[root]) {
        flag[root<<1]+=flag[root];
        tn[root<<1]+=flag[root];
        flag[(root<<1)|1]+=flag[root];
        tn[(root<<1)|1]+=flag[root];
        flag[root]=0;
    }
}

ll query(int root,int x) {
    int l=tl[root],r=tr[root],mid=l+r>>1;
    if(r==x) return tn[root];
    pushdown(root);
    if(x<=mid) return query(root<<1,x);
    else return max(tn[root<<1],query((root<<1)|1,x));
}

void change(int root,int l,int r,ll x) {
    int lc=tl[root],rc=tr[root],mid=lc+rc>>1;
    if(l<=lc&&r>=rc) {
        flag[root]+=x;
        tn[root]+=x;
        return;
    }
    pushdown(root);
    if(l<=mid) change(root<<1,l,r,x);
    if(r>mid) change((root<<1)|1,l,r,x);
    update(root);
}

struct node {
    int l,r;
    ll x;
}b[Maxn];

int cmp(node a,node b) {
    return a.r<b.r;
}

signed main() {
//  freopen("test.in","r",stdin);
    read(n,m);
    for(int i=1;i<=m;i++)
        read(b[i].l,b[i].r,b[i].x);
    sort(b+1,b+m+1,cmp);
    build(1,1,n);
    int zhy=1,nh=1;
    for(int i=1;i<=n;i++) {
        change(1,i,i,query(1,i));
        while(b[nh].r==i) {
            change(1,b[nh].l,b[nh].r,b[nh].x);
            nh++;
        }
    }
    printf("%lld",max(tn[1],0ll));
    return 0;
}

Measured memory_bytes: 24704
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
	int x;
	cin >> x;
	if (x == 3 || x == 5 || x == 7) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace  std;

#define ll long long
#define ull unsigned long long
#define f first
#define s second
typedef pair<int , int > pii;
typedef pair<ll,ll> pll;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

const ll MOD = 1e9+7;

void min_self(ll &a , ll b){a=min(a,b);}
void max_self(ll &a, ll b){a=max(a,b);}
ll add(ll x, ll y){return (x + y) % MOD;}
ll sub(ll x, ll y){return add(x, MOD - y);}
ll mul(ll x, ll y){return (x * 1ll * y) % MOD;}
ll binpow(ll x, ll y)
{   ll z = 1;
    while(y > 0)
    {if(y % 2 == 1) z = mul(z, x);
        x = mul(x, x);
        y /= 2;
    }
    return z;
}
ll inv(ll x){return binpow(x, MOD - 2);}
const int MXN = 1e6+10;
ll fact[MXN];
void fac_pre()
{
    fact[0]=1;
    for(ll i=1; i<MXN; i++){
        fact[i]=mul(fact[i-1],i);
    }
}
ll C(ll n, ll k)
{
    return mul(fact[n], inv(mul(fact[k], fact[n - k])));
}

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

int  main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen ("output.txt","w",stdout);
    /* KEEP IN MIND
     * take care when sorting a 1 based indexed vector
     * use greater<ll> for ll's
    */
    int n,x,t; cin>>n>>x>>t;
    cout<<((n+x-1)/x)*t;



}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int MM=413;
long long pre[MM];
long long dp[MM][MM];

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    long long a;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a;
        pre[i]=pre[i-1]+a;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j+i<=n;j++)
        {
            dp[j][j+i]=1000000000000000013;
            for(int k=j;k<j+i;k++)
            {
                dp[j][j+i]=min(dp[j][j+i],dp[j][k]+dp[k+1][j+i]+pre[j+i]-pre[j-1]);
            }
        }
    }
    cout<<dp[1][n];
    return 0;
}


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

using namespace std;

using int64 = long long;
const int INF = 1 << 30;

string S;
int idx;

pair< int, int > expression(int low, int high)
{
  int last = INF;

  if(isdigit(S[idx])) {
    int left = S[idx] - '0';
    int right = (left == 0 ? 0 : left * 10 + 9);
    if(right <= low || high <= left) {
      last = idx;
    }
    ++idx;
    if(isdigit(S[idx])) {
      left = left * 10 + S[idx] - '0';
      last = min(last, idx);
      ++idx;
    } else {
      last = min(last, idx);
    }
    return {left, last};
  } else {
    bool ismin = S[idx] == '_';
    ++idx;
    ++idx;
    auto latte = expression(low, high);
    if(ismin) high = min(high, latte.first);
    else low = max(low, latte.first);
    if(low >= high) last = latte.second;
    ++idx;
    auto malta = expression(low, high);
    last = min(last, malta.second);
    ++idx;
    if(ismin) return {min(latte.first, malta.first), last};
    else return {max(latte.first, malta.first), last};
  }
}

int main()
{
  int Q;
  cin >> Q;
  while(Q--) {
    cin >> S;
    idx = 0;
    auto ret = expression(0, 99);
    cout << ret.first << " " << ret.second + 1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define PI (6.28318530718/2.0)
#define ft first
#define sec second
#define ll long long
#define pb push_back
using namespace std;
int t,n;
int main()
{
	cin >> n;
	cout << !n;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramB
    {
        static void Main()
        {
            int a = NextInt, b = NextInt, c = NextInt, d = NextInt;
            bool flag = true;
            while (Math.Min(a, c) > 0)
            {
                if (flag) c -= b;
                else a -= d;

                flag = !flag;
            }

            if (!flag) System.Console.WriteLine("Yes");
            else System.Console.WriteLine("No");
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


Measured memory_bytes: 27876
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N, ans=0; cin>>N;
  for(int i=1; i<=N; i++){
    if(i%3==0 || i%5==0)
      continue;
    ans+=i;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3620
use proconio::input;

fn main() {
    input! {
        n: usize
    }

    let (x,y,z) = {
        let mut x = 0;
        let mut y = 0;
        let mut z = 0;
        for i in 0..=3500 {
            for j in i..=3500 {
                if 4*i*j > n*(i+j) {
                    if (n*i*j) % (4*i*j - n*(i+j)) == 0 {
                        x = i;
                        y = j;
                        z = (n*i*j) / (4*i*j - n*(i+j));
                        break;
                    }
                }
            }
        }
        (x,y,z)
    };

    println!("{} {} {}",x,y,z)
    
}

Measured memory_bytes: 2172
#include<bits/stdc++.h>
using namespace std;
const int N=4e5+5;
int n,num,ans[N],rt[N],t[N*50],ls[N*50],rs[N*50],tot,a[N],hs[N],head[N],nex[N<<1],to[N<<1];
void add(int u,int v){to[++tot]=v;nex[tot]=head[u];head[u]=tot;}
int newnode(){return ++num;}
void Insert(int l,int r,int x,int v,int &now,int pre)
{
    if(!now) now=newnode(),t[now]=t[pre];
    t[now]=max(t[now],v);
    if(l==r) return;
    int m=l+r>>1;
    if(x<=m) Insert(l,m,x,v,ls[now],ls[pre]),rs[now]=rs[pre];
    else Insert(m+1,r,x,v,rs[now],rs[pre]),ls[now]=ls[pre];
}
int query(int l,int r,int x,int now)
{
    if(!now||l>x) return 0;
    if(r<=x) return t[now];
    int m=l+r>>1;
    return max(query(l,m,x,ls[now]),query(m+1,r,x,rs[now]));
}
void dfs(int u,int p)
{
    ans[u]=query(1,n,a[u]-1,rt[p])+1;
    Insert(1,n,a[u],ans[u],rt[u],rt[p]);
    ans[u]=max(ans[u],ans[p]);
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];if(v==p) continue;
        dfs(v,u);
    }
}
void build(int l,int r,int &now)
{
    now=newnode();
    if(l==r) return;
    int m=l+r>>1;
    build(l,m,ls[now]);build(m+1,r,rs[now]);
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]),hs[i]=a[i];
    sort(hs+1,hs+1+n);
    for(int i=1;i<=n;i++) a[i]=lower_bound(hs+1,hs+1+n,a[i])-hs;
    build(1,n,rt[0]);
    for(int i=1;i<n;i++)
    {
        int u,v;scanf("%d%d",&u,&v);add(u,v);add(v,u);
    }
    dfs(1,0);
    for(int i=1;i<=n;i++) printf("%d\n",ans[i]);
}


Measured memory_bytes: 66048
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9;

int h, w;
int dp[51][51];
char fie[51][51];
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};

void dfs(int y, int x){
	rep(i,4){
		int ny = y + dy[i];
		int nx = x + dx[i];
		if(ny < 0 || h <= ny || nx < 0 || w <= nx) continue;
		if(fie[ny][nx] == '#') continue;
		if(dp[ny][nx] > dp[y][x]+1){
			dp[ny][nx] = dp[y][x] + 1;
			dfs(ny, nx);
		}
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> h >> w;
	int ans = h*w;
	rep(i,h)rep(j,w){
		cin >> fie[i][j];
		dp[i][j] = INF;
		if(fie[i][j] == '#') ans--;
	}
	if(fie[0][0] == '#' || fie[h-1][w-1] == '#'){
		cout << -1 << endl;
		return 0;
	}
	dp[0][0] = 1;
	dfs(0, 0);
	if(dp[h-1][w-1] == INF){
		cout << -1 << endl;
		return 0;
	}
	ans -= dp[h-1][w-1];
	cout << ans << endl;
	return 0;
}

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

int main(){
	int n;
	while(cin >> n,n){
		vector<double> a(n);
		rep(i,n) cin >> a[i];

		double ave = accumulate(a.begin(), a.end(), 0.0) / n;

		int ans = 0;
		rep(i,n){
			if(ave >= a[i]) ans++;
		}
		cout << ans << endl;
	}
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *max_element(all(a));}

template<class T>void puta(T&&t){cout<<t<<endl;}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void OUT(bool b){tf(b,"YES","NO");}
void Out(bool b){tf(b,"Yes","No");}
void out(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	vvl edge(n+1);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	vl d(n+1,-1);
	d[1]=0;
	queue<int> q;
	q.push(1);
	bool ok=true;
	while(!q.empty()){
		int p=q.front();
		q.pop();
		for(auto&e:edge[p]){
			if(d[e]!=-1 and (d[p]+1)%2!=d[e]%2){
				ok=false;
				goto fin;
			}else if(d[e]==-1){
				d[e]=d[p]+1;
				q.push(e);
			}
		}
	}
	fin:;
	//cout<<d<<endl;
	if(ok){
		ll x=0,y=0;
		range(i,1,n+1){
			if(d[i]%2==0)x++;else y++;
		}
		puta(x*y-m);
	}else{
		puta(n*(n-1)/2-m);
	}
	return 0;
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string data;
  int N,A,B;
  int ok = 0;
  int B_cnt = 1;
  cin >> N >> A >> B;
  cin >> data;
  
  for (int i=0; i<N; i++) {
    if (data[i] == 'c') {
      cout << "No" << endl;
    }
    
    if (data[i] == 'a') {
      if (ok < A+B) {
        cout << "Yes" << endl;
        ok++;
      }
      else {
        cout << "No" << endl;
      }
    }
    if (data[i] == 'b') {
      if ((ok < A+B)&&(B_cnt <= B)) {
        cout << "Yes" << endl;
        B_cnt++;
        ok++;
      }
      else {
        cout << "No" << endl;
      }
    } 
  }
}

Measured memory_bytes: 896
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	lint N;
	cin >> N;
	vector<lint>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	lint sum = 0;
	lint ans = 10000000000000000;
	for(int i=-100;i<=100;i++) {
		rep(j, N) {
			sum += pow(A[j] - i, 2);
		}
		ans = min(ans, sum);
		sum = 0;
	}
	cout << ans << endl;
}




Measured memory_bytes: 256
N = int(input())

possible = True

H = list(map(lambda x: int(x), input().split()))
H[0] -= 1

for i in range(N - 1):
	if H[i] > H[i + 1]:
		possible = False
		break
	elif H[i] < H[i + 1]:
		H[i + 1] -= 1

if possible:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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

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

int n,t;
bool cmp(P x,P y)
{
    return x.se*y.fi < x.fi*y.se;
}


int main(){
  int i,j;
  cin>>n>>t;
  t++;
  vector<P> v;
  VI h;
  for(i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    b++;
    if(a>=1) v.pb(P(a,b));
    else h.pb(b);
  }
  sort(v.begin(),v.end(),cmp);
  sort(h.begin(),h.end());
  VI ti;
  VI cn;
  ti.pb(0);
  cn.pb(0);
  for(i=0;i<h.size();i++){
    int tt=ti.back();
    ti.pb(tt+h[i]);
    int cc=cn.back();
    cn.pb(cc+1);
  }
  ti.pb(INF);
  cn.pb(-1);

  VI dp(50,inf);
  dp[0]=1;
  //for(i=0;i<ti.size();i++) cout<<ti[i]<<" ";
  //cout<<endl;
  //for(i=0;i<v.size();i++) cout<<v[i].fi<<" "<<v[i].se<<endl;

  for(i=0;i<v.size();i++){
    for(j=49;j>=0;j--){
      if(dp[j]==inf) continue;
      chmin(dp[j+1],dp[j]*(1+v[i].fi)+v[i].se);
    }
  }
  int ans=0;
  for(i=0;i<49;i++){
    if(dp[i]<=t){
      int y = t-dp[i];
      int u = upper_bound(ti.begin(),ti.end(),y)-ti.begin()-1;
      ans=max(ans,i+u);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 6768
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int arra[10],i;
    for(i=0;i<10;i++)
        cin>>arra[i];
    sort(arra,arra+10);
    for(i=9;i>6;i--)
        cout<<arra[i]<<endl;
    return 0;
}

Measured memory_bytes: 1176
import sys
from collections import deque
import collections
import numpy as np

n = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def hantei(n):
    i = 0
    if n == 1 or n==2:
        return 1
    while (i+1)*i/2<=n:
        i+=1
    return i-1

c = collections.Counter(prime_factorize(n))
ans = 0
#print(c)

for i in c.values():
    #print("val=",i)
    ans += hantei(i)
print(ans)


Measured memory_bytes: 27156
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char* argv[]) {
    int n;
    string s;
    cin >> n >> s;
    int res = 0;
    int status = 0;
    for (auto c: s) {
        switch (c) {
            case 'A': status = 1; break;
            case 'B': status = status == 1? 2:0; break;
            case 'C': if (status == 2)
                          ++res;
                      status = 0;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,a[102],n,m,t;
    int ss=0;
    scanf("%d",&n);

    for(i=0; i<n; i++)
     scanf("%d",&a[i]);

    for(i=0; i<n-1; i++)
    {
        m=i;
        for(j=n-1; j>=i+1; j--)
        {
            if(a[j]<a[j-1])
            {
                swap(a[j],a[j-1]);
                ss++;
            }
        }

    }

    for(i=0; i<n-1; i++)
    {
        printf("%d ",a[i]);
    }
    printf("%d\n",a[n-1]);
    printf("%d\n",ss);
    return 0;
}

Measured memory_bytes: 3232
n = int(input())
xn = []
yn = []
for i in range(n):
    x,y = map(int, input().split())
    xn.append(x)
    yn.append(y)
    

def kaijou(n):
    if n == 1:
        return 1
    else:
        return n * kaijou(n-1)
p = [2, 2*2, 2*2*3, 2*2*3*4,  2*2*3*4*5,  2*2*3*4*5*6, 2*2*3*4*5*6*7, 2*2*3*4*5*6*7*8]
ans = 0
for i in range(n-1):
    for j in range(i+1,n):
        #print(i+1 ,j+1)
        diff = (((xn[i] - xn[j]) ** 2) + ((yn[i] - yn[j]) ** 2)) ** 0.5
        #print(diff)
        ans += diff *  ( p[n-2])
nkaijou = kaijou(n)
print(ans/ nkaijou)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S,T;
  cin >> S >> T;
  bool flag = false;
  for(int i=0; i<S.size(); i++){
    S.push_back(S.at(0));
    S.erase(S.begin());
    if(S==T){
      flag = true;
      break;
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define all(v) (v).begin(),(v).end()
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 
const ll inf=1LL<<60;

int main() {
  ll i,j,k,N,ans=0;
  cin>>N;
  string s;
  mat G(N),g(N,vec(N));
  vec color(N,-1);
  rep(i,N){
    cin>>s;
    rep(j,N){
      g[i][j]=(s[j]=='1')?1:inf;
      if(g[i][j]==1){
        G[i].push_back(j);
      }
    }
    g[i][i]=0;
  }
  color[0]=0;
  queue<ll> que;
  que.push(0);
  while(!que.empty()){
    auto x=que.front();que.pop();
    for(auto i:G[x]){
      if(color[i]<0){
        color[i]=1-color[x];
        que.push(i);
      }else if(color[i]==color[x]){
        cout<<-1<<endl;
        return 0;
      }
    }
  }
  rep(k,N){
    rep(i,N){
      rep(j,N){
        chmin(g[i][j],g[i][k]+g[k][j]);
      }
    }
  }
  rep(i,N){
    chmax(ans,*max_element(all(g[i])));
  }
  cout<<ans+1<<endl;
  return 0;
}

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

const int N = 1000 * 3;

long long n, x, sum, ans;
long long dp[N][N], a[N];

int main() {
	cin >> n >> x;
	for (int i = 0; i < n; i++) 
		cin >> a[i];
	for (int i = 0; i < n; i++) {
		dp[0][i] = a[i];
		ans += a[i];
	}
	for (int j = 1; j < n; j++) {
		sum = j * x;
		dp[j][0] = min(a[0], dp[j - 1][n - 1]);
		sum += dp[j][0];
		for (int i = 1; i < n; i++) {
			dp[j][i] = min(a[i], dp[j - 1][i - 1]);
			sum += dp[j][i];
		}
		ans = min(ans, sum);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 46976
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }

int main() {
   int R, G, B, N;
   cin >> R >> G >> B >> N;

   int cnt = 0;
   for (int r = 0; r <= N / R; r++) {
      for (int g = 0; g <= N / G; g++) {
         int tmp = r * R + g * G;
         if ((N - tmp) % B == 0 && N - tmp >= 0) {
            cnt++;
         }
      }
   }
   cout << cnt << endl;
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in a,b,c;
  cin>>a>>b>>c;
  forn(z,1000){
    if(a%2 || b%2 || c%2){
      cout<<z<<endl;
      return 0;
    }
    in ta=(b+c)/2;
    in tb=(a+c)/2;
    in tc=(a+b)/2;
    a=ta;
    b=tb;
    c=tc;
  }
  cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 764
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n, m; cin >> n >> m;
  int mx = n / 2 - (n % 2 == 0);
  vector<pair<int, int>> ans(mx);
  int r = (mx + 1) / 2 * 2;
  for (int a = 1; a < r + 1 - a; ++a) ans[r + 1 - a - a - 1] = {a, r + 1 - a};
  int now = 2;
  for (int a = (r + 1 + n + 1) / 2 - 1; a > r; --a) {
    if (now <= ans.size()) ans[now - 1] = {a, a + now};
    now += 2;
  }
  REP(i, m) cout << ans[i].first << ' ' << ans[i].second << '\n';
  return 0;
}


Measured memory_bytes: 3940
def changeSecond(time)
  splitedTime = time.split(":").map(&:to_i)
  secondTime = 60*60*splitedTime[0] + 60*splitedTime[1] + splitedTime[2]
  return secondTime
end

oneDaySecond = 60*60*24
loop do
  n = gets.chomp.to_i
  break if n == 0

  s = Array.new(oneDaySecond,0)
  (0..n-1).each do |i|
    start, finish = gets.chomp.split(" ").map(&:to_s)
    start = changeSecond(start)
    finish = changeSecond(finish)
    s[start] += 1
    s[finish] += -1
  end 
  (0...oneDaySecond-1).each do |j|
    s[j+1] += s[j]
  end
  p s.max
end



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

int main() {
  string S, T;
  cin >> S >> T;
  int s = S.size();
  int t = T.size();
  bool ans = true;
  rep(i, s) {
    if (S[i] != T[i]) {
      ans = false;
      break;
    }
  }
  if (ans && s != t-1) {
    ans = false;
  }
  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3548
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RSORT(x) sort(x.begin(), x.end(), std::greater<int>())
#define swap(a, b) \
  do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
#define vi vector<int>
using namespace std;

const double EPS = 1e-10;
const double PI  = acos(-1.0);

int C[3][3];

int main() {
  
  REP(i, 3) {
    REP(j, 3) {
      cin >> C[i][j];
    }
  }

  vi a;
  a.push_back(0);
  
  vi b;
  REP(i, 3) {
    b.push_back(C[0][i]);
  }

  REP(i, 2) {
    a.push_back(C[i+1][0] - b[0]);
  }
  
  REP(i, 3) {
    REP(j, 3) {
      if(C[i][j] != a[i] + b[j]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  
  cout << "Yes" << endl;
}


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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

int main(){

    int n, k;
    cin >> n >> k;
    vector<ll> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    ll ans = LINF;
    for(int i = 0; i < n-k+1; i++){
        ans = min(ans, h[i+k-1] - h[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
n,m,l = map(int, input().split())
mA = [[0 for i in range(m)] for j in range(n)]
mB = [[0 for i in range(l)] for j in range(m)]
mC = [[0 for i in range(l)] for j in range(n)]
for i in range(n):
  mA[i] = list(map(int, input().split()))
for j in range(m):
  mB[j] = list(map(int, input().split()))
for i in range(n):
  for j in range(l):
    for k in range(m):
      mC[i][j] += mA[i][k]*mB[k][j]
  print(" ".join(map(str, mC[i])))


Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
 
long long f(long long n){
  if(n<=0)return 0;
  if(n%2==1)return ((n+1)/2)%2;
  return f(n-1)^n;
}
 
int main(){
  long long a,b;
  cin>>a>>b;
  long long ans=f(a-1)^f(b);
  cout<<ans<<endl;
  
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

int N;
int num[100];
long long int dp[100][21];

int main() {
	ios::sync_with_stdio(false);
	cin >> N;
	for (int i = 0; i < N; i++)cin >> num[i];
	dp[0][num[0]] = 1;
	for (int i = 1; i < N - 1; i++) {
		for (int j = 0; j <= 20; j++) {
			if (j + num[i] <= 20)dp[i][j] += dp[i - 1][j + num[i]];
			if (j - num[i] >= 0)dp[i][j] += dp[i - 1][j - num[i]];
		}
	}
	cout << dp[N - 2][num[N - 1]] << endl;
	return 0;
}

Measured memory_bytes: 3232
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Globalization;
using System.Threading.Tasks;


class maki {
    static void Main(string[] args) {
        int[] cin=Console.ReadLine().Split().Select(int.Parse).ToArray();
        //int n = int.Parse(Console.ReadLine());
        //string s=Console.ReadLine();
        int a=0;
        for(int i=100;i>=1;i--){
            if(cin[0]%i==0 && cin[1]%i==0){
                a++;
                if(a==cin[2]){
                    Console.WriteLine(i);
                    return;
                }
            }
        }
        
    }
}


Measured memory_bytes: 13268
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int main(void){
	int a, b;
	cin >> a >> b;
	cout << (a+b)%24 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N=200010;
int n,m,k,fa[N],is[N],tot;
struct Q{
	int u,v,id;
	bool operator<(const Q&o)const{
		return id<o.id;
	}
}q[N];
int getfa(int x){
	return fa[x]==x?x:fa[x]=getfa(fa[x]);
}
int main(){
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=k;i++){
		scanf("%d%d%d",&q[i].u,&q[i].v,&q[i].id);
		q[i].u++,q[i].v++;
	}
	sort(q+1,q+k+1);
	for(int i=1;i<=n;i++){
		fa[i]=i;
	}
	for(int i=1;i<=k;i++){
		if(q[i].id==0){
			int u=getfa(q[i].u),v=getfa(q[i].v);
			if(u!=v)fa[u]=v,m--;
		}
		else{
			int u=getfa(q[i].u),v=getfa(q[i].v);
			if(u==v){
				puts("No");
				return 0;
			}
			is[u]=is[v]=1;
		}
	}
	bool flag=0;
	for(int i=1;i<=n;i++){
		if(fa[i]==i){
			if(is[i]==0)flag=1;
			tot++;
		}
	}
	LL mi,mx;
	if(flag)mi=tot-1;
	else mi=tot;
	mx=(LL)tot*(tot-1)/2;
	if(mi<=m&&m<=mx)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) b.rbegin(),v.rend()
typedef long long ll;
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  ll n,k;
  cin >> n >> k;
  ll plus = n%k;
  ll minus = abs(plus - k); 
  cout << min(plus,minus) << endl;
}

Measured memory_bytes: 256
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())|	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import collections
import math

#### START
N,K = map(int,input().split())
A = list(map(int,input().split()))

c = collections.Counter(A)

now = len(c)
ans = 0
for _, i in c.most_common()[::-1]:
  if now <= K:
    break
  ans += i
  now -= 1

print(ans)

Measured memory_bytes: 39352
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int n, x, cnt = 0;
	cin >> n >> x;
	vector<int> v(n),w(n+1);
	for(int i=0;i<n;i++){
		cin>>v.at(i);
	}
	w.at(0)=0;
	w.at(1)=v.at(0);
	for(int i=2;i<n+1;i++){
		w.at(i)=w.at(i-1)+v.at(i-1);
	}
	for(int i=0;i<n+1;i++){
		if(w.at(i)<=x)cnt++;
	}

	cout<<cnt<<endl;
	return 0;
}



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

int main(){
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++){
      if (s[i] == '1') s[i] = '9';
      else s[i] = '1';
  }
  cout << s << endl;
  return 0;
}


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

using namespace std;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define long long int ll
#define endl '\n'


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


const int MOD = 1000000007;





int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b;

    cin >> a >> b;

    int tot = 1;

    int ans = 0;


    while(tot < b) {

        tot += a - 1;
        ans++;
    }

    cout << ans << endl;




}



Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int H, W;
  cin >> H >> W;
  vector<int> cnt(26, 0);
  for (int i = 0; i < H * W; i++) {
    char c;
    cin >> c;
    ++cnt[c - 'a'];
  }
  vector<int> mod(4, 0);
  for (int x : cnt) {
    if (x > 0) {
      ++mod[x % 4];
    }
  }
  if (mod[1] + mod[3] >= 2) {
    cout << "No" << endl;
    return 0;
  }
  if (mod[1] > 0) {
    ++mod[0];
  }
  if (mod[3] > 0) {
    ++mod[2];
  }
  int K =
      (H % 2 == 1 ? W : 0) + (W % 2 == 1 ? H : 0) - ((H * W) % 2 == 1 ? 1 : 0);
  K /= 2;
  bool res = mod[2] <= K && (K - mod[2]) % 2 == 0;
  cout << (res ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
bool isprime(int x)
{
    if(x<=1)
    {
        return 0;
    }
    for(int i=2;i*i<=x;i++)
    {
        if(x%i==0)
        {
            return 0;
        }
       
    }
     return true;
}
int main() {
    int x;
    cin>>x;
    
    while(!isprime(x))
    x++;
    cout<<x;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ost;

const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

const ll maxN = 55;

char tl[maxN][maxN];
ll n, m;
bool vis[maxN][maxN];

bool isS(ll i, ll j){
	return (i>=0 and i<n) and (j>=0 and j<m) and tl[i][j] != '#' and !vis[i][j];
}

ll bfs(){
	memset(vis, 0, sizeof(vis));
	using pll = pair<ll, pair<ll,ll> >;
	queue<pll> qpl;
	qpl.push(mp(0,mp(0,0)));
	ll mn = INF;
	vis[0][0] = 1;
	while(!qpl.empty()){
		pll tp = qpl.front();
		qpl.pop();
		if(tp.F == n-1 and tp.S.F == m-1)
			mn = min(mn, tp.S.S+1);
		for(ll i=0; i<4; i++){
			if(isS(tp.F+xs[i], tp.S.F+ys[i])){
				vis[tp.F+xs[i]][tp.S.F+ys[i]] = 1;
				qpl.push(mp(tp.F+xs[i], mp(tp.S.F+ys[i], tp.S.S+1)));
			}
		}
	}
	return mn;
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	ll cnt = 0;
	for(ll i=0; i<n; i++)
		for(ll j=0; j<m; j++){
			cin >> tl[i][j];
			if(tl[i][j] == '#')
				cnt++;
		}
	ll q = bfs();
	cnt += q;
	if(cnt < 0 or cnt >= INF)
		cout << -1;
	else
		cout << n*m - cnt;
	return 0;
}

Measured memory_bytes: 3660
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner ir = new Scanner(System.in);
        int n = ir.nextInt();
        long l = ir.nextLong();
        long[][] x = new long[n][];
        for (int i = 0; i < n; i++) {
            x[i] = new long[] { ir.nextLong(), ir.nextLong() };
        }
        int[][] a = compress(x);
        // System.out.println(Arrays.deepToString(a));
        Arrays.sort(a, new Comparator<int[]>() {
            public int compare(int[] A, int[] B) {
                return A[0] - B[0];
            }
        });
        int ma = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 2; j++) {
                ma = Math.max(ma, a[i][j]);
            }
        }
        PriorityQueue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder());
        int end = 0;
        int res = 0;
        for (int i = 0; i < n; i++) {
            if (end == ma) {
                break;
            }
            while (i < n && a[i][0] <= end) {
                pq.add(a[i][1]);
                i++;
            }
            i--;
            end = pq.poll();
            // System.out.println(end);
            res++;
        }
        System.out.print(res + " ");
        int[] imos = new int[ma + 1];
        for (int i = 0; i < n; i++) {
            imos[a[i][0]]++;
            imos[a[i][1]]--;
        }
        res = imos[0];
        for (int i = 0; i < ma; i++) {
            imos[i + 1] += imos[i];
            res = Math.min(res, imos[i]);
        }
        System.out.println(n + 1 - res);
    }

    static int[][] compress(long[][] a) {
        int[][] ret = new int[a.length][2];
        TreeSet<Long> st = new TreeSet<>();
        for (int i = 0; i < a.length; i++) {
            for (int j = 0; j < 2; j++) {
                st.add(a[i][j]);
            }
        }
        ArrayList<Long> l = new ArrayList<>(st);
        for (int i = 0; i < a.length; i++) {
            for (int j = 0; j < 2; j++) {
                ret[i][j] = Collections.binarySearch(l, a[i][j]);
            }
        }
        return ret;
    }
}


Measured memory_bytes: 191188
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
using P = pair<int, int>;
using ll = long long;
const int md = 998244353;
const int mx = 200005;
int n, a[mx], b[mx];
ll ans, e[mx];
P pr[mx];
struct BIT{
	vector<int> dat;
	int sz;
	BIT(int n){
		for(sz = 1; sz < n; sz *= 2);
		dat.resize(++sz);
	}
	int q(int n){
		int ret = 0;
		for(int i = n; i > 0; i -= i&-i) ret += dat[i];
		for(int i = n; i < sz; i += i&-i) dat[i]++;
		return ret;
	}
};
int main(){
	scanf("%d", &n);
	rep(i,n) e[i+1] = (e[i] * 2 + 1) % md;
	rep(i,n) scanf("%d%d", &pr[i].first, &pr[i].second);
	sort(pr,pr+n);
	rep(i,n) pr[i] = P {pr[i].second,i+1};
	sort(pr,pr+n);
	BIT bt1(n), bt2(n);
	rep(i,n) a[i] = bt1.q(pr[i].second);
	rep(i,n) b[n-1-i] = bt2.q(pr[n-1-i].second);
	rep(i,n) (ans += (e[i-a[i]] * e[n-i-1-b[i]] + e[a[i]] * e[b[i]])) %= md;
	printf("%lld\n", (e[n] * (n-2) + n*2 + md - ans) % md);
}

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

int main() {
  int H,W,N;
  cin >> H >> W;
  N=W+2;
  
  for(int i = 0; i < N; i++){
  cout << "#" ;
  }
  
  cout << endl;
  string str;
  
  for(int i= 0; i < H; i++){
  cin >> str;
  cout << "#" << str << "#" << endl;
  }
  
  for(int i = 0; i < N; i++){
  cout << "#" ;
  }
  cout << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i=0; i<n; i++)
    cin >> a.at(i);
  sort(a.begin(), a.end());
  
  int ans;
  int temp = 0;
  for(int i=0; i<n; i++) {
    temp += (a.at(i)-a.at(0)) * (a.at(i)-a.at(0));
  }
  ans = temp;
  for(int i=a.at(0); i<a.at(n-1); i++) {
    temp = 0;
    for(int j=0; j<n; j++) {
      temp += (a.at(j) - i) * (a.at(j)-i);
    }
    if(temp < ans) {
      ans = temp;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const ll INFL = (1LL << 60);
 const int INFI = (1 << 30);

 int main() {
   string S; cin >> S;
   if (S == "ABC") cout << "ARC" << endl;
   else cout << "ABC" << endl;
 }


Measured memory_bytes: 3628
H,W = map(int,input().split())
if H % 3 == 0 or W % 3 == 0:
  print(0)
  exit()

ans = float('inf')
for _ in range(2):
  for i in [H//3,H//3+1]:
    a = i*W
    b = ((H - i)//2)*W
    c = ((H - i + 1)//2)*W
    ans = min(ans, abs(max(a, b, c) - min(a, b, c)))
 
    b = (W//2) * (H-i)
    c = ((W + 1)//2) * (H-i)
    ans = min(ans, abs(max(a, b, c) - min(a, b, c)))
  H, W = W, H
print(ans)

Measured memory_bytes: 3064
/*
5
100 1 2 3 14 15 58 58 58 29

100 58 58 58 29 15 14 3 2 1
    58    58    15    3   1
*/
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] L = new int[2*N];
    for (int i = 0 ; i < 2*N; i++) {
      L[i] = sc.nextInt();
    }
    Arrays.sort(L);
    int ans = 0;
    for (int i = 0; i < 2*N; i+=2) {
      ans += L[i];
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<stdlib.h>

int compare_int(const void *a,const void *b){
	return *(int*)a - *(int*)b;
}

int main(void){
	int food[3];
	int juice[2];
	int i;
	for(i = 0;i < 3;i++){
		scanf("%d",&food[i]);
	}
	for(i = 0;i < 2;i++){
		scanf("%d",&juice[i]);
	}
	qsort(food,3,sizeof(int),compare_int);
	qsort(juice,2,sizeof(int),compare_int);
	printf("%d\n",food[0] + juice[0] - 50);
	return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;

//Tic Tac Toe
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			char[] m = sc.next().toCharArray();
			char[][] s = new char[3][3];
			for(int i=0;i<3;i++)for(int j=0;j<3;j++)s[i][j]=m[i*3+j];
			char win = 'd';
			int[] c = new int[2];
			for(int i=0;i<3;i++){
				c[0]=c[1]=0;
				for(int j=0;j<3;j++){
					if(s[i][j]=='o')c[0]++;
					else if(s[i][j]=='x')c[1]++;
				}
				if(c[0]==3)win='o';
				else if(c[1]==3)win='x';
				c[0]=c[1]=0;
				for(int j=0;j<3;j++){
					if(s[j][i]=='o')c[0]++;
					else if(s[j][i]=='x')c[1]++;
				}
				if(c[0]==3)win='o';
				else if(c[1]==3)win='x';
				c[0]=c[1]=0;
			}
			for(int i=0;i<3;i++){
				if(s[i][i]=='o')c[0]++;
				else if(s[i][i]=='x')c[1]++;
			}
			if(c[0]==3)win='o';
			else if(c[1]==3)win='x';
			c[0]=c[1]=0;
			for(int i=0;i<3;i++){
				if(s[i][2-i]=='o')c[0]++;
				else if(s[i][2-i]=='x')c[1]++;
			}
			if(c[0]==3)win='o';
			else if(c[1]==3)win='x';
			System.out.println(win);
		}
	}
}

Measured memory_bytes: 12000
#include <stdio.h>

int digit(int x){
	int i=0,j=x;
	while(j>0){
		i++;
		j=j/10;
	}
	return i;
}

int main (){
	int x,y;
	while(scanf("%d %d",&x,&y)>0){
		printf("%d\n",digit(x+y));
	}
	return 0;
}

Measured memory_bytes: 600
function main(input) {
    const lines = input.split("\n");
    const K = +lines[0];

    const array = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];
    
    console.log(array[K-1]);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
# coding = SJIS

n, m = map(int, input().split())
ab = []
for i in range(n):
    an, bn = map(int, input().split())
    ab.append([an, bn])
cd = []
for i in range(m):
    cn, dn = map(int, input().split())
    cd.append([cn, dn])

for i in range(n):
    dis = []
    for j in range(m):
        dis.append(abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]))
    print((dis.index(min(dis)) + 1))

Measured memory_bytes: 9140
import java.io.*;
import java.util.*;
public class Main{

public static void main(String arg[]){

	Scanner s = new Scanner(System.in);
	int a = s.nextInt();
	int b = s.nextInt();

	if(a>=1 && a<=9 && b>=1 && b<=9){
	System.out.println(a*b);
	}else{
	System.out.println("-1");
	}
}
}

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

int main()
{
  int a[100010][3];
  int dp[100010][3]; 
  int N;
  cin >> N;
  rep(i, N) rep(j, 3) cin >> a[i][j];
  rep(i, N+1) rep(j, 3) dp[i][j] = 0;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (j == k) continue;
        dp[i+1][j] = max(dp[i+1][j], dp[i][k] + a[i][k]);
      }
    }
  }
  int res = 0;
  rep(i, 3) res = max(res, dp[N][i]);
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 2560
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
	Scanner scn = new Scanner(System.in);
	long x = scn.nextLong();
      long num = 0;
      long ans = 0;
      long[] a = new long[1000000];
      for(int i=0; i<a.length; ++i){
        a[i]= num * num;
        num = num +1;
      }
      for(int i=0; i<a.length; ++i){
        if(x>=a[i]){
          ans = a[i];
        }
      }
      System.out.println(ans);
	}
}


Measured memory_bytes: 43476
//Solution by Zhusupov Nurlan
#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef map<string , int> MSI;
typedef vector<int> VI;
typedef pair<int, int> PII;

#define endl '\n'
#define pb(x) push_back(x)
#define sqr(x) ((x) * (x))
#define F first
#define S second
#define SZ(t) ((int) t.size())
#define len(t) ((int) t.length())
#define base LL(1e9 + 7)
#define fname ""
#define sz 1000 * 1000
#define EPS (1e-8)
#define INF ((int)1e9 + 9)
#define mp make_pair

int n, s, x, f = INF;

int main()
{
//    freopen(fname"in", "r", stdin);
//    freopen(fname"out", "w", stdout);

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    s += x;
    if (x % 10 != 0) f = min(f, x);
  }
  if (f == INF) {
    cout << 0;
    return 0;
  }
  if (s % 10 == 0) s -= f;
  cout << s;

}


Measured memory_bytes: 256