akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

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

    int tmp_n = n, digits_sum = 0;
    while (0 < tmp_n) {
        digits_sum += tmp_n % 10;
        tmp_n /= 10;
    }

    cout << (n % digits_sum == 0 ? "Yes" : "No") << endl;
}

int main() {
    solve();

    return 0;
}


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

int main() {
  int A, B;
  char op;
  cin >> A >> op >> B;
  
  int answer;
  
  if (op == '+') {
    answer = A + B;
  }
  else if (op == '-') {
    answer = A - B;
  }
  
  cout << answer << endl;

  // ここにプログラムを追記
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
string s,t;
int dp[3010][3010]={{0}};
#define inf -1
int cal(int i,int j){
if(i==s.size()||j==t.size())return 0;
if(dp[i][j]!=inf)return dp[i][j];
if(s[i]==t[j])return dp[i][j]=1+cal(i+1,j+1);
return dp[i][j]=max(cal(i,j+1),cal(i+1,j));
}
int main(){
    cin>>s>>t;
    memset(dp,inf,sizeof dp);
    int i=0,j=0;
    cal(0,0);
    string is;
    while(dp[i][j]!=0){
          //  cout<<i<<' '<<j<<'\n';
        if((i==s.size())||(j==t.size()))break;
        if(s[i]==t[j]){is.push_back(s[i]);i++;j++;continue;}
        if(dp[i+1][j]>dp[i][j+1]){i++;}
        else {j++;}
    }
    cout<<is<<'\n';
    return 0;
}


Measured memory_bytes: 35968
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Int32;

namespace ConsoleApp1
{
    class Program
    {
        static void Main()
        {
            label:
            WriteLine(hoge());
        }

        static int hoge()
        {
            var sp = ReadLine().Split();
            int q = Parse(sp[1]);
            var s = ReadLine();
            var ary = new string[q];
            for (int i = ary.Length - 1; 0 <= i; --i)
            {
                ary[i] = ReadLine();
            }
            int right = 0;
            int left = s.Length - 1;
            for (int i = 0; i < ary.Length; ++i)
            {
                if (ary[i][2] == 'L')
                {
                    if (ary[i][0] == s[right])
                    {
                        if (++right == s.Length)
                        {
                            return 0;
                        }
                    }
                    if (left < s.Length - 1 && ary[i][0] == s[left + 1])
                    {
                        ++left;
                    }
                }
                else
                {
                    if (0 < right && ary[i][0] == s[right - 1])
                    {
                        --right;
                    }
                    if (ary[i][0] == s[left])
                    {
                        if (--left < 0)
                        {
                            return 0;
                        }
                    }
                }
            }
            int result = s.Length - right - (s.Length - 1 - left);
            return Math.Max(result, 0);
        }
    }
}


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

#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mod 1000000007

ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
/*
ll factor(ll n){
    vll ans;
	if(n==2)ans.pb(2);
	else
    {for(ll i=2;i*i<=n;i++){if(n%i==0 && n%i!=i){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}ans.pb(n);}
    return ans.sz+1;
}
ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i; 
    return res; } 
  
ll nCr(ll n, ll r){ return fact(n) / (fact(r) * fact(n - r)); } 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 

ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
*/
void solve()
{
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for(ll i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	ll ans=0;
	for(ll i=n-1;i>=0;i--)
	{
		ans+=a[i];
		k--;
		if(k==0)
		{
			cout<<ans;
			return;
		}
	}
}            
int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


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

int main()
{
   ll a[5],b,c,k,ans;
   for(int i=0;i<3;i++)
   cin>>a[i];
   cin>>k;
   sort(a,a+3);
   b=a[2];
   ans=a[0]+a[1];
   for(int i=1;i<=k;i++)
   {
       b=(2*b);
   }

   cout<<ans+b;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int N;
	cin >> N;
	cout << N * N * N << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int l,r,d,sum=0;
  scanf("%d %d %d", &l, &r, &d);
  for(int i=l;i<=r;i++){
    if(i%d == 0)
      sum++;
  }
  printf("%d", sum);
  
  return 0;
}

Measured memory_bytes: 1732
#include <iostream>
using namespace std;
 
int main() {
	int A, B, C;
cin>>A>>B;
C=A+B;
if((C>=0)&&(C<=23)) {
cout<<C;
} else if(C>24) {
cout<<C-24;
} else if(C=24) {
cout<<0;
} 
	return 0;
}

Measured memory_bytes: 256
ac,wa,tle,re = 0,0,0,0
N=int(input())
for _ in range(N):
  s=str(input())
  if(s=="AC"):
  	ac+=1
  elif(s=="WA"):
  	wa+=1
  elif(s=="TLE"):
  	tle+=1
  elif(s=="RE"):
  	re+=1

print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re))

