akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<cctype>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<string>

using namespace std;
char  s[300005];
int p[300005],q[300005];
int main()
{
    int a,b,n,c,d,e,i;
    scanf("%d %s",&n,s);
    for(i=0,a=0,b=0; i<n; i++)
    {
        if(s[i]=='W')
            a++;
        p[i]=a;
        if(s[n-i-1]=='E')
            b++;
        q[n-i-1]=b;
    }
    d=q[0];
    e=p[n-1];
    d=min(e,d);
    for(i=1; i<n-1; i++)
    {
        c=p[i-1]+q[i+1];
        d=min(c,d);
    }
    cout<<d<<endl;
    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>
#include <functional>
using namespace std;

int main(){
    int N,M;
    cin>>N>>M;
    if(M%2){
        cout<<-1<<endl;
        return 0;
    }
    vector<vector<int>> E(N);
    for(int m=0;m<M;m++){
        int u,v;
        cin>>u>>v;
        u--;v--;
        E[u].push_back(v);
        E[v].push_back(u);
    }
    vector<int> D(N);
    vector<int> visited(N);
    int cnt=0;
    function<void(int,int)> dfs = [&](int v, int prev){
        visited[v]=++cnt;
        for(auto to:E[v]){
            if(to==prev) continue;
            if(visited[to]==0){
                dfs(to,v);
            }else if(visited[to]<visited[v]){
                cout<<v+1<<' '<<to+1<<endl;
                D[v]^=1;
            }
        }
    };
    dfs(0,-1);
    fill(visited.begin(), visited.end(),0);
    function<void(int,int)> dp = [&](int v, int prev){
        visited[v]=1;
        for(auto to:E[v]){
            if(to==prev) continue;
            if(visited[to]) continue;
            dp(to,v);
        }
        if(prev==-1) return;
        if(D[v]){
            cout<<v+1<<' '<<prev+1<<endl;
            D[v]^=1;
        }else{
            cout<<prev+1<<' '<<v+1<<endl;
            D[prev]^=1;
        }
    };
    dp(0,-1);
    return 0;
}

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

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

#define P105 100000

signed main()
{
    vector<int> count(P105*11);
    int n; cin >> n;
    vector<int> a(n); rep(i,n) { cin >> a[i]; count[a[i]]++; }
    int q; cin >> q;
    vector<int> b(q), c(q); rep(i,q) { cin >> b[i] >> c[i]; }

    ll sum = 0;
    rep(i,n) sum += a[i];
    rep(j,q){
        int& bj = b[j];
        int& cj = c[j];
        int c = count[bj];
        sum -= c * (bj - cj);
        count[bj] = 0;
        count[cj] += c;
        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 8760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int d[] = new int[N];
		for(int i = 0; i < N; i++) { 
			d[i] = sc.nextInt();
		}
		int sum = 0;
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < N; j++) {
				sum += d[i] * d[j];
			}
		}
		for(int i = 0; i < N; i++) {
			sum -= Math.pow(d[i], 2);
		}
		sum /= 2;
		System.out.println(sum);
	}

}


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

struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<int>> ;
using GraphEdge = vector<vector<int>> ;

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    int N,K;cin>> N >> K;
    ll h[100001];
    rep(i,N){
        cin >> h[i];
    }

    sort(h,h+N);
    ll mi = LLONG_MAX;
    rep(i,N-K+1){ 
        mi = min(h[i+K-1] - h[i],mi);
    }

    cout << mi << endl;


    return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    long n, x=0, y=0, t=0;
    cin >> n;
    for (int i=0; i<n; i++) {
        long xi, yi, ti;
        cin >> ti >> xi >> yi;
        long d = abs(xi - x)+abs(yi - y);
        if ((d > ti - t) ||
            ((d - (ti - t)) % 2 != 0)) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
//https://github.com/beet-aizu/library/blob/master/segtree/basic/ushi.cpp
#ifndef call_from_test
#include<bits/stdc++.h>
using namespace std;
#endif
//BEGIN CUT HERE
template <typename T>
struct SegmentTree{
  using F = function<T(T,T)>;
  int n;
  F f;
  T ti;
  vector<T> dat;

  SegmentTree(){}
  SegmentTree(F f,T ti):f(f),ti(ti){}

  void init(int n_){
    n=1;
    while(n<n_) n<<=1;
    dat.assign(n<<1,ti);
  }

  void build(const vector<T> &v){
    int n_=v.size();
    init(n_);
    for(int i=0;i<n_;i++) dat[n+i]=v[i];
    for(int i=n-1;i;i--)
      dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
  }

  void set_val(int k,T x){
    dat[k+=n]=x;
    while(k>>=1)
      dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]);
  }

  T query(int a,int b){
    if(a>=b) return ti;
    T vl=ti,vr=ti;
    for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[l++]);
      if(r&1) vr=f(dat[--r],vr);
    }
    return f(vl,vr);
  }

  template<typename C>
  int find(int st,C &check,T &acc,int k,int l,int r){
    if(l+1==r){
      acc=f(acc,dat[k]);
      return check(acc)?k-n:-1;
    }
    int m=(l+r)>>1;
    if(m<=st) return find(st,check,acc,(k<<1)|1,m,r);
    if(st<=l&&!check(f(acc,dat[k]))){
      acc=f(acc,dat[k]);
      return -1;
    }
    int vl=find(st,check,acc,(k<<1)|0,l,m);
    if(~vl) return vl;
    return find(st,check,acc,(k<<1)|1,m,r);
  }

  template<typename C>
  int find(int st,C &check){
    T acc=ti;
    return find(st,check,acc,1,0,n);
  }
};
//END CUT HERE
#ifndef call_from_test

