akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
signed main()
{
    IOS
    int n,k; cin>>n>>k;
    string str; cin>>str;
    int c = 0;
    for(int i=0;i<n-1;i++)
    {
      if(str[i] != str[i+1]) c++;
    }
    int ans = n-c-1;
    ans += min(2*k,c);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
vector<int> a(15), b(15);
bool dfs(int left, int right, int turnA, int cntA, int cntB)
{
    if(turnA == 0)
    {
        if(cntA == 0) return 1;
        if(a[left] == 0 && a[right] == 0) return dfs(left, right, 1, cntA, cntB);
        if(a[left] && dfs(left - 1, right, 1, cntA - 1, cntB)) return 1;
        if(a[right] && dfs(left, right + 1, 1, cntA - 1, cntB)) return 1;
        return 0;
    }
    else
    {
        if(cntB == 0) return 0;
        if(b[left] == 0 && b[right] == 0) return dfs(left, right, 0, cntA, cntB);
        if(b[left] && not dfs(left - 1, right, 0, cntA, cntB - 1)) return 0;
        if(b[right] && not dfs(left, right + 1, 0, cntA, cntB - 1)) return 0;
        return 1;
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    for(int i = 0; i < n; i++)
    {
        a.clear(); b.clear();
        for(int j = 0; j <= 14; j++) a[j] = b[j] = 0;
        for(int j = 0; j < 6; j++)
        {
            int x; cin >> x;
            a[x] = 1;
        }
        for(int j = 1; j <= 13; j++) if(a[j] == 0) b[j] = 1;
        a[7] = b[7] = 1;
        cout << (dfs(6, 8, 0, 6, 6) ? "yes" : "no") << endl;
    }
    return 0;
}




Measured memory_bytes: 3200
from collections import Counter


def main():
    n, p = map(int, input().split())
    f = []
    while p % 2 == 0:
        p //= 2
        f.append(2)
    tmp = 3
    while tmp * tmp <= p:
        if p % tmp == 0:
            p //= tmp
            f.append(tmp)
        else:
            tmp += 2
    if p != 1:
        f.append(p)
    f = Counter(f)
    f = sorted(f.items(), key=lambda x: x[1], reverse=True)
    answer = 1
    for ff, cnt in f:
        if cnt < n:
            break
        answer *= ff ** (cnt // n)
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 38512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
using namespace std;



int main(void){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
    }
    
    int ans=0;
    int p=-1;
    int t=0;
    rep(i,n){
        if (p>=a[i]){
            t++;
            p=a[i];
        }else{
            ans=max(t,ans);
            p=a[i];
            t=0;
        }
        //cout<<i<<' '<<p<<' '<<a[i]<<' '<<t<<endl;
    }
    
    ans=max(t,ans);
    cout<<ans;
}


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

class Program
{
    static void Main(string[] args)
    {
        var input = long.Parse(Console.ReadLine());

        var primeList = GetPrimeFactor(input);

        var ans = 0;

        foreach(var p in primeList)
        {
            var count = 1;
            var n = input;
            while (true)
            {
                if(n % Math.Pow(p, count) == 0)
                {
                    ans++;
                    n = n / (long)Math.Pow(p, count);
                    count++;
                }
                else
                {
                    break;
                }

            }
        }

        Console.WriteLine(ans);
        Console.Read();
    }

    public static List<long> GetPrimeFactor(long max)
    {
        var primeList = new List<long>();

        for (long i = 2; i * i <= max; i++)
        {
            while (max % i == 0)
            {
                primeList.Add(i);
                max /= i;
            }
        }
        if (max > 1)
        {
            primeList.Add(max);
        }
        return primeList.Distinct().ToList();
    }

}



Measured memory_bytes: 19260
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#define INF (long long)1000000007
#define MOD (long long)998244353
using namespace std;



int main(void){
    int n;
    cin >> n;
    int temp;
    long long ans=1;
    vector<int> s(n,0);
    for(int i=0; i<n; i++){
        cin >> temp;
        if((i==0)^(temp==0))ans=0;
        s[temp]++;
    }
    long long count=0;
    for(int i=0; i<=n; i++){
        count+=s[i];
        if(i==0)continue;
        for(int j=0; j<s[i]; j++){
            ans=(ans*s[i-1])%MOD;
        }
        if(s[i]==n)break;
    }
    cout << ans << endl;
    return 0;
}


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

def input_multiple_number():
    return map(int, input().split())

def input_multiple_number_as_list():
    return list(map(int, input().split()))


N,M = input_multiple_number()
list_A = input_multiple_number_as_list()


sums = 0

for a in list_A:
	sums += a

thre = -(-sums//4//M)

cnt = 0
for a in list_A:
	if a >= thre:
		cnt += 1

if cnt >= M:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
const int infii=1e9+7;
int max_out(int we[],int v[],int n,int w){
    int sum=0;
    rep(i,n) sum+=v[i];
    int dp[n+1][sum+1];
    rep(i,sum+1) dp[0][i]=infii;
    dp[0][0]=0;
    for(int i=1;i<n+1;i++){
        rep(j,sum+1){
            if(j==0) dp[i][j]=0;
            else if(j-v[i-1] >=0) dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i-1]] + we[i-1]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    int maxs=0;
    rep(i,n+1){
        rep(j,sum+1){
            // cout<<dp[i][j]<<" ";
            if(dp[i][j] <= w) maxs=max(maxs,j);
        }
        // cout<<endl;
    }
    return maxs;
}
int main() {
    int n,w;cin>>n>>w;
    int we[n],v[n];
    for(int i=0;i<n;i++) cin>>we[i]>>v[i];
    cout<<max_out(we,v,n,w);
	return 0;
}

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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;


int main() {
    int N, M;
    cin >> N >> M;

    vi val(N, -1);
    bool invalid = false;

    rep(i, 0, M) {
        int s, c;
        cin >> s >> c;

        if (val[s-1] == -1) {
            val[s-1] = c;
        } else if (val[s-1] != c) {
            invalid = true;
            break;
        }
    }
    if (val[0] == 0 && N > 1) { invalid = true; }

    if (invalid) { cout << -1 << endl; return 0; }

    int power = 1;
    int num = 0;

    while (!val.empty()) {
        int v = val.back(); val.pop_back();
        if (v == -1) {
            if (!val.empty() || N == 1) { v = 0; }
            else { v = 1; }
        }
        num += v * power;
        power *= 10;
    }
    cout << num << endl;
    return 0;
}

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

main()
{
  int n;
  int a, b;

  cin >> a >> b;
  a *= b;

  if ( a & 1 ) {
    cout << "Odd" << endl;
  } else {
    cout << "Even" << endl;
  }

  return (0);
}

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


int main(){
    string s;
    while (cin >> s){
	for (int i = 0; i < s.size(); i++){
	    if (s[i] == '@'){
		int n = s[i+1] - '0';
		for (int j = 0; j < n; j++){
		    cout << s[i+2];
		}
		i += 2;
	    }
	    else cout << s[i];
	}
	cout << endl;
    }
}

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

int main(void){
  int A, B, Q;
  cin >> A >> B >> Q;
  ll const INF = 1e12;
  ll const MINUSINF = -1e12;
  ll s[A+2], t[B+2];
  s[0] = MINUSINF; s[A+1] = INF;
  t[0] = MINUSINF; t[A+1] = INF;
  for(ll i=1; i<=A; i++) cin >> s[i];
  for(ll i=1; i<=B; i++) cin >> t[i];
  for(ll i=0; i<Q; i++){
    ll x;
    cin >> x;
//    cout << x << endl;
    ll* e_s = upper_bound(s, s+A+1, x);
    ll* w_s = e_s -1;
    
    ll* e_t = upper_bound(t, t+B+1, x);
    ll* w_t = e_t -1;
    
    ll ans = abs(*e_s-x) + abs(*e_s-*e_t); //es->et
    ans = min(ans, abs(*e_s-x) + abs(*e_s-*w_t)); //es->wt
    ans = min(ans, abs(*e_t-x) + abs(*e_t-*e_s)); //et->es
    ans = min(ans, abs(*e_t-x) + abs(*e_t-*w_s)); //et->ws

    ans = min(ans, abs(*w_s-x) + abs(*w_s-*e_t)); //ws->et
    ans = min(ans, abs(*w_s-x) + abs(*w_s-*w_t)); //ws->wt
    ans = min(ans, abs(*w_t-x) + abs(*w_t-*e_s)); //wt->es
    ans = min(ans, abs(*w_t-x) + abs(*w_t-*w_s)); //wt->ws
    
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 2816
#include <stdio.h>

int main(){
  int r,c;
  int work;
  scanf("%d",&r);
  scanf("%d",&c);

  int colTotals[c]; for(int i=0;i<c;i++) colTotals[i] = 0;
  int rowTotal = 0;
  for(int i=0;i<r;i++){
    for(int j=0;j<c;j++){
      scanf("%d",&work);
      if(j) printf(" ");
      printf("%d", work);
      rowTotal += work;
      colTotals[j] += work;
    }
    printf(" %d\n", rowTotal);
    rowTotal = 0;
  }

  rowTotal = 0;
  for(int i=0;i<c;i++){
    rowTotal += colTotals[i];
    if(i) printf(" ");
    printf("%d", colTotals[i]);
  }
  printf(" %d\n", rowTotal);
}


Measured memory_bytes: 2736
using System;

class plogram
{
    static void Main()
    {

        string[] str = Console.ReadLine().Split(' ');

        int N = int.Parse(str[0]);
        int K = int.Parse(str[1]);

        string S = Console.ReadLine();

        Console.WriteLine(S.Substring(0, K-1) + S.Substring(K-1,1).ToLower() + S.Substring(K));
    }
}

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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	long long X;
	scanf("%lld",&X);
	long long Y;
	scanf("%lld",&Y);

	ll max_count = ((ll) log2l((long double) Y / (long double) X)) + 1LL;

	cout << max_count << endl;

	return 0;
}


Measured memory_bytes: 512
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#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 <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int dp[101] = {};
	int N;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		int d;
		cin >> d;
		dp[d] = 1;
	}
	int count = 0;
	for (int i = 0; i < 101; i++)
	{
		if (dp[i] > 0)
		{
			count++;
		}
	}
	cout << count << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll  long long int
#define db long double 
#define ull unsigned long long int
// #define mp make_pair
#define F first
#define S second
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
#define Nmax 1000005
// #define INF 10000000000000
#define MOD 1000000007
#define MAXN 200005
 
using namespace std;

ll mod=1e9+7;
 
ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}

const ll M=3000006;
ll f[M],inv[M];

void compute(){
    f[0]=1;
    rep(i,1,M-1){
        f[i]=(1LL*i*f[i-1])%mod;
    }
    inv[M-1]=expo(f[M-1],mod-2,mod);
    for(ll i=M-2;i>=0;i--){
        inv[i]=(1LL*(i+1)*inv[i+1])%mod;
    }
}
ll C(ll n,ll r){
    return (1LL*((1LL*f[n]*inv[r])%mod)*inv[n-r])%mod;
}

bool mysort(pair<ll,ll>&p1, pair<ll,ll>&p2)
{
	return p1.F+p1.S<p2.F+p2.S;
}



bool sorter(pair<ll,ll>&p1,pair<ll,ll>&p2)
{
	return (mod-p1.F+mod-p1.S)<(mod-p2.S+mod-p2.F); 
}

int main()
{
        ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // compute();
    int tests=1;
    // cin>>tests;    
    while(tests--)
    {
    	ll i,j,n;
    	cin>>n;
    	vector<pair<ll,ll>>v;
    	ll mx=LLONG_MIN,mn=LLONG_MAX,mx1=LLONG_MIN,mx2=LLONG_MIN;
    	rep(i,1,n)
    	{
    		ll x,y;
    		cin>>x>>y;
    		mx=max(mx,x+y);
    		mn=min(mn,x+y);
    		mx1=max(mx1,x-y);
    		mx2=max(mx2,y-x);
    	}
    	ll ans=LLONG_MIN;
    	ans=max(ans,mx-mn);
    	ans=max(ans,mx1+mx2);
    	cout<<ans;

    }

    return 0;
}
    

Measured memory_bytes: 3652
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>









int h,w;
char g[60][60],c;





void solve()
{
	cin>>h>>w;
	for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)cin>>g[i][j];
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			if(g[i][j]=='.')
			{
				c='0';
				for(int x=-1;x<=1;x++)
				{
					for(int y=-1;y<=1;y++)
					{
						if(g[i+x][j+y]=='#')c++;
					}
				}
				g[i][j]=c;
			}
			cout<<g[i][j];
		}
		cout<<"\n";
	}
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }
// ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }
//

