akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<vector<int>> a(2, vector<int>(n));
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	int sum = a[0][0];
	for (int i = 0; i < n; i++) {
		sum += a[1][i];
	}
	int max = sum;
	for (int i = 1; i < n; i++) {
		sum -= a[1][i - 1];
		sum += a[0][i];
		if (max < sum) {
			max = sum;
		}
	}
	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

ans = 0
sum = [0 for i in range(n+1)]

for i in range(1, n+1):
    sum[i] = sum[i-1] + a[i-1]

count = Counter(sum)

for values in count.values():
    if values >= 2:
        ans += values * (values-1) // 2

print(ans)

Measured memory_bytes: 41760
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class162
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var P = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int min = P[0];
            int count = 0;
            for(int i = 0; i < N; i++)
            {
                if (min >= P[i])
                {
                    count++;
                    min = P[i];
                }
            }
            Console.WriteLine(count);
        }
    }
}


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

using namespace std;

int main() {
	double a, b;
	cin >> a >> b;
	// O(1)
	int x1_low = (a * 100 + 7) / 8;
	int x1_high = ((a+1) * 100 + 7) / 8 - 1;
	int x2_low = (b * 100 + 9) / 10;
	int x2_high = ((b+1) * 100 + 9) / 10 - 1;
	int ans = max(x1_low, x2_low);
	if (ans > min(x1_high, x2_high))
		cout << -1 << endl;
	else
		cout << ans << endl;
	return 0;
}

Measured memory_bytes: 888
// Ninjo ~ khaledalam.net@gmail.com
#include <bits/stdc++.h>
using namespace std;
#define sz(A)      (int)(A).size()
#define all(B)     (B).begin(),(B).end()
#define file       freopen("input.txt", "r", stdin)
#define ios        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main() {
	//file;
	int n, m;
	cin >> n >> m;
	string s[n];
	for (int i = 0; i < n; ++i) {
		cin>>s[i];
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < 2; ++j) {
			cout << s[i] << endl;
		}
	}
}


Measured memory_bytes: 256
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut iter = buf.split_whitespace();
	let mut sum = 0;
	for n in 0..3 {
		let i:i32 = match iter.next().unwrap().parse() {
			Ok(k) => k,
			_ => panic!(""),
		};
		sum = sum + i;
	}
	if sum >= 22 {
		println!("bust");
	}else{
		println!("win");
	}
}

Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> K >> N;
    if (500 * K >= N) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import re  # 正規表現, findall('正規表現', 文字列), search('正規表現', 文字列)
import sys # プログラム終了：sys.exit()
# sys.setrecursionlimit(10**6) # 再帰呼び出しの上限を上げる

def i_input(): return int(input())
def s_input(): return map(int,input().split())
def l_input(): return list(map(int, input().split()))
# 文字列のまま受け取りたいときはinput()

n = i_input()
current_a_list = l_input()
count = 0

while 1:
    # print(current_a_list)
    new_a_list = []
    for a in current_a_list:
        if a % 2 == 0:
            new_a_list.append(a // 2)
        else:
            print(count)
            sys.exit()

    count += 1
    current_a_list = new_a_list
    

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<queue>
#include<set>
#include<stdio.h>
#include<iomanip>
#include<algorithm>
#include<map>
#include<math.h>
#include<string.h>
#define ll long long
#define eb emplace_back
#define pb push_back
#define ins insert 
#define mp make_pair
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define M 1e9+7
#define inf 1000000000000000000
using namespace std;
ll sum(ll*a, ll ind1,ll ind2){
    ll ans=0;
    if(ind1>ind2){
        ll temp=ind2;
        ind2=ind1;
        ind1=temp;
    }
    for (int i = ind1; i <= ind2; ++i)
    {
        ans+=a[i];
    }
    return ans;
}
void solve(){
    ll n;
    cin>>n;
    ll a[n];
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
    }
    ll dp[n][n];// min val when starting from i and ending on j
    for (int i = n-1; i >=0; --i)
    {
        for (int j = i; j <n; ++j)
        {
            dp[i][j]=inf;
            if(i==j){
                dp[i][j]=0;
            }
            else{
                ll s=sum(a,i,j);
                for (int k = i; k<=j; ++k)
                {
                    dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+s);
                }
            }
        }
    }
    cout<<dp[0][n-1]<<endl;
    
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1,t1=1;
    //cin>>t;
    while(t--){
        //cout<<"Case #"<<t1++<<": ";        
        solve();
    }
    return 0 ;
}

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

typedef long long ll;
typedef long double ld;

int niz[1000005];
vector <int> vec;
multiset <int> treba;

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

    int n;
    cin >> n;
    n = (1<<n);
    for(int i=1; i<=n; i++) cin >> niz[i];
    sort(niz+1, niz+1+n);
    reverse(niz+1, niz+1+n);
    vec.push_back(niz[1]);
    for(int i=2; i<=n; i++){
        treba.insert(-niz[i]);
    }
    vector <int> nvec;
    for(int j=1; (1<<j)<=n; j++){
        nvec.clear();
        for(auto c : vec){
            auto x = treba.upper_bound(-c);
            if(x == treba.end()){
                cout << "No\n";
                return 0;
            }
            nvec.push_back(-(*x));
            treba.erase(x);
        }
        for(auto c : nvec) vec.push_back(c);
    }
    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 13568
/* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod (int)(1e9+7)
#define MAXI (int)(1e17+100)
#define N 1000005

int dp[N];

int sum(vector<int> &num, int k)
{
    int n = num.size();
    int sum = 0;

    priority_queue<int>q;

    for(int i=0;i<n;i++)
        q.push(num[i]);

    while(k--)
    {
        int x = q.top();
        q.pop();

        q.push(x/2 + (x%2==1));
    }

    while(!q.empty()){
        sum += q.top();
        q.pop();
    }

    return sum;
}

// Driver code to test above functions
int32_t main()
{
    
 

     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    int r, c, n;
    cin >> r >> c >> n;

    int x = max(r, c);

    int ans = 0;
    while(ans*x<n)
        ans++;

    cout << ans;

    return 0;
    
} 

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

int main(int argc, char const *argv[])
{
    int n,x;
    long max,min,sum;
    cin >> n;
    x=0;
    sum=0;
    max=-1000000;
    min=1000000;
    for (int i=0;i<n;i++){
        cin >> x;
        sum += x;
        if (max < x) max = x;
        if (min > x) min = x;
    }
    cout << min << " " << max << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3104
N=int(input())
A=list(range(N))


r=0
count=0
for i in range(N):
    A[i]=int(input())
    if A[i]>r:
     r=A[i]
     count=i

for i in range(N):
    if i==count:
     del A[i]
     print(max(A))
    else:
     print(r)


Measured memory_bytes: 12476
#include <bits/stdc++.h>
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector<int> a(n);
  for (auto& x : a) std::cin >> x;
  std::vector<int> now;
  for (auto x : a) {
    auto ub = std::upper_bound(now.begin(), now.end(), x, std::greater<int>{});
    if (ub != now.end()) {
      *ub = x;
    } else {
      now.push_back(x);
    }
  }
  std::cout << now.size() << std::endl;
  return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf 10000000000000
#define mod 1000000007
#define maxn 100009
#define maxr 100009
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	VI dp(3,0);
	int n;
	rd(n);
	fr(i,0,n)
	{
		VI c(3),ndp(3,0);

		cin>>c[0]>>c[1]>>c[2];
		fr(i,0,3)
		{
			fr(j,0,3)
			{
				if(i!=j)
				{
					ndp[j]=max(ndp[j],dp[i]+c[j]);
				}
			}
		}
		dp=ndp;
	}
	cout<<max({dp[0],dp[1],dp[2]})<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
namespace mp = boost::multiprecision;
// 任意長整数型
using bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;
// ついでに有理数型
using rat = boost::rational<bint>;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
const string YES = "Yes";
const string NO = "No";

void solve(long long X){
  cout << (X >= 30 ? YES : NO) << endl;
}

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


Measured memory_bytes: 3664
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
inline long long int gcd(long long int a,long long int b) {
	return b>0 ? gcd(b,a%b):a;
}
int main() {
	int n;
	long long int a[105];
	scanf("%d",&n);
	for(int i=0; i<n; i++) {
		scanf("%lld",&a[i]);
	}
	if(n==1) {
		printf("%lld",a[0]);
	} else {
		for(int i=0; i<n-1; i++) {
			long long int t=gcd(a[i],a[i+1]);
			a[i+1]=a[i]/t*a[i+1];
		}
		printf("%lld",a[n-1]);
	}
	return 0;
}

Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    auto s = sread();
    foreach_reverse (i; 0 .. s.length)
    {
        auto t = s[0 .. i];
        if (t[0 .. $ / 2] == t[$ / 2 .. $])
        {
            writeln(t.length);
            return;
        }
    }
}


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

using LL = long long;

int N;
int big = 0;
multiset<int> S;

int main(){
  cin >> N;
  for(int i=0; i < (1 << N); i++){
    int elm;
    cin >> elm;
    S.insert(elm);
    big = max(big, elm);
  }

  vector<int> T;
  T.push_back(big);
  S.erase(S.find(big));

  for(int i=0; i<N; i++){
    vector<int> uT;
    for(int elm : T){
      auto itr = S.lower_bound(elm);
      if(itr == S.begin()){
        cout << "No" << endl;
        return 0;
      }
      --itr;
      uT.push_back(*itr);
      S.erase(itr);
    }

    for(int elm: uT){
      T.push_back(elm);
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 13884
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define trav(x,a) for (const auto& x: a)
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), x.end()
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int _i = 0; _i < (n); _i++) ni(a[_i])
#define nal(a, n) for (int _i = 0; _i < (n); _i++) nl(a[_i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const ll inf = 1e18 + 7;
const int N = 1e6 + 5;
const double eps = 1e-9;
map<ll,ll> dp;
ll cs[3], d; 
vector<ll> pr = {2, 3, 5};

ll mul(ll x, ll y) {
  if (x == 0) return 0;
  if (inf / x < y) return inf;
  return x * y;
}

void solve(ll n, ll mx) {
  if (dp.count(n) || n > mx || n <= 0) return;
  dp[n] = inf;
  bool ok = 1;
  for (int i = 0; i < 3; i++) {
    ll md = n % pr[i];
    ll nx = (n-md) / pr[i];
    solve(nx, mx);
    if (dp.count(nx))
      dp[n] = min(dp[n], dp[nx] + min(mul(n-md - nx, d), cs[i]) + md * d);
    nx = (n+pr[i]-md) / pr[i];
    solve(nx, mx);
    if (dp.count(nx))
      dp[n] = min(dp[n], dp[nx] + min(mul(n+pr[i]-md - nx, d), cs[i]) + (pr[i] - md) * d);
  }
  // if (ok) {
  //   solve(n - 1, mx);
  //   solve(n + 1, mx);
  //   dp[n] = min(dp[n], dp[n-1] + d);
  //   dp[n] = min(dp[n], dp[n+1] + d);
  // }
}

void solve() {
  ll n; nl(n);
  scanf("%lld %lld %lld %lld", &cs[0], &cs[1], &cs[2], &d);
  dp.clear();
  // dp[1] = d;
  dp[0] = 0;
  solve(n, 2ll*n);
  ll ans = dp[n];
  printf("%lld\n", ans); fflush(stdout);
}

int main() {
  int t; ni(t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 4992
#include <algorithm>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define REP(i, m, n) for (int i = int(m); i < int(n); i++)
#define RREP(i, m, n) for (int i = int(n) - 1; i >= int(m); --i)
#define EACH(i, c) for (auto &(i) : c)
#define all(c) begin(c), end(c)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(begin(c), end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x) cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s)                                                               \
    do {                                                                       \
    } while (0)
#define dump(x)                                                                \
    do {                                                                       \
    } while (0)
#define BR
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int, int>;
using VP = vector<PII>;

constexpr double EPS = 1e-10;
// constexpr double PI  = acos(-1.0);
// constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
// inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template <class T> inline T sqr(T x) { return x * x; }

void solve() {
    int n;
    cin >> n;
    VLL a(n);
    REP(i, 0, n) cin >> a[i];
    map<int, int> m;
    REP(i, 0, n) m[a[i]]++;
    LL ans = 0;
    for (auto &p : m) {
        int k = p.first, v = p.second;
        if (v < k)
            continue;
        ans += k;
    }
    cout << n - ans << endl;
}

signed main() {
    solve();

    return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s, t = "keyence";
  cin >> s;
  
  int ans = 0;
  for(int i = 0; i < 7; i++){
    if(s.at(i) == t.at(i)) ans++;
    else continue;
  }
  for(int i = 6; i >= 0; i--){
    if(s.at(i + s.size() - 7) == t.at(i)) ans++;
    else continue;
  }
  
  if(ans >= 7) cout << "YES\n";
  else cout << "NO\n";
}

Measured memory_bytes: 256
def main(s):
    if len(s)%2 != 0 :
        return False
    for i in range(len(s)):
        res = True
        if i%2 == 1:
            continue
        else:
            if s[i]!="h" or s[i+1]!="i":
                return False
    return res

s = input()
print("Yes" if main(s) else "No")

Measured memory_bytes: 2940
n = int(input())
li_v = list(map(int, input().split()))
li_c = list(map(int, input().split()))

li_a = list()

for i in range(n):
    li_a.append(li_v[i] - li_c[i])

print(sum(list(filter(lambda x: x >= 0, li_a))))


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

int N, A[1 << 18];

int main() {
	cin >> N;
	bool flag = false;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		if (A[i] % 2 == 1) flag = true;
	}
	if (flag == true) cout << "first" << endl;
	else cout << "second" << endl;
	return 0;
}

Measured memory_bytes: 640
class dice:

    def __init__(self, numlist):
        self._men = {"T": numlist[0],
                     "B": numlist[5],
                     "N": numlist[4],
                     "S": numlist[1],
                     "W": numlist[3],
                     "E": numlist[2]}

    def roll(self, direction):
        t = dict(self._men)

        if direction == "N":
            self._men["T"] = t["S"]
            self._men["B"] = t["N"]
            self._men["N"] = t["T"]
            self._men["S"] = t["B"]
        elif direction == "S":
            self._men["T"] = t["N"]
            self._men["B"] = t["S"]
            self._men["S"] = t["T"]
            self._men["N"] = t["B"]
        elif direction == "W":
            self._men["T"] = t["E"]
            self._men["B"] = t["W"]
            self._men["W"] = t["T"]
            self._men["E"] = t["B"]
        elif direction == "E":
            self._men["T"] = t["W"]
            self._men["B"] = t["E"]
            self._men["W"] = t["B"]
            self._men["E"] = t["T"]


    def settopsouth(self, top, south):
        if self._men["T"] == top:
            pass
        elif self._men["S"] == top:
            self.roll("N")
        elif self._men["N"] == top:
            self.roll("S")
        elif self._men["W"] == top:
            self.roll("E")
        elif self._men["E"] == top:
            self.roll("W")
        elif self._men["B"] == top:
            self.roll("N")
            self.roll("N")

        if self._men["S"] == south:
            return self._men["E"]
        elif self._men["E"] == south:
            return self._men["N"]
        elif self._men["N"] == south:
            return self._men["W"]
        elif self._men["W"] == south:
            return self._men["S"]


    def gettop(self):
        return self._men["T"]

def decode():
    numlist = [int(x) for x in input().split()]
    n = int(input())
    qs = []
    for _ in range(n):
        al = [int(x) for x in input().split()]
        qs.append(al)

    return numlist, n, qs


if __name__ == '__main__':

    numlist, n, qs = decode()
    d1 = dice(numlist)
    for q in qs:
        print(d1.settopsouth(*q))



Measured memory_bytes: 5628
n,m = map(int,input().split())
s = [list(map(int,input().split()))+[i] for i in range(m)]
s.sort()
l = [[] for i in range(n)]
for e in s:
    l[e[0]-1] += [e]
s = []
for e in l:
    k = 0
    for i in e:
        s += [[i[0],k+1,i[2]]]
        k += 1
s.sort(key=lambda x: x[2])
for e in s:
    print(str('0'*(6-len(str(e[0]))))+str(e[0])+str('0'*(6-len(str(e[1]))))+str(e[1]))

Measured memory_bytes: 46392
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int T = sc.nextInt();
        int[] A = new int[N];
        for(int i=0;i<N;i++){
            A[i]=sc.nextInt();
        }
        int[] mx = new int[N+1];
        for(int i=N-1;i>=0;i--) mx[i]=Math.max(A[i],mx[i+1]);
        int[] dif = new int[N];
        int maxDif = 0;
        for(int i=0;i<N-1;i++){
            dif[i]=mx[i+1]-A[i];
            maxDif = Math.max(maxDif,dif[i]);
        }
        int cnt = 0;
        for(int i=0;i<N-1;i++) {
            if(dif[i]==maxDif) cnt++;
        }
        System.out.println(cnt);
    }
}


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

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

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

use std::cmp::min;

fn main() {
    let pqr: Vec<u32> = read_vec();
    if pqr[0] < pqr[1] {
        println!("{}", pqr[0] + min(pqr[1], pqr[2]));
    } else {
        println!("{}", pqr[1] + min(pqr[0], pqr[2]));
    }
}


Measured memory_bytes: 4352
#include <cstdio>
#include <queue>
#define maxn 100005
using namespace std;

typedef long long LL;

LL a[maxn], b[maxn], sm, sp;
priority_queue<LL> q;

int main(int argc, char** argv)
{
	int n, res = 0;
	scanf("%d", &n);
	for(int i=0; i<n; i++) scanf("%lld", &a[i]);
	for(int i=0; i<n; i++) scanf("%lld", &b[i]);
	for(int i=0; i<n; i++)
		if(a[i] < b[i])
		{
			sm += b[i] - a[i];
			res ++;
		}
		else if(a[i] > b[i])
		{
			sp += a[i] - b[i];
			q.push(a[i] - b[i]);
		}
	if(sm > sp) {puts("-1"); return 0;}
	if(sm == 0) {puts("0"); return 0;}
	while(!q.empty())
	{
		LL x = q.top(); q.pop();
		sm -= x, res ++;
		if(sm <= 0)
		{
			printf("%d\n", res);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main(){
 int K,S;
 cin >> K >> S;
 int ans = 0;
 for(int X = 0; X <= K; X++){
     for(int Y = 0; Y <= K; Y++){
         if(S - X - Y <= K && S - X - Y >= 0){
             ans += 1;
         }
         }
     }
     cout << ans << endl;
}

Measured memory_bytes: 256
/*|In The Name of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

int n;
int k;
int cnt[N];
priority_queue < pair < int , int > > pq1 , pq2;

int main(){
    scanf("%d%d" , &n , &k);
    for(int i = 1; i <= n; i++){
        int t , d;
        scanf("%d%d" , &t , &d);
        pq1.push({d , t});
    }
    int took = k;
    long long x = 0 , sum = 0 , best = 0;
    while(took){
        int d = pq1.top().first;
        int t = pq1.top().second;
        pq1.pop();
        pq2.push({-d , t});
        sum += d;
        if(!cnt[t])
            x++;
        cnt[t]++;
        took--;
    }
    best = sum + x*x;
    while(pq1.size()){
        int d = pq1.top().first;
        int t = pq1.top().second;
        pq1.pop();
        if(cnt[t])
            continue;
        int tm = -1;
        while(pq2.size()){
            int d2 = -pq2.top().first;
            int t2 = pq2.top().second;
            pq2.pop();
            if(cnt[t2] > 1){
               cnt[t2] --;
               tm = d2;
               break;
            }
        }
        if(tm == -1)
          break;
        x++;
        sum -= tm;
        sum += d;
        cnt[t]++;
        best = max(best , sum + x*x);
    }
    printf("%lld\n" , best);
    return 0;
}


Measured memory_bytes: 2932
#include<stdio.h>
#include<stdlib.h>
#define N 10000
#define INFTY 1<<20
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,A[500000][3];

int main()
{
  int i,j,x,y,z,s,cnt=0,d[N],color[N],v;
  scanf("%d",&n);

  for(i=0;i<n;i++)
    {scanf("%d%d",&x,&y);
      for(j=0;j<y;j++){
	A[cnt][WHITE]=x;
	scanf("%d%d",&z,&s);
	A[cnt][GRAY]=z;
	A[cnt][BLACK]=s;
	cnt++;}
    }
  for(i=0;i<n;i++)d[i]=INFTY;
  d[0]=0;
  color[x]=GRAY;

  while(color[x]!=0){
    color[x]=WHITE;
    for(v=0;v<cnt;v++){
      if(d[A[v][GRAY]]>d[A[v][WHITE]]+A[v][BLACK]){
	d[A[v][GRAY]]=d[A[v][WHITE]]+A[v][BLACK];
	color[x]=GRAY;
      }
    }
  }

  for(i=0;i<n;i++)
    {
      printf("%d ",i);
      if(d[i]==INFTY)printf("%d\n",-1);
      else printf("%d\n",d[i]);
    }
  return 0;      
}




Measured memory_bytes: 7656
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
ll n,s;
ll solve(){
    ll b=2;
    while(b*b<=n){
	ll sum=0,cop=n;
	while(cop)sum+=cop%b,cop/=b;
	if(sum==s)return b;
	b++;
    }
    ll mini=(ll)mod*(ll)mod;
    for(ll i=1;i*i<=n-s;i++){
	if((n-s)%i==0){
	    if(n/(i+1)*i==n-s&&b<=i+1&&i+1<=n)return i+1;
	    ll j=(n-s)/i;
	    if(n/(j+1)*j==n-s&&b<=j+1&&j+1<=n)mini=min(mini,j+1);
	}
    }
    if(mini<(ll)mod*(ll)mod)return mini;
    if(n==s)return s+1;
    return -1;
}
int main(){
    cin>>n>>s;
    cout<<solve()<<endl;
    return 0;
}


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

int main() {
    string Str;
    cin >> Str;
    bool N = false, W = false, S = false, E = false;
    for(auto &p : Str) {
        if(p == 'N') N = true;
        else if(p == 'W') W = true;
        else if(p == 'S') S = true;
        else E = true;
    }
    if((N^S) || (W^E)) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
N,*P = `dd`.split.map(&:to_i)

ain  = Array.new(N+1, 0)
bin  = Array.new(N+1, 0)

P.each_with_index{ |q,k|
  bin[0]   += k+1
  bin[q]   -= k+1
  ain[q-1] += k+1
  ain[N]   -= k+1
}

x = 0
puts (0...N).map{ |i| x += ain[i] }.join(" ")
x = 0
puts (0...N).map{ |i| x += bin[i] }.join(" ")


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

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; }
const ll llINF = 1LL << 60;
const int iINF = 1e8;

//---main---------------------------------------------
int main(){
    //main
    int N;
    cin >> N;

    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    ll ans = 0;
    for(int i=1; i<N; i++){
        ll d = A[i-1] - A[i];
        if(d>0){
            A[i] = A[i-1];
            ans += d;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4776
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


class UnionFind:
    def __init__(self, n_nodes):
        self.n_nodes = n_nodes

        # self.parents[x] < 0 の時，xが根である．
        # また，xが根の時，(-1) * (同一グループの要素数) が格納されるようになる.
        self.parents = [-1] * n_nodes

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        # 常にxの方が要素数が多くなるように，スワップする
        if self.parents[x] > self.parents[y]:
            x, y = y, x

        # 要素数の少ない方のグループを，要素数が多い方の木に貼る．
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def get_size(self, x):
        return -self.parents[self.find(x)]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def get_members(self, x):
        parent = self.find(x)
        return [i for i in range(self.n_nodes) if self.find(i) == parent]

    def get_parent_list(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def get_n_groups(self):
        return len(self.get_parent_list())

    def get_members_dict(self):
        return {par: self.get_members(par) for par in self.get_parent_list()}


def main():
    N, M = map(int, input().split())
    P = list(map(lambda x: int(x) - 1, input().split()))
    tree = UnionFind(N)
    for _ in range(M):
        x, y = map(lambda x: int(x) - 1, input().split())
        tree.unite(x, y)

    ans = 0
    for i in range(N):
        if tree.is_same(i, P[i]):
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 13812
from scipy.signal import*
n,m,*a=map(int,open(0).read().split())
b=[0]*2**17
for i in a:b[i]+=1
i=2**18-1
c=0
for a in(fftconvolve(b,b)+.5).astype(int)[::-1]:
  i-=1
  if a:
    t=min(m,a)
    c+=i*t
    m-=t
    if not m:break
print(c)

Measured memory_bytes: 54192
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      final int n = Integer.parseInt(br.readLine());
      String op;
      String[] words;
      Tree tree = new Tree();

      for(int i=0,k=0; i<n; i++,k=0){
        words = br.readLine().split(" ");
        op  = words[k++];
        if ( op.equals("insert") ) { 
          tree.insert(Integer.parseInt(words[k++]));
        }
        else {
          tree.dispRoundPath();
        }
      }

    }
    catch(IOException e) {
      System.out.println("IOException!");
    }
  }
}

class Tree {

  static final BTreeNode NIL = new BTreeNode(-1);
  BTreeNode root;
  StringBuilder buf;

  public Tree() {
    root = NIL;
    buf = new StringBuilder();
  }

  public void insert(int val) {
    BTreeNode y = NIL;
    BTreeNode x = root;
    BTreeNode z = new BTreeNode(val);

    while( !x.equals(NIL) ) {
      y = x;
      if( z.key < x.key )
        x = x.left;
      else
        x = x.right;
    }
    z.parent = y;

    if( y.equals(NIL) ){
      root = z;
    }
    else if( z.key < y.key )
      y.left = z;
    else
      y.right = z;
  } 
  void preParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      buf.append(" ").append(u.key);
      preParse(u.left);
      preParse(u.right);
    }
  }
  void inParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      inParse(u.left);
      buf.append(" ").append(u.key);
      inParse(u.right);
    }
  }

  void dispRoundPath() {

    inParse(root);
    buf.append("\n");
    preParse(root);
    buf.append("\n");

    System.out.print(buf);
    buf.setLength(0);
  }
}

class BTreeNode {
  int key;
  BTreeNode parent,left,right;

  public BTreeNode(int key) {
    this.key = key;
    this.parent =
    this.left =
    this.right = Tree.NIL;
  }

  @Override
  public boolean equals(Object o) {
    if(o == this) return true;
    if(o == null) return false;
    if(!(o instanceof BTreeNode)) return false;

    BTreeNode node = (BTreeNode)o;
    if(!(this.key == node.key)) return false;

    return true;
  }
}


Measured memory_bytes: 125780
from itertools import combinations_with_replacement

N = int(input())
ans = [0] * (N + 1)            

for x, y, z in combinations_with_replacement(list(range(1, 100)), 3):
    val = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + x * z

    n_diff = len(set([x, y, z]))
    if n_diff == 3:
        cnt = 6
    if n_diff == 2:
        cnt = 3
    if n_diff == 1:
        cnt = 1

    # print(val)
    
    if val <= N:
        ans[val] += cnt

print('\n'.join(map(str, ans[1:])))


Measured memory_bytes: 9392
#include<bits/stdc++.h>
using namespace std ;
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 4e5 + 5 ; 
int H ; 
int F( int x ) {
	if( x == 1 ) return 1 ; 
	return 2ll * F( x / 2 ) + 1ll ; 
}
signed main()
{
	H = gi() ; 
	printf("%lld\n", F(H) ) ;
	return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;



int main(){
    int h,n;
    cin >> h >> n;
    vector<pair<int, int>> m(n);
    for(int i = 0; i < n; i++){
        cin >> m[i].first >> m[i].second;
    }

    int dp[h+1];
    for(int i = 0; i <= h; i++){
        dp[i] = 999999999;
    }
    dp[0] = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < n; j++){
            int tg = i+m[j].first;
            if(tg > h) tg = h;
            dp[tg] = min(dp[tg], dp[i]+m[j].second);
        }
    }

    cout << dp[h] << endl;

    return 0;
}

Measured memory_bytes: 3636
lst = []
atari = [0 for _ in range(9)]
for _ in range(3):
	a, b, c = map(int, input().split())
	lst.append(a)
	lst.append(b)
	lst.append(c)

N = int(input())

for _ in range(N):
	b = int(input())
	if b in lst:
		atari[lst.index(b)] = 1
	
if atari[0] * atari[1] * atari[2] == 1 or atari[3] * atari[4] * atari[5] == 1 or atari[6] * atari[7] * atari[8] == 1 or atari[0] * atari[3] * atari[6] == 1 or atari[1] * atari[4] * atari[7] == 1 or atari[2] * atari[5] * atari[8] == 1 or atari[0] * atari[4] * atari[8] == 1 or atari[2] * atari[4] * atari[6] == 1:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 38256
import sys
input = sys.stdin.readline

n = int(input())
tl = [0]*n
for i in range(n-1):
  c,s,f = map(int,input().split())  
  for j in range(i+1):
    if tl[j] < s:
      tl[j] = s + c
    elif tl[j] % f == 0:
      tl[j] += c
    else:
      tl[j] += c + f - tl[j] % f
for k in tl:
  print(k)

Measured memory_bytes: 3064
n = gets.chop
arrp = gets.chop.split.map(&:to_i)
arrq = gets.chop.split.map(&:to_i)
arr_p = arrp.sort
arr_q = arrq.sort

p_hash = Hash.new(0)
q_hash = Hash.new(0)

p_count = 1
arr_p.permutation do |x|
  p_hash[x] = p_count
  p_count += 1
end
q_count = 1
arr_q.permutation do |x|
  q_hash[x] = q_count
  q_count += 1
end

print (p_hash[arrp] - q_hash[arrq]).abs

Measured memory_bytes: 16636
use proconio::input;

fn main() {
    input! {
        n: usize,
        k: usize,
    }

    solve(n, k);
}

fn solve(n: usize, k: usize) {
    let mut s = k;
    for _ in 1..n {
        s = s * (k - 1);
    }
    println!("{}", s);
}


Measured memory_bytes: 2076
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
const int INFI=2147483647;
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


template<class Abel> struct UnionFind {
  vector<int> par;
  vector<int> rank;
  vector<Abel> diff_weight; // 親ノードとの距離みたいなもの。重み。根では0

  UnionFind(int N = 1, Abel SUM_UNITY = 0) : par(N), rank(N, 0), diff_weight(N, SUM_UNITY){
    for (int i=0; i<N; i++) par[i] = i;
  }

  int root(int x){
    if (par[x] == x) return x;
    else{
      int r = root(par[x]); // この時点で経路圧縮を行っておく
      diff_weight[x] += diff_weight[par[x]]; // 根の方から順々に重みが決定していく
      return par[x] = r;
    }
  }

  Abel weight(int x){ // ノードxの重みを返す
    root(x); // 経路圧縮
    return diff_weight[x];
  }

  bool same(int x, int y){
    return root(x) == root(y);
  }

  bool unite(int x, int y, Abel w){ // 重み差分がweight(y)-weight(x) = wとなるように併合
    w += weight(x); w -= weight(y); // 実際に繋げるのはx,yのroot同士なので重み差分を修正
    x = root(x); y = root(y);
    if (x == y) return false;
    if (rank[x] < rank[y]) swap(x, y), w = -w; // swapに併せてwも符号反転
    if (rank[x] == rank[y]) rank[x]++;
    par[y] = x;
    diff_weight[y] = w; // xrootがyrootの親になる
    return true;
  }

  Abel diff(int x, int y){ // 重みの差分を返す
    return weight(y) - weight(x);
  }
};

int main() {
  int N,M; cin >>N >>M;
  UnionFind<int> uf(N);
  bool ok = true;
  rep(q, M){
    int l,r,d; cin >>l >>r >>d;
    l--; r--;
    if (!uf.unite(l, r, d)){
      if (d != uf.diff(l, r)){
        ok = false; break;
      }
    }
  }
  cout <<(ok ? "Yes" : "No") <<endl;
}

Measured memory_bytes: 1408
#include <iostream>
using namespace std;
using ll = long long;

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

#define out(v) cout<<v<<"\n"
const ll INF = 1e10;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int V, E; cin >> V >> E;

  ll cost[V][V];
  rep(s, V) rep(t, V) {
    if (s == t)
      cost[s][t] = 0;
    else
      cost[s][t] = INF;
  }

  rep(i, E) {
    int s, t, d;
    cin >> s >> t >> d;
    cost[s][t] = d;
  }
  rep(k, V) rep(i, V) rep(j, V) {
    if (cost[i][k] == INF || cost[k][j] == INF)
      continue;
    cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
  }
  rep(i, V) {
    if (cost[i][i] < 0) {
      cout << "NEGATIVE CYCLE\n";
      return 0;
    }
  }
  rep(i, V) {
    rep(j, V) {
      if (cost[i][j] == INF)
        cout << "INF";
      else
        cout << cost[i][j];
      if (j + 1 != V)
        cout << " ";
    }
    cout << "\n";
  }

  return 0;
}


Measured memory_bytes: 3276
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
public class Main {
	int N;
	String A,B;
	char[] a,b;
	
	public boolean dfs(int n,int x,int y,int m)
	{
		if(n == N)return true;
		boolean ret = false;
		
		if(m == 0){
			for(int i = x;i < N;i++){
				if(a[i] == a[n]){
					ret = dfs(n + 1,i + 1,y,1);
					
					if(ret)return true;
					break;
				}
			}
		}else{
			for(int i = y;i < N;i++){
				if(b[i] == a[n]){
					ret = dfs(n + 1,x,i + 1,0);
					
					if(ret)return true;
					break;
				}
			}
		}
		return false;
	}
	
    public void solve() {
		A = next();
		B = next();
		a = A.toCharArray();
		b = B.toCharArray();
		N = A.length();
		
		if(dfs(0,0,0,0) || dfs(0,0,0,1)){
			out.println("Yes");
		}else{
			out.println("No");
		}
    }
 
	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}
		/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 24432
import bisect
N = int(input())
L = sorted([int(x) for x in input().split()])
cnt = 0
#print(L)
for i in range(N-2):
    for j in range(i+1, N-1):
        #print(i, j)
        #print(bisect.bisect_left(L, L[i]+L[j]))
        cnt +=  bisect.bisect_left(L, L[i]+L[j]) - (j+1)
print(cnt)

Measured memory_bytes: 44424
#B
N, K = map(int, input().split())

def base10to(n, b):
    if (int(n/b)):
        return base10to(int(n/b), b) + str(n%b)
    return str(n%b)

ans = base10to(N, K)
ans = str(ans)
print(len(ans))

Measured memory_bytes: 3060
main :: IO ()
main = do
  n <- readLn
  putStrLn $ solve n

solve :: Int -> String
solve n
  | r `elem` [2,4,5,7,9] = "hon"
  | r `elem` [0,1,6,8]   = "pon"
  | r == 3               = "bon"
 where r = n `rem` 10
      


Measured memory_bytes: 3872
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define xxx         exit(0);
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;

}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x) {
    return (ll)(log(x) / log(base));
}
lld dp[303][303][303]; ll n;
lld E(ll a, ll b, ll c)
{
	if(a<0 || b<0 || c<0) return 0;
	if(dp[a][b][c]!=-1.00) return dp[a][b][c];
	lld ans=((n*1.0)/((a+b+c)*1.00));
	if(a>0) ans+=((a*1.0)/((a+b+c)*1.00))*E(a-1,b,c);
	if(b>0) ans+=((b*1.0)/((a+b+c)*1.00))*E(a+1,b-1,c);
	if(c>0) ans+=((c*1.0)/((a+b+c)*1.00))*E(a,b+1,c-1);
	return dp[a][b][c]=ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll k,i,j,l,m,h,w,val,d,a,b,c;
    	cin>>n;
    	a=0; b=0; c=0;
    	rep(i,0,n)
		{
    		cin>>h;
    		if(h==1) a++;
    		else if(h==2) b++;
    		else c++;
		}
		cout<<fixed<<setprecision(15);
		repi(i,0,300){
			repi(j,0,300){
				repi(k,0,300) dp[i][j][k]=-1.00;
			}
		}
		dp[0][0][0]=0.00;
    	cout<<E(a,b,c);
	}
	return 0;
}

Measured memory_bytes: 433868
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector <int> p(a), q(b), r(c);
    for(int i = 0; i < a; i ++) cin >> p[i];
    for(int i = 0; i < b; i ++) cin >> q[i];
    for(int i = 0; i < c; i ++) cin >> r[i];
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    vector <int> d;
    for(int i = 0; i < x; i ++)
        d.push_back(p[i]);
    for(int i = 0; i < y; i ++)
        d.push_back(q[i]);
    for(int i = 0; i < c; i ++)
        d.push_back(r[i]);
    sort(d.rbegin(), d.rend());
    long long ans = 0;
    for(int i = 0; i < x + y; i ++)
        ans += d[i];
    cout << ans;
}

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

int n;
long long a[300005];
long long sumesBlyat[200005];
long long sumesBlyat2[200005];
long long sumS = 0, sumE = 0;
multiset<long long> setS, setE;
long long pot = 0;

void ShowSet() {
	multiset<long long>::iterator it;
	for (it = setS.begin(); it != setS.end(); it++)
		cout << *it << " ";
	cout << endl;
}

int main() {
	/*
	setS.insert(1);
	setS.insert(1);
	setS.insert(2);
	ShowSet();
	setS.erase(setS.begin());
	ShowSet();
	*/

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

	for (int i = 0; i < n; i++) {
		setS.insert(a[i]);
		setE.insert(a[3 * n - 1 - i]);
		sumS += a[i];
		sumE += a[3 * n - 1 - i];
	}

	long long ans = sumS - sumE;
	multiset<long long>::iterator it1 = setS.begin();
	multiset<long long>::iterator it2 = --setE.end();


	sumesBlyat[n - 1] = sumS;
	for (int l = n; l < 2 * n; l++) {
		if (a[l] - *it1 > 0) {
			sumS += a[l] - *it1;
			//setS.erase(setS.begin());
			setS.insert(a[l]);
			it1++;
		}
		sumesBlyat[l] = sumS;
	}

	sumesBlyat2[2 * n] = sumE;
	for (int r = 2 * n - 1; r >= n; r--) {
		if (*it2 - a[r] > 0) {
			sumE -= *it2 - a[r];
			//setE.erase(--setE.end());
			setE.insert(a[r]);
			it2--;
		}
		sumesBlyat2[r] = sumE;
	}

	for (int i = n - 1; i < 2 * n; i++) {
		if (ans < sumesBlyat[i] - sumesBlyat2[i + 1])
			ans = sumesBlyat[i] - sumesBlyat2[i + 1];
	}

	cout << ans << endl;


	/*
	int l = n;
	int r = 2 * n - 1;
	while (l <= r) {
		if (a[l] - *setS.begin() > 0 && pot - *setS.begin() >= *(--setE.end()) - pot) {
			sumS += a[l] - *setS.begin();
			setS.erase(setS.begin());
			setS.insert(a[l]);
			pot -= a[l];
			l++;
		}
		else if (*(--setE.end()) - a[r] >  0 && pot - *setS.begin() <= *(--setE.end()) - pot) {
			sumE -= *(--setE.end()) - a[r];
			setE.erase(--setE.end());
			setE.insert(a[r]);
			pot -= a[r];
			r--;
		}
		else {
			if (pot - *setS.begin() > *(--setE.end()) - pot) {
				pot -= a[l];
				l++;
			}
			else {
				pot -= a[r];
				r--;
			}
		}
	}
	
	//multiset<long long>::iterator it;
	//for (it = setS.begin(); it != setS.end(); it++)
	//	sumS +=*it;
	//for (it = setE.begin(); it != setE.end(); it++)
	//	sumE += *it;
	cout << sumS - sumE <<endl;

	*/
	return 0;
}

Measured memory_bytes: 23168