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

int main(){
	int a;
	cin>>a;
	if(a==25){
		cout<<"Christmas "<<endl;
	}else if(a==24){
		cout<<"Christmas Eve"<<endl;
	}else if(a==23){
		cout<<"Christmas Eve Eve"<<endl;
	}else if(a==22){
		cout<<"Christmas Eve Eve Eve"<<endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[100005];
int main()
{
    int n,sum=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]>a[i-1]) sum+=a[i]-a[i-1];
        else sum+=a[i-1]-a[i];
    }
    a[n+1]=0;
    sum+=abs(a[n+1]-a[n]);
//  printf("sum=%d\n",sum);
    for(int i=1;i<=n;i++)
    {
        if(a[i]>=a[i-1]&&a[i]<=a[i+1]||a[i]<=a[i-1]&&a[i]>=a[i+1]) printf("%d\n",sum);
        else
        {
            int l1=abs(a[i]-a[i-1]);
            int l2=abs(a[i+1]-a[i]);
            int minn=min(l1,l2);
            printf("%d\n",sum-2*minn);
        }
    }
} 

Measured memory_bytes: 1664
def d10(n):
    return n//10
def d1(n):
    return n%10
def sekinohi(m, d):
    return d1(d)>=2 and d10(d)>=2 and m==d1(d)*d10(d)

ans = 0
m, d = map(int, input().split())
for i in range(1, m+1):
    for j in range(1, d+1):
        if sekinohi(i, j):
            ans += 1
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

const int mod = 1000000007;
int N; long long D[100100][2];
vector<int> G[100100];

void go(int x, int l)
{
	D[x][0] = D[x][1] = 1;
	for (auto y : G[x]) if (l != y){
		go(y,x);
		D[x][0] = D[x][0] * (D[y][0] + D[y][1]) % mod;
		D[x][1] = D[x][1] * D[y][0] % mod;
	}
}

int main()
{
	scanf ("%d",&N);
	for (int i=1;i<N;i++){
		int x,y; scanf ("%d %d",&x,&y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
	go(1,0);
	printf ("%lld\n",(D[1][0]+D[1][1]) % mod);

	return 0;
}

Measured memory_bytes: 14208
def is_kaibun(s)
  # p s
  n = s.size
  (n/2).times.all? do |i|
    s[i] == s[n - 1 - i]
  end
end

s = gets.chomp
n = s.size
t = s[0,n/2]
u = s[n/2+1,n/2]

# p [s,t,u]

ans = is_kaibun(s) && is_kaibun(t) && is_kaibun(u)
puts ans ? "Yes" : "No"


Measured memory_bytes: 3836
#include <cstdio> 
#include <cstdlib> 
#include <cmath> 
#include <cstring> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <numeric>
#include <cassert>

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

template<typename T>
vector<T> getVector(int N) {
    vector<T> v(N);
    REP(i, N) cin >> v[i];
    return v;
}

int main(void)
{
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    ll ret = 0;
    
    ret += min(A, K);
    K -= min(A, K);
    K -= min(B, K);
    ret -= min(C, K);
    K -= min(C, K);
    assert(K == 0);

    cout << ret << endl;
    
    return 0;
}


Measured memory_bytes: 3672
import sys
import itertools
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n,x = IL()
    l = [0]+list(IL())
    l = list(itertools.accumulate(l))
    ans = 0
    for rep in l:
        if x<rep:   break
        ans += 1
    print(ans)
    return

if __name__=='__main__':
    Main()

Measured memory_bytes: 9068
N, Y = map(int, input().split())

for i in range(N+1):
    for j in range(N+1-i):
        if Y == 10000*i + 5000*j + 1000*(N-i-j):
            print(i, j, (N-i-j))
            exit()

print(-1, -1, -1)


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

const int A = 1000006;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> c(A);
  rep(i,n) {
    cin >> a[i];
    c[a[i]]++;
  }
  bool pairwise = true;
  for (int i = 2; i < A; i++) {
    int cnt = 0;
    for (int j = i; j < A; j += i) {
      cnt += c[j];
    }
    if (cnt > 1) pairwise = false;
  }
  if (pairwise) {
    cout << "pairwise coprime" << endl;
    return 0;
  }
  int g = 0;
  rep(i,n) g = gcd(g, a[i]);
  if (g == 1) {
    cout << "setwise coprime" << endl;
    return 0;
  }
  cout << "not coprime" << endl;
  return 0;
}


Measured memory_bytes: 11160
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll n;cin>>n;
    vector<pair<ll,ll>> v;
    REP(i,n){
        ll a;
        cin>>a;
        v.push_back(make_pair(a,i));
    }
    sort(ALL(v));
    vector<ll> w(n);
    REP(i,n){
        ll median,num;
        if(i<=(n/2)-1){
            median=v[n/2].first;
        }else{
            median=v[(n/2)-1].first;
        }
        num=v[i].second;
        w[num]=median;
    }
    REP(i,n){
        cout<<w[i]<<endl;
    }

    return 0;
}


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