bool possible(vi& v, int x){
    int L = v.size();
    set<int> s; s.insert(0);
    rep(i,L) {
        set<int> s2;
        for (int si: s) {
            s2.insert(si + v[i]);
            s2.insert(si - v[i]);
        }
        s = s2;
    }
    // cerr << s << x << endl;
    return found(s, x);
}
bool solve(string&s, int x, int y) {
    int L=s.size();

    vvi ls(2, vi(0));

    int from = 0;
    rep(i,L){
        if (s[i] == 'T') break;
        --x; ++from;
    }
    int dir=0, l=0;
    for (int i=from; i<L; ++i) {
        if (s[i] == 'F') {
            ++l;
        } else {//T
            ls[dir].pb(l);
            dir=1-dir;
            l=0;
        }
    }
    if (l>0) ls[dir].pb(l);

    sort(ALL(ls[0]));
    sort(ALL(ls[1]));
    return possible(ls[0],x) && possible(ls[1],y);
}

int main() {
    string s; cin >> s;
    int x,y; cin >> x >> y;
    cout << (solve(s,x,y) ? "Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long double n;
    cin>>n;
    int flag=0;
    for (int i=1;i<=50000;i++) {
        if (floor(i*1.08)==n) {
            cout<<i<<endl;
            flag=1;
            break;
        }
    }
    if (flag==0) {
        cout<<":("<<endl;
    }
}

Measured memory_bytes: 256
//omajinai c++ atcoder
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define itn int
typedef long long ll;
constexpr auto mod = 1000000007;
using namespace std;
int main() {
int a,b,c;
  cin>>a>>b>>c;
  cout<<c<<' '<<a<<' '<<b;
}


Measured memory_bytes: 256
n = int(input())
graph = [[] for _ in range(n+1)]
for i in range(1,n):
    a,b = map(int,input().split())
    graph[a].append((i,b))
    graph[b].append((i,a))
colors = [0 for _ in range(n)]
parents = [0]*(n+1)
stack = [(1,0)]
while stack:
    x,c = stack.pop()
    color = 1
    for i,y in graph[x]:
        if parents[x] == y:
            continue
        else:
            parents[y] = x
            if color == c:
                color += 1
            colors[i] = color
            stack.append((y,color))
            color += 1
print(max(colors))
for i in range(1,n):
    print(colors[i])     

Measured memory_bytes: 39648
S=list(input())
flag1=0
if S[0]!="A":
  flag1=1

S.pop(0)
flag2=0
for i in range(1,len(S)-1):
  if S[i]=="C":
    flag2=1
    S.pop(i)
    break
if flag2==0:
  flag1=1

for i in range(len(S)):
  if S[i] in list("ABCDEFGHIJKLMNOPQRSTUVWXYZ"):
    flag1=1

if flag1==0:
  print("AC")
else:
  print("WA")

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>

using namespace std;
const double Inf = 2.83e9;

int main(){
  long long xs,ys,xt,yt;
  cin >> xs >> ys >> xt >> yt;
  int N;
  cin >> N;
  vector<long long> x(N+2), y(N+2), r(N+2);
  x[0] = xs; y[0] = ys; r[0] = 0;
  x[N+1] = xt; y[N+1] = yt; r[N+1] = 0;
  for(int i = 1; i <= N; i++){
    cin >> x[i] >> y[i] >> r[i];
  }
  vector<vector<double> > edge(N+2, vector<double>(N+2, -1.0));
  for(int i = 0; i < N+2; i++){
    for(int j = i+1; j < N+2; j++){
      edge[i][j] = max(sqrt((x[j] - x[i]) * (x[j] - x[i]) + (y[j] - y[i]) * (y[j] - y[i])) - (r[i] + r[j]), 0.0);
      edge[j][i] = edge[i][j];
    }
  }

  vector<double> cost(N+2, Inf);
  cost[0] = 0.0;
  priority_queue<pair<double, int>, vector<pair<double, int> >, greater<pair<double, int> > >  q;
  q.push({0.0, 0});

  vector<bool> check(N+2, false);

  while(!q.empty()){
    auto now_pair = q.top();
    double ncost = now_pair.first; int nid = now_pair.second;
    q.pop();
    if(check[nid]) continue;
    check[nid] = true;
    cost[nid] = ncost;

    for(int i = 0; i < N+2; i++){
      if(!check[i]){
        if(cost[nid] + edge[nid][i] < cost[i]){
          cost[i] = cost[nid] + edge[nid][i];
          q.push({cost[i], i});
        }
      }
    }
  }

  printf("%.9lf\n",cost[N+1]);
}


Measured memory_bytes: 12404
/*　　　　　　　{:i:i:|i:i:/l/l--　 　 　--l/li:i:i|i:i:i:i}
　　　　　　 　 {:rx|:i:i ィi芥ミ 　 　 .ィi芥ミｉ:ｉ|ﾍ:i:i:}
.　　　 　 　 　 ｛ﾏ|ｉ:  {::’:} 　 　 　{:‘::} :ｉ:i:|〉｝:/
　　 　 　 　 　 乂|:i:| ｀¨¨¨¨´ 　 　　｀¨¨¨´  :i:ｉ:|ｼ/
　 　 　 　 　 　 ﾉ:|:i|　　　　　　′　　　 　   |:i:i:|ﾂ
　　　　　　　　/:/|:i:| ､　　　 　_ _ 　　　　  |:i:i:|
　 　 　　 　 /:/ .|:i:|/ ＼　　　 　 　     ｨ〔|:i:/
　　 　 　  　 〈;/ く刈＿ 个 　   -   　＜}　./|/_〉
　　     　　 r-っ'~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ|___
　　 　     /／ニつ　　　　　　 ､　　　　　　　ノﾆﾆ　＼
.　　　     |　　ニ⊃ 　./　/　 ──   /　/　　..⊆ﾆﾆ　　:|
.　　　     |　　丁´　 /|￣|￣  ─‐ /|￣|￣ 　 .￣|丁 　|
.　　　     |　　ﾉ.  　 |￣|￣  ─‐  |￣|￣ 　 　.|八 　|
.　　　     |　　||. 　 |￣|￣ |￣| |￣|￣ 　   .|　|
.　 　 　   |  　||   　￣￣￣　￣ 　￣￣￣　　  .|　|  |
.　 　 　  　    ||＿＿＿＿＿＿＿＿＿＿＿＿______|__　　 ',
　 　      ,′　 | ７ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ}  ,′
.　　     {　　　|/　}ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ{/ 　 　
*///讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐。
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>

using namespace std;

#define rep(b) for(int aaa=0;aaa<int(b);aaa++)
#define ll long long
#define fst first
#define snd second
#define pf(b) printf("%.12f\n",(double)b)
#define _GLIBCXX_DEBUG
const double pai = 3.1415926535897;
#define _cos(n) cos(n*pai/180)
#define l_b lower_bound
#define u_b upper_bound
#define b_s binary_search

//factorial(練習)　階乗
int fact(int n) {
	int a = 1;
	for (int i = 1;i <= n;i++) a *= i;
	return a;
}
int sa(int n, int m) {      //差！
	if (n < m)return m - n;
	else return n - m;
}
int keta(int num) {
	int n = 0;
	if (num == 0) {
		return 1;
	}
	while (num != 0) {
		num /= 10;
		n++;
	}
	return n;
}

ll n;
char s[100000000];
signed main() {
	cin >> n;
	int i = 0;
	while (n > 0) {
		ll a = n % 26;
		if (a == 0)a = 26;
		n = (n - a) / 26;
		s[i]=(char)(a + ('a'-1));
		i++;
	}
	for (int j = i-1;j >=0;j--)cout << s[j];
	cout << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;
//const ll mod=998244353;
template <typename T>
class SegmentTree {
  ll n;
  vector<T> node;
  function<T(T, T)> fun, fun2;
  bool customChange;
  T outValue, initValue;
public:
  void init(ll num, function<T(T, T)> resultFunction, T init, T out, function<T(T, T)> changeFunction = NULL) {
    // changeFunction: (input, beforevalue) => newvalue
    fun = resultFunction;
    fun2 = changeFunction;
    customChange = changeFunction != NULL;
    n = 1;
    while (n < num) n *= 2;
    node.resize(2 * n - 1);
    fill(node.begin(), node.end(), init);
    outValue = out;
    initValue = init;
  }
  void valueChange(ll num, T value) {
    num += n-1;
    if (customChange) node[num] = fun2(value, node[num]);
    else node[num] = value;
    while (num > 0) num = (num - 1) / 2, node[num] = fun(node[num * 2 + 1], node[num * 2 + 2]);
  }
  T rangeQuery(ll a, ll b, ll l = 0, ll r = -1, ll k = 0) { // [a, b)
    if (r == -1) r = n;
    if (a <= l && r <= b) return node[k];
    if (b <= l || r <= a) return outValue;
    ll mid = (l + r) / 2;
    return fun(rangeQuery(a, b, l, mid, 2*k+1), rangeQuery(a, b, mid, r, 2*k+2));
  }
};

ll Max(ll a,ll b){
    if(a>b) return a;
    return b;
}

int main(void){
    string s;
    ll n,q;
    cin>>n>>s>>q;
    SegmentTree<ll> sgt[26];
    for(ll i=0;i<26;i++){
        sgt[i].init(n,Max,0,0);
    }
    for(ll i=0;i<n;i++){
        ll a=s[i]-'a';
        sgt[a].valueChange(i,1);
    }
    for(ll i=0;i<q;i++){
        ll a;
        cin>>a;
        if(a==1){
            ll x;
            char z;
            cin>>x>>z;
            x--;
            ll y=z-'a';
            for(ll j=0;j<26;j++){
                sgt[j].valueChange(x,0);
            }
            sgt[y].valueChange(x,1);
        }
        else{
            ll L,R;
            cin>>L>>R;
            L--;
            ll count=0;
            for(ll j=0;j<26;j++){
                count+=sgt[j].rangeQuery(L,R);
            }
            cout<<count<<endl;
        }
    }
}

Measured memory_bytes: 217092
#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 <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int N;
        cin >> N;
        Int ans = N / 2;
        if (N % 2 == 0) ans--;
        cout << ans << endl;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}

Measured memory_bytes: 3648
import java.util.*;
import java.io.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main {
    static int[][] t;
    static int n;
    static int[][] dp;

    public static int dist(String a,String b){
        int res = 0;

        for(int i=0;i<=min(a.length(),b.length());i++){
            String asub = a.substring(a.length()-i);
            String bsub = b.substring(0,i);

            if(asub.equals(bsub)){
                res = max(res,i);
            }
        }
        return res;
    }

    static int solve(int id,int bit){
        if(bit == (1<<n)-1){
            return 0;
        }
        if(dp[id][bit] != -1) return dp[id][bit];

        int res = 0;
        for(int i=0;i<n;i++){
            if(t[id][i] != -1 && (bit & (1<<i)) == 0){
                res = max(res,solve(i,bit|(1<<i))+t[id][i]);
            }
        }
        return dp[id][bit] = res;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while(true){
            n = sc.nextInt();
            if(n ==0) break;

            ArrayList<String> al = new ArrayList<String>();
            for(int i=0;i<n;i++){
                al.add(sc.next());
            }

            for(int i=0;i<al.size();i++){
                String s = al.get(i);

                for(int j=0;j<al.size();j++){
                    if(i == j) continue;

                    if(al.get(j).contains(s)){
                        al.remove(i);
                        i--;
                        break;
                    }
                }
            }

            n = al.size();
            t = new int[n][n];
            for(int i=0;i<n;i++){
                for(int j=0;j<n;j++){
                    t[i][j] = -1;
                }
            }
            
            for(int i=0;i<al.size();i++){
                for(int j=0;j<al.size();j++){
                    if(i == j) continue;
                    t[i][j] = dist(al.get(i),al.get(j));
                }
            }

            dp = new int[n][(1<<n)];

            int ans = 0;
            for(int i=0;i<n;i++){
                for(int j=0;j<n;j++) Arrays.fill(dp[j],-1);
                ans = max(ans,solve(i,1<<i));
            }

            int sum = 0;
            for(String s : al){
                sum += s.length();
            }

            System.out.println(sum-ans);
        }
    }
}

Measured memory_bytes: 17000
s=input()
n=int(input())
for i in range(n):
    c=input().split()
    st=int(c[1])
    en=int(c[2])
    if c[0]=='replace':
        s=s[:st]+c[3]+s[en+1:]
    elif c[0]=='reverse':
        s=s[:st]+s[st:en+1][::-1]+s[en+1:]
    else:
        print(s[st:en+1])


Measured memory_bytes: 5612
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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



int main(){
	int n;
	cin >> n;
	int p[100005] = {};

    int ans = 0;
	rep(i,0,n){
	    cin >> p[i];
	}

    rep(i,0,n){
        if(i+1 == p[i]){
            swap(p[i],p[i+1]);
            ans++;
        }
    }

    P(ans);
	
	

	return  0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back
#define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power_mod(a,mod-2);}
ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}

int main(){
  
  
  int n;
  cin>>n;
  int a[n+1];
  for(int i=0;i<n;i++) cin>>a[i];
  
  map<int,int> m1,m2;
  
  for(int i=0;i<n;i+=2)
  {
     m1[a[i]]++;
  }
  
  
  for(int i=1;i<n;i+=2)
  {
     m2[a[i]]++;
  }

  int mx1=-1,mx2=-1,mx3=-1,mx4=-1;
  int n1=-1,n2=-1,n3=-1,n4=-1;
  for(auto i: m1)
  {
  	 if(i.second>mx1){
  	 	mx1=i.second;
  	 	n1=i.first;
  	 }
  }

  m1.erase(n1);

   for(auto i: m1)
  {
  	 if(i.second>mx2){
  	 	mx2=i.second;
  	 	n2=i.first;
  	 }
  }

   for(auto i: m2)
  {
  	 if(i.second>mx3){
  	 	mx3=i.second;
  	 	n3=i.first;
  	 }
  }

  m2.erase(n3);

   for(auto i: m2)
  {
  	 if(i.second>mx4){
  	 	mx4=i.second;
  	 	n4=i.first;
  	 }
  }
  	
 // cout<<n1<<" "<<n2<<" "<<n3<<" "<<n4<<endl;
  //cout<<mx1<<" "<<mx2<<" "<<mx3<<" "<<mx4<<endl;	
  if(n1!=n3)
  {
  	 cout<<n-mx1-mx3<<endl;
  }
  else
  	if(n1==n3)
  	{
          if(mx2==-1&&mx4==-1)
          {
          	  cout<<n/2<<endl;
          }
          else
          	if(mx2==-1)
          	{
          		cout<<(n/2)-mx4<<endl;
          	}
          else
            if(mx4==-1)
            {
            	cout<<(n/2)-mx2<<endl;
            }	
           else{
           	  cout<<min(n-mx1-mx4,n-mx2-mx3)<<endl;
           } 

  	}

   return 0;

}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define P pair<int,int>
#define prique priority_queue
string s;
int n,k;
signed main(){
    cin>>n>>s>>k;
    char base=s[k-1];
    rep(i,n){
        if(s[i]==base)cout<<s[i];
        else cout<<"*";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int, input().split()))
A.sort()
inf=10**6+1
t=[True for i in range(inf)]

ans=0
for j in range(N):
    if j+1<=N-1 and t[A[j]]:
        if A[j+1]!=A[j]:
            ans+=1
        else:
            t[A[j]]=False
        for numb in range(A[j],inf,A[j]):
            t[numb]=False
    elif j==N-1 and t[A[j]]:
        ans+=1

print(ans)

Measured memory_bytes: 32380
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)

