akhauriyash/Code-Regression huggingface dataset:
#include<climits>
const int INF = INT_MAX;

#include<vector>
template<typename T>
class LazyPropagationSegmentTree {
public:
  LazyPropagationSegmentTree(int n) : size_(1) {
    while(size_ < n) size_ <<= 1;
    node_.assign(size_ << 1, INF);
    lazy_.assign(size_ << 1, 0);
  }
  T find(int left, int right) {return find(left, right + 1, 1, 0, size_);}
  void add(int left, int right, T value) {add(left, right + 1, value, 1, 0, size_);}
  void set(int i, T value) {set(i, i + 1, value, 1, 0, size_);}
private:
  int left_child(int node) const {return node << 1;}
  int right_child(int node) const {return (node << 1) + 1;}
  T find(int a, int b, int k, int l, int r) {
    if(b <= l || r <= a) return INF;
    if(a <= l && r <= b) return node_.at(k) + lazy_.at(k);
    lazy_.at(left_child(k)) += lazy_.at(k);
    lazy_.at(right_child(k)) += lazy_.at(k);
    lazy_.at(k) = 0;
    auto vl = find(a, b, left_child(k), l, (l + r) / 2);
    auto vr = find(a, b, right_child(k), (l + r) / 2, r);
    return std::min(vl, vr);
  }
  T add(int a, int b, T value, int k, int l, int r) {
    if(b <= l || r <= a) return node_.at(k) + lazy_.at(k);
    if(a <= l && r <= b) return node_.at(k) + (lazy_.at(k) += value);
    lazy_.at(left_child(k)) += lazy_.at(k);
    lazy_.at(right_child(k)) += lazy_.at(k);
    lazy_.at(k) = 0;
    auto vl = add(a, b, value, left_child(k), l, (l + r) / 2);
    auto vr = add(a, b, value, right_child(k), (l + r) / 2, r);
    return node_.at(k) = std::min(vl, vr);
  }
  T set(int a, int b, T value, int k, int l, int r) {
    if(b <= l || r <= a) return node_.at(k) + lazy_.at(k);
    if(a <= l && r <= b) {
      lazy_.at(k) = 0;
      return node_.at(k) = value;
    }
    lazy_.at(left_child(k)) += lazy_.at(k);
    lazy_.at(right_child(k)) += lazy_.at(k);
    lazy_.at(k) = 0;
    auto vl = set(a, b, value, left_child(k), l, (l + r) / 2);
    auto vr = set(a, b, value, right_child(k), (l + r) / 2, r);
    return node_.at(k) = std::min(vl, vr);
  }
  int size_;
  std::vector<T> node_;
  std::vector<T> lazy_;
};

#include<iostream>
using namespace std;
int main() {
  int n,q;
  cin>>n>>q;
  LazyPropagationSegmentTree<long long> RMQ(n);
  while(0<q--){
    int com, x, y;
    cin >> com >> x >> y;
    if(com) cout << RMQ.find(x,y) << endl;
    else    RMQ.set(x,y);
  }
}