// find with non-invertible monoid
signed KUPC2013_D(){
  int n;
  scanf("%d",&n);
  vector<int> as(n+2,0);
  for(int i=1;i<=n;i++) scanf("%d",&as[i]);

  const int INF = 1.1e9;
  auto f=[](int a,int b){return min(a,b);};
  SegmentTree<int> seg(f,INF);
  seg.build(as);

  using P = pair<int, int>;
  set<P> sp;
  for(int k=0;k<2;k++){
    for(int i=1;i<=n;i++){
      auto check=[&](int x){return x<as[i];};
      int l=seg.find(i,check);
      sp.emplace(k?n+2-l:l,as[i]);
    }
    reverse(as.begin(),as.end());
    seg.build(as);
  }

  printf("%d\n",(int)sp.size()/2);
  return 0;
}
/*
  verified on 2019/12/26
  https://atcoder.jp/contests/kupc2013/tasks/kupc2013_d
*/
signed main(){
  //KUPC2013_D();
  int N;
  string S;
  cin>>N>>S;
  auto addfunc=[](int x,int y){return x+y;};
  vector<SegmentTree<int>> Seg;
  vector<int> as(N,0);
  for(int i=0;i<26;i++){
    SegmentTree<int> seginit(addfunc,0);
    Seg.push_back(seginit);
    Seg[i].build(as);
  }
  for(int i=0;i<N;i++){
      Seg[int(S[i])-97].set_val(i,1);
  }
  int Q;
  cin>>Q;
  for(int line=0;line<Q;line++){
      int type;cin>>type;
      if (type==1){
          int iq;
          char cq;
          cin>>iq>>cq;
          iq-=1;
          Seg[int(S[iq])-97].set_val(iq,0);
          Seg[int(cq)-97].set_val(iq,1);
          S[iq]=cq;
      }
      else{
          int lq,rq;
          cin>>lq>>rq;
          lq--;
          int ans=0;
          for(int i=0;i<26;i++){
              if (Seg[i].query(lq,rq)>0){
                  ans++;
              }
          }
          cout<<ans<<endl;
      }
  }
  return 0;
}
#endif

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

using namespace std;

const int maxn = 300010;
int w,h,n,tag[maxn << 2],maxx[maxn << 2],ans,top1,top2;

struct node
{
	int x,y;
}e[maxn];

struct node2
{
	int x,y;
}S1[maxn],S2[maxn];

bool cmp(node a,node b)
{
	if (a.x == b.x)
		return a.y < b.y;
	return a.x < b.x;
}

void pushup(int o)
{
	maxx[o] = max(maxx[o * 2],maxx[o * 2 + 1]);
}

void pushdown(int o)
{
	if (tag[o])
	{
		tag[o * 2] += tag[o];
		tag[o * 2 + 1] += tag[o];
		maxx[o * 2] += tag[o];
		maxx[o * 2 + 1] += tag[o];
		tag[o] = 0;
	}
}

void build(int o,int l,int r)
{
	tag[o] = maxx[o] = 0;
	if (l == r)
		return;
	int mid = (l + r) >> 1;
	build(o * 2,l,mid);
	build(o * 2 + 1,mid + 1,r);
}

void update(int o,int l,int r,int x,int y,int v)
{
	if (x <= l && r <= y)
	{
		tag[o] += v;
		maxx[o] += v;
		return;
	}
	pushdown(o);
	int mid = (l + r) >> 1;
	if (x <= mid)
		update(o * 2,l,mid,x,y,v);
	if (y > mid)
		update(o * 2 + 1,mid + 1,r,x,y,v);
	pushup(o);
}

void solve()
{
	for (int i = 0; i <= top1; i++)
		S1[i].x = S1[i].y = 0;
	top1 = 0;
	for (int i = 0; i <= top2; i++)
		S2[i].x = S2[i].y = 0;
	top2 = 0;
	S1[0].y = S2[0].y = 1;
	sort(e + 2,e + 1 + n,cmp);
	build(1,1,n);
	update(1,1,n,1,n,h << 1);
	for (int i = 2; i <= n; i++)
	{
		update(1,1,n,1,i - 1,(e[i].x - e[i - 1].x) << 1);
		ans = max(ans,maxx[1]);
		if (e[i].y <= h / 2)
		{
			update(1,1,n,S1[top1].y,i - 1,-e[i].y * 2);
			while (top1 && S1[top1].x <= e[i].y)
			{
				update(1,1,n,S1[top1 - 1].y,S1[top1].y - 1,(S1[top1].x - e[i].y) * 2);
				top1--;
			}
			++top1;
			S1[top1].x = e[i].y;
			S1[top1].y = i;
		}
		else
		{
			update(1,1,n,S2[top2].y,i - 1,(e[i].y - h) * 2);
			while (top2 && e[i].y <= S2[top2].x)
			{
				update(1,1,n,S2[top2 - 1].y,S2[top2].y - 1,(e[i].y - S2[top2].x) * 2);
				top2--;
			}
			++top2;
			S2[top2].x = e[i].y;
			S2[top2].y = i;
		}
	}
}

