akhauriyash/Code-Regression huggingface dataset:
#pragma region 宣言部分
#include <iostream>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 28;
const int MOD = 1e9+7;

#pragma endregion



int main(){
    int n,m,x;
    cin >> n >> m >> x;
    int c[n] = {0};
    int a[n][m];
    REP(i,n){
        cin >> c[i];
        REP(j,m){
            cin >> a[i][j];
        }
    }
    int up = (1 << n);
    ll costres = INF, Ares[m] = {0};
    REP(i,up){
        ll A[m] = {0};
        ll cost = 0;
        REP(j,n){
            int y = (i >> j) % 2;
            if(y == 1){
                cost += c[j];
                REP(k,m){
                    A[k] += a[j][k];
                }
            }
        }
        bool f = true;
        REP(j,m){
            if(A[j] < x)
                f = false;
        }
        if(f)
            costres = min(costres, cost);
    }
    if(costres != INF)
        cout << costres << endl;
    else
    {
        cout << -1 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
using namespace std;



int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a+b>=c) {
		cout << "Yes";
	}


	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
    
ll n,cnt,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ll dat[ohara];
ll ga[ohara];    

//-------------------------↓↓↓↓↓↓------------------------
    
//------ 自分を天才だと信じる ------
    
template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;
 
public:
  u64 a;
 
  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n>>k;
    using mint=modint<MOD>;
    mint ans=0;
    rep(i,n)cin>>a[i];
    rep(i,n){
        rrep(j,i+1,n){
            if(a[i]>a[j])(ga[i]+=1)%=MOD;
        }
    }
    rep(i,n)(dat[a[i]]+=1)%=MOD;
    rrep(i,1,3001){
        (dat[i]+=dat[i-1])%=MOD;
    }
    rep(i,n){
        mint nn=k;
        mint aa=ga[i];
        mint dd=dat[a[i]-1];
        (ans+=(nn*(mint(2)*aa+(nn-mint(1))*dd))/mint(2));
    }
    Cout(ans.value());
    return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <cstdlib>
#include <sstream>
#include <algorithm>
using namespace std;

string its(int n){
    stringstream s;
    s << n;
    
    return s.str();
}

int main(){
    string str;
    int n;
    
    cin >> n;
    while(n--){
        int cnt = 0;
        cin >> str;
        int len = str.size();
        
        while(len > 1){
            cnt++;
            int MAX = 0;
            for(int i = 0 ; i < len-1; i++){
                int a = atoi(str.substr(0,i+1).c_str());
                int b = atoi(str.substr(i+1,len-1).c_str());
                MAX = max(MAX,a*b);
            }
            str = "";
            str += its(MAX);
            len = str.size();
        }
        cout << cnt << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,j,k;
    map<long long int , long long int>mp;
    map<long long int , long long int>:: iterator it;
    cin>>n;
    for(i=1;i<=n-1;i++)
    {
        cin>>j;
        mp[j]++;
    }
    for(i=1;i<=n;i++)
    {
        cout<<mp[i]<<endl;
    }
}


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

typedef long long int llint;

int main()
{
  int n;
  cin>> n; 
  
  int x[200003];
  int s[200003];
  for(int i = 1; i <= n; i++) {
    cin>> x[i];
    s[i] = x[i];
  }

  sort(&s[1], &s[1] + n);
  int one = s[n / 2];
  int two = s[n / 2 + 1];

  for(int i = 1; i <= n; i++) {
    if(x[i] <= one) cout<< two <<endl;
    else            cout<< one <<endl;
  }
  

  return 0;
}

// 2 3 4 4


Measured memory_bytes: 3712
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N,K; cin >> N >> K;
    vector<ll> X(N);
    for(int i = 0; i < K;i++){
        ll d; cin >> d;
        for(int j = 0; j < d;j++){
            ll a; cin >> a;
            X[a-1]++;
        }
    }
    res = count(X.begin(),X.end(),0);
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int SIZE=3*100000;
typedef pair<int,int>P;
int N,a[SIZE],b[SIZE];

bool C(int x){
    priority_queue<int>que;
    int sum=0;
    for(int i=0;i<x-1;i++){
        que.push(a[i]);
        sum+=a[i];
    }

    for(int i=x-1;i<N;i++){
        que.push(a[i]);
        sum+=a[i];
        if(sum<=x*b[i])return true;
        sum-=que.top();
        que.pop();
    }
    return false;
}

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

    cin>>N;
    for(int i=0;i<N;i++)cin>>a[i]>>b[i];

    vector<P>st;
    for(int i=0;i<N;i++)st.push_back(P(b[i],a[i]));
    sort(st.rbegin(),st.rend());
    for(int i=0;i<N;i++){
        a[i]=st[i].second;
        b[i]=st[i].first;
    }


    int lb=0,ub=N+1;

    while(ub-lb>1){
        int mid=(lb+ub)/2;
        if(C(mid))lb=mid;
        else ub=mid;
    }

    cout<<lb<<endl;
    return 0;
}

Measured memory_bytes: 20020
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class D {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            String S = in.next();

            boolean[][] dp = new boolean[3][1000];
            for (int i = 0; i < N; i++) {
                int c = S.charAt(i) - '0';
                if (i > 1) {
                    for (int j = 0; j < 100; j++) {
                        dp[2][j * 10 + c] |= dp[1][j];
                    }
                }
                if (i > 0) {
                    for (int j = 0; j < 10; j++) {
                        dp[1][j * 10 + c] |= dp[0][j];
                    }
                }
                dp[0][c] = true;
            }
            int cnt = 0;
            for (int i = 0; i < 1000; i++) {
                if (dp[2][i]) {
                    cnt++;
                }
            }
            out.println(cnt);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 24236
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long A, long long B, long long C){
    ll ans = INF;

    ans = min(ans, abs((A-A/2)-A/2)*B*C);
    for(ll i=1; i < B; i++){
        ans = min(ans, abs((B-B/2)-B/2)*A*C);
    }
    for(ll i=1; i < C; i++){
        ans = min(ans, abs((C-C/2)-C/2)*A*B);
    }
    cout << ans << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


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

int main() {
	long long N,W;cin>>N>>W;
	long long dp[N][W+1];
     long long w[N],v[N];
     for(int i=0;i<N;i++)
       cin>>w[i]>>v[i];
     
     for(int j=0;j<=W;j++)
     {
     	if(j<w[0]){dp[0][j]=0;}
     	else dp[0][j]=v[0];
     }
     for(int i=1;i<N;i++)
     {
     	for(int j=0;j<=W;j++)
     	{
     		if(j-w[i]<0)
     		{dp[i][j]=dp[i-1][j];}
     		else 
     		{dp[i][j]=max(dp[i-1][j-w[i]]+v[i],dp[i-1][j]);}
     	}
     }cout<<dp[N-1][W]<<endl;
     
     return 0;
}

Measured memory_bytes: 78336
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

using Graph = vector<vector<ll>>;

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

#define MAX_N 2010

const long long INF = 1LL << 60;

//境界値に注意！！！

ll some(ll n){
    ll i=1,x=0;
    while(i<n*10){
        x+=max(n/i-(n/(i*10))*10,0LL);
        i*=10;
    }
    return x;
}

int main() {
    ll n,a,b,ans=0;
    cin >> n >> a >> b;
    for (ll i=1;i<=n;i++){
        ll x=some(i);
        if (x>=a && x<=b)ans+=i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define INF 1000000001
int N;
unsigned long long int counter=0;
int merge(long long int array[520000],int left ,int middle,int right){
        int N1=middle-left;
        int N2=right-middle;
        long long int l[300000],r[300000];
        for(int i=0 ; i<N1 ; i++ )
                l[i]=array[left+i];
        for(int i=0 ; i<N2 ; i++ )
                r[i]=array[middle+i];
        l[N1]=INF;r[N2]=INF;
        int i=0,j=0;
        for(int k=left ; k<right ; k++ ){
                counter++;
                if(l[i]<=r[j]){
                        array[k]=l[i];
                        i++;
                }else{
                        array[k]=r[j];
                        j++;
                }
        }
}
int mergesort(long long int array[520000],int left ,int right){
        if(left+1<right){
                int middle=(left+right)/2;
                mergesort(array,left,middle);
                mergesort(array,middle,right);
                merge(array,left,middle,right);
        }
        return true;
}
int main(){
        cin >> N;
        long long int array[520000];
        for(int i=0 ; i<N ; i++ )
                cin >> array[i];
        mergesort(array,0,N);
        for(int i=0 ; i<N ; i++ ){
                cout << array[i];
                if(i<N-1)
                        cout<<" ";
        }
        cout << endl<<counter<<endl;
        return 0;
}

Measured memory_bytes: 10844
#include <iostream>
#include <vector>
#include <climits>

using namespace std;

int main()
{
    int n, t, a, h, ans, bst = INT_MAX;
    cin >> n;
    cin >> t >> a;
    vector<int> av(n);
    for (int i = 0; i < n; ++i) {
        cin >> h;
        av[i] = (t * 1000 - h * 6) - a * 1000;
        if (av[i] < 0) av[i] = -av[i];
        if (bst >  av[i]) {
            bst =  av[i];
            ans = i+1;
        }
    }
    cout << ans << endl;

    return 0;
}

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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    int a,b,n,m;
    cin >> a >> b >> n >> m;
    double kakudo=min(abs(((n%12)*30.0)+(m*0.5)-(m*6.0)),360-abs(((n%12)*30.0)+(m*0.5)-(m*6.0)));
    //cout << kakudo << endl;
    double pi=acos(-1);
    double ans=a*a+b*b-2*a*b*cos(kakudo*(pi/180));
    ans=sqrt(ans);
    printf("%.12f",ans);

    return 0;
}











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

int n, m, ans, x;
string s[100], t[100];
int main() {
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>s[i];
    cin>>m;
    for(int i=0; i<m; i++)
        cin>>t[i];
    ans = 0;
    for(int i=0; i<n; i++){
        x = 0;
        for(int j=0; j<n; j++)
            if(s[j]==s[i])
                x++;
        for(int j=0; j<m; j++)
            if(t[j]==s[i])
                x--;
        ans = max(ans, x);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import           Data.List -- sort
import           Control.Monad -- replicateM

readInt = read <$> getLine :: IO Integer
arrayInt = map read . words <$> getLine :: IO [Integer]
writeln x = putStrLn $ unwords x :: IO ()

main = do
    n <- readInt
    a <- arrayInt
    let l = scanl' gcd 0 a
    let r = scanr gcd 0 a

    print $ maximum $ zipWith gcd l (tail r)


Measured memory_bytes: 63612
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define inf 1000000005
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))
#define mod 1000000007
#define sz(a) ((int)(a).size())

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcount(s);}
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define eps 1e-12
typedef pair<int, int> II;
typedef pair<ll, ll> LL;
template<class T> T gcd(T a, T b){ T r; while (b != 0) { r = a % b; a = b; b = r; } return a;}
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define PI (2 * acos(0))
#define linf (1ll << 60)

#define maxn 100005

int n;
int cal(vector<int> V){
	bool khac1 = 0;
	Rep(i, sz(V)) if(V[i] != 1){
		khac1 = 1;
		break;
	}
	if(!khac1) return 0;

//	Rep(i, sz(V)) cout << V[i] << " "; cout << endl;
	int numodd = 0, sum = 0, have1 = 0;;
	int d = 0;
	Rep(i, sz(V)){
		sum += 1 - (V[i] & 1);
		if(V[i] == 1) have1 = 1;
		if(V[i] & 1) {
			numodd++;
			d = gcd(d, V[i] - 1);
		} else d = gcd(d, V[i]);
	}

	if(sum & 1) return 1;
	if(numodd != 1) return 0;
	if(have1) return 0;
	vector<int> A;
	Rep(i, sz(V)){
		if(V[i] & 1) {
			A.pb((V[i] - 1) / d);
		} else A.pb(V[i] / d);
	}
	return 1 - cal(A);
}

int main(){

//	freopen("in.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    vector<int> V;
    cin >> n;
    Rep(i, n){
    	int x;
    	cin >> x;
    	V.pb(x);
    }
    if(cal(V)){
    	cout << "First" << endl;
    } else cout << "Second" << endl;

    return 0;
}


Measured memory_bytes: 19192
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    s = list(input())
    t = list(input())
    s.sort()
    t.sort(reverse=True)
    ss = "".join(s)
    st = "".join(t)
    if ss < st:
        print("Yes")
    else:
        print("No")


    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 9428
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s,t="";
  	cin >> s;
  	for(int i=0;i<s.size();i++){
  		if(s[i]=='0'||s[i]=='1'){
  			t+=s[i];
  		}else if(s[i]=='B'){
  			t=t.substr(0,t.size()-1);
  		}  		
  	}
  	cout << t << endl;
  	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
	int X,b,sum=0;
	cin>>X;
	for(int i =1; ;i++){
	b=sum;
	sum+=i;
	if(X<=sum && b<=X){
	cout<<i;
	break;
	}
		
	}
}

Measured memory_bytes: 256
let m = 1000000007
let ( *^ ) x y = x * y mod m

let () = Scanf.scanf "%d\n%s\n%s\n" @@ fun n s1 s2 ->
  Array.init (n - 1) (( + ) 1)
  |> Array.fold_left (fun acc i ->
      if s1.[i] = s2.[i] then
        if s1.[i - 1] = s2.[i - 1] then 2 *^ acc
        else acc
      else
        if s1.[i - 1] = s1.[i] then acc
        else if s1.[i - 1] = s2.[i - 1] then 2 *^ acc
        else 3 *^ acc) (if s1.[0] = s2.[0] then 3 else 6)
  |> Printf.printf "%d\n"

Measured memory_bytes: 2432
n = int(input())
p = [int(i) for i in input().split()]
a = list(range(1,n+1))
dif = 0
for i in range(n):
    if p[i] != a[i]:
        dif += 1
if dif == 0 or dif == 2:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 38256
import java.util.Scanner;

public class Main {
	public static void main(String arg[]) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();

		String S = sc.next();
		char[] ch = new char[N];

		for (int i = 0; i < N; i++) {
			ch[i] = S.charAt(i);

			if (i == K - 1) {
				if (ch[i] == 'A') {
					ch[i] = 'a';
				} else if (ch[i] == 'B') {
					ch[i] = 'b';
				} else if (ch[i] == 'C') {
					ch[i] = 'c';
				}
			}
		}

		for (int i = 0; i < N; i++) {
			System.out.print(ch[i]);
		}

	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
  int N; cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }

  double ans=0.0;
  for(int i=0;i<N;i++){
    ans+=1.0/a[i];
  }
  cout<<1.0/ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main()
{
	int a, b, c;
	int i;
	int counter = 0; 
	scanf("%d %d %d", &a, &b, &c);
	for (i = a; i < b + 1; ++i) {
		if (c % i == 0) {
			counter++;
		}
	}
	printf("%d\n", counter);
	return 0;
}

Measured memory_bytes: 596
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var digit = GetDigit(N);
            var ans = 0;
            for (int i = 1; i < digit; i++)
            {
                if (i % 2 != 0)
                {
                    ans += 9 * (int)Pow(10, i - 1);
                }
            }
            if (digit % 2 != 0)
            {
                ans += N - (int)Pow(10, digit - 1) + 1;
            }
            Console.WriteLine(ans);
        }

        static int GetDigit(int n)
        {
            if (n < 10)
            {
                return 1;
            }
            else
            {
                return 1 + GetDigit(n / 10);
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 13268
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }




void main() {
  /*
  debug {
    enum lim = 21;
    for (int m = 1; m <= lim; m = m * 2 + 1) for (int n = 1; m * n <= lim; n = n * 2 + 1) {
      int mx = -1;
      int[] pms;
      foreach (p; 0 .. 1 << (m * n)) {
        auto sum = new int[][](m + 1, n + 1);
        foreach (x; 0 .. m) foreach (y; 0 .. n) {
          sum[x + 1][y + 1] = sum[x + 1][y] + sum[x][y + 1] - sum[x][y] + ((p >> (x * n + y)) & 1);
        }
        int cnt;
        foreach (xa; 0 .. m) foreach (xb; xa + 1 .. m + 1) foreach (ya; 0 .. n) foreach (yb; ya + 1 .. n + 1) {
          if ((sum[xa][ya] - sum[xa][yb] - sum[xb][ya] + sum[xb][yb]) & 1) {
            ++cnt;
          }
        }
        if (chmax(mx, cnt)) {
          pms = [];
        }
        if (mx == cnt) {
          pms ~= p;
        }
      }
      writeln(m, " ", n, ": ", mx, " ", pms.length);
      {
        const p = pms[0];
        foreach (x; 0 .. m) {
          foreach (y; 0 .. n) {
            write((p >> (x * n + y)) & 1);
          }
          writeln();
        }
      }
      stdout.flush;
    }
  }
  //*/
  
  try {
    for (; ; ) {
      const A = readInt();
      const B = readInt();
      foreach (x; 1 .. 2^^A) {
        foreach (y; 1 .. 2^^B) {
          write((bsf(x) + bsf(y) == max(A, B) - 1) ? 1 : 0);
        }
        writeln();
      }
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 1276
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define  DESC std::greater<int>() //sort 3rd arg



int main()
{
	ll n;

	cin >> n;
	vector<long double> v;
	long double res = 0;

	const long double lim = (long double)pow(10, 18);



	REP(i, n) {
		long double tmp;
		cin >> tmp;
		if (tmp > lim) {
			cout << -1 << endl;
			return 0;
		}
		v.push_back(tmp);
	}

	sort(v.begin(), v.end());

	res = v[0];
	for (int i = 1; i < n; i++) {
		res *= v[i];
		if (res > lim) {
			cout << -1 << endl;
			return 0;
		}
	}



	//res = pow(10, 18)+2;

	if (res > lim) {
		cout << -1 << endl;

	}
	else {
		cout << (ll)res << endl;
	}



	return 0;
}



Measured memory_bytes: 5440
function main()
  
  X, N = map(x -> parse(Int, x), split(readline()))
  p = map(x -> parse(Int, x), split(readline()))
  
  ans = Dict()
  check = [X, X]
  
  while length(keys(ans)) < 1
    if in(check[1], p)
      check[1] += 1
    else
      ans[abs(check[1] - X)] = check[1]
    end
    if in(check[2], p)
      check[2] -= 1
    else
      ans[abs(check[2] - X)] = check[2]
    end
  end
  
  println(ans[minimum(keys(ans))])
  
end

main()

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

string s;

int a = 1e5, z = 1e9;

int main() {
	ios_base::sync_with_stdio(0);

	getline(cin,s);


	for (int i = 0; i < s.size(); ++i)
		if (s[i] == 'A') {
			a = i;
			break;
		}

	for (int i =  s.size()-1; i >= 0; --i) 
		if (s[i] == 'Z') {
			z = i;
			break;
		}

	if (z < a) {
		cout << "0\n";
		return 0;
	}

	cout << z-a+1 << '\n';

	return 0;
}


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

using namespace std;

#define MAXN 1005
#define INF 1000000000000000LL
#define MOD 1000000007
#define pb push_back

typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> vi;

int n, m;
ll dp[MAXN][MAXN];
int mapa[MAXN][MAXN];

ll mod(ll x){
	if(x >= 0) return x % MOD;
	else if(-x < MOD) return MOD + x;
	return mod(x % MOD);
}

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

	cin >> n >> m;

	char aux;

	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			cin >> aux;
			if(aux == '.') mapa[i][j] = 0;
			else mapa[i][j] = 1;
		}
	}

	dp[0][1] = 1LL;

	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			if(!mapa[i][j]){
				dp[i][j] = mod(dp[i - 1][j] + dp[i][j - 1]);
			}
		}
	}

	cout << dp[n][m] << endl;

	return 0;
}

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