Measured memory_bytes: 9212
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#include <bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    int ans = a[0];
    rep(i,n)ans = __gcd(ans,a[i]);
    cout << ans << endl;
}


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

int main(){
	int l[4][3][10];
	for(int p = 0; p < 4; p++){
		for(int q = 0; q < 3; q++){
			for(int r = 0; r < 10; r++){
				l[p][q][r] = 0;
			}
		}
	}

	int n;
	cin >> n;

	for(int i = 0; i < n; i++){
		int p, q, r, s;
		cin >> p >> q >> r >> s;
		l[p-1][q-1][r-1] += s;
	}

	for(int p = 0; p < 4; p++){
		for(int q = 0; q < 3; q++){
			for(int r = 0; r < 10; r++){
				cout << ' ' << l[p][q][r] << flush;
			}
			cout << endl;
		}
		if(p == 3){
			break;
		}
		cout << "####################" << endl;
	}

	return(0);
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
 
using namespace std;
 
typedef pair<int,int> P;
vector<P> vec;
 
void change(int p, int S, int l){
  vector<P> tmp;
  int Next = vec[p].second - S;
 
  for(int i = 0 ; i < p ; i++){
    tmp.push_back(vec[i]);
  }
 
  tmp.push_back(P(l, S));
  tmp.push_back(P(-1,Next));
 
  for(int i = p+1 ; i < vec.size() ; i++){
    tmp.push_back(vec[i]);
  }
 
  vec = tmp;
}
 
void Wri(){
  int len = vec.size(), l, S;
 
  cin >> l >> S;
 
  if(len == 0){
    vec.push_back(P(l,S));
    return;
  }
 
  for(int i = 0 ; i < len ; i++){
    if(vec[i].first == -1){
      if(S - vec[i].second >= 0){
        vec[i].first = l;
        S -= vec[i].second;
      }else{
        change(i, S, l);
        return;
      }
    }
  }
 
  if(S > 0){
    vec.push_back(P(l,S));
  }
}
 
void Del(){
  int len = vec.size(), l;
 
  cin >> l;
  if(len == 0){
    return;
  }
 
  for(int i = 0 ; i < len ; i++){
    if(vec[i].first == l){
      vec[i].first = -1;
    }
  }
}
 
int Ref(){
  long long cnt = 0;
  int len = vec.size(), l, num = vec[0].first;
 
  cin >> l;
  if(len == 0){
    return -1;
  }
 
  for(int i = 0 ; i < len ; i++){
    cnt += vec[i].second;
    num = vec[i].first;
     
    if(cnt > l){
      return num;
    }
  }
 
  if(cnt <= l){
    return -1;
  }else{
    return vec[len-1].first;
  }
}
 
int main(){
  int N;
  char ch;
 
  while(cin >> N, N){
    vec.clear();
    for(int i = 0 ; i < N ; i++){
      cin >> ch;
 
      switch(ch){
      case 'W':
        Wri();
        break;
      case 'D':
        Del();
        break;
      default:
        cout << Ref() << endl;
        break;
      }
    }
 
    cout << endl;
  }
 
  return 0;
}

Measured memory_bytes: 1396
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;

int gcd(int a, int b) {
    if (b == 0) return a;
    if (a < b) swap(a, b);
    return gcd(b, a % b);
}

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

    vector<int> positions(n);
    int ans = numeric_limits<int>::max();
    for (auto& i : positions) {
        cin >> i;
        ans = min(ans, abs(i-x));
    }
    sort(positions.begin(), positions.end());
    for (size_t i=0; i < n-1; i++) {
        ans = gcd(ans, abs(positions[i]-positions[i+1]));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
n,k = map(int, raw_input().split())
ais = map(int, raw_input().split())

def p(m,ais,k):
	t = [ m, ais, k]
	for ai in ais:
		if ai > m:
			k-= ai / m
	return k >=0

lo,hi = 1, max(ais)

while(lo < hi):
	med = (lo + hi)/2
	if p(med, ais, k):
		hi = med
	else:
		lo = med + 1

print lo



Measured memory_bytes: 95084
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

A=list(reversed(A))
B=list(reversed(B))
cnt=0
tmp=0
for i in range(N):
    if A[i]>=B[i]:
        cnt+=B[i]
        tmp=0
    else:
        cnt+=A[i]
        tmp=min(B[i]-A[i],A[i+1])
        cnt+=tmp
        A[i+1]-=tmp
print(cnt)

Measured memory_bytes: 18476
#include "bits/stdc++.h"
using namespace std;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int N = 1e6;

int main() {
	ios_base::sync_with_stdio(0);
	int a,b,n,T,cas=0;
	string s;
	cin>>n>>s;
	int cnt=0;
	for(int i=2;i<n;++i) {
		if(s[i-2]=='A' && s[i-1]=='B' && s[i]=='C') cnt++;
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define MOD 1000000007

ll fact[200000], fact_i[200000];

ll power(int x, int y) {
    if (y == 1) return x;
    ll p = power(x, y >> 1);
    if (y & 1) return p * p % MOD * x % MOD;
    else return p * p % MOD;
}

ll inv(ll n) {
    return power(n, MOD - 2);
}

void init(int n) {
    fact[0] = 1;
    REP(i, n) fact[i + 1] = fact[i] * (i + 1) % MOD;
    fact_i[n] = inv(fact[n]);
    REP(i, n) fact_i[n - i - 1] = fact_i[n - i] * (n - i) % MOD;
}

ll nCr(ll n, ll r) {
    return fact[n] * fact_i[r] % MOD * fact_i[n - r] % MOD;
}

int main() {
    init(200000);
    ll N, M, K;
    cin >> N >> M >> K;

    ll ans = 0;
    FOR(i, 1, N) {
        ans += i * (N - i) % MOD * M * M % MOD;
        ans %= MOD;
    }
    FOR(i, 1, M) {
        ans += i * (M - i) % MOD * N * N % MOD;
        ans %= MOD;
    }
    ans = ans * nCr(N*M-2, K-2) % MOD;


    // FOR(i, 1, N) ans = (ans + i * (N - i) % MOD * M * M % MOD) % MOD;
    // FOR(i, 1, M) ans = (ans + i * (M - i) % MOD * N * N % MOD) % MOD;
    // ans = ans * nCr(N * M - 2, K - 2) % MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
n = gets.to_i
puts 8 if n >= 400 && n <= 599
puts 7 if n >= 600 && n <= 799
puts 6 if n >= 800 && n <= 999
puts 5 if n >= 1000 && n <= 1199
puts 4 if n >= 1200 && n <= 1399
puts 3 if n >= 1400 && n <= 1599
puts 2 if n >= 1600 && n <= 1799
puts 1 if n >= 1800 && n <= 1999

Measured memory_bytes: 14380
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

constexpr ll mod=1e9+7;
vector<pair<int,int>> v[301];
ll dp[303][303]={1};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    while(m--){
        int l,r,x; cin >> l >> r >> x;
        v[r-1].push_back({l,x});
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<i;j++){
            for(int k=0;k<i;k++){
                (dp[i][j]+=dp[max(j,k)][min(j,k)])%=mod;
            }
        }
        for(auto p:v[i]){
            for(int j=0;j<=i;j++){
                for(int k=0;k<=j;k++){
                    if(p.second+(j<p.first)+(k<p.first)-3){
                        dp[j][k]=0;
                    }
                }
            }
        }
    }
    ll res=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<i;j++){
            (res+=6*dp[i][j])%=mod;
        }
    }
    printf("%lld\n",(res+dp[0][0]*3)%mod);
}

Measured memory_bytes: 4524
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]*(N+1)
b = [0]*(M+1)
for i in range(1, N+1):
    a[i] = a[i-1] + A[i-1]