Measured memory_bytes: 5220
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
using namespace std;
int main(void){
	int i,t,n,x,ans;
	cin>>n;
	int a[n],b[n];
	for(i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	sort(a,a+n);
	sort(b,b+n);
	if(n&1){
		ans=b[n/2]-a[n/2]+1;
		cout<<ans<<endl;
	}
	else{
		ld ans1=(b[n/2]+b[(n/2)-1])/2.0;
		ld ans2=(a[n/2]+a[(n/2)-1])/2.0;
		ans=(int)((ans1-ans2)/0.5+1);
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 5072
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Spandan Mishra
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BJudgeStatusSummary solver = new BJudgeStatusSummary();
        solver.solve(1, in, out);
        out.close();
    }

    static class BJudgeStatusSummary {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            //AC WA TLE RE
            int n = in.readInt();
            int[] cnt = new int[4];
            while (n-- > 0) {
                String s = in.readString();
                if (s.equals("AC"))
                    cnt[0]++;
                else if (s.equals("WA"))
                    cnt[1]++;
                else if (s.equals("TLE"))
                    cnt[2]++;
                else if (s.equals("RE"))
                    cnt[3]++;
            }
            System.out.println("AC x " + cnt[0]);
            System.out.println("WA x " + cnt[1]);
            System.out.println("TLE x " + cnt[2]);
            System.out.println("RE x " + cnt[3]);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new RuntimeException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String readString() {
            final StringBuilder stringBuilder = new StringBuilder();
            int c = read();
            while (isSpaceChar(c))
                c = read();
            do {
                stringBuilder.append((char) c);
                c = read();
            } while (!isSpaceChar(c));
            return stringBuilder.toString();
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 46852
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define MAX_N (100000L)
#define NUM_MOD (1000000007L)

using namespace std;

int main() {
  // read inputs
  long N, as[MAX_N], bs[MAX_N];
  scanf("%ld", &N);
  for (long i = 0; i < N; i++) {
    scanf("%ld", &as[i]);
  }
  for (long i = 0; i < N; i++) {
    scanf("%ld", &bs[i]);
  }

  // sort
  sort(as, as + N);
  sort(bs, bs + N);

  // solve
  long ans = 1, i = 0, j = 0, cnt = 0;
  while (i < N && j < N) {
    const long a = as[i], b = bs[j];
    if (a < b) {
      if (cnt < 0) {
        ans = (ans * abs(cnt)) % NUM_MOD;
      }
      cnt++;
      i++;
    } else {
      if (cnt > 0) {
        ans = (ans * abs(cnt)) % NUM_MOD;
      }
      cnt--;
      j++;
    }
    // printf("i = %ld, j = %ld, cnt = %ld, ans = %ld\n", i, j, cnt, ans);
  }
  while (i < N) {
    const long a = as[i];
    ans = (ans * abs(cnt)) % NUM_MOD;
    cnt++;
    i++;
  }
  while (j < N) {
    const long b = bs[j];
    ans = (ans * abs(cnt)) % NUM_MOD;
    cnt--;
    j++;
  }
  printf("%ld\n", ans);
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fip ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define reptUsual(b) for(i=0; i<b; ++i)
#define reptArIn(i,a,b,ar) for( i=a; i<b; ++i) cin>>ar[i];
#define rept(i,a,b) for(i=a; i<b; ++i)
#define all(a)  a.begin(), a.end()
#define maX(a,b)    ( (a) > (b) ? (a) : (b))
#define miN(a,b)    ( (a) < (b) ? (a) : (b))
#define sz(a) ((int)(a.size()))
#define pb(a) push_back(a)
#define ins(a) insert(a)
#define mkpr make_pair
#define fi first
#define se second
#define newln cout<<"\n"
#define bigPrime 1000000007
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef pair<ll , ll> pll;
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>  new_data_set;
// continue // break // greater // string // length // while

int main()
{
    fip;
    ll a,b,res;
    cin>>a>>b;
    res=(a+b);
    if((res)&1)
        cout<<"IMPOSSIBLE";
    else 
        cout<<res/2;
    return 0;

}


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

int main() {
    int a,b,c; cin >> a >> b >> c;
    for(int i = 1; i < b; i ++) {
        if((a*i)%b==c) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

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

template<class T> T read() {
	T t;
	cin >> t;
	return t;
}

template<class T> vector<T> read_vector(sint n) {
	vector<T> vs;
	for (sint i = 0; i < n; ++i) {
		vs.push_back(read<T>());
	}
	return vs;
}

inline void write() {
}

template<class T> void write(T const& t) {
	cout << t;
}

template<class T> void write(vector<T> const& ts) {
	if (ts.size() > 0) {
		cout << ts[0];
	}
	for (size_t i = 1; i < ts.size(); ++i) {
		cout << ' ' << ts[i];
	}
}

template<class T, class... Args> void write(T const& t, Args const&... args) {
	cout << t << ' ';
	write(args...);
}

template<class... Args> void writeln(Args const&... args) {
	write(args...);
	cout << '\n';
}

int main() {
	ios_base::sync_with_stdio(false);
	cin .exceptions(ios_base::badbit | ios_base::failbit);
	cout.exceptions(ios_base::badbit | ios_base::failbit);
	cin .tie(nullptr);
	cout.tie(nullptr);
	cout.precision(16);
	void run();
	run();
	return 0;
}

void run() {
	auto const N = read<sint>();
	auto const ds = read_vector<sint>(N);

	sint sum = 0;
	for (sint i = 0; i < N - 1; ++i) {
		for (sint j = i + 1; j < N; ++j) {
			sum += ds[i] * ds[j];
		}
	}
	writeln(sum);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,i,x,sum1=0,sum2=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if(x%4==0)
			sum1++;
		if(x%2!=0)
			sum2++;
	}
	if(sum2-sum1>1||sum2-sum1==1&&sum2+sum1!=n)
		printf("No");
	else
		printf("Yes");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,vis[1000003],a,ans,d;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=k;i++)
	{
		cin>>d;
		for(int j=1;j<=d;j++)
		{
			cin>>a;
			vis[a]=1;			
		}
	}
	for(int i=1;i<=n;i++)
		if(vis[i]==0)
			ans++;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3680
import sys
import itertools
import copy
from collections import defaultdict

input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    N, K = MI()
    index = 0
    d = defaultdict(int)
    for i in range(N):
        a, b = MI()
        d[a] += b
    d = sorted(d.items(), key=lambda x:x[0])
    for i in d:
        index += i[1]
        if index >= K:
            print(i[0])
            sys.exit()
        
        
main()

Measured memory_bytes: 50268
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<ll> h(n), v;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
        v.push_back(h[i]);
    }
    v.push_back(0);
    sort(all(v));
    v.erase(unique(all(v)), v.end());
    int m = v.size();
    vector<vector<vector<ll>>> dp(
        n + 1, vector<vector<ll>>(k + 1, vector<ll>(m + 1, LINF)));
    dp[0][0][0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= k; j++) {
            if (j > 0) {
                vector<ll> mi(m + 1, LINF);
                for (int s = m - 1; s >= 0; s--) {
                    chmin(mi[s], dp[i][j - 1][s]);
                    chmin(mi[s], mi[s + 1]);
                }
                for (int s = 0; s < m; s++) {
                    if (s > 0) {
                        chmin(dp[i + 1][j][s],
                              dp[i + 1][j][s - 1] + v[s] - v[s - 1]);
                    }
                    chmin(dp[i + 1][j][s], mi[s]);
                }
            }
            for (int s = 0; s < m; s++) {
                if (v[s] == h[i]) {
                    for (int t = 0; t < m; t++) {
                        chmin(dp[i + 1][j][s],
                              dp[i][j][t] + max(0LL, v[s] - v[t]));
                    }
                    break;
                }
            }
        }
    }
    ll res = LINF;
    for (int i = 0; i <= k; i++) {
        for (int j = 0; j < m; j++) {
            chmin(res, dp[n][i][j]);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 218368
import sys
sys.setrecursionlimit(2*10**6)
input = sys.stdin.readline
N, M = map(int, input().split())
G = [[] for _ in [0]*N]
for _ in [0]*M:
    a, b, d = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append((b, d))
    G[b].append((a, -d))

X = [None]*N

def dfs(i, x=0):
    for j, d in G[i]:
        if X[j] is None:
            X[j] = x+d
            dfs(j, x+d)
        elif X[j] != x+d:
            print('No')
            exit()

for i in range(N):
    if X[i] is not None:
        continue
    X[i] = 0
    dfs(i)
print('Yes')

Measured memory_bytes: 160728
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define deb(x) cout << #x << " = "<< x << "\n";
#define F first
#define S second

signed main()
{
	//freopen("in.txt", "r",stdin);
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	int a, b, c; cin >> a >> b >> c;
	cout << c << " " << a << " " << b << "\n";	
	
}

Measured memory_bytes: 256
n,k=gets.split.map(&:to_i)
arr = Array.new(n,0)
arr2 = gets.split.map(&:to_i)
n.times do |i|
  arr[arr2[i]-1]+=1
end
arr.sort!.reverse!
ans = arr[0..k-1].inject(:+)
puts n - ans



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

static const int MAX = 1e5;
int n, m, b;
long a, c, ans;
vector<pair<long, int>> AB;

int main() {
    scanf("%d %d", &n, &m);
    
    for ( int i = 0; i < n; i++ ) {
        scanf("%ld %d", &a, &b);
        AB.push_back(make_pair(a, b));
    }

    sort(AB.begin(), AB.end());
    c = 0;
    ans = 0;

    while ( m > 0 ) {
        m -= AB[c].second;
        ans += AB[c].first * AB[c].second;
        c++;
    }

    ans += AB[c-1].first * m;
    printf("%ld\n", ans);
    return 0;
}



Measured memory_bytes: 2420
#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()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int N;
vi v;
set<array<int,3>> cur;

void ad(int x) {
    set<array<int,3>> CUR; swap(cur,CUR);
    for (auto a: CUR) {
        cur.insert({min(a[0],min(x-a[2],24-x-a[1])),a[1],x});
        cur.insert({min(a[0],min(x-a[1],24-x-a[2])),x,a[2]});
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N; 
    F0R(i,N) {
        int x; cin >> x;
        v.pb(x);
    }
    cur.insert({24,0,0});
    sort(all(v));
    for (int i: v) ad(i);
    int ans = 0;
    for (auto a: cur) ans = max(ans,a[0]);
    cout << ans;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 256
using System;

class C
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var p = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

		int r = 0, m = n + 1;
		for (int i = 0; i < n; i++)
			if (p[i] <= (m = Math.Min(m, p[i]))) r++;
		Console.WriteLine(r);
	}
}


Measured memory_bytes: 42188
#include<iostream>

using namespace std;

typedef long long ll;

int main() {
	ll S;
	cin >> S;
	ll a = 10e8, b = -1, c = 1, d = -1;
	if (S % a == 0)b = S / a;
	else b = S / a + 1;
	d = (a - S % a);
	if (d == a)d = 0;
	cout << 0 << " " << 0 << " " << a << " " << c << " " << d << " " << b << endl;
	return 0;
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod =1000000009;






int main() {
	int n;
	cin >> n;
	VLL a(n);
	REP(i, n)cin >> a[i];
	
	VLL cs(n + 1, 0);
	REP(i, n)cs[i + 1] = cs[i] + a[i];
	
	VVLL dp(n, VLL(n, INFL));

	REP(i, n)dp[i][i] = 0;

	FOR(d, 1, n) {
		REP(i, n - d) {
			FOR(j, i, i + d) {
				dp[i][i + d] = min(dp[i][i + d], dp[i][j] + dp[j + 1][i + d] + cs[i + d + 1] - cs[i]);
			}
		}
	}

	cout << dp[0][n - 1] << endl;
}

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

// dp[day][activity]
int dp[3];

int main() {
	int n, x, y, z;
	cin >> n;
	vector<int> a(n, 0), b(n, 0), c(n, 0);

	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}

	//BaseCases
	dp[0] = a[0]; dp[1] = b[0]; dp[2] = c[0];

	for (int i = 1; i < n; i++) {
		x = a[i] + max(dp[1], dp[2]);
		y = b[i] + max(dp[0], dp[2]);
		z = c[i] + max(dp[0], dp[1]);

		dp[0] = x; dp[1] = y; dp[2] = z;
	}

	cout << max({dp[0], dp[1], dp[2]}) << endl;
	return 0;

}

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

int n;
bool e[51][51];
bool flag[51] = {};


void dfs(int vertex){
    int i;
    if(flag[vertex])
        return;
    
    flag[vertex] = 1;

    for(i = 0;i <= n;++i)//各頂点について
        if(e[vertex][i])//点vertexを始点とするiへの辺があれば行かざるを得ない(既に到達してればすぐ戻れるし)
            dfs(i);
        else if(e[i][vertex])
            dfs(i);
}

bool iscon(){
    dfs(1);
   /* for(int i =1;i <=n;++i)
        cout << flag[i] << " ";
    cout << endl;*/
    for(int i = 1;i <= n;++i)
        if(flag[i] == false)
            return false;
    
    return true;
}

int main(){
    int m;
    cin >> n>>m;
    pair<int,int> taple[50];
    int c = 0;
    int bridge = 0;

    for(int i = 0;i < 51;++i)
        for(int j = 0;j < 51;++j)
            e[i][j] = 0;

    for(int i = 0;i < m;++i){
        int a,b;
        cin >> a >> b;
        e[a][b] = 1;
        taple[c].first = a;
        taple[c].second =b;
        ++c;
    }
    
    for(int i = 0;i < m;++i){
        for(int j = 0;j < n+1;++j)
            flag[j] = 0;
        e[taple[i].first][taple[i].second] = 0;
       /* for(int j = 0;j < m;++j){
            cout << taple[j].first << "," << taple[j].second<< " ";         
        }*/
        if(iscon() == 0) {bridge += 1;}
        e[taple[i].first][taple[i].second] = 1;
    }

    cout << bridge << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a; //高橋の初期体力
  int b; //高橋の攻撃力
  int c; //青木の初期体力
  int d; //青木の攻撃力
  
  cin>>a>>b>>c>>d;
  
  
  for (int i = 0; i <1000; i++) {
    c=c-b;
    if(c<=0){break;}
    a=a-d;
    if(a<=0){break;}
  i++;}
  if(a<=0){cout<<"No"<<endl;}
  else{cout<<"Yes"<<endl;}
}

Measured memory_bytes: 3624
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N = int(input())
    S = list(input()[:-1])
    A = [str(i) for i in range(10)]

    cnt = 0
    for P in itertools.product(A, repeat=3):
        m = 0
        for s in S:
            if s==P[m]:
                m += 1
            if m==3:
                break
        if m==3:
            cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()

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

long long int h,w;

int n;

map<pair<int,int>,int> ma;

long long int ans[10];

int main(){
	cin >> h >> w >> n;
	for(int i=1;i<=n;i++){
		int a,b;
      
		cin >> a >> b;
      
		for(int j=-1;j<=1;j++){
			for(int k=-1;k<=1;k++){
				int nx = a+j;
				int ny = b+k;
				if(nx < 2 || nx > h-1 || ny < 2 || ny > w-1) continue;
              
				ma[make_pair(nx,ny)]++;
			}
		}
	}
	long long int res = (h-2)*(w-2);
	for(auto x : ma ){
		res--;
		ans[x.second]++;
	}
	ans[0] = res;
  
	for(int i=0;i<=9;i++){
		cout << ans[i] << endl;
      
	}
	return 0;
}


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

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

  int former = stoi(S.substr(0,2));
  int latter = stoi(S.substr(2,2)); 

  string ans;

  if(former >=1 && former <= 12){
    if(latter >=1 && latter <= 12){
      ans = "AMBIGUOUS";
    }else{
      ans = "MMYY";
    }
  }else{
        if(latter >=1 && latter <= 12){
      ans = "YYMM";
    }else{
      ans = "NA";
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;

int main(int argc, char **argv)
{
	double a, tmp;
	
	while(cin >> a){
		tmp = a;
		a *= 2;
		tmp += a;
		for(int i = 1; i < 5; i++){
			a /= 3;
			tmp += a;
			a *= 2;
			tmp += a;
		}
		
		printf("%.8lf\n", tmp);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int maxn=0x7fffff;
int main(){
	int a,b,c,i;
	cin>>a>>b>>c;
	for(i=a;i<=maxn;i+=a){
		if(i%b==c){
			cout<<"YES";
			return 0;
		}
	}
	cout<<"NO";
	return 0;
}

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

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

	int ans = 0;
	for (int i = 1; i < n - 1; i++) {
		if (p[i - 1] < p[i] && p[i] < p[i + 1]) ans++;
		if (p[i - 1] > p[i] && p[i] > p[i + 1]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{   int h,w;
    scanf("%d%d",&h,&w);
    char s[h][w+1];
    for(int i=0;i<h;i++){
        scanf("%s",s[i]);
    }
    for(int i=0;i<h;i++){
        printf("%s\n%s\n",s[i],s[i]);
    }
    return 0;
}


Measured memory_bytes: 128
n,m=map(int,input().split())
l=[[]for i in range(n)]
for _ in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  l[a]+=[b]
  l[b]+=[a]
k=0
for i in l[0]:
  if n-1 in l[i]:
    k=1
if k:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 38296
import sys
sys.setrecursionlimit(10**6)


def f(n):
    if n == 0:
        return 1
    p = n % (bin(n).count('1'))
    return f(p) + 1


def main(input, print):
    N = int(input())
    X = list(map(int, list(input().strip())))
    ans = [0] * N

    pcnt = 0
    for i in range(N):
        if X[i] == 1:
            pcnt += 1
    for is_up in range(2):
        current_pcnt = pcnt
        if is_up:
            current_pcnt -= 1
        else:
            current_pcnt += 1
        if current_pcnt <= 0:
            continue
        total = 0
        for i in range(N):
            total = (total*2) % current_pcnt
            total += X[i]
        current_mask = 1
        for i in reversed(range(N)):
            if(X[i] == is_up):
                current_total = total
                if is_up:
                    current_total = (current_total-current_mask+current_pcnt) % current_pcnt
                else:
                    current_total = (current_total+current_mask) % current_pcnt
                ans[i] = f(current_total)
            current_mask = current_mask * 2 % current_pcnt

    for i in range(N):
        print(ans[i])


if __name__ == '__main__':
    main(sys.stdin.readline, print)


Measured memory_bytes: 97344
S, T = [0] * 26, [0] * 26

for s in input():
    S[ord(s) - ord('a')] += 1
for t in input():
    T[ord(t) - ord('a')] += 1
S.sort()
T.sort()
ans = 'Yes' if S == T else 'No'
print(ans)


Measured memory_bytes: 41952
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    string S;
    cin >> S;
    cout << S.substr(0, S.size() - 8) << '\n';
}



Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define db(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define ll long long
#define ld long double
#define pll pair<ll, ll>
#define MOD 1000000007
#define FOR(i, n) for(ll i = 0; i < n; i++)
using namespace std;
const long long INF = 3*1e18;

int main() {
    ios::sync_with_stdio(0);    
    cin.tie(0);
    ll K;
    cin >> K;
    set<ll> s;
    // 11 places
    // 1
    for(ll a = 1; a <= 9; a++){
        s.insert(a);
        //db(a);
        for(ll b = max(0LL, a-1); b <= min(9LL, a+1); b++){
            s.insert(10*a + b);
            for(ll c = max(0LL, b-1); c <= min(9LL, b+1); c++){
                s.insert(100*a + 10*b + c);
                for(ll d = max(0LL, c-1); d <= min(9LL, c+1); d++){
                    //temp = 10*temp + d;
                    s.insert(1000*a + 100*b + 10*c + d);
                    for(ll e = max(0LL, d-1); e <= min(9LL, d+1); e++){
                        //temp = 10*temp + e;
                        s.insert(10000*a + 1000*b + 100*c + 10*d + e);
                        for(ll f = max(0LL, e-1); f <= min(9LL, e+1); f++){
                            //temp = 10*temp + f;
                            s.insert(100000*a + 10000*b + 1000*c + 100*d + 10*e + f);
                            for(ll g = max(0LL, f-1); g <= min(9LL, f+1); g++){
                                //temp = 10*temp + g;
                                s.insert(1000000*a + 100000*b + 10000*c + 1000*d + 100*e + 10*f + g);
                                for(ll h = max(0LL, g-1); h <= min(9LL, g+1); h++){
                                    //temp = 10*temp + h;
                                    s.insert(10000000*a + 1000000*b + 100000*c + 10000*d + 1000*e + 100*f + 10*g + h);
                                    for(ll i = max(0LL, h-1); i <= min(9LL, h+1); i++){
                                        //temp = 10*temp + i;
                                         s.insert(100000000*a + 10000000*b + 1000000*c + 100000*d + 10000*e + 1000*f + 100*g + 10*h + i);
                                        for(ll j = max(0LL, i-1); j <= min(9LL, i+1); j++){
                                            //temp = 10*temp + j;
                                            s.insert(1000000000*a + 100000000*b + 10000000*c + 1000000*d + 100000*e + 10000*f + 1000*g + 100*h + 10*i + j);
                                            for(ll k = max(0LL, j-1); k <= min(9LL, j+1); k++){
                                                //temp = 10*temp + k;
                                                s.insert(10000000000*a + 1000000000*b + 100000000*c + 10000000*d + 1000000*e + 100000*f + 10000*g + 1000*h + 100*i + 10*j + k);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    auto it = s.begin();
    advance(it, K-1);
    cout << *it << "\n";
}

Measured memory_bytes: 27520
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  
  ll T[10][10];
  for (int i = 1; i <= 9; ++i) {
    for (int j = 1; j <= 9; ++j) {
      T[i][j] = 0;
    }
  }
  
  for (int x = 1; x <= N; ++x) {
    stringstream ss;
    ss << x;
    string S = ss.str();
    int a = S.front() - '0';
    int b = S.back() - '0';
    T[a][b]++;
  }

  ll count = 0;
  for (int i = 1; i <= 9; ++i) {
    for (int j = 1; j <= 9; ++j) {
      count += T[i][j] * T[j][i];
    }
  }

  cout << count << endl;
  
  return 0;
}


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

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

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

    return 0;
}

Measured memory_bytes: 256
import itertools
N = int(input())
names = []
chars = ["M","A","R","C","H"]
name_dic = {}
for i in range(N):
    name = input()
    if name[0] in chars:
        if   name[0] not in name_dic:
            name_dic[name[0]] = 1
        else:
            name_dic[name[0]] += 1


# print(name_dic)
chars2 = []
for c in chars:
    if  c in name_dic:
        chars2.append(c)
ans = 0
p = 0
coms= itertools.combinations(chars2,3)

for com in coms:
    temp = 1
    for c in com:
        temp*=name_dic[c]
    ans +=temp
print(ans)

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

int main(){
  int N;
  cin >> N;
  int P[200000];
  for(int i=0; i<N; ++i){
    cin >> P[i];
  }
  
  int count = 0;
  int min = N;
  for(int i=0; i<N; ++i){
    if(P[i] <= min){
      count++;
      min = P[i];
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define bs binary_search
#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); t=(t*t)%m; if(b&1)t=(t*a)%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ipr pair<ll,ll>
#define ps push_back
#define fs first
#define sc second
#define mkp make_pair
#define mod 1000000007
int main(){
  
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  
  char ar[100001];
  cin>>ar;
  ll i,j,k,l,n=strlen(ar);
  l=0;
  stack<char> st;
  for(i=0;i<n;i++){
    if(st.size()>0){
      if(st.top()!=ar[i]){
        st.pop();
        l+=2;
      }
      else st.push(ar[i]);
    }
    else st.push(ar[i]);
  }
  cout<<l;
  return 0;
}

Measured memory_bytes: 512
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!

    #include <bits/stdc++.h>
    using namespace std;

    #pragma GCC target("popcnt")

    string to_string(const string& s) { return '"' + s + '"'; }
    void debug_out() { cout << endl; }
    template <typename Head, typename... Tail>
    void debug_out(Head H, Tail... T) { cout << " " << to_string(H); debug_out(T...); }
    #ifdef LOCAL
        #define debug(...) cout << "#" << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
    #else
        #define debug(...) 3;
    #endif

    #define fast_io ios_base::sync_with_stdio(false); \
                    cin.tie(nullptr); cout.tie(nullptr);
    using ld = long double;  using ui = uint_fast32_t;
    using ll = int_fast64_t; using ul = uint_fast64_t;

// -----------------------------------------------------------------------------

const int N = 1e5 + 5;
const int INF = 1e9 + 5;
const int A = 3;
int n;
int p[A];
int dp[N][A];

void solve() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        for (int a = 0; a < A; ++a) {
            cin >> p[a];
        }
        for (int a = 0; a < A; ++a) {
            for (int b = 0; b < A; ++b) {
                if (b == a) continue;
                dp[i][a] = max(dp[i][a], dp[i - 1][b] + p[a]);
            }
        }
    }
    cout << *max_element(dp[n], dp[n] + A) << '\n';
}

// -----------------------------------------------------------------------------

int main() {
    fast_io; int t = 1;
    // cin >> t;
    // precompute();
    for (int i = 1; i <= t; ++i) solve();
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  ll N;
  cin >> N;
  vector<int> vec(N);
  rep(i, N)
  {
    cin >> vec[i];
  }
  ll k = 0;
  ll l = 1000000000+1;
  rep(i, N)
  {
    if(k<vec[i])
    {
      k = vec[i];}
    if(l>vec[i]){
      l = vec[i];}
  }
  cout << k - l << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.PriorityQueue;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    int h = sc.nextInt();
    int w = sc.nextInt();
    System.out.println((H-h)*(W-w));
  }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define endl "\n";
#define int long long
#define uint unsigned long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define double long double
const int mod = 1e9 + 7;

int32_t main()
{
    fastio;
    string s; cin >> s;
    if(s == "ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
    return 0;
}



Measured memory_bytes: 3640
/************************************************
 * Au: Hany01
 * Date: Jul 23rd, 2018
 * Prob: AGC 010 D
 * Email: hany01@foxmail.com
 * Inst: Yali High School
************************************************/

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
#define File(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout)
#define rep(i, j) for (register int i = 0, i##_end_ = (j); i < i##_end_; ++ i)
#define For(i, j, k) for (register int i = (j), i##_end_ = (k); i <= i##_end_; ++ i)
#define Fordown(i, j, k) for (register int i = (j), i##_end_ = (k); i >= i##_end_; -- i)
#define Set(a, b) memset(a, b, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define x first
#define y second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) ((int)(a).size())
#define INF (0x3f3f3f3f)
#define INF1 (2139062143)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define y1 wozenmezhemecaia

template <typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }

inline int read() {
	static int _, __; static char c_;
    for (_ = 0, __ = 1, c_ = getchar(); c_ < '0' || c_ > '9'; c_ = getchar()) if (c_ == '-') __ = -1;
    for ( ; c_ >= '0' && c_ <= '9'; c_ = getchar()) _ = (_ << 1) + (_ << 3) + (c_ ^ 48);
    return _ * __;
}

const int maxn = 1e5 + 5;

int n, a[maxn], cnt[2];

inline int sp() {
	register int ans = 0;
	For(i, 1, n) (ans += a[i] - 1) &= 1;
	return ans;
}

int solve()
{
	cnt[0] = cnt[1] = 0;
	For(i, 1, n) {
		if (a[i] == 1) return sp();
		++ cnt[a[i] & 1];
	}
	if (cnt[0] & 1) return 1;
	if (cnt[0] & 1 ^ 1 && cnt[1] != 1) return 0;
	int t = 0;
	For(i, 1, n) a[i] >>= 1, t = __gcd(t, a[i]);
	For(i, 1, n) a[i] /= t;
	return solve() ^ 1;
}

int main()
{
#ifdef hany01
	File("agc010d");
#endif

	n = read();
	For(i, 1, n) a[i] = read();
	
	puts(solve() ? "First" : "Second");

    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
using namespace std;
const long long MOD = 1000000007;

typedef long long ll;

int
main(int argc, const char *argv[])
{
  int n; ll a[300010];
  scanf("%d", &n);
  for (int i = 0; i < 3 * n; i++) scanf("%lld", &a[i]);

  ll sum = 0;
  
  priority_queue<ll> que;
  for (int i = 0; i < n; i++) {
    que.push(-a[i]);
    sum += a[i];
  }

  ll sumf[300010]; ll Min;
  sumf[n - 1] = sum;
  for (int i = n; i < 2 * n; i++) {
    que.push(-a[i]);
    Min = -(que.top());
    que.pop();
    sumf[i] = sumf[i - 1] - Min + a[i];
  }

  sum = 0;

  priority_queue<ll> euq;
  for (int i = 3 * n - 1; i >= 2 * n; i--) {
    euq.push(a[i]);
    sum += a[i];
  }

  ll sumb[300010]; ll Max;
  sumb[2 * n] = sum;
  for (int i = 2 * n - 1; i >= n; i--) {
    euq.push(a[i]);
    Max = euq.top();
    euq.pop();
    sumb[i] = sumb[i + 1] - Max + a[i];
  }

  ll ans = -100000000000000;
  for (int i = n - 1; i < 2 * n; i++) {
    ans = max(ans, sumf[i] - sumb[i + 1]);
  }
  
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 9204
import java.math.BigInteger;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        String x = scanner.next();
        String y = scanner.next();

        BigInteger X = new BigInteger(x);
        BigInteger Y = new BigInteger(y);

        int cnt = 0;
        while(X.compareTo(Y) <= 0){
            X = X.multiply(new BigInteger("2"));
            cnt++;
        }

        System.out.println(cnt);
    }
}


Measured memory_bytes: 23764
int a[200010];
int ans[200010];
int main(){
  int n;
  scanf("%d",&n);
  for(int i=2;i<=n;i++)scanf("%d",&a[i]);
  for(int i=2;i<=n;i++)ans[a[i]]++;
  for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
}

Measured memory_bytes: 3236
#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "vector"
using namespace std;
#define MAXN 2016
#define P 1000000007
int n;
vector<int> G[MAXN];
int A[MAXN] , F[MAXN] , d[MAXN] , s[MAXN] , siz[MAXN];
void dfs( int u , int fa ) {
    if( A[u] ) s[u] = d[u] , siz[u] = 1; else siz[u] = s[u] = 0;
    int mxp = 0;
    for( int v : G[u] ) if( v != fa ) {
        d[v] = d[u] + 1 , dfs( v , u ) , s[u] += s[v] , siz[u] += siz[v];
        mxp = ( !mxp || s[v] > s[mxp] ) ? v : mxp;
    }
    int sum = s[u] - siz[u] * d[u] , mx = s[mxp] - siz[mxp] * d[u];
    if( sum >= 2 * mx ) F[u] = sum / 2;
    else
        F[u] = sum - mx + min( F[mxp] , ( 2 * mx - sum ) / 2 );
}
int main() {
    cin >> n;
    for( int i = 1 ; i <= n ; ++ i ) scanf("%1d",&A[i]);
    for( int i = 1 , u , v ; i < n ; ++ i ) {
        scanf("%d%d",&u,&v);
        G[u].push_back( v ) , G[v].push_back( u );
    }
    int res = 0x3f3f3f3f + 2;
    for( int i = 1 ; i <= n ; ++ i ) {
        d[i] = 0, dfs( i , i );
        if( ( ~s[i] & 1 ) && F[i] == s[i] / 2 ) res = min( res , s[i] / 2 );
    }
    cout << ( res == 0x3f3f3f3f + 2 ? -1 : res ) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll pow5(ll a) {
    ll ret = 1;
    for(int i = 0; i < 5; i++) {
        ret *= a;
    }
    return ret;
}

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

    ll x;
    cin >> x;

    for(ll a = -1000; a <= 1000; a++) {
        for(ll b = -1000; b <= 1000; b++) {
            if(pow5(a) - pow5(b) == x) {
                cout << a << ' ' << b << '\n';
                return 0;
            }
        }
    }
}


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

typedef long long 		ll;
typedef vector<ll> 		vll;
typedef pair<ll,ll> 	pll;
typedef vector<pll> 	vpll;
typedef vector<int> 	vi;
typedef pair<int,int> 	pii;
typedef vector<pii> 	vpii;

#define fi				first
#define se 				second
#define pb 				push_back
#define mp 				make_pair
#define all(v)			v.begin(),v.end()
#define sz(v)			s.size()
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define per(i,a,b) 		for(int i=a;i>=b;i--)
#define fill(a,v)		memset(a,v,sizeof(a))
#define tc				int T;cin>>T;while(T--)
#define nl				printf("\n")
#define aya				cerr<<"yaha aya"<<"\n"
#define debug(x,y)		printf("%d %d\n",x,y)
#define fast_io			ios_base::sync_with_stdio(false);cin.tie(NULL);
#define grt				greater<int>()

const int mod = 1e9+7;
const int mod2= 1e9+9;

inline int pow_(ll a, int n, int p=mod){
	int r=1;while(n){if(n&1)r=r*a%p;n>>=1;a=a*a%p;}return r;
}

const int MAX = 1e5+1;
const int LG = 30+1;

int main(void)
{
	int n;cin>>n;
	string s;cin>>s;
	stack<char> st;
	st.push(s[0]);
	rep(i,1,n-1)
	{
		if(s[i] == st.top()) continue;
		else st.push(s[i]);
	}
	int ans = st.size();
	cout<<ans<<"\n";
}


Measured memory_bytes: 512
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            for (int i=1; i<10; i++)
            {
                for(int j=0; j<10; j++)
                {
                    if(i*j == N)
                    {
                        Console.WriteLine("Yes");
                        return;
                    }
 
                }
            }
            Console.WriteLine("No");

        }
    }
}


Measured memory_bytes: 27464
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

vector<vector<ll> > v(200001);
bool maki[200001];
ll uni[200001];
ll root(ll u){
    if(uni[u]<0)return u;
    return uni[u]=root(uni[u]);
}
void connect(int a,int b){
    a=root(a);
    b=root(b);
    if(a==b)return;
    if(uni[a]<uni[b]){
        a^=b;
        b^=a;
        a^=b;
    }
    uni[a]+=uni[b];
    uni[b]=a;
    return;
}
ll size(ll u){
    return -uni[root(u)];
}

void dfs(ll n){
	maki[n]=true;
	if(!v[n].size())return;
	ll num=v[n][0];
	for(auto& i:v[n]){
		connect(i,num);
		if(!maki[i])dfs(i);
	}
	return;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    memset(uni,-1,sizeof(uni));
    memset(maki,0,sizeof(maki));
    ll n;
    cin>>n;
    ll a,b;
    for(int i=0;i<n-1;i++){
    	cin>>a>>b;
    	a--;b--;
    	v[a].pb(b);
    	v[b].pb(a);
    }
    dfs(0LL);
    ll c,d;
    for(int i=0;i<n;i++){
    	if(root(i)!=root(0LL)){
    		a=size(i);
    		b=size(0LL);
    		c=root(i);
    		d=root(0LL);
    		break;
    	}
    }
    
    if(a<b){swap(a,b);swap(c,d);}
    bool niko=(b>ll(n/3));
    ll m1=1,m2=2,m3=3;
    ll ans[n];
    if(niko){
    	for(int i=0;i<n;i++){
    		if(root(i)==c){
    			if(m1<=n){
    				ans[i]=m1;
    			    m1+=3;
    			}else{
    				ans[i]=m3;
    				m3+=3;
    			}
    		}else{
    			if(m2<=n){
    				ans[i]=m2;
    				m2+=3;
    			}else{
    				ans[i]=m3;
    				m3+=3;
    			}
    		}
    	}
    }else{
    	for(int i=0;i<n;i++){
    		if(root(i)==c){
    			if(m1<=n){
    				ans[i]=m1;
    				m1+=3;
    			}else if(m2<=n){
    				ans[i]=m2;
    				m2+=3;
    			}else{
    				ans[i]=m3;
    				m3+=3;
    			}
    			
    		}else{
    			ans[i]=m3;
    			m3+=3;
    		}
    	}
    }
    for(int i=0;i<n;i++){
    	cout << ans[i]<<" ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 18408
n = int(input())
s = input()
ans = 0
for i in range(10):
	i2 = str(i)
	a = s.find(i2)
	if a != -1:
		s2 = s[a+1:]
		for j in range(10):
			j2 = str(j)
			b = s2.find(j2)
			if b != -1:
				s3 = s2[b+1:]
				for k in range(10):
					k2 = str(k)
					c = s3.find(k2)
					if c != -1:
						ans += 1
print(ans)

Measured memory_bytes: 3188
#include <stdio.h>
      #define MAX 100000

      int T[MAX] = {0};

      void init() {

        int j;

        for (j = 0; j < MAX; j++) {
          T[j] = j;
        }

      }

      int find(int num) {

        if (num == T[num]) {
          return num;
        }

        return T[num] = find(T[num]);

      }

      int isSame(int x, int y) {

        if (find(x) == find(y)) {
          return 1;
        }else {
          return 0;
        }

      }

      void unite(int a, int b) {

        a = find(a);
        b = find(b);

        if (a == b) return;

        T[b] = a;
      }

      int main() {
        int i,j;
        int num,num2, q, k;
        init();
        scanf("%d %d", &num, &num2);
        for ( i = 0; i < num2; ++i ) {
          scanf("%d %d", &j, &k);
          unite(j, k);
        }
        scanf("%d", &q);

        for ( i = 0; i < q; i++ ) {
          scanf("%d %d", &j, &k);
          if (isSame(j, k)) {
            printf("yes\n");
          } else {
            printf("no\n");
          }
        }

        return 0;
      }



Measured memory_bytes: 2096
a = map(int, raw_input().split())
w = a[0]
h = a[1]
x = a[2]
y = a[3]
r = a[4]
if x+r <= w and x-r >= 0 and y+r <= h and y-r >= 0:
    print 'Yes'
else:
    print 'No'

Measured memory_bytes: 6420
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

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

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  char a[2][3];
  rep(i,2)rep(j,3) cin >> a[i][j];
  if(a[0][0] == a[1][2] && a[0][1] == a[1][1] && a[0][2] == a[1][0]){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}






Measured memory_bytes: 256