int g[101],p[101],c;
int dp[100001];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        cin>>p[i]>>g[i];
    for(int i=1; i<=100000; i++)
        dp[i]=1100000000;
    for(int i=1; i<=n; i++)
        for(int j=100000; j>=g[i]; j--){
            dp[j]=min(dp[j],dp[j-g[i]]+p[i]);
            //dp[j]=min(dp[j],m+1);
        }

    for(int j = 100000; j >= 0; j--)
        if(dp[j] <= m){
            cout << j;
            return 0;
        }

    return 0;
}


Measured memory_bytes: 640
can = [0]
gets
a = gets.split.map(&:to_i)
gets
m = gets.split.map(&:to_i)
a.each_with_index {|e,i|
  if i == 0
    can << e
  else
    can = Marshal.load(Marshal.dump(can + can.map {|ele| ele + e}))
  end
}
m.each{|e|
  if can.include?(e)
    puts 'yes'
  else
    puts 'no'
  end
}

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define long long long
#define db double
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template <class T> inline void chmin(T &a, const T& val) { if (a > val) a = val; }
template <class T> inline void chmax(T &a, const T& val) { if (a < val) a = val; }
template <class T> long sqr(T a) { return 1ll * a * a; }
template <class T> void compress(T &a){
  sort(all(a)); a.resize(unique(all(a)) - a.begin());  
}