for j in range(1, M+1):
    b[j] = b[j-1] + B[j-1]

ans = 0
j = M
for i in range(N+1):
    if K - a[i] < 0:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)

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

int main() {
  int a, b;
  cin >> a >> b;
  if ((a + b) % 2 == 0 ) {
    cout << (a + b) / 2 << endl;
  }
  else {
    cout << (a + b) / 2 + 1 << endl;
  }
}

Measured memory_bytes: 3556
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        ll n;
        cin >> n;
        vector<double> p(n);
        rep(i, n) cin >> p[i];
        double ans = 0;

        double dp[n + 1][n + 1]; // dp[i][j] 最初のi枚のコインを投げた時に，表がj枚となる確率．
        rep(i, n + 1) rep(j, n + 1) dp[i][j] = 0.0;
        dp[0][0] = 1.0;
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j <= i; ++j) {
                dp[i + 1][j + 1] += dp[i][j] * p[i];
                dp[i + 1][j] += dp[i][j] * (1.0 - p[i]);
            }
        }
        for (int i = n / 2 + 1; i <= n; ++i) {
            ans += dp[n][i];
        }

        cout << fixed << setprecision(10) << ans << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 70528
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>

using namespace std;

int main(){
	int64_t n;
	cin>>n;
	vector<int64_t > a;
	a.reserve(n);
	for(int64_t i1=0;i1<n;i1++){
		int64_t temp;
		cin>>temp;
		a.push_back(temp);
	}
	const int64_t sum=accumulate(a.begin(),a.end(),0);
	bitset<2000001> current;
	current[0]=true;
	for(int64_t i1=0;i1<n;i1++){
		bitset<2000001> cp=current<<a[i1];
		current|=cp;
	}
	for(int64_t i1=sum/2;i1>=0;i1--){
		if(current[i1]){
			cout<<sum-i1<<endl;
			break;
		}
	}





}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
int col[100005];
int f[100005];
bool vis[100005];
vector<pair<int,int> > v[100005];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n-1;i++)
    {
        int c,d;
        cin>>c>>d;
        v[c].push_back({d,i});
        v[d].push_back({c,i});
        f[d]=i;
    }
    queue<int> q;
    q.push(1);
    vis[1]=1;

    int ans=1;
    while(!q.empty())
    {
        int t=q.front();
        q.pop();
        int num=1;
        //cout<<"F"<<f[t]<<'\n';
        for(int i=0;i<v[t].size();i++)
        {
            if(!vis[v[t][i].F])
            {
                if(t>1&&col[f[t]]==num) num++;
                vis[v[t][i].F]=1;
                q.push(v[t][i].F);
                col[v[t][i].S]=num;
                //cout<<v[t][i].S<<' '<<num<<'\n';
                ans=max(ans,num);
                num++;
            }
        }
    }
    cout<<ans<<'\n';
    for(int i=1;i<n;i++)
        {
            cout<<col[i]<<'\n';
        }
}