using namespace std;
using p = pair<long long, int>;
#define INF 100000000

int main(){
    string s,t;
	cin >> s >> t;
	
	if(s == t.substr(0,s.size()))    cout << "Yes" << endl;
	else cout << "No" << endl;
    return 0;
		
}

Measured memory_bytes: 3624
#include <stdio.h>
#define N_MAX 100001

int main() {
    int n, q, a[N_MAX];
    scanf("%d%d", &n, &q);
    for (int i=0; i<n; i++) scanf("%d", a+i);
    while (q--) {
        int s = 0, t = 0;
        long x, res = 0, sum = 0;
        scanf("%ld", &x);
        for (;;) {
            while (t <= n && sum <= x) {
                sum += a[t++];
            }
            if (s == t) break;
            sum -= a[s++];
            res += t - s;
        }
        printf("%ld\n", res);
    }
}



Measured memory_bytes: 2120
#include <iostream>

using namespace std;


int main(void)
{
    int a, b;

    cin >> a >> b;

    if(a < b) cout << "a < b" << endl;    
    if(a == b) cout << "a == b" << endl;
    if(a > b) cout << "a > b" << endl;

    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
signed main()
{
    int n;
    cin >> n;
    int sum = 0;

    if (n >= 10) {
        sum += 9;
    }
    if (n >= 1000) {
        sum += 1000 - 100;
    }
    if (n >= 100000) {
        sum += 100000 - 10000;
    }

    int d = 0;
    int t = n;
    while (t > 0) {
        t /= 10;
        d += 1;
    }
    if (d % 2 == 1) {
        sum += n - pow(10, d-1) + 1;
    }
    put(sum)

    return 0;
}

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

int main(){
  int i;
  char s[5],days[8][8]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
  scanf("%s",s);
  for(i=0;i<7;i++){
    if(strcmp(days[i],s)==0){
      printf("%d",7-i);
      return 0;
    }
  }
}

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


def main():
    s = list(input())
    n = len(s)
    large_k = int(input())
    # KeyInsight: 桁DP
    # dp[i][j][k]
    # i桁目、j個の非0、k:そこまでの桁がNと一致する(0), N未満(1)
    ## i, kは典型的な状態、jに気が付けるかどうか
    # See:
    # http://hiroto1979.hatenablog.jp/entry/2016/03/18/224631
    dp = [[[0 for k in range(2)] for j in range(4)] for i in range(105)]
    ## なぜ初期値が1になる?
    dp[0][0][0] = 1

    # See:
    # https://www.youtube.com/watch?v=JQmQjJd-sLA&feature=youtu.be
    # http://drken1215.hatenablog.com/entry/2019/02/04/013700
    # https://torus711.hatenablog.com/entry/20150423/1429794075
    for i in range(n):
        for j in range(4):
            for k in range(2):
                # 次の桁の数字
                nd = int(s[i])

                # 各桁で0〜9を試す
                for digit in range(10):
                    ni, nj, nk = i + 1, j, k

                    # 遷移ができるかどうかを判定
                    ## 遷移できない条件を列挙して、計算をしないようにする
                    # ある桁で、0以外の数字を使う
                    if digit != 0:
                        nj += 1

                    # 0でない数字がK個より大きいときは、遷移しない
                    if nj > large_k:
                        continue

                    # ある桁まで見たときに、Nと一致する
                    if k == 0:
                        # ある桁の数字より大きいときは、遷移しない
                        if digit > nd:
                            continue
                        # 小さいときは、Nと一致しない(=それ以降の桁にはどんな数字を入れてもよい)
                        elif digit < nd:
                            nk = 1

                    dp[ni][nj][nk] += dp[i][j][k]

    # N未満とNの合計
    print(dp[n][large_k][0] + dp[n][large_k][1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
N = int(input())
h = list(map(int, input().split()))

ans = 0
while sum(h) != 0:
    count = 0
    for i in range(N):
        if h[i] > 0:
            h[i] -= 1
            count += 1
        elif h[i] == 0:
            if count == 0:
                continue
            elif count > 0:
                break
    ans += 1

print(ans)

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;

int main() {
    string s;
    cin >> s;
    cout << s.substr(0, 4) << " " << s.substr(4) << endl;
}


Measured memory_bytes: 256
from collections import Counter

n,a = map(int, input().split())
x = [int(i) - a for i in input().split()] # 合計を0にする

total = Counter([0])

for i in x:
    tmp = Counter()
    for j, cnt in total.items():
        tmp[i+j] += cnt
    total += tmp # 各合計値のカウントを積む

print(total[0] - 1)
exit(0)

Measured memory_bytes: 40944
#include<iostream>
#include<bitset>
#include<vector>
using namespace std;

int main(){

    bitset<28> subset, T;
    
    int n, k, b;
    cin >> n >> k;
    while (k--){
        cin >> b;
        T[b] = 1;
    }

    for(int i = 0; i < (1 << n); i++){
        subset = i;
        if((subset & T) == subset){
            cout << i << ":";            
            for(int j = 0; j < n; j++){
                if(subset[j]){
                    cout << ' ' <<  j;
                }
            }
            cout << endl;            
        }

    }
    return 0;
}


Measured memory_bytes: 3096
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    for _ in 0..3000 {
        let x:i32 = read();
        let y:i32 = read();
        if x == 0 && y == 0 {
            break;
        }
        println!("{} {}", min(x,y), max(x,y));
    }
}


Measured memory_bytes: 5024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Sanket Makani
 */
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);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader sc, PrintWriter w) {

            int arr[] = new int[9];

            int max = 0;

            int n = sc.nextInt();

            for (int i = 0; i < n; i++) {
                int index = Math.min(8, sc.nextInt() / 400);
                arr[index]++;
            }

            int min = 0;
            int count = 0;
            for (int i = 0; i < 8; i++) {
                if (arr[i] != 0)
                    count++;
            }

            if (count == 0) {
                min = 1;
                max = arr[8];
            } else {
                min = count;
                max = min + arr[8];
            }


            w.println(min + " " + max);

        }

    }

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

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

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

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

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 22740
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