const db pi = acos(-1.00);
const db eps = 1e-6;
const int INF = 1e9;
const int MOD = 1e9+7;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};

db Get(db x){
  return x * pi * 2;
}

int main()
{
  fastio;
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  db x = Get(1.00 * h / 12 + (1.00 / 12) * (1.00 * m / 60));
  db y = Get(1.00 * m / 60);
  db ang = abs(x - y);
  cout << fixed << setprecision(10);
  cout << sqrt(1.00 * sqr(a) + sqr(b) - 2.00 * a * b * cos(ang));
  return 0;
}


Measured memory_bytes: 4196
#include <stdio.h>

int main (void)

{
	int a;
	int b;
	scanf("%d%d\n",&a,&b);
	if(a<b){
		printf("a < b\n");
	}else if(a>b){
		printf("a > b\n");
	}else if (a==b){
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 584
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int A, B;
  while (cin >> A >> B) {
    int H = 100, W = 100;
    string color = ".#";
    if (A > B) {
      swap(color[0], color[1]);
      swap(A, B);
    }
    --A;
    vector<string> ans(H, string(W, color[0]));
    for (int i = 0; i < H / 4; i++) {
      for (int j = 0; j < W / 4; j++) {
        int y = i * 4, x = j * 4;
        if (B > 0) {
          ans[y + 1][x] = color[1];
          --B;
        }
        if (A > 0) {
          for (int dy = 0; dy < 3; dy++) {
            for (int dx = 0; dx < 3; dx++) {
              if (dy == 1 && dx == 1) {
                continue;
              }
              ans[y + dy][x + dx] = color[1];
            }
          }
          --A;
        }
      }
    }
    cout << H << " " << W << endl;
    for (auto line : ans) {
      cout << line << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
template<typename T, typename V = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, V, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>; // find_by_order(), order_of_key()
using ll = long long int;
using i64 = long long int;
#define SZ(v) (int((v).size()))
#define ALL(vec) (vec).begin(),(vec).end()
template <typename T> inline void ckmax(T &x, T y) {if (y > x) x = y; }
template <typename T> inline void ckmin(T &x, T y) {if (y < x) x = y; }

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " =: " << a << endl;
    err(++it, args...);
}
template <typename T1, typename T2>
inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& buf) {
    return os << "(" << buf.first << ": " << buf.second << ")";
}
template<typename T>
inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v) {
    bool first = true;
    os << "[";
    for(unsigned int i = 0; i < v.size(); i++) {
        if(!first) os << ", ";
        os << v[i];
        first = false;
    }
    return os << "]";
}
template<typename T>
inline std::ostream &operator << (std::ostream & os,const set<T>& v) {
    bool first = true;
    os << "{";
    for (auto ii = v.begin(); ii != v.end(); ++ii) {
        if(!first) os << ", ";
        os << *ii;
        first = false;
    }
    return os << "}";
}
inline std::ostream &operator << (std::ostream & os,const std::multiset<pair<int,int>,greater<pair<int,int>>>& v) {
    bool first = true;
    os << "{";
    for (auto x: v) {
        if(!first) os << ", ";
        os << x;
        first = false;
    }
    return os << "}";
}
template<typename T1, typename T2>
inline std::ostream &operator << (std::ostream & os,const std::map<T1, T2>& v) {
    bool first = true;
    os << "{";
    for (typename std::map<T1, T2>::const_iterator ii = v.begin(); ii != v.end(); ++ii) {
        if(!first) os << ", ";
        os << *ii ;
        first = false;
        return os << "}";
    }
}
template<typename T>
inline std::ostream &operator << (std::ostream & os,const vector<vector<T>>& v) {
    for (auto &u: v) os << '\n' << u;
    return os;
}
template<typename T>
void finish(T ans) {cout << ans << '\n'; exit(0);}
const int MOD = 1e9 + 7;
const long long INF = 1e18;
const double EPS = 1e-6;
#define PI 3.14159265358979323846
/***********************************************************************/

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    vector<int> a(n);
    for (int &e: a) cin >> e;
    sort(ALL(a));
    int sum = accumulate(ALL(a), 0);
    bool ok = sum - a.back() > a.back();
    cout << (ok ? "Yes\n" : "No\n");
    
    return 0;
}