int main()
{
	scanf("%d%d%d",&w,&h,&n);
	n++;
	for (int i = 2; i <= n; i++)
		scanf("%d%d",&e[i].x,&e[i].y);
	e[++n].x = w;
	e[n].y = h;
	solve();
	swap(w,h);
	for (int i = 1; i <= n; i++)
		swap(e[i].x,e[i].y);
	solve();
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 15232
#include<stdio.h>

int main(void)
{
int A,B,K;

scanf("%d%d",&A,&B);

if(A<0) A = A*(-1);
if(B<0) B = B*(-1);

K=(A+B)/2;

if((A+B)%2==0)

printf("%d",K);

else
printf("IMPOSSIBLE");

return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using Graph = vector<vector<int>>;


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() {
    ll n,k;
    cin >> n >> k;
    vector<ll> p(n);
    REP(i, n){
        cin >> p[i];
    }
    sort(p.begin(),p.end());
    ll ans = 0;
    REP(i ,k){
        ans += p[i];
    }
    cout << ans << endl;
}



Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <stack>
using namespace std;

void solve(){
  int n; cin >> n;
  vector<int> s(n);
  for(int i = 0; i < n; i++) cin >> s[i];
  int q; cin >> q;
  vector<int> t(q);
  int ans = 0;
  for(int i = 0; i < q; i++) cin >> t[i];
  for(int i = 0; i < q; i++){
    int l = 0, r = n;
    int m = (l + r) / 2;
    while(l != r){
      if(s[m] == t[i]){
        ans++;
        break;
      }
      else if(s[m] > t[i]){
        r = m;
      }
      else{
        l = m + 1;
      }
      m = (l + r) / 2;
    }
  }
  cout << ans << endl;
  return;
}

int main(){
  solve();
  return 0;
}



Measured memory_bytes: 3400
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> w(n);
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> w[i];
        sum += w[i];
    }

    int absmin = sum - w[0];
    for (int i = 1, l = w[0], r = sum - w[0]; i < n - 1; i++) {
        l += w[i];
        r -= w[i];
        absmin = min(absmin, abs(r - l));
    }

    cout << absmin << endl;
}


Measured memory_bytes: 256
# -*- coding:utf-8 -*-

INF = 10**9

def solve():
    N, A, B, C = [int(x) for x in input().split(" ")]
    ls = []
    for _ in range(N):
        ls.append(int(input()))

    def _dfs(depth, a, b, c):
        if depth == N:
            # 全ての竹を選び終わったら、延長魔法と短縮魔法を使ってA,B,Cの長さにする
            return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a, b, c) > 0 else INF
        ret0 = _dfs(depth+1, a, b, c)  # 使わない
        ret1 = _dfs(depth+1, a+ls[depth], b, c) + 10  # Aに使う
        ret2 = _dfs(depth+1, a, b+ls[depth], c) + 10  # Bに使う
        ret3 = _dfs(depth+1, a, b, c+ls[depth]) + 10  # Cに使う
        
        return min(ret0, ret1, ret2, ret3)

    print(_dfs(0,0,0,0))


if __name__ == "__main__":
    solve()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
#define double long double

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T>
vector<vector<T> > make_v(size_t a,size_t b){
  return vector<vector<T> >(a,make_v<T>(b));
}
template<typename T>
vector<vector<vector<T> > > make_v(size_t a,size_t b,size_t c){
  return vector<vector<vector<T> > > (a,make_v<T>(b,c));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;

//INSERT ABOVE HERE
signed main(){
  int h,n,p,m,k;
  cin>>h>>n>>p>>m>>k;
  p--;
  
  vector<int> b(h,-1);
  for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    b[h-x]=y-1;
  }
  
  auto dp=make_v<double>(h+1,k+1,n+1);
  fill_v(dp,0);
  dp[0][0][p]=1;
  for(int i=0;i<h;i++){
    for(int j=0;j<=k;j++){
      if(~b[i]){
	swap(dp[i][j][b[i]],dp[i][j][b[i]+1]);
	for(int l=0;l<n;l++) dp[i+1][j][l]+=dp[i][j][l];
	continue;
      }
      for(int l=0;l<n;l++) dp[i+1][j][l]+=dp[i][j][l];
      if(j+1>k) continue;
      for(int l=0;l<n;l++){
	double x=0.0;
	if(l+1<n)  dp[i+1][j+1][l+1]+=dp[i][j][l]/(n-1.0),x+=1.0;
	if(l-1>=0) dp[i+1][j+1][l-1]+=dp[i][j][l]/(n-1.0),x+=1.0;
	dp[i+1][j+1][l]+=dp[i][j][l]*(n-1.0-x)/(n-1.0);
      }
    }
  }
  
  double ans=*max_element(dp[h][k].begin(),dp[h][k].end());
  for(int i=0;i<k;i++){
    ans/=(h-m-i);
    ans*=(i+1);
  }
  cout<<ans<<endl;
  
  return 0;
}



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