int main()
{
    ll N;
    cin >> N;
    string S;
    vector<ll> march(5,0);
    int P[10] = {0,0,0,0,0,0,1,1,1,2};
    int Q[10] = {1,1,1,2,2,3,2,2,3,3};
    int R[10] = {2,3,4,3,4,4,3,4,4,4};
    for (int i = 0; i < N; i++)
    {
        cin >> S;
        if ('M' == S[0])
        {
            march[0]++;
        }
        else if('A' == S[0]){
            march[1]++;
        }
        else if('R' == S[0]){
            march[2]++;
        }
        else if('C'== S[0]){
            march[3]++;
        }
        else if('H' == S[0]){
            march[4]++;
        }
    }
    ll ans = 0;
    for (int d = 0; d < 10;d++)
    {
        ans += march[P[d]] * march[Q[d]] * march[R[d]];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
# coding: utf-8

N,X,Y=map(int,input().split())
G=[[] for i in range(N)]

for i in range(N):
    if i<N-1:
        G[i].append(i+1)
    if i>0:
        G[i].append(i-1)

G[X-1].append(Y-1)
G[Y-1].append(X-1)

ans=[0 for i in range(N)]

INF=10**5

for i in range(N):
    queue=[]
    queue.append(i)
    d=[INF for j in range(N)]
    d[i]=0
    unused=[True for j in range(N)]
    unused[i]=False
    
    while queue:
        u=queue.pop(0)
        
        for j in range(len(G[u])):
            n=G[u][j]
            if unused[n] and d[n]>d[u]+1:
                unused[n]=False
                d[n]=d[u]+1
                queue.append(n)
    
    for j in range(N):
        ans[d[j]]+=1


for i in range(N-1):
    print(ans[i+1]//2)




Measured memory_bytes: 52828
// Example program
#include <iostream>
#include <string>
using namespace std;
int main()
{
char a, b;
cin >> a >> b;
if (a - b == 0) {cout << "=\n";}
else if (a - b < 0) {cout << "<\n";}
else if (a - b > 0) {cout << ">\n";}

return 0;
}


Measured memory_bytes: 256