Measured memory_bytes: 256
//****author RKN
//DATE 5/2/2020 5.15 AM
 
 
// ***************DREAM IS NOT THAT YOU SEE WHILE SLEEPING BUT IT IS WHAT DONT LET YOU SLEEP************//
 
 
///////////////////////    machayenge......sala hoga apne se bhi ek din    ///////////////////////////////////////////////////////////

#include<bits/stdc++.h>
using namespace std;
 
/////////////////////////////   %   variable  %   //////////////////////////////////////////////////////////////
 
#define ll long long
#define pb push_back 
#define f1 first
#define s2 second
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pr pair<ll,ll>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
int dir1[8]={1,0,0,-1,-1,1,-1,1};
int dir2[8]={0,-1,1,0,-1,1,1,-1};
#define en "\n"

ll MAX=1e9+7;

////////////////////////////////////////////////////////////////////////////////////////////
int n;
int ans[100001][3];
int arr[100001][3];
ll go(int j,int lev)
{
  //  cout<<lev<<" "<<j<<en;
    if(lev>=n)
    return 0;
    if(lev==n-1){
    ans[lev][j]=arr[lev][j];
    //cout<<lev<<" "<<j<<" "<<"val"<<" "<<ans[lev][j]<<en;
    return ans[lev][j];
    }
    if(ans[lev][j])
    {
    //cout<<lev<<" "<<j<<" "<<"val"<<" "<<ans[lev][j]<<en;
    return ans[lev][j];
    }
    ll val=0;
    for(int i=0;i<3;i++)
    {
        if(i!=j)
        val=max(val,go(i,lev+1));
    }
    ans[lev][j]+=(val+arr[lev][j]);
    //cout<<lev<<" "<<j<<" "<<val<<" "<<ans[lev][j]<<en;
    return ans[lev][j];
}