int main(){
    // 制約見て！！！デカかったらlong longにすること！
    int n,k;
    cin >> n>>k;
    int sunukes[n];
    rep(i,n){
        sunukes[i]=0;
    }
    rep(i,k){
        int d;
        cin >> d;
        rep(j,d){
            int tmp;
            cin >> tmp;
            sunukes[tmp-1]++;
        }
    }
    int ans = 0;
    rep(i,n){
        if(sunukes[i] ==0){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
# dp[i][j] := i番目までのitemを使って価値がj以下の時の最小の重み
N, W = map(int, input().split())
weight = []
value = []
for _ in range(N):
    w, v = map(int, input().split())
    weight.append(w)
    value.append(v)
dp = [[10**12] * (sum(value)+1) for _ in range(N+1)]
dp[0][0] = 0
for i in range(N):
    for j in range(sum(value)+1 - value[i]):
        # i番目のitemを使わない場合
        dp[i+1][j] = min(dp[i][j], dp[i+1][j])  # 重みを最小にしたい
        # i番目のitemを使う場合
        dp[i+1][j+value[i]] = min(dp[i][j] + weight[i], dp[i+1][j+value[i]])  # 重みを最小にしたい

ans = 0
for j in range(sum(value)+1):
    if dp[N][j] > W:
        continue
    ans = max(ans, j)
print(ans)


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

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

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
# include"stdio.h"
int main(){
    char s[27];
    scanf("%s",s);
    int cnt=0;
    while(s[cnt]!='\0') cnt++;
    int f[26];
    for(int i=0;i<26;i++) f[i]=0;
    char a ='a';
    for(int i=0;i<cnt;i++){
        if(f[s[i]-a]){
             printf("no\n");
             return 0;
        }else f[s[i]-a]=1;
    }
    printf("yes\n");
}


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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

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


int n;

int main(){
	cin >> n;
	if(n % 10 == 0){
		cout << 10 << endl;
	}
	else{
		int ans = 0;
		int a = 1;
		for(; a < n; a*=10);
		for(; a >= 1; a /=10){
			ans += n/a;
			n %= a;
		}
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	int k,i;
	cin>>k;
	string s="ACL";
	for(i=1;i<=k;i++){
		cout<<s;
	}
	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>

using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    char s[n];
    scanf("%s", s);

    int i, j, k, c, left, right;
    int m;
    int ans = 0, cnt;
   

    for (i = 1; i < n; i++){
        cnt = 0;
            int left[26]={0};
            int right[26]={0};
        for (c = 0; c < 26; c++){

            for (j = 0; j < i; j++){
                if (s[j] - 'a' == c)
                    left[c]++;
            }
            for (k = i; k < n; k++){
                if (s[k] - 'a' == c)
                    right[c]++;
            }
            if (left[c] >= 1 && right[c] >= 1)
                cnt++;
        }
        if (ans < cnt)
            ans = cnt;
    }
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
 
typedef long long ll;
 
#define N 20
const int INF = 1 << 30;
const int P = 10007, A = 31, B = 7;
const ll mod = 1e12 + 22333;
const double pi = acos(-1);

int main()
{
	//freopen("in.in", "r", stdin);
	//freopen("out.out", "w", stdout);
 	
 	ll A, B, ans; int r, k;
	cin >> A >> B;
	if (A == B) puts("1");
	else
	{
		for (int i = 60; i >= 0; --i)
		{
			if ((A & (1ll << i)) == (B & (1ll << i))) 
			{
				if (A & (1ll << i)) A ^= 1ll << i, B ^= 1ll << i;
			}
			else 
			{
				r = i; 
				break;
			}
		} 
		ans = (1ll << r) - A;
		ll l1 = 1ll << r, r1, l2, r2;
		for (k = r - 1; k >= 0 && (1ll << r) + (1ll << k) > B; --k);
		if (k == -1) r1 = l1;
		else r1 = l1 + (1ll << (k + 1)) - 1;
		l2 = (1ll << r) + A;
		r2 = (1ll << (r + 1)) - 1;
		ans += r1 - l1 + 1 + r2 - l2 + 1;
		if (l2 <= r1) ans -= r1 - l2 + 1;
		printf("%lld\n", ans);
	}
 
	return 0;
} 

Measured memory_bytes: 256
H,W=map(int,input().split())
f=lambda S,L:"".join(map(lambda x:S[x],L))
S=[]

B=[]
for w in range(H):
    K=input()
    S.append(K)

    if K.count("#"):
        B.append(w)
        

A=[]
for x in range(W):
    F=False
    for y in range(H):
        F|=(S[y][x]=="#")

    if F:
        A.append(x)
        
T=[]
for b in B:
    T.append(f(S[b],A))
print("\n".join(T))


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

using namespace std;
long long candles[100005];
int main()
{
    int n,k;
    cin >> n >> k;
    for(int i = 1;i <= n;i++)
        cin >> candles[i];
    long long fx = 1e18;
    for(int i = 1;i <= n-k+1;i++)
    {
        long long f1 = candles[i];
        long long f2 = candles[i+k-1];
        if(f2 < 0 && f1 < 0)
            fx = min(fx,max(abs(f1),abs(f2)));
        else if(f1 < 0 && f2 > 0)
            fx = min(fx,min(abs(f1),abs(f2))*2 +max(abs(f1),abs(f2)));
        else
            fx = min(fx,max(f1,f2));
    }
    cout << fx;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n,dice[100][6], tmp;
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        for(int j=0; j<6; j++){
            scanf("%d", &dice[i][j]);
        }
    }
    for(int h=1; h<n; h++){
        for(int i=0; i<4; i++){
            for(int j=0; j<4; j++){
                for(int k=0; k<4; k++){
                    for(int l=0; l<n-1; l++){
                        for(int m=l+1; m<n; m++){
                            if(dice[l][0] == dice[m][0] && dice[l][1] == dice[m][1] && dice[l][2] == dice[m][2] &&
                               dice[l][3] == dice[m][3] && dice[l][4] == dice[m][4] && dice[l][5] == dice[m][5]){
                                printf("No\n");
                                return 0;
                            }
                        }
                    }
                    tmp = dice[h][0];
                    dice[h][0] = dice[h][1];
                    dice[h][1] = dice[h][5];
                    dice[h][5] = dice[h][4];
                    dice[h][4] = tmp;
                }
                tmp = dice[h][1];
                dice[h][1] = dice[h][2];
                dice[h][2] = dice[h][4];
                dice[h][4] = dice[h][3];
                dice[h][3] = tmp;
            }
            tmp = dice[h][0];
            dice[h][0] = dice[h][3];
            dice[h][3] = dice[h][5];
            dice[h][5] = dice[h][2];
            dice[h][2] = tmp;
        }
    }
    printf("Yes\n");
    return 0;
}



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

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
static const int MAX_M = 100000;
typedef pair<int, int> P;

int N, M;
P a[MAX_M];

int main(){
	cin >> N >> M;
	for(int i = 0; i < M; i++){
		cin >> a[i].first >> a[i].second;
	}
	sort(a, a + M);
	int cnt = 0;
	for(int i = 0; i < M; i++){
		P b = a[i];
		while(i < M && a[i + 1].first < b.second){
			b.first = a[i + 1].first;
			b.second = min(b.second, a[i + 1].second);
			i++;
		}
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x,t;
  cin>>n>>x>>t;
  int k =  x/t;
  int pp = n/x;
  int ans = pp*t;
  int left = n - pp*x;
  if(left){
  	ans+=t;
  }
  
  
  cout<<ans<<endl;
  
  
}

Measured memory_bytes: 3548
#include<iostream>
#include<algorithm>
using namespace std;
int main () {
    int a,b,c;
    cin>>a>>b;
    if(b/a==1000){
        cout<<0<<" "<<0<<" "<<a<<endl;
        return 0;
    }else if(b/a==5000){
        cout<<0<<" "<<a<<" "<<0<<endl;
        return 0;
    }else if(b/a==10000){
        cout<<a<<" "<<0<<" "<<0<<endl;
        return 0;
    }
    for(int i=0;i<a;i++){
        c=10000*i+5000*(a-i);
        if(c==b){
            cout<<i<<" "<<a-i<<" "<<0<<endl;return 0;
        }
        c=5000*i+1000*(a-i);
        if(c==b){
            cout<<0<<" "<<i<<" "<<a-i<<endl;return 0;
        }
        c=10000*i+1000*(a-i);
        if(c==b){
            cout<<i<<" "<<0<<" "<<a-i<<endl;return 0;
        }
    }
    for(int i=0;i<a;i++){
        for(int q=0;q<i;q++){
            c=10000*(a-i)+5000*(i-q)+1000*q;
        
            if(c==b){
            cout<<a-i<<" "<<i-q<<" "<<q<<endl;return 0;
        }
        }
        
    }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 0x7fffffff
using namespace std;
typedef long long ll;
int a,b,c;
int main()
{
    cin>>a>>b>>c;
    cout<<max(a,max(b,c))-min(a,min(b,c))<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
	long long X, Y;
	//X = 1, Y = 1000000000000000000;
	//X = 1, Y = 10;
	scanf("%lld%lld", &X, &Y);
	long long ans = 1;
	while (X * 2 <= Y) {
		X = X * 2;
		ans++;
	}
	printf("%lld\n", ans);
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

bool ok(ii &a, int H, int W) {
	return 0<=a.first&&a.first<H&&0<=a.second&&a.second<W;
}

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int H,W; cin>>H>>W;
	vector<string> g(H);
	for (int i=0; i<H; i++)
		cin>>g[i];
	vector<vector<int>> dp(H,vector<int>(W,0));
	if(g[0][0]=='#')
		dp[0][0]++;
	for (int i=1; i<H; i++) {
		dp[i][0]=dp[i-1][0];
		if(g[i][0]=='#'&&g[i-1][0]=='.')
			dp[i][0]++;
//		cout<<i<<" "<<0<<"::"<<dp[i][0]<<endl;
	}
	for (int j=1; j<W; j++) {
		dp[0][j]=dp[0][j-1];
		if(g[0][j]=='#'&&g[0][j-1]=='.')
			dp[0][j]++;
//		cout<<0<<" "<<j<<"::"<<dp[0][j]<<endl;
	}
	for (int i=1; i<H; i++) {
		for (int j=1; j<W; j++) {
			int down=dp[i-1][j], right=dp[i][j-1];
			if(g[i][j]=='#'&&g[i-1][j]=='.')
				down++;
			if(g[i][j]=='#'&&g[i][j-1]=='.')
				right++;
			dp[i][j]=min(down,right);
//			cout<<i<<" "<<j<<"::"<<dp[i][j]<<endl;
		}
	}
	cout<<dp[H-1][W-1]<<"\n";
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include<math.h>
#include<bitset>
#include<string>
#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
#include <iomanip>
using namespace std;

int main()
{
    bool flag=true;
    long long n;
    cin>>n;
    vector<long long>h(n);
    for(int i=0;i<n;i++) cin>>h[i];
    
    for(int i=n-1;0<i;i--){
        if(h[i]-h[i-1]>=0){}
        else if(h[i]-h[i-1]==-1)h[i-1]--;
        else flag=false;

    }
    
    if(flag==true)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int cnt[200010];

int main() {
  // 入力
  int N, K;
  cin >> N >> K;
  int a[N];
  for (int i = 0; i < N; i++) cin >> a[i];

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

  vector<int> c;
  for (int i = 0; i <= N; i++) {
    if (cnt[i] == 0) continue;
    c.push_back(cnt[i]);
  }

  sort(c.begin(), c.end());
  int ans = 0;
  if (c.size() > K) {
    for (int i = 0; i < c.size() - K; i++) {
      ans += c[i];
    }
  }

  // 解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2936
import copy

def j(n):
    if n:print("yes")
    else:print("no")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printrow(a):
    for i in a:
        print(i)
n = ip()
a = iprow()
cons = 0
m = 0
for i in range(n-1):
    if a[i] >= a[i+1]:
        cons+=1
    else:
        m = max(m,cons)
        cons = 0
print(max(m,cons))

Measured memory_bytes: 14784
#include<stdio.h>
#include<iostream>
#include<stack>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    stack<int> S1;
    stack<pair<int, int> > S2;
    char ch;
    int sum=0;
    for(int i=0;scanf("%c",&ch)!=EOF;i++)
    {
        if(ch=='\\')
        {
            S1.push(i);
        }
        else if(ch=='/'&&S1.size()>0)
        {
            int j=S1.top();
            S1.pop();
            sum+=i-j;
            int a=i-j;
            while(S2.size()>0&&S2.top().first>j)
            {
                a+=S2.top().second;
                S2.pop();
            }
            S2.push(make_pair(j,a));
        }
    }
    vector<int> ans;
    while(S2.size()>0)
    {
        ans.push_back(S2.top().second);
        S2.pop();
    }
    reverse(ans.begin(),ans.end());
    printf("%d\n",sum);
    printf("%d",ans.size());
    for(int i=0;i<ans.size();i++)
    {
        printf(" ");
        printf("%d",ans[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 3244
#include <iostream>

int main()
{
        std::string a,b,c;
        std::cin >> a >> b >> c;
        if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0])
                std::cout<<"YES\n";
        else
                std::cout<<"NO\n";
        return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, m) = (v[0], v[1]);
    let mut a = read_vec::<i64>().into_iter().collect::<BinaryHeap<_>>();

    for _ in 0..m {
        let top = a.pop().unwrap();
        a.push(top / 2);
    }
    let ans = a.iter().sum::<i64>();
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 1e5;
struct node{
	ll a,b;
	bool operator<(const node& temp) const{
		return this->b<temp.b;
	}
}no;
vector<node> v;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>no.a>>no.b;
		v.push_back(no);
	}
	sort(v.begin(),v.end());
	ll t=0;
	for(int i=0;i<v.size();i++){
		if(t+v[i].a<=v[i].b){
			t+=v[i].a;
		}
		else{
			cout<<"No\n";
			return 0;
		}
	}
	cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 6384
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl;
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2

int n, k;
vector<int>a;
int dp[5050][5050];
int check(int ex) {
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	rep(i, 0, n - 1)rep(x,0,k+1) {
		int ind = (i < ex) ? i : i + 1;
		dp[i + 1][x] = max(dp[i][x],dp[i+1][x]);
		if (x + a[i] < 5050) {
			dp[i + 1][x + a[ind]] = max(dp[i + 1][x + a[ind]], dp[i][x]);
		}
	}
	for (int i = max(0, k - a[ex]); i < k;i++) {
		if (dp[n-1][i])return 1;
	}
	return 0;
}

int main() {
	cin >> n >> k;
	a.resize(n);
	rep(i, 0, n)cin >> a[i];
	sort(all(a));

	if (check(0)) {
		puts(0);
	}
	else if (!check(n-1)) {
		puts(n);
	}
	else {
		int noneed = 0, need = n - 1;
		while (need - noneed > 1) {
			int mid = (need + noneed) / 2;
			if (check(mid))need = mid;
			else noneed = mid;
		}
		puts(noneed + 1);
	}

	return 0;
}


Measured memory_bytes: 99840
#include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;
int a[4];
int cnt;
int ans=0x7fffffff;
int main()
{
	for(int i=1;i<=3;i++)scanf("%d",a+i);
	for(int i=1;i<=3;i++)
	{
		for(int j=1;j<=3;j++)
		{
			for(int k=1;k<=3;k++)
			{
				if(i!=k && i!=j && j!=k)
				{
					cnt=0;
					cnt+=abs(a[j]-a[i]);
					cnt+=abs(a[k]-a[j]);
					ans=min(ans,cnt);
				}
			}
		}
	}
	printf("%d",ans);
	return 0;
}

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

r=[]
r.append(N%26)
x=N//26

if N%26==0:
  x=x-1
while x > 0:
  t=x%26
  r.append(t)
  x=x//26
  if t==0:
    x=x-1
  
A=["z","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"]

X = A[r[0]]
for i in range(len(r)-1):
    X = X + A[r[i+1]]

print(X[::-1])

Measured memory_bytes: 9244
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define ll long long
#define pb push_back
int main(){
    fastio
    ll a, b; cin >> a >> b;
    cout << (int)a*b <<"\n";
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const double EPS = 1e-7;
const long long mod = 1e9 + 7;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define X real()
#define Y imag()
#define cross(a,b) (conj(a)*(b)).imag()
#define dot(a,b) (conj(a)*(b)).real()
#define dist(a,b) ( pow(a.X - b.X, 2) + pow( a.Y - b.Y, 2 ) )
typedef tuple <int, int, int> line;
typedef complex <double> point;
typedef vector <point> polygon;
int n, k, h[1000000], arr[1000000];
int solve( int idx)
{
    if ( idx == n - 1 )
        return 0;
    if ( arr[idx] != -1 )
        return arr[idx];
    int ans = 2e9;
    int last = min(idx + k, n - 1);
    for(int i = idx + 1; i <= last; i++)
    {
        ans = min(ans, abs(h[idx] - h[i]) + solve(i) );
    }
    arr[idx] = ans;
    return ans;
}
int main()
{
    Hello
    memset(arr, -1, sizeof arr);
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> h[i];
    cout << solve(0);
    return 0;
}



Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <vector>
#include <bitset>
#include <numeric>
#include <limits>
#include <algorithm>
#include <functional>
#include <map>

using namespace std;

using ll = long long;

template <class T>
using grid = vector<vector<T>>;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

template<class T>
void print(vector<T> a) {
  cout << "[ ";
  REP(i, a.size()) cout << a[i] << " ";
  cout << "]" << endl;
}

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

// vector<int> d;
// ll dp(int i, int m) {
//   if (i == d.size()) {
//     return 0;
//   }
//   int value = (m * 10 + d[i]) % 2019;
//   return dp(i + 1, value) + (value == 0);
// }

int main() {
  string input(s);
  int n = s.size();
  vector<int> d(n);
  REP(i, n) d[n - i - 1] = s[i] - '0';

  vector<int> p(n);
  ll m = 1;
  ll pp = 0;
  REP(i, n) {
    p[i] = pp = (m * d[i] + pp) % 2019;
    (m *= 10) %= 2019;
  }

  map<int, int> cnt;
  for (auto v: p) {
    cnt[v] += 1;
  }

  ll ans = 0;
  for (auto v: cnt) {
    if (v.first == 0) ans += v.second;
    if (v.second >= 2) {
      ans += (v.second * (v.second - 1)) / 2;
    }
  }
  print(ans);
}


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

int main() {
	 
	 int n;
	 string s;
	 
	 cin >>n>>s;
	 
	 int i ,min=0,x=0;
	 
	 for(i=0;i<n;i++)
	 {
	     if(s[i]=='I')
	     {
	         x++;
	     }
	     else
	     {
	         x--;
	     }
	     if(min<x)
	     {
	         min=x;
	     }
	 }
	 
	 cout <<min;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,count=1;
    char s[100000];
    cin >> n;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    char c=s[0];
    for(int i=1;i<n;i++){
        if(c!=s[i]){
            count++;
            c=s[i];
        }
    }
    cout << count <<endl;
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main(){
  string s;
  cin >> s;
  int n;
  n = s.length();
  char pp = s[0], p=s[1];
  if (pp == p){
    cout << 1 << " " << 2 << endl;
    return 0;
  }
  for(int i=2;i<n;i++){
    if (p == s[i]){
      cout << i << " " << i+1 << endl;
      return 0;
    }else if (pp == s[i]){
      cout << i-1 << " " << i+1 << endl;
      return 0;
    }
    pp = p;
    p = s[i];
  }
  cout << -1 << " " << -1 << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int n,s;
	while(1){
		cin>>n>>s;
		if(n+s==0) break;
		vi r(n,0);
		rep(i,0,n) cin>>r[i];

		sort(all(r));
		int ans=0;
		rep(i,0,n-1){
			int it=max((int)(upper_bound(all(r),s-r[i])-r.begin()),(int)(i+1));
			ans+=n-it;
		}
		o(ans);
	}
}

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

using namespace std;

const int MAXN = 100000;

vector<pair<int, int>> edges[MAXN];
int dist[MAXN];
bool bio[MAXN];

bool dfs(int i)
{
	for (const auto& edge: edges[i])
	{
		if (!bio[edge.first])
		{
			dist[edge.first] = dist[i] + edge.second;
			bio[edge.first] = true;
			if (dfs(edge.first))
				return true;
		}
		else if (dist[edge.first] != dist[i] + edge.second)
			return true;
	}
	return false;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n, m, i;
	int l, r, d;
	
	cin>>n>>m;
	
	while (m--)
	{
		cin>>l>>r>>d;
		--l, --r;
		
		edges[l].push_back({r, d});
		edges[r].push_back({l, -d});
	}
	
	for (i = 0; i < n; ++i) if (!bio[i])
	{
		dist[i] = 0;
		bio[i] = true;
		if (dfs(i))
		{
			cout<<"No\n";
			return 0;
		}
	}
	
	cout<<"Yes\n";
}


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

#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int, int> pi;
typedef vector<int> vi;
void print_pair(pi a){
  cerr<<"("<<a.first<<", "<<a.second<<") ";
}
template<int T1, int T2>
void print_2d(int a[T1][T2], int x, int y){
  For(i, x){
    For(j, y){
      cerr<<a[i][j]<<" ";
    }
    cerr<<endl;
  }
}
template<class T>
void print_array(T a[],size_t n){
  cerr<<"array:";
  REP(n-1)cerr<<a[i]<<",";
  cerr<<a[n-1]<<endl;
}

string in_str;

int main(){
  cin>>in_str;
  ll cnt_b=0;
  ll ans=0;
  for(auto tmp:in_str){
    if(tmp=='B')
      cnt_b++;
    else
      ans+=cnt_b;
  }
  cout<<ans<<endl;

  return 0;
}



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

typedef long long ll;
typedef long double ld;

ll br[200005];
ll a[200005];

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

	int n;
	cin >> n;
	ll res = 0;
	for(int i=1; i<=n; i++){
        cin >> a[i];
        res += br[a[i]];
        br[a[i]]++;
	}
	for(int i=1; i<=n; i++){
        cout << res-br[a[i]]+1 << "\n";
	}
    return 0;
}


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

int main(void){
  int a, b, i, p, c=0;
  char s[15];
  scanf("%d %d",&a, &b);
  scanf("%s",s);
  for(i=0;i<strlen(s);i++) if(s[i]=='-'){p=i; c++;};
  if(c==1 && a==p && b==strlen(s)-p-1) printf("Yes\n");
  else printf("No\n");

  return 0;
}


Measured memory_bytes: 128
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N, U, V = getNM()
U -= 1
V -= 1
# 高橋君はできるだけ遅くゲームが終了するように移動し、青木君はできるだけ早くゲームが終了するように移動します。
# 高橋君は逃げ、青木君は追いかける
dist = [[] for i in range(N)]
for i in range(N - 1):
    a, b = getNM()
    dist[a - 1].append(b - 1)
    dist[b - 1].append(a - 1)

taka_d = [-1] * N
aoki_d = [-1] * N

taka_d[U] = 0
pos = deque([[U, taka_d[U]]])
while len(pos) > 0:
    u, dis = pos.popleft()
    for i in dist[u]:
        if taka_d[i] == -1:
            taka_d[i] = dis + 1
            pos.append([i, taka_d[i]])

aoki_d[V] = 0
pos = deque([[V, aoki_d[V]]])
while len(pos) > 0:
    u, dis = pos.popleft()
    for i in dist[u]:
        if aoki_d[i] == -1:
            aoki_d[i] = dis + 1
            pos.append([i, aoki_d[i]])

ans = 0
for a, b in zip(taka_d, aoki_d):
    if a < b:
        ans = max(ans, b - 1)
print(ans)


Measured memory_bytes: 103284
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007
ll fac[1000000];
ll finv[1000000];
ll inv[1000000];

void comb_init(){
  fac[0] = 1;
  for(int i=1;i<1000000;i++){
    fac[i] = i*fac[i-1];
    fac[i] %= MOD;
  }
  inv[1] = 1;
  for(int i=2;i<1000000;i++){
    inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
  }
  finv[0] = 1;
  for(int i=1;i<1000000;i++){
    finv[i] = inv[i]*finv[i-1];
    finv[i] %= MOD;
  }
}

ll comb(ll n,ll k){
  ll c = fac[n];
  c *= finv[k];c %= MOD;
  c *= finv[n-k];c %= MOD;
  return c;
}
int main(){
  ll a,b;
  cin >> a >> b;
  ll ans = 0;
  if(a == 3) ans += 100000;
  if(a == 2) ans += 200000;
  if(a == 1) ans += 300000;
  if(b == 3) ans += 100000;
  if(b == 2) ans += 200000;
  if(b == 1) ans += 300000;
  if(a == 1 && b== 1) ans += 400000;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 764
/*
Author: CNYALI_LK
LANG: C++
PROG: A.cpp
*/
#include<bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define all(x) x.begin(),x.end()
#define end(...) {printf(__VA_ARGS__);exit(0);}
using namespace std;
const double eps=1e-8;
const double PI=acos(-1.0);
typedef long long ll;
template<class T>void chkmin(T &a,T b){a=a<b?a:b;}
template<class T>void chkmax(T &a,T b){a=a>b?a:b;}
template<class T>T sqr(T a){return a*a;}
template<class T>T mmin(T a,T b){return a<b?a:b;}
template<class T>T mmax(T a,T b){return a>b?a:b;}
template<class T>T aabs(T a){return a<0?-a:a;}
#define min mmin
#define max mmax
#define abs aabs
char s[233];
int main(){
#ifdef cnyali_lk
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
	int n;
	scanf("%s",s+1);
	n=strlen(s+1);
	s[n-7]=0;
	printf("%s\n",s+1);
	
	return 0;
}



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

int main(){
  
  int N;
  cin >> N;
  
  for(int i = 0; i < N; i++){
    string x;
    cin >> x;
   
    if(x =="Y"){
      
      cout << "Four"<<endl;
      break;
    }
    if( i == N-1 && x != "Y"){
      cout << "Three"<< endl;
      break;
    }
  }
}

Measured memory_bytes: 256
from collections import Counter
def main():
    n=int(input())
    v=list(map(int,input().split()))
    v0=Counter(v[0::2]).most_common(2)
    v1=Counter(v[1::2]).most_common(2)
    
    if v0[0][0] != v1[0][0]:
        print(n - v0[0][1] - v1[0][1])
    else:
        if len(v0) == 1 and len(v1) == 1:
            print(n//2)
        else:
            print(n-max(v0[0][1]+v1[1][1], v0[1][1]+v1[0][1]))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 21368
def power(a,n):
    x=1
    L=list(format(n,'b'))
    l=len(L)
    for i in range(l):
        if int(L[l-i-1])==1:        
            x=(x*a)%(10**9+7)
        a=(a*a)%(10**9+7)
    return x
n,k=map(int,input().split())
a=1
b=1
y=0
for i in range(n):
    a=(a*(i+1))%(10**9+7)
    b=(b*(2*n-i-1))%(10**9+7)
aa=power(a,10**9+5)
x=(b*aa)%(10**9+7)
if k<n-1:
    c=1
    d=1
    e=1
    f=1
    for i in range(k+1):
        c=(c*(n-i))%(10**9+7)
        d=(d*(i+1))%(10**9+7)
    d=power(d,10**9+5)
    c=(c*d)%(10**9+7)
    for i in range(n-k-2):
        e=(e*(n-1-i))%(10**9+7)
        f=(f*(i+1))%(10**9+7)
    f=power(f,10**9+5)
    e=(e*f)%(10**9+7)
    y=(c*e)%(10**9+7)
    if k+2<=n-1:
        for i in range(k+2,n):
            c=(c*(n-i+1))%(10**9+7)
            d=power(i,10**9+5)
            c=(c*d)%(10**9+7)
            e=(e*(n-i))%(10**9+7)
            f=power(i,10**9+5)
            e=(e*f)%(10**9+7)
            y+=(c*e)%(10**9+7)
            y=y%(10**9+7)
x=x-y
if x<0:
    x=10**9+7+x
print(x)






Measured memory_bytes: 45312
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <functional>
using namespace std;

int n, a[100009];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	int cnt = 0;
	while (true) {
		bool flag = false;
		for (int i = 0; i < n; i++) {
			if (a[i] % 2 == 0)a[i] /= 2;
			else flag = true;
		}
		if (flag == true)break;
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
hs = list(map(int, input().split()))
flags = [i >= 1 for i in hs]
# 最後のエッジ
flags.append(False)

ans = 0
while any(flags):
    for i in range(n):
        # 1→0 のエッジ
        if flags[i] and not flags[i+1]:
            ans += 1
        hs[i] = hs[i] - 1 if hs[i] else 0
    flags = [j>=1 for j in hs]
    flags.append(False)
print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize("O3")
        #pragma comment(linker, "/stack:200000000")
        #pragma GCC optimize("unroll-loops")
         
        #include <algorithm>
        #include <bitset>
        #include <cassert>
        #include <chrono>
        #include <cmath>
        #include <complex>
        #include <cstdio>
        #include <cstdlib>
        #include <cstring>
        #include <ctime>
        #include <deque>
        #include <functional>
        #include <iomanip>
        #include <iostream>
        #include <iterator>
        #include <limits>
        #include <climits>
        #include <list>
        #include <map>
        #include <numeric>
        #include <queue>
        #include <random>
        #include <ratio>
        #include <set>
        #include <sstream>
        #include <stack>
        #include <string>
        #include <unordered_map>
        #include <unordered_set>
        #include <utility>
        #include <vector>
        using namespace std;
         
        typedef long long ll;
        typedef long double LD;
        #define int ll
        #define double LD
        #define pb push_back
        #define mp make_pair
        #define REP(i,n) for (int i = 0; i < n; i++)
        #define loop(i,n) for (int i = 0; i < n; i++)
        #define FOR(i,a,b) for (int i = a; i < b; i++)
        #define REPD(i,n) for (int i = n-1; i >= 0; i--)
        #define FORD(i,a,b) for (int i = a; i >= b; i--)
        #define remax(a,b) a = max(a,b)
        #define remin(a,b) a = min(a,b)
        #define mem(a, b) memset(a, b, sizeof a)
        #define append push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define print(x) cout << (x) << endl
        #define PRECISION(x) cout << fixed << setprecision(x)
        #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
        #define N 200005
        #define pb push_back
        const double PI=acos(-1);
        const int MOD = 1000000007;
        const int FMOD = 998244353;
        const double eps = 1e-9;
         
        mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 

		signed main()
		{
			int a[6];
			FOR(i,1,6)
			{
				cin>>a[i];
				if(a[i]==0)
				{
					cout<<i;
					break;
				}
			}
		}

Measured memory_bytes: 3524
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ll = long long;
#define MAX_N 1010
#define MAX_M 100010
const long long mod = pow(10,9)+7;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define veche vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define ent cout<<endl
#define printvec(vec) for(int aqw=0;aqw<vec.size();aqw++){cout<<vec[aqw]<<" ";}ent;
#define rep1(n) for(ll i = 0; i < (n); ++i)
#define rep2(i, n) for(ll i = 0; i < (n); ++i)
#define rep3(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep4(i, a, b, c) for(ll i = (a); i < (b); i += (c))
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; }
#define INF 1e+9
#define print(x) cout<<x<<endl;
using P = pair<int, int>;
#define PLL pair<ll, ll>;
#define MAX_V 10010
#define PI 3.141592653589793
#define vecP vector<P>
 //cout << setprecision(15) << std::fixed;


class Radix {
private:
    const char* s;
    int a[128];
public:
    Radix(const char* s = "0123456789ABCDEF") : s(s) {
        int i;
        for (i = 0; s[i]; ++i)
            a[(int)s[i]] = i;
    }
    std::string to(long long p, int q) {
        int i;
        if (!p)
            return "0";
        char t[64] = { };
        for (i = 62; p; --i) {
            t[i] = s[p % q];
            p /= q;
        }
        return std::string(t + i + 1);
    }
    std::string to(const std::string& t, int p, int q) {
        return to(to(t, p), q);
    }
    long long to(const std::string& t, int p) {
        int i;
        long long sm = a[(int)t[0]];
        for (i = 1; i < (int)t.length(); ++i)
            sm = sm * p + a[(int)t[i]];
        return sm;
    }
};

int main() {
    Radix r;
    int a, b;
    cin >> a >> b;
    print(string(r.to(a, b)).size());
}


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

using namespace std;
#define ll long long
const int mod=1e9+7;
const int N=3e5+100;
typedef pair<int,int>pa;
int a[N];
int n,m;
ll qpow(ll x,ll n)
{
    ll sum=1;
    while(n){
       if(n&1) sum=sum*x%mod;
       x=x*x%mod;
       n>>=1;
    }
    return sum;
}

int r[N],c[N];
map<pa,int>mp;
int main()
{
    ios::sync_with_stdio(0);
    int h,w,m;
    cin>>h>>w>>m;
    int rm=0,cm=0,rk=0,ck=0;
    for(int i=1;i<=m;i++){
        int x,y;
        cin>>x>>y;
        r[x]++,c[y]++;
        if(r[x]>rm) rm=r[x],rk=x;
        if(c[y]>cm) cm=c[y],ck=y;
        mp[make_pair(x,y)]=1;
    }

    vector <int>rr,cc;
    rr.push_back(rk);
    cc.push_back(ck);

    for(int i=1;i<=h;i++){
        if(r[i]==rm && i!=rk)
        rr.push_back(i);
    }
    for(int i=1;i<=w;i++){
        if(c[i]==cm && i!=ck)
        cc.push_back(i);
    }

    for(auto v:rr){
        for(auto vv:cc){
            if(!mp[make_pair(v,vv)]){
                cout<<rm+cm<<endl;
                return 0;
            }
        }
    }
    cout<<rm+cm-1<<endl;

    return 0;
}



Measured memory_bytes: 28544
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define pb push_back
#define MOD 1000000007
#define INF 1000000000
#define EPS 0.0000000001
typedef long long ll;

ll n,q;
vector<vector<ll>> edge;
vector<ll> cost;
vector<bool> check;

void dfs(ll current){
    check[current]=true;
    for(ll next:edge[current]){
        if(check[next]){
            continue;
        }
        cost[next]+=cost[current];

        dfs(next);
    }
}

int main()
{
    cin>> n>>q;
    ll a,b,p,x;
    cost.resize(n);
    edge.resize(n);
    rep(i,n-1){
        cin>>a>>b;
        edge[a-1].pb(b-1);
        edge[b-1].pb(a-1);
    }
    rep(i,q){
        cin>>p>>x;
        cost[p-1]+=x;
    }
    check.resize(n);
    dfs(0);
    rep(i,n){
        cout<<cost[i]<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 24320
using System;
class ProgramA
    {
        static void Main(string[] args)
        {
            //まずは数を読む
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int k = int.Parse(input[1]);

            //数出力
            int output = n - k;
            if (k == 1)
                output = 0;

            //出力
            Console.WriteLine(output);
        }
    }

Measured memory_bytes: 13140
# https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_d



N = gets.to_i
S = gets.chomp

ans = 0
(0..999).each do |x|
  code = sprintf("%03d", x)

  p0 = S.index(code[0])
  next if p0.nil?

  p1 = S[(p0 + 1)..(S.length - 1)].index(code[1])
  next if p1.nil?

  p2 = S[(p0 + p1 + 2)..(S.length - 1)].index(code[2])
  next if p2.nil?

  ans += 1
end
puts ans


Measured memory_bytes: 1788
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		final long MOD = (long)1000000007;
		int n = in.nextInt();
		long[] ints = new long[n];
		for(int i = 0; i < n; i++) ints[i] = in.nextLong();
		int[][] solve = new int[n][61];
		for(int i = n - 1; i > 0; i--) {
			for(int j = 0; j < 61; j++) {
				if(((ints[i] >> j) & (1)) == 1) {
					solve[i][j] += 1;
					solve[i - 1][j] = solve[i][j];
				}else {
					solve[i - 1][j] = solve[i][j];
				}
			}
		}
		long ans = 0L;
		for(int i = 0; i < n - 1; i++) {
			for(int j = 0; j < 61; j++) {
				if(((ints[i] >> j) & (1)) == 1) { 
					long save = ((long)(((1L << j) % MOD) * (((n - 1) - i - solve[i + 1][j]) % MOD))) % MOD;
					ans = ((ans % MOD) + (save % MOD)) % MOD;
				}else {
					long save = ((long)(((1L << j) % MOD) * ((solve[i + 1][j]) % MOD))) % MOD;
					ans = ((ans % MOD) + (save % MOD)) % MOD;
				}
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 129244
IDENTIFICATION DIVISION.
PROGRAM-ID. 148B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP PIC X(300).
01 N   PIC 9(3).
01 S   PIC X(100).
01 T   PIC X(100).
01 ST  PIC X(200).
01 I   PIC 9(3).
*>
PROCEDURE DIVISION.
  ACCEPT N.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ' '
      INTO S T.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > N
    MOVE S(I:1) TO ST(I * 2 - 1:1)
    MOVE T(I:1) TO ST(I * 2    :1)
  END-PERFORM.
*>
  DISPLAY ST(1:N * 2).
*>
  STOP RUN.


Measured memory_bytes: 384