int main() {
    int X;
    cin >> X;

   	if(X==0){
       cout << 1 << endl;
    }else{
      cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <cstdio>

using namespace std;

int main(){
  int n;
  long long a[300][300] = {};
  long long b[300][300] = {};
  long long tot = 0;
  cin >> n;
  for (int i=0;i<n;i++) {
    for (int j=0;j<n;j++) {
      cin >> a[i][j];
      b[i][j] = a[i][j];
    }
  }
  for (int i=0;i<n;i++) {
    for (int j=0;j<n;j++) {
      for (int k=0;k<n;k++) {
	if (a[i][j] > a[i][k] + a[j][k]) {
	  cout << -1 << endl;
	  return 0;
	}
	if (i!=k && k!=j && a[i][j] == a[i][k] + a[j][k]) {
	  b[i][j] = 0;
	}
      }
    }
  }
  for (int i=0;i<n;i++) {
    for (int j=0;j<n;j++) {
      tot += b[i][j];
    }
  }
  cout << tot/2 << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>


int main()
{
	int a[1000];
	int i, j, k, v, n;
	
	scanf("%d",&n);
	
	for (i = 0; i < n; i++) {
		scanf("%d",&a[i]);
	}
	
	for (k = 0; k < n; k++) {
			if (k > 0) {
				printf(" ");
			
			}
			printf("%d",a[k]);
		}
		printf("\n");
		
	for (i = 1; i <= n-1; i++) {
		v = a[i];
		j = i - 1;
		

		while (j >= 0 && a[j] > v) {
			a[j + 1] = a[j];
			j--;

		}

		a[j + 1] = v;
		for (k = 0; k < n; k++) {
			if (k > 0) {
				printf(" ");
			
			}
			printf("%d",a[k]);
		}
		printf("\n");
	}

return 0;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<bool> ch(n+1, false);
  int d;
  for ( int i = 0; i < k; i++ ) {
    cin >> d;
    for ( int j = 0; j < d; j++ ) {
      int snk;
      cin >> snk;
      ch[snk] = true;
    }
  }

  int ans = 0;
  for ( int i = 1; i <= n; i++ ) {
    if ( ! ch[i] ) { ans++; }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (',' == s.at(i)) {
			s.at(i) = ' ';
		}
	}
	cout << s << endl;
	return 0;
}

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

#include <iostream>
using namespace std;

int N,Ma,Mb;
int a[41]={};
int b[41]={};
int c[41]={};
int dp[401][401][41]={};
const int INF=1000000000;

int main() {

	cin>>N>>Ma>>Mb;
	for(int i=1;i<N+1;++i)cin>>a[i]>>b[i]>>c[i];

	for(int i=0;i<401;++i){
		for(int j=0;j<401;++j){
			dp[i][j][0]=INF;
		}
	}
	dp[0][0][0]=0;
	for(int k=1;k<41;++k){
		for(int i=0;i<401;++i){
			for(int j=0;j<401;++j){
				dp[i][j][k]=dp[i][j][k-1];
				if(i>=a[k]&&j>=b[k])dp[i][j][k]=min(dp[i][j][k],dp[i-a[k]][j-b[k]][k-1]+c[k]);
			}
		}
	}
	int total=INF;
	for(int i=1;i<401;++i){
		for(int j=1;j<401;++j){
			if(Ma*j==Mb*i)total=min(total,dp[i][j][N]);
		}
	}
	if(total==INF){
		cout<<-1<<endl;
	}else{
		cout<<total<<endl;
	}
	return 0;
}


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

using namespace std;

int main(){
  int N;
  cin >> N;
  
  double v[N];
  for(int i=0;i<N;i++){
    cin >> v[i];
  }
  
  sort(v,v+N);

  double sum = (v[0] + v[1])/2.0;
  
  for(int i=2;i<N;i++){
    sum = (sum + v[i])/2.0;
  }

  cout << sum << endl;
  return 0;

}



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

using namespace std;

int n;

void solve(){
    int i,j;
    string str;
    cin >> n;
    int a = 0,b = 0,ab = 0;
    long long ans = 0;
    for(i = 0;i < n;i++){
        cin >> str;
        for(j = 0;j < str.length()-1;j++){
            if(str[j] == 'A' && str[j+1] == 'B') ans++;
        }
        if(str[0] == 'B') b++;
        if(str[str.length()-1] == 'A') a++;
        if(str[0] == 'B' && str[str.length()-1] == 'A') ab++;
    }
    if(max(a,b) == ab && ab > 0) ans += ab-1;
    else ans += min(a,b);
    cout << ans << endl;
}

int main(){
    solve();
}


Measured memory_bytes: 764
from typing import List


class Info:
    def __init__(self, arg_start, arg_end, arg_area):
        self.start = arg_start
        self.end = arg_end
        self.area = arg_area


if __name__ == "__main__":
    LOC: List[int] = []
    POOL: List[Info] = []
    all_symbols = input()
    loc = 0
    total_area = 0

    for symbol in all_symbols:
        if symbol == '\\':
            LOC.append(loc)

        elif symbol == '/':
            if len(LOC) == 0:
                continue

            tmp_start = int(LOC.pop())
            tmp_end = loc
            tmp_area = tmp_end - tmp_start
            total_area += tmp_area

            while len(POOL) > 0:
                # \  / : (tmp_start, tmp_end)
                #  \/ : (POOL[-1].start, POOL[-1].end)
                if tmp_start < POOL[-1].start and POOL[-1].end < tmp_end:
                    tmp_area += POOL[-1].area
                    POOL.pop()
                else:
                    break

            POOL.append(Info(tmp_start, tmp_end, tmp_area))

        else:
            pass

        loc += 1

    print(f"{total_area}")
    print(f"{len(POOL)}", end="")
    while len(POOL) > 0:
        print(f" {POOL[0].area}", end="")
        POOL.pop(0)
    print()



Measured memory_bytes: 8296
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define li long int
//#define for(i : n) for(int i=0; i < n; i++)
using namespace std;
int main(){
li n,l,min;
cin>>n>>l;
int a[n+1];
li ans=0,count=0,count1=0,count2=0;
for(int i =1; i <=n ; i++){
    a[i]= i + l -1;
    ans+=a[i];
    if(a[i]< 0 )
        count++;
    if(a[i]==0)
        count1++;
    if(a[i]>0)
        count2++;
}
if(count1>0)
    cout<<ans<<endl;
else if(count == n)
    cout<<ans - a[n]<<endl;
else if(count2 == n)
    cout<<ans - a[1]<<endl;
else{
    if(abs(a[count] ) > a[count+1])
        cout<<ans  - a[count +1 ] ;
    else
        cout<<ans + abs( a[count]) ;
}



}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int N,M,Q;
vector<ll> a,b,c,d;

ll score(vector<int> &A)
{
    ll res = 0;
    for(int i = 0; i < Q; i++) if(A[b[i]] - A[a[i]] == c[i]) res += d[i];
    return(res);
}

ll dfs(vector<int> &A)
{
    if(A.size() == N) return(score(A));

    ll res = 0;
    int prev_last = (A.empty() ? 0 : A.back());
    for(int add = prev_last; add < M; add++)
    {
        A.push_back(add);
        res = max(res, dfs(A));
        A.pop_back();
    }
    return(res);


}

int main()
{

    cin >> N >> M >> Q;
    a.resize(Q),b.resize(Q),c.resize(Q),d.resize(Q);
    for(int i = 0; i < Q; i++) cin >> a[i] >> b[i] >> c[i] >> d[i], a[i]--,b[i]--;
    vector<int> A;
    cout << dfs(A) << endl;

}

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = (int)1e5 + 9;
const ll inf = (ll)1e15;
vector<pii> T[2][N];

ll d[2][N];
ll ans[N];

int n;
void dij(int node, int q){
  for(int i = 1; i <= n; i ++ ){
    d[q][i] = inf;
  }
  d[q][node] = 0;
  priority_queue<pii,vector<pii>, greater<pii>> ff;
  ff.push(mp(0,node));
  ll dis;
  while(!ff.empty()){
    node = ff.top().se;
    dis = ff.top().fi;
    ff.pop();
    if(dis != d[q][node]) continue;
    for(auto x : T[q][node]){
      if(d[q][node] + x.se < d[q][x.fi]){
        d[q][x.fi] = d[q][node] + x.se;
        ff.push(mp(d[q][x.fi], x.fi));
      }
    }
  }
}

int main(){
  fastIO;
  int m, s, t;
  cin >> n >> m >> s >> t;
  int u, v;
  ll a, b;
  for(int i = 0 ; i < m ; i ++ ){
    cin >> u >> v >> a >> b;
    T[0][u].push_back(mp(v,a));
    T[0][v].push_back(mp(u,a));
    T[1][u].push_back(mp(v,b));
    T[1][v].push_back(mp(u,b));
  }
  dij(s,0);
  dij(t,1);
  for(int i = n; i >= 1; i -- ){
    ans[i] = inf - d[0][i] - d[1][i];
    ans[i] = max(ans[i], ans[i + 1]);
  }
  for(int i = 1; i <= n; i ++ ){
    cout << ans[i] << "\n";
  }
  return 0;
}

Measured memory_bytes: 19196
n = int(input())
ans = 0
#A==Bのとき
i = 1
while i ** 2 < n:
    ans += 1
    i += 1
#A!=Bのとき
i = 1
while i*(i+1) < n:
    j = i+1
    while i*j < n:
        ans += 2
        j += 1
    i += 1
print(ans)

Measured memory_bytes: 9172
n = gets.chomp.to_i
p = []
n.times do
  p << gets.chomp.to_i
end

hash = []

p.each do |i|
  if hash[i-1].nil?
    hash[i] = 1
  else
    hash[i] = hash[i-1] + 1
  end
end

puts n - hash[1..-1].max


Measured memory_bytes: 5756
#include <stdio.h>

int main(int argc, char** argv)
{
  char s[4];
  int cnt[256] = {0};
  
  fgets(s, sizeof(s), stdin);
  cnt[s[0]]++;
  cnt[s[1]]++;
  cnt[s[2]]++;
  if(cnt['A']==3){
    printf("No\n");
  } else if(cnt['B']==3){
    printf("No\n");
  }else {
    printf("Yes\n");
  }
  return 0;
}



Measured memory_bytes: 128
s = raw_input()
a = (s[0] == 'A')
c = False
cx = -1
for i in range(2, len(s)-1):
	if s[i] == 'C':
		c = True
		cx = i
		break
other = True
for i in range(1, len(s)):
	if i != cx:
		if 65 <= ord(s[i]) and ord(s[i]) <= 90:
			other = False
status = 'WA'
if a and c and other: status = 'AC'
print status

Measured memory_bytes: 2692
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

const int MAXN = 3000;

LL a[MAXN], left[MAXN], right[MAXN];

int main() {
	int n;
	LL x;
	cin >> n >> x;
	FOR (i, n)
		cin >> a[i];
	LL sum = -1;
	FOR (dist, n + 1) {
		LL m = x * dist;
		priority_queue<pair<LL, int> > q;
		ffor (i, n - dist, n)
			q.push(make_pair(-a[i], i));
		FOR (i, n) {
			LL best = -1;
			q.push(make_pair(-a[i], i));
			while (!q.empty()) {
				pair<LL, int> el = q.top();
				int d;
				if (el.second <= i)
					d = i - el.second;
				else
					d = n - el.second + i;
				if (d > dist)
					q.pop();
				else
					break;
			}
			m -= q.top().first;
		}
		if (sum == -1 || sum > m)
			sum = m;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 384
n, a, b = map(int, input().split())

if (b-a)%2 == 0:
  print((b-a)//2)
else:
  if (a+b) > n:
    print(((n-a)+(n-b)+1)//2)
  else:
    print((a+b-1)//2)

    

Measured memory_bytes: 2940
import java.io.IOException;
import java.util.Scanner;
public class Main {
	static int mod=1000000007;
	static Scanner scan=new Scanner(System.in);
	static long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}
	static long lcm (long a, long b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
			}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	static String reverce(String str) {
		String strr="";
		for(int i=str.length()-1;i>=0;i--) {
			strr+=str.charAt(i);
		}
		return strr;
	}
	static long modpow(long a,long n) {
		if(n==0) return 1;
		else if(n==1)return a;
		long tmp=modpow(a,n/2);
		tmp%=mod;
		tmp*=tmp;
		tmp%=mod;
		if(n%2==0)return tmp;
		else return (tmp*a)%mod;
	}
	public static void main(String[] args) throws IOException {
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		int d=scan.nextInt();
		int max=max(a,b);
		max=max(max,c);
		int sum=a+b+c-max;
		for(int i=0;i<d;i++) {
			max*=2;
		}
		System.out.println(max+sum);
	}
}


Measured memory_bytes: 21716
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

const double EPS = 1e-11;

/*
 * r1 > 0 ===> outer tangent
 * r1 < 0 ===> inner tangent
 * ax + by = c
 */
void circle_tangent(double x0, double y0, double r0,
		    double x1, double y1, double r1,
		    double &a, double &b, double &c) {
  double rd = r0 - r1;
  // p = ((x1 - x0) + (y1 - y0)i) / (u + (r0 - r1)i)
  double u = sqrt(pow(x1 - x0, 2) + pow(y1 - y0, 2) - rd * rd);
  double alpha = u * u + (r0 - r1) * (r0 - r1);
  double px = (x1 - x0) * u + (y1 - y0) * (r0 - r1);
  double py = - (x1 - x0) * (r0 - r1) + (y1 - y0) * u;
  px /= alpha;
  py /= alpha;
  a = py;
  b = -px;
  double qx = x0 - r0 * py;
  double qy = y0 + r0 * px;
  c = a * qx + b * qy;
}

int main(void){
  int n;
  while (cin >> n && n) {
    vector<double> x(n), y(n), r(n), m(n);
    REP(i, 0, n) {
      cin >> x[i] >> y[i] >> r[i] >> m[i];
    }
    int ma = 0;
    if (n >= 2) {
    REP(i, 0, n) {
      REP(j, 0, n) {
	int cnt = 0;
	double a, b, c;
#define ITSUMONO do {\
	cnt = 0;\
	REP(k, 0, n) {\
	  double dist = abs(a * x[k] + b * y[k] - c) / sqrt(a * a + b * b);\
	  if (dist > r[k] - EPS && dist < r[k] + m[k] + EPS) {\
	    cnt++;\
	  }\
	}\
	ma = max(ma, cnt);\
	}while(0)
	REP(s1, 0, 2) {
	  REP(s2, 0, 2) {
	    circle_tangent(x[i], y[i], r[i] + s1 * m[i],
			   x[j], y[j], r[j] + s2 * m[j],
		       a, b, c);
	    ITSUMONO;
	    circle_tangent(x[i], y[i], r[i] + s1 * m[i],
			   x[j], y[j], - (r[j] + s2 * m[j]),
		       a, b, c);
	    ITSUMONO;
	  }
	}
	
      }
    }
    } else {
      ma = 1;
    }
    cout << ma << endl;
  }
  
}

Measured memory_bytes: 3208
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

int N, M;

signed main()
{
	cin >> N >> M;
	priority_queue<int> pq;
	rep(i, N) pq.push(read());

	rep(i, M) {
		int a = pq.top(); pq.pop();
		a /= 2;
		pq.push(a);
	}

	int ans = 0;

	rep(i, N) {
		ans += pq.top(); pq.pop();
	}

	cout << ans << endl;
}




Measured memory_bytes: 1400
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    string str;
    cin>>str;
    if(str[2]==str[3] && str[4]==str[5])
    {
    	cout<<"Yes"<<endl;
    }
    else
    {
    	cout<<"No"<<endl;
    }
	
	return 0;
}
 


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

public class Prime{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
         
        var primeFactors = PrimeFactors(n);
         
        string output = primeFactors.Count() == 0 
                        ? n.ToString() 
                        : string.Join(" ", primeFactors.Select (f => f.ToString()).ToArray()); //AOJ??¨
                        //:string.Join(" ", primeFactors);
        Console.WriteLine("{0}: {1}", n, output);
    }
     
    public static IEnumerable<int> PrimeFactors(int n)
    {
        int i = 2;
        int tmp = n;
         
        while (i * i <= n)
        {
            if(tmp % i == 0){
                tmp /= i;
                yield return i;
            }else{
                i++;
            }
        }
		if(tmp != 1) yield return tmp;
    }
}

Measured memory_bytes: 20300
N=gets.to_i
I=Array.new(N+1)
(1 .. N).each{|i| I[i] = gets.to_i}

dp = Array.new(N+1, -1)
N.times.inject(1) do |from, d|
  break if dp[from] > 0
  
  dp[from] = d
  break if from == 2
  
  I[from]
end
puts dp[2]


Measured memory_bytes: 3580
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>

using namespace std;

int main(void)
{
	string a, b, c;
	int x, y;

	cin >> a >> b;
	c = a + b;
	x = stoi(c);

	y = sqrt(x);
	if (y*y == x)
	{
		cout << "Yes" << '\n';
	}
	else
	{
		cout << "No" << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = input[0];
            var K = input[1];
            var S = Console.ReadLine().ToCharArray();

            S[K - 1] = S[K - 1].ToString().ToLower().ToCharArray().First();

            Console.WriteLine(new string(S));
        }
    }
}


Measured memory_bytes: 28424
A, B, C, D = map(int, input().split())
import fractions
from functools import reduce


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def calc_kukan_num(mod):
    start = A if A % mod == 0 else A + mod - (A+mod) % mod
    return (B - start) // mod + 1
# print(B-A-1, calc_kukan_num(C), calc_kukan_num(D), calc_kukan_num(C*D))
print(B-A+1-calc_kukan_num(C)-calc_kukan_num(D)+calc_kukan_num(lcm(C, D)))


Measured memory_bytes: 5332
fn main() {
    let nm = read_vec::<i32>();
    let n = nm[0];
    let m = nm[1];

    let ret = n * (n-1) / 2 + m * (m-1) / 2;
    println!("{}", ret);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
#include <iostream>
#define FOR(i,a,b) for(int i=a;i<b;i++)
using namespace std;

int main() {
	// your code goes here
	int n,k;cin>>n>>k;
	int a[n],dp[n];
	FOR(i,0,n)cin>>a[i];
	FOR(i,0,n)dp[i]=-1;
	dp[0]=0;
	FOR(i,1,n){
		FOR(j,max(0,i-k),i){
			if(dp[i]==-1){
				dp[i]=dp[j]+abs(a[i]-a[j]);
			}else{
				dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
			}
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

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

int main() {
  int N, X;
  cin >> N >> X;
  int a[N];
  int sum = 0;
  int ans;
  FOR(i,0,N) {
    cin >> a[i];
    sum += a[i];
  }
  int nokori = X - sum;
  ans = N;
  sort(a,a+N);
  while(nokori >= 0) {
    nokori -= a[0];
    if (nokori >= 0) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
//Unplanned Queries

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int n,m;cin>>n>>m;
    map<int,int>t;
    rep(i,0,m){
        int a,b;cin>>a>>b;
        t[a]++;
        t[b]++;
    }
    for(auto i:t){
        if(i.second%2){
            cout<<"NO"<<nnn;
            return 0;
        }
    }
    cout<<"YES"<<nnn;
    return 0;
}

Measured memory_bytes: 8856
using System;
using System.Collections.Generic;

public class Answer {
    private static readonly string TextOK = "Yay!";
    private static readonly string TextNG = ":(";
  
    private static void Main(string[] args) {
        var numberOfLines = 5;
        var inputs = new List<string>();
        
        for (int lineIndex = 0; lineIndex < numberOfLines; lineIndex++) {
            inputs.Add(Console.ReadLine().Trim());
        }

        var inputLastLine = Console.ReadLine().Trim();
        
        Console.WriteLine(GetAnswer(inputs, inputLastLine));
    }
  
    private static string GetAnswer(List<string> inputs, string inputLastLine) {
        for (int indexA = 0; indexA < inputs.Count - 1; indexA++) {
            for (int indexB = indexA + 1; indexB < inputs.Count; indexB++) {
                int distance = CalculateDistance(int.Parse(inputs[indexA]), int.Parse(inputs[indexB]));

                if (!IsDistanceOK(distance, int.Parse(inputLastLine))) {
                    return TextNG;
                }
            }
        }

        return TextOK;
    }

    private static int CalculateDistance(int a, int b) => Math.Abs(a - b);
    private static bool IsDistanceOK(int distance, int standard) => distance <= standard;

}

Measured memory_bytes: 13268
import java.util.*;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        String s = sc.next();
        if (s.length() != a + b + 1) {
            System.out.println("No");
            System.exit(0);
        }
        for (int i = 0 ; i <= a + b ; i++) {
            if (i == a) {
                if (s.charAt(i) != '-') {
                    System.out.println("No");
                    System.exit(0);
                }
            } else {
                if (!Character.isDigit(s.charAt(i))) {
                    System.out.println("No");
                    System.exit(0);
                }
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 23764
#include<iostream>
using namespace std;
int main() {
	string s;
	cin >> s;
	char x;
	int a[26] = {};
	for (int i = 0; i < 26; i++) {
		for(int j = 0; j<s.size(); j++){
			if (s[j] == 'a' + i) {
				a[i] += 1;
			}
		}
	}
	for (int i = 0; i < 26; i++) {
		if (a[i] == 0) {
			x = i + 'a';
			cout << x << endl;
			return 0;
		}
	}
	cout << "None" << endl;
	return 0;
}

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

int main(){
	int s;
	cin >> s;
	map<double,int> mp;
	int i = 1;
	while(1){
        //cout << s << endl;
		if(mp[s] == 1){
			cout << i << endl;
			return 0;
		}else{
            mp[s] = 1;
            i++;
			s = (s % 2 == 0) ? (s/2) : (3*s+1);
		}
	}
}

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

int main() {

    int a, b, c;

    scanf("%d%d%d", &a, &b, &c);

    int mysum = a + b + c;

    int mindata = mysum - a;

    if (mindata > mysum - b) {
        mindata = mysum - b;
    }
    if (mindata > mysum - c) {
        mindata = mysum - c;
    }

    printf("%d", mindata);


    return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int q;cin>>q;
    vin ans(q);
    ll a,b,c;
    rep(i,q){
        cin>>a>>b;
        if(a==b||a+1==b)ans[i]=2*a-2;
        else{
            c=sqrt(a*b);
            if(c*c==a*b)c--;
            if(c*(c+1)>=a*b)ans[i]=2*c-2;
            else ans[i]=2*c-1;
        }
    }
    rep(i,q)cout<<ans[i]<<endl;
}

Measured memory_bytes: 3708
#include<bits/stdc++.h>
#define ii pair<int,int>
#define ll long long

using namespace std;

int main(){
    string a;cin>>a;
    if(a[0] == 'S'){
        cout<<"Cloudy";
    }
    else if( a[0] == 'C'){
        cout<<"Rainy";
    }
    else{
        cout<<"Sunny";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
typedef pair<int,int> pi;
int k,x,y,t;
pi a[200020];
pi cal(int x,int y){
	if (x>y){
		pi t=cal(y,x);
		return {t.y,t.x};
	}
	if (x<0){
		pi t=cal(-x,y);
		return {-t.x,t.y};
	}
	if (x+y>=2*k) return {x,y-k};
	if (x+y==k) return {0,0};
	return {(x+y)/2-k,(x+y+1)/2};
}
int main(){
	scanf("%d%d%d",&k,&x,&y);
	if (!(k&1) && (x+y)&1) return puts("-1"),0;
	a[0]={x,y};
	for (;a[t].x || a[t].y;t++) a[t+1]=cal(a[t].x,a[t].y);
	printf("%d\n",t);
	for (;t--;) printf("%d %d\n",a[t].x,a[t].y);
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;

int main() {
    int n;
    cin >> n;
    n %= 10;
    if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
        cout << "hon" << endl;
    }
    if(n == 0 || n == 1 || n == 6 || n == 8) {
        cout << "pon" << endl;
    }
    if(n == 3) {
        cout << "bon" << endl;
    }
}


Measured memory_bytes: 3624
import fractions
a,b,c,d=map(int,input().split())
base=b-a+1
n_c=b//c-(a+c-1)//c+1
n_d=b//d-(a+d-1)//d+1
cd=c*d // fractions.gcd(c,d)
n_cd=b//cd-(a+cd-1)//cd+1
print(base-n_c-n_d+n_cd)


Measured memory_bytes: 5048
#include <iostream>

using namespace std;

int main()
{  int i , h , m , s ;
   
   cin >> i ;
   h = i / 3600;
   m = (i / 60 - h * 60);
   s = i % 60;
   cout << h << ":" << m << ":"  << s << endl; 
   
   return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define task "TEST"

const int maxn=1e5+5;
const long long w=1e9+7;

using namespace std;

int n,a,b;
string kq;

inline void init(){
    cin>>n>>a>>b;
}

inline void prepare(){
    if((b-a)%2==0) kq="Alice";
    else kq="Borys";
}

inline void solve(){
    prepare();
    cout<<kq;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    //freopen(task".INP","r",stdin);
    //freopen(task".OUT","w",stdout);
    init();
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <string.h>
#include <ctype.h>
#include <iostream>
#include <string>

using namespace std;

int main()
{
	char str[200 + 1] = { 0 };
	char backup[200 + 1] = { 0 };
	int str_len = 0;
	int shuffle_times = 0;
	int shuffle = 0;

	while (true)
	{
		cin >> str;
		if (str[0] == '-' && str[1] == '\0') break;
		str_len = strlen(str);
		cin >> shuffle_times;
		for (int i = 0; i < shuffle_times; i++) {
			cin >> shuffle;
			for (int j = 0; j < shuffle; j++) {
				backup[j] = str[j];
			}
			backup[shuffle] = '\0';
			for (int j = 0; j < str_len - shuffle; j++) {
				str[j] = str[j + shuffle];
			}
			for (int j = 0; j < str_len; j++) {
				str[j + str_len - shuffle] = backup[j];
			}
			str[str_len] = '\0';
		}
		cout << str << endl;
	}
	return 0;
}

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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int mod = 1e9+7;

template <typename T>
void add_self(T &a, T b){
    a += b;
    if(a >= mod) a -= mod;
}

void sub_self(int &a, int b){
    a -= b;
    if(a < 0) a += mod;
}

void solve(){
    int n, k;
    cin>>n>>k;
    vector<int> dp(k + 1, 0);
    dp[0] = 1;

    for(int child = 0; child < n; child++){
        int ub;
        cin>>ub;
        vector<int> fake(k + 1, 0);
        for(int used = k - 1; used >= 0; --used){
            int temp = dp[used];
            int L = used + 1;
            int R = used + ub;
            if(L <= R){
                add_self(fake[L], temp);
                if(R + 1 <= k)
                    sub_self(fake[R + 1], temp);
            }
        }
        int pref = 0;
        for(int i = 1; i <= k; i++){
            add_self(pref, fake[i]);
            add_self(dp[i], pref);
        }
    }

    cout<<dp[k];
}

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

    ll t = 1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007
using namespace std;

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

	int ans=0;
	for(int i=1;i<=n;i++){
		int tmp=i;
		int cnt=0;
		while(tmp!=0){
			tmp/=10;
			cnt++;
		}
		if(cnt%2==1)ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    H, W = map(int, readline().split())
    A = [list(map(int, readline().split())) for _ in range(H)]
    B = [list(map(int, readline().split())) for _ in range(H)]

    G = [[0] * W for _ in range(H)]
    for i in range(H):
        for j in range(W):
            G[i][j] = abs(A[i][j] - B[i][j])

    dp = [set() for j in range(W)]
    dp[0].add(G[0][0])

    for i in range(H):
        for j in range(W):
            if i == 0 and j == 0:
                continue
            s = set()
            b = G[i][j]
            if i > 0:
                for k in dp[j]:
                    s.add(k + b)
                    s.add(abs(k - b))
            if j > 0:
                for k in dp[j - 1]:
                    s.add(k + b)
                    s.add(abs(k - b))
            dp[j] = s

    print(min(dp[W - 1]))
    return


if __name__ == '__main__':
    main()


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

using namespace std;
#define ll long long

ll f(ll n)
{
    if (n%2 == 1)
        return 0;
    n /= 2;
    ll ans = 0;
    while(n)
    {
        ans += (n/5);
        n /= 5;
    }
    return ans;
}
int main()
{
    ll n;
    cin >> n;
    int A[n],val = 1,ans = 0;
    for (int i = 0; i < n; i++)
        cin >> A[i];
    for (int i = 0; i < n; i++)
    {
        if (A[i] == val)
        {
            ans++;
            val++;
        }
    }
    if (ans == 0)
        cout << "-1";
    else
        cout << n - ans;
    return 0;
}


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

int main(){
    int n,m,c,x;
    cin >>n >>m;
    int a[n+1][m+1];
    int b[m+1];
    
    for (int i=1;i<=n;i++){
        for (int j=1; j<=m;j++){
            cin >>x;
            a[i][j]=x;
        }
    }
    for(int i=1;i<=m;i++){
        cin>>x;
        b[i]=x;
    }
    for(int i=1;i<=n;i++){
        c=0;
        for(int j = 1;j<=m;j++){
            c += a[i][j]*b[j];
        }
        cout << c <<endl;
    }return 0;
}


Measured memory_bytes: 3108