int main()
{
 fast;
 int a,b,c;
 cin>>n;
 for(int i=0;i<n;i++)
 {
     cin>>a>>b>>c;
     arr[i][0]=a;
     arr[i][1]=b;
     arr[i][2]=c;
 }
 ll ans=max({go(0,0),go(1,0),go(2,0)});
 cout<<ans;
    return 0;
}


Measured memory_bytes: 8832
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String str = s.next();
        StringBuilder sb = new StringBuilder(str);
        sb.setCharAt(3, '8');
        str = sb.toString();
        System.out.println(str);
    }
}


Measured memory_bytes: 21588
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int hp, n, w;
  cin >> hp >> n;
  for(int i=0; i<n; i++) {
    cin >> w;
    hp -= w;
  }
  if (hp <= 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

int main() {
	char a, b;
	cin >> a >> b;
	if ((a == 'H' && b == 'H') || (a == 'D' && b == 'D')) {
		cout << 'H';
	} else {
		cout << 'D';
	}
	return 0;
}

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

int main() {
  int A,B,C;
  cin>>A>>B>>C;
  if(A<C&&C<B){
    cout<<"Yes"<< endl;
  }
  if(B<C&&C<A){
    cout<<"Yes"<< endl;
  }
  if(C<A&&C<B){
    cout<<"No"<< endl;
  }
  if(A<C&&B<C){
    cout<<"No"<< endl;
  }
  
}


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

typedef long long int ll;
#define loop(i,s,e) for(ll i=s;i<e;i++)
#define test ll x;cin>>x;while(x--)
#define pb push_back
#define vec vector<ll>
#define sortvec(x) sort(x.begin(),x.end())
#define sz(x) x.size()

int main () {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll a[n];
    ll sum=0;
    loop(i,0,n)
    {
    	cin>>a[i];
    	sum+=a[i];
    }

    ll red=0,pos;
    loop(i,0,n-1)
    {
    	if (a[i]+a[i+1]>=k)
    	{
    		pos=i+1;
    		red=1;
    		break;
    	}
    }
    if (red==0)
    	cout<<"Impossible\n";
    else
    {
    	cout<<"Possible\n";
    	loop(i,1,pos)
   			cout<<i<<"\n";

    	for(ll i=n-1;i>pos;i--)
    		cout<<i<<"\n";
    	
    	cout<<pos<<"\n";
    }

}


Measured memory_bytes: 4328
A, B, C, D = gets.chomp.split.map(&:to_i)

def gcd(a, b)
  a, b = b, a if a < b
  return a if b == 0
  _mod = a.modulo(b)
  if _mod == 0
    b
  else
    gcd(b, _mod)
  end
end

def lcm(a, b)
  a * b / gcd(a, b)
end


# A以下のCの約数の個数
A_1 = A - 1

a_c_cnt = A_1/C
a_d_cnt = A_1/D
a_cd_cnt = A_1/lcm(C,D)

a_cnt = A_1 - a_c_cnt - a_d_cnt + a_cd_cnt

b_c_cnt = B/C
b_d_cnt = B/D
b_cd_cnt = B/lcm(C,D)

b_cnt = B - b_c_cnt - b_d_cnt + b_cd_cnt


p b_cnt - a_cnt


Measured memory_bytes: 1788
package main

import "fmt"

func main() {
        var n int
        fmt.Scanf("%d", &n)
        fmt.Printf("%d\n", numOfOddDigitNum(n))
}

func numOfOddDigitNum(n int) (count int) {
        for i := 1; i <= n; i++ {
                if digit(i)%2 == 1 {
                        count++
                }
        }
        return count
}
func digit(n int) int {
        if n == 0 {
                return 0
        }
        digit := 0
        for i := 1; i <= n; i *= 10 {
                digit++
        }
        return digit
}

Measured memory_bytes: 512
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n = readline() |> parseInt
	d = readline() |> split |> parseMap
	m = readline() |> parseInt
	t = readline() |> split |> parseMap
	d = sort(d)
	t = sort(t)
	l = 1
	r = 1
	while l <= n && r <= m
		if d[l] == t[r]
			l += 1
			r += 1
		elseif d[l] < t[r]
			l += 1
		else
			break
		end
	end
	println(r>m?"YES":"NO")
end

main()


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

int main() {
	int N;
	cin >> N;
	int L[N];
	for (int i = 0; i < N; i++) {
		cin >> L[i];
	}

	int max = 0;
	for (int i = 0; i < N; i++) {
		if (L[i] >= max) {
			max = L[i];
		}
	}
	int ans = 0;	int a = 0;
	for (int i = 0; i < N; i++) {
		if (a == 0) {
			if (L[i] != max) {
				ans += L[i];
			}
			else {
				a += 1;
			}
		}
		else {
			ans += L[i];

		}
	}
	if (max < ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int n, d, i, j, x, a[100], s;

  scanf("%d %d %d",&n,&d,&x);
  for(i=0;i<n;i++){
   scanf("%d",&a[i]);
  }

  s = 0;

  for(i=0;i<n;i++){
    for(j=1;j<=d;j=j+a[i]) s++;
  }

  printf("%d",x+s);
  return 0;

}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    list<int> l;
    bool flgpush = true;
    bool flgreverse = true;

    int a;
    for(int in=0;in<n;in++) {
        cin >> a;
        
        if(flgpush) {
            l.push_front(a);
        }
        else {
            l.push_back(a);
        }

        flgpush = !flgpush;
        flgreverse = !flgreverse;
    }

    if(flgreverse) l.reverse();
    for(auto itr=l.begin();itr!=l.end();itr++) {
        cout << *itr << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 9860
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split(" ");
	
	//文字列から10進数に変換するときはparseIntを使います
	var n = parseInt(input[0], 10);
    var r = parseInt(input[1], 10);
    
    if(n>=10){
        //出力
	    console.log('%d',r);
    }else{
        var r2 = r+100*(10-n);
        //出力
	    console.log('%d',r2);
    }
	
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string S;
  cin >> S;
  bool isExist = false;
  for (int i = 1; i < 3; i++)
    if (S[i - 1] != S[i])
      isExist = true;
  if (isExist)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include <random>
#define ll long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s;
    cin>>s;
    if(s.substr(0,4)=="YAKI") cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
from sys import stdin
#, setrecursionlimit, stdout
#setrecursionlimit(1000000)
#from collections import deque
#from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin
#from heapq import heapify, heappop, heappush, heappushpop, heapreplace
def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return list(mi())
def si(): return stdin.readline().rstrip()
def lsi(): return list(si())
#mod=1000000007
res=['NET', 'DA']
############# CODE STARTS HERE #############


test_case=1
while test_case:
    test_case-=1


    a=lsi()
    b=lsi()
    c=0
    for i in range(len(a)):
        if a[i]!=b[i]:
            c+=1
    print(c)

Measured memory_bytes: 76628
#include <iostream>

int main(void){
  int a, b, c, d;
  std::cin >> a >> b >> c >> d;
  if(a + b > c + d) std::cout << "Left" << std::endl;
  else if(a + b < c + d) std::cout << "Right" << std::endl;
  else std::cout << "Balanced" << std::endl;
  return 0;
}

Measured memory_bytes: 3604