Measured memory_bytes: 7424
#include <iostream>

using namespace std;

int main() {
    int n;
    string s, t;

    long long int puttern[26] = { 0 };

    cin >> n >> s >> t;

    puttern[s[0]-'a'] = 1;

    for (int i=1; i<n-1; i++) {
        puttern[s[i]-'a'] += puttern[t[i]-'a'];
        if (puttern[s[i]-'a'] >= 1000000007) puttern[s[i]-'a'] -= 1000000007;
        //cout << puttern[0] << " " << puttern[1] << endl;
    }

    cout << puttern[t[n-1]-'a'] << endl;

    return 0;
}


Measured memory_bytes: 3276
my $a = getc;
my $b = getc;
my $c = getc;
my $d = getc;

$a + $b + $c + $d == 7 and printf "%d+%d+%d+%d=7\n", $a, $b, $c, $d and exit;
$a + $b + $c - $d == 7 and printf "%d+%d+%d-%d=7\n", $a, $b, $c, $d and exit;
$a + $b - $c + $d == 7 and printf "%d+%d-%d+%d=7\n", $a, $b, $c, $d and exit;
$a + $b - $c - $d == 7 and printf "%d+%d-%d-%d=7\n", $a, $b, $c, $d and exit;
$a - $b + $c + $d == 7 and printf "%d-%d+%d+%d=7\n", $a, $b, $c, $d and exit;
$a - $b + $c - $d == 7 and printf "%d-%d+%d-%d=7\n", $a, $b, $c, $d and exit;
$a - $b - $c + $d == 7 and printf "%d-%d-%d+%d=7\n", $a, $b, $c, $d and exit;
$a - $b - $c - $d == 7 and printf "%d-%d-%d-%d=7\n", $a, $b, $c, $d

Measured memory_bytes: 512
import Control.Arrow
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = breads >>= print . solve 

solve :: [Int] -> Int
solve [n, m] = prodOnVal . map mf . group $ sort es
    where
        mf x = fact (calcH $ head x) (length x)
        prodOnVal = foldl' (\l r -> val $ l * r) 1

        calcH v = val $ x * y
            where
                x = prodOnVal [n..(n + v - 1)]
                y = prodOnVal $ map inv [2..v]

        es = dcmp m [2..m]
        
        dcmp v (x : xs)
            | x > v = []
            | v `mod` x /= 0 = dcmp v xs
            | otherwise = c : dcmp w xs
            where
                (c, w) = count x v
        dcmp _ _ = []

        
        count = loop 0
            where
                loop acc x v
                    | b == 0 = loop (acc + 1) x a
                    | otherwise = (acc, v)
                    where
                        (a, b) = v `divMod` x

inv :: Int -> Int 
inv = (`fact` m)
    where
        m = 10 ^ 9 + 5

fact :: Int -> Int -> Int
fact b e
    | e == 0 = 1
    | odd e = val $ b * fact b (e - 1)
    | otherwise = val $ v * v
    where
        v = fact b $ e `div` 2

val :: Int -> Int 
val = (`mod` m)
    where
        m = 10 ^ 9 + 7

breads :: IO [Int]
breads = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

Measured memory_bytes: 892
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		WriteLine((F + 110) / 111 * 111);
	}
}


Measured memory_bytes: 11092
#define onlycc ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#include <iostream>
#include <algorithm>
using namespace std;

typedef long long ll;

int n, x, t;

int main()
{
    onlycc;
    cin >> n >> x >> t;

    int sum = 0, ret = 0;
    while(sum < n)
    {
        sum += x;
        ret += t;
    }

    cout << ret;

    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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;}
int const INF = 1001001001;


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

int N,K;
cin >> N >> K;
vi D(K);
rep(i,K) cin >> D[i];

auto F = [&](int c) {
    int d;
    vector<int> res;
    while(c) {
        d = c % 10;
        res.push_back(d);
        c /= 10;
    }
    return res;
};

for(int i = N; i < 100000; ++i) {
    vi now = F(i);
    bool ok = true;
    rep(p, now.size()) {
        rep(q, D.size()) {
            if(now[p] == D[q]) ok = false;
        }
    }
    if(ok) {
        cout << i << endl;
        return 0;
    }
}
return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>     
using namespace std;
int main() 
{
    int n,a=0;
    cin>>n;
    int p[n];
    for(int i=1;i<=n;i++)
    {
        cin>>p[i];
    }
    for(int i=1;i<=n;i++)
    {
        if(i!=p[i])
        {
                a++;
        }
    }
    if(a==0 || a==2)
    {
        cout<<"YES"<<endl;
    }
    else
    {
            cout<<"NO"<<endl;
    }
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  for(int i=0; i<n; i++){
    int num;
    cin >> num;
    num--;
    vec[i] = num;
  }
  int cnt = 0;
  if(vec[n-1] == n-1){
    int tmp = vec[n-1];
    vec[n-1] = vec[n-2];
    vec[n-2] = tmp;
    cnt++;
  }
  for(int i=0; i<n-1; i++){
    if(vec[i] == i){
      int tmp = vec[i];
      vec[i] = vec[i+1];
      vec[i+1] = tmp;
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3736
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string T, P; cin >> T >> P;
	int index(0);
	set<int>f, b;

	for (int i = 0; i < T.size() && index < P.size(); i++) {
		if (T[i] == P[index]) {
			f.insert(i);
			index++;
		}
	}
	bool h(index == P.size());

	index = P.size() - 1;
	for (int i = T.size() - 1; i >= 0 && index >= 0; i--) {
		if (T[i] == P[index]) {
			b.insert(i);
			index--;
		}
	}
	bool g(index == -1);
	if (h&&g&&b == f)cout << "yes" << endl;
	else cout << "no" << endl;
	return 0;
}

Measured memory_bytes: 50776
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

long long calc(long long A) {
  // 10^3<2^10
  // 1000 < 1024
  // 10^12 < 2^40
  // 10^12 <= 2進数40桁ぐらい
  A++;
  long long ans = 0;

  // i桁目の1の偶奇を調べる
  for (int i = 0; i < 50; i++) {
    //周期を求める　0桁目は周期2(01)　1桁目は周期4(0011)　2桁目は周期8(00001111)
    long long loop = (1LL << (i + 1));
    long long cnt = (A / loop) * (loop / 2);
    cnt += max(0LL, (A % loop) - (loop / 2));
    if (cnt % 2 == 1) {
      ans += (1LL << i);
    }
  }

  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long A, B;
  cin >> A >> B;
  long long ans = calc(B) ^ calc(A - 1);
  cout << ans << '\n';
}

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

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

  string ans = "";
  while (n > 0) {
    n--;
    ans += 'a' + n % 26;
    n /= 26;
  }
  reverse(rng(ans));
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3580
#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;
vector<int>sosuu2(100001, 0);
vector<int>sosuu3(100001, 0);
vector<int>sosuu;
int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	vector<int>arr(10001, 0);
	int N; cin >> N;
	arr[0] = 1;
	for (int i = 0; i < N; i++)
	{
		int a; cin >> a;
		for (int j = 10000; j >= 0; j--)
		{
			if (arr[j] > 0)
			{
				arr[j + a]++;
			}
		}
	}
	for (int i = 10000; i >= 0; i--)
	{
		arr[i] += 10;
		if (i == 0)
		{
			cout << 0 << "\n";
		}
		if (arr[i] > 10 && i % 10 != 0)
		{
			cout << i << "\n";
			return 0;
		}
	}
}

Measured memory_bytes: 1024
import java.util.Scanner

import scala.collection.mutable

object Main extends App {
  val sc = new Scanner(System.in)
  val N, M = sc.nextInt
  val AB = Array.fill(M)((sc.nextInt, sc.nextInt))

  val G = (AB ++ AB.map(_.swap)).groupBy(_._1).map(x => { x._1 -> x._2.map(_._2) })

  val X = Array.fill(N)(false)
  val Y = Array.fill(N)(0)

  val Q = new mutable.Queue[Int]()
  X(0) = true
  Q += 1
  while (Q.nonEmpty) {
    val v = Q.dequeue
    X(v - 1) = true
    G(v).foreach(i => {
      if (!X(i - 1)) {
        X(i - 1) = true
        Y(i - 1) = v
        Q += i
      }
    })
  }

  println("Yes")
  println(Y.tail.mkString("\n"))
}


Measured memory_bytes: 123312
#include<bits/stdc++.h>
using namespace std;
int main(){
  long n;
  cin>>n;
  string s;
  while(n){
    s=(n%2?"1":"0")+s;
    (n-=(n%2?1:0))/=(-2);
  }
  cout<<(s.length()?s:"0");
  return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int K;
string S;
vector <string> V;

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

  for (int i = 0; i < S.length(); i++){
    string now = "";
    for (int j = 0; j < 5 && i + j < S.length(); j++){
      now += S[i + j];
      V.push_back(now);
    }
  }
  sort(V.begin(), V.end());

  int now = 0;
  for (int i = 0; i < V.size(); i++){
    if (V[i] == V[i + 1]) continue;
    now++;
    if (now == K){
      cout << V[i] << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 4272
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,m=LI()

  # x=1900*m+(n-m)*100
  # p=1/2^m

  # y=x+(1-p)*y
  # y=x/p
  # y=2^m*(1900*m+(n-m)*100)

  return 2**m*(1900*m+(n-m)*100)

# main()
print(main())


Measured memory_bytes: 5840
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;
long long int MOD = 1000000007;

int main(){
	while(true){
		int N;
		cin >> N;
		if(N == 0){
			break;
		}
		
		double x[500], y[500];
		for(int i = 0; i < N; i++){
			cin >> x[i] >> y[i];
		}
		int ans = 0;
		for(int i = 0; i < N; i++)for(int j = 0; j < N; j++){
			double vx = x[j] - x[i];
			double vy = y[j] - y[i];
			double norm = sqrt(vx * vx + vy * vy);
			if(norm > 2 || i == j){
				continue;
			}
			double vnx = vx / norm;
			double vny = vy / norm;
			norm /= 2;
			double norm2 = sqrt(1 - norm * norm);
			double v90x = -vny;
			double v90y = vnx;
			double centx = x[i] + vx / 2 + v90x * norm2;
			double centy = y[i] + vy / 2 + v90y * norm2;
			int S = 2;
			for(int k = 0; k < N; k++){
				if(i == k || j == k){
					continue;
				}
				double xx = centx - x[k];
				double yy = centy - y[k];
				if(xx * xx + yy * yy <= 1){
					S++;
				}
			}
			ans = max(S, ans);
		}
		cout << max(1, ans) << endl;
	}
	return 0;
}




Measured memory_bytes: 3236
import java.math.BigDecimal;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		double L = scan.nextDouble();


		BigDecimal Max = new BigDecimal(Math.pow(L/3, 3));

		System.out.printf(Max.toPlainString());
		scan.close();

	}

}


Measured memory_bytes: 25428
import numpy as np
N=int(input())
x = [0] * N
y = [0] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())

x=np.array(x)
y=np.array(y)
z=np.vstack((x,y))
zz=np.argsort(z[1,:])[::-1]
z=z[:,zz]

left=z[1,0]
flag='Yes'
sumarray=np.cumsum(z[0][::-1])[::-1]
for i in range(N):
  
  if min(left,z[1,i])<sumarray[i]:
    flag='No'
    break
  else:
    left=z[1,i]-z[0,i]
print(flag)

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

int main() {
  string w;
  int a[100] = {0};

  cin >> w;
  for (int i = 0; i < w.size(); i++) {
    int x = w[i] - 'a';
    a[x]++;
  }

  for (int i = 0; i < 26; i++) {
    if (a[i] % 2 == 1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const long long int inf = 1e18+7;
const int mod = 998244353;

using namespace std;

inline ll int max(ll int a,ll int b) { return a>b?a:b; }
inline ll int min(ll int a,ll int b) { return a<b?a:b; }

const int maxn=2e5+100;

int num[maxn];

int pre[maxn];

int lst[maxn];

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	int n;
	
	cin>>n;
		
	for(int i=1;i<=n;i++)
	{
		cin>>num[i];
		pre[i]=pre[i-1]^num[i];
	}
	
	for(int i=n;i>=1;i--)
	{
		lst[i]=lst[i+1]^num[i];
	}
	
	for(int i=1;i<=n;i++)
	{
		cout<<(pre[i-1]^lst[i+1])<<" ";
	}
	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 5940
S = input()
str_a = ""
str_b = ""
if (len(S) % 2 == 1) :
    str_a = S[0:len(S)//2]
    str_b = S[(len(S)//2) + 1 :][::-1]
else :
    str_a = S[0:len(S)//2]
    str_b = S[len(S)//2:][::-1]

diff = 0
for i in range(len(str_a)) :
    if (str_a[i] != str_b[i]) :
        diff += 1

print(diff)
    


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;
const int MOD = 1000000007;

int n,q;
std::vector<std::vector<int>> to;
std::vector<int> points;

void dfs(int node, int parent, int carryover){

    points[node] += carryover;

    for(int next_node : to[node]){

        if(next_node == parent) continue;

        dfs(next_node, node, points[node]);

    }
}

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

    cin >> n >> q;

    points = std::vector<int>(n,0);

    to = std::vector<std::vector<int>>(n, std::vector<int>(0));

    rep(i,n-1){
        int a,b; cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    rep(i,q){
        int p,x; cin >> p >> x; --p;
        points[p] += x;
    }

    dfs(0,-1,0);

    rep(i,n-1){
        cout << points[i] << " ";
    }
    cout << points[n-1] << endl;
    
    return 0;
}

Measured memory_bytes: 23552
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int x;
    cin>>x;
    while(1){
        for(int i=2; i<=x; i++){
            //cout << i << " " << x << endl;
            if(i == x){
                cout << x << endl;
                return 0;
            }
            if(x%i == 0) break;

        }x++;
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h() if m > 1 else typ(input()) for _ in range(n)]


def main():
    N, D = read_h()
    X = read_v(N, m=D)

    import numpy as np

    cnt = 0
    for i in range(0, N - 1):
        for j in range(i + 1, N):
            dist = np.sqrt(np.sum(np.power(np.asarray(X[i]) - np.asarray(X[j]), 2)))
            if dist - np.floor(dist) == 0.0:
                cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 12440
#include <iostream>
#include <map>
#include <vector>

using namespace std;

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

    vector<long long> a(n + 1, 0);
    map<int, int> cnt;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        a[i] += a[i - 1];
        cnt[a[i] % m]++;
    }

    long long res = 0;
    for (int i = 1; i <= n; i++) {
        res += cnt[a[i - 1] % m];
        cnt[a[i] % m]--;
    }

    cout << res << endl;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,num,ans;
  cin >> a >> b;
  num = a + b;
  if((num%2) == 1){
    ans = (num/2)+1;
  }else{
    ans = num/2;
  }
  cout << ans << endl;
}

    

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

int main() {
	long long nAns = 0;
	int N;
	cin >> N;
	map<int,int>B;//j -A[j] 
	map<int,int>C;//i +A[i]
	for (int n = 0;n<N;++n) {
		int m = 0;
		cin >> m;
		nAns += B[n + m] + C[n - m];
		++B[n - m];
		++C[n + m];
	}
	cout << nAns << endl;
	return 0;
}

Measured memory_bytes: 37616
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define MOD 1000000007
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

#define MAXN 305

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unordered_map<int,int> umii;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

ll gcd(ll a, ll b) {return b == 0 ? a : gcd(b, a % b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

int len,arr[MAXN],cnt[4];
bool vis[MAXN][MAXN][MAXN];
double dp[MAXN][MAXN][MAXN];

double solve(int s1, int s2, int s3){
    if(s1 == -1 || s2 == -1 || s3 == -1) return 0;
    if(s1 == 0 && s2 == 0 && s3 == 0) return 0;
    if(vis[s1][s2][s3]) return dp[s1][s2][s3];
    double res = 1;
    if(s1 > 0) res+=solve(s1-1,s2,s3)*s1/len;
    if(s2 > 0) res+=solve(s1+1,s2-1,s3)*s2/len;
    if(s3 > 0) res+=solve(s1,s2+1,s3-1)*s3/len;
    res = res/(1.0-(double)(len-s1-s2-s3)/len);
    vis[s1][s2][s3] = true;
    return dp[s1][s2][s3] = res;
}

int main(){
    scanf("%d",&len);
    for(int i=1; i<=len; i++){
        scanf(" %d",&arr[i]);
        cnt[arr[i]]++;
    }
    printf("%.9f\n",solve(cnt[1],cnt[2],cnt[3]));
}


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

int main(){
  int y, m, d;
  char c1, c2;
  cin >> y >> c1 >> m >> c2 >> d;
  if ( m <= 4 ) cout << "Heisei" << endl;
  else cout << "TBD" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
	long long int count =0,i;
	char s[200001],a[200001];
	cin>>s>>a;
	long long int l = strlen(s);
	for(i=0; i<l; i++)
	{
		if(s[i]!=a[i])
		{
			count++;
		}
	}	
	cout<<count;
return 0;	
}

Measured memory_bytes: 3980
#include "iostream"
#include "vector"
#include "array"
#include "string"
#include "algorithm"
#include<queue>

using namespace std;
#define rep(p,q) for(int i = p;i < q;i++)

//4

int main(void) {
	vector<string> board = vector<string>();
	int w, h = 0;
	cin >> h >> w;
	int panel_num = -1; //start 分
	rep(0, h) {
		string str = "";
		cin >> str;
		board.push_back(str);
		for (int j = 0; j < str.size(); j++) {
			if (str[j] == '.') panel_num++;
		}

	}
	const int INF = 1000000;
	typedef pair<int, int> P;
	int sx = 0, sy = 0;
	int gx = w - 1, gy = h - 1;
	int d[50][50];
	int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
	for (int i = 0; i < 50; i++) {
		for (int j = 0; j < 50; j++) {
			d[i][j] = INF;
		}
	}
	
	queue<P> que;
	que.push(P(sx, sy));
	que.push(P(sx, sy));
	d[sx][sy] = 0;

	while (!que.empty()) {
		P p = que.front(); que.pop();
		if (p.first == gx && p.second == gy) break;

		rep(0, 4) {
			int nx = p.first + dx[i], ny = p.second + dy[i];

			if (0 <= nx && nx < w && 0 <= ny && ny < h && board[ny][nx] != '#' && d[nx][ny] == INF) {
				que.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	if (d[gx][gy] == INF) cout << -1 << endl;
	else cout << panel_num - d[gx][gy] << endl;
}




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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back


using namespace std;

void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {std::cout << x;}
void __print(unsigned x) {std::cout << x;}
void __print(unsigned long x) {std::cout << x;}
void __print(unsigned long long x) {std::cout << x;}
void __print(float x) {std::cout << x;}
void __print(double x) {std::cout << x;}
void __print(long double x) {std::cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
template <typename T> inline void inp(T &any) {cin >> any;} template <typename T, typename... U>inline void inp(T &a, U &...b) {cin >> a; inp(b...);}
#define rin(args...) ll args; inp(args);
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#define matdeb(mat,row,col) cout << #mat << "::" << endl; printmat(mat,row,col); printpartition;
#define debugv(v,n) cout << #v << ":" << endl; printv(v,0,n-1); printpartition;
#else
#define debug(x...)
#define matdeb(mat,row,col)
#define debugv(v,n)
#endif

const int maxm = 1000000000 + 7;

const ll MOD = 1e9 + 7;
const int INF = 55;
ll dp [INF] [INF * INF];

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}


//----------->CODE BEGINS --------------->


int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    IOS;

    int n, k;

    cin >> n >> k;

    ll ans = 1;
    ans *= k;


   loop(i,n-1)
   {
      ans *= (k-1);
   }
    

    cout << ans << endl;



}


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

int A[1000000], n;

int binarysearch(int key){
    int left = 0;
    int right = n;
    int mid;
    while( left < right){
        mid = ( left + right ) / 2;
        if( key == A[mid] ) return 1;
        if( key < A[mid] ) right = mid;
        else if( key > A[mid] ) left = mid + 1;
    }
    return 0;
}

int main(){
    int i, q, key, sum = 0;
    
    cin >> n;
    for( i = 0; i < n; i++) cin >> A[i];
    
    cin >> q;
    for( i = 0; i < q; i++){
        cin >> key;
        if( binarysearch( key )) sum++;
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 3428
#include <bits/stdc++.h>
using namespace std;
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
#define pb push_back
#define mp make_pair
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
 
const int inf = int(1e9);
const int mod = 1e9 + 7;
const int N = 1e6 + 555;
const long double PI = acos(-1.0);
void solve()
{	
	int m, d;
	cin >> m >> d;
	int res = 0;
	for(int i = 1; i <= m; ++i){
		for(int j = 10; j <= d; ++j){
			if(j % 10 >= 2 && j / 10 >= 2 && (j % 10) * (j / 10) == i) res++;
		}
	}
	cout << res;
}
int main()
{
	Red;
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    string S; cin >> S;
    int ans=0;
    rep(i,(1<<(SZ(S)-1))){
        int pos=0;
        rep(j,SZ(S)-1){
            if((i>>j)&1){
                pos+=S[j]-'0';
                ans+=pos;
                pos=0;
            } else {
                pos+=S[j]-'0';
                pos*=10;
            }
        }
        ans+=pos;
        ans+=S[SZ(S)-1]-'0';
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def main():
    A,B,M = map(int,input().split())
    val_a = [int(i) for i in input().split()]
    val_b = [int(j) for j in input().split()]
    lucky = [map(int,input().split()) for _ in range(M)]
    min_a = min(val_a)
    min_b = min(val_b)
    ans = min_a + min_b
    for i in range(M):
        a,b,c = lucky[i]
        p = val_a[a-1] + val_b[b-1] - c
        if p < ans:
            ans = p
    #ansをpにしてました><
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 62324