akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define zahyoutype double
typedef struct Point{zahyoutype x,y;}P;
typedef struct line{P p1,p2;}L;

P crosspoint(L s,L t){
	zahyoutype x=1;if(x/2==0){puts("type error");exit(0);}
	double deno=(s.p1.x-s.p2.x)*(t.p1.y-t.p2.y)-(t.p1.x-t.p2.x)*(s.p1.y-s.p2.y);
	zahyoutype xnume=  s.p1.x*t.p1.x*(s.p2.y-t.p2.y)-s.p1.x*t.p2.x*(s.p2.y-t.p1.y)-s.p2.x*t.p1.x*(s.p1.y-t.p2.y)+s.p2.x*t.p2.x*(s.p1.y-t.p1.y);
	zahyoutype ynume=-(s.p1.y*t.p1.y*(s.p2.x-t.p2.x)-s.p1.y*t.p2.y*(s.p2.x-t.p1.x)-s.p2.y*t.p1.y*(s.p1.x-t.p2.x)+s.p2.y*t.p2.y*(s.p1.x-t.p1.x));
	P p={xnume/deno,ynume/deno};
	return p;
}
double seglen(L s){return hypot(s.p2.x-s.p1.x,s.p2.y-s.p1.y);}
double distPP(P p,P q){return hypot(p.x-q.x,p.y-q.y);}

void readpoint(P*p){zahyoutype x=1;scanf(x/2?"%lf%lf":"%ld%ld",&p->x,&p->y);}
void printpoint(P p){zahyoutype x=1;printf(x/2?"%.f %.f\n":"%ld %ld\n",p.x,p.y);}

int main(){
	P p;
	int r;
	readpoint(&p);
	scanf("%d",&r);
	int q;
	scanf("%d",&q);
	while(q--){
		L s,t;
		readpoint(&s.p1);
		readpoint(&s.p2);
		t.p1=p;
		P q={p.x+(s.p2.y-s.p1.y),p.y-(s.p2.x-s.p1.x)};
		t.p2=q;
		P c=crosspoint(s,t);
		double d=distPP(c,p);
		double coe=sqrt(r*r-d*d)/seglen(s);
		double x1,y1,x2,y2;
		x1=c.x+coe*(s.p2.x-s.p1.x);
		y1=c.y+coe*(s.p2.y-s.p1.y);
		x2=c.x-coe*(s.p2.x-s.p1.x);
		y2=c.y-coe*(s.p2.y-s.p1.y);
		if(x2<x1||(x2==x1&&y2<y1)){
			double t=x1;x1=x2;x2=t;
			t=y1;y1=y2;y2=t;
		}
		printf("%.9f %.9f %.9f %.9f\n",x1,y1,x2,y2);
	}
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;
/// khodaya komak kon
/// ya navid navid
/// ye tec khaphan ke yadam bemone : age jayi didi soale masir hamiltoni mikhad rasasho bokon yal oilery;
/// age ye ja mikhasti to dp az ozv i k ta entekhab koni bejash ye log bezan (nominal) hamoon 2**k va o 1 ent kon

///\\\///\\\///\\\\\\\\\\\\\\\\\///\\\///\\\///

const int N=410,mod=1e9+7;

ll dp[N][N];
ll g[N][N];
ll a[N];
ll b[N];
ll p[N][N];
int32_t main(){
    sync;
    ll n,c;
    cin >> n >> c;
    for (int i=1;i<N;i++){
        p[i][0]=1;
        for (int j=1;j<N;j++){
            p[i][j]+=p[i][j-1]*i%mod;
        }
    }
    for (int i=0;i<n;i++){
        cin >> a[i+1];
    }
    for (int i=0;i<n;i++){
        cin >> b[i+1];
    }
    for (int i=1;i<=n;i++){
        for (int l=0;l<N;l++){
            for (int j=a[i];j<=b[i];j++){
                g[i][l]+=p[j][l];
                g[i][l]%=mod;
            }
        }
    }
    dp[0][c]=1;
    for (int i=1;i<=n;i++){
        for (int j=0;j<=c;j++){
           // for (int o=a[i];o<=b[i];o++){
                for (int l=0;l<=c;l++){
                    /// dp[i][j]
                    if (j+l<=c){
                        ll z=g[i][l];
                        dp[i][j]+=z*dp[i-1][j+l]%mod;
                        dp[i][j]%=mod;
                    }
                }
            //}
           // cout << i << " " << j << " " << dp[i][j] << endl;
        }
    }
    cout << dp[n][0];


}


















Measured memory_bytes: 4096
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx2,tune=native") // Auto-Vectorisation

#include "bits/stdc++.h"
#include "chrono"
#include "random"
using namespace std;

/*
//large integers
#include <boost/multiprecision/cpp_int.hpp>
__int128 s128; // pollard rho
__uint128_t u128;

//policy based data structures
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace boost::multiprecision; 
using namespace __gnu_pbds;
*/

typedef long long int ll;
typedef long double ld;
typedef double db;
typedef pair<ll,ll> pll;
typedef unsigned long long u64;
typedef vector<ll> vl;
typedef vector<pll> vpl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef unordered_set<ll> usl;
typedef set<ll> sl;
typedef multiset<ll> mul;
typedef unordered_map<ll,ll> umll;
typedef map<ll,ll> mll;

#define int long long int
#define sz(a) (ll)a.size()
#define lt(a) (ll)a.length()
#define tc(x) ll x; cin>>x; while(x--)
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define bac(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define print(a)  for (auto x : a) cout << x << " "; cout << endl
#define mt make_tuple
#define eb emplace_back
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define endl '\n'
#define all(a) a.begin(),a.end()
#define Sort(x) sort(all((x)))
#define setbits(a) __builtin_popcountll(a)
#define ps(x,y) fixed<<setprecision(y)<<x;
#define hell cout<<"hello"<<'\n'
#define deb(x) cerr<<#x<<" = "<<x<<'\n'
#define F first
#define S second
#define teevra_gati ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //shuffle(all(v), rng);

const string alpha   =   "zabcdefghijklmnopqrstuvwxyz";
const ld PI          =   ld(3.14159265359);
const ll P           =   1e9 + 7; // 998244353; // 1e9 + 9 // 7340033 // 4294967296;
const ll Q           =   1e9 + 6; // 998244352; // 1e9 + 8 // 7340032;
const ll ninf        =   LONG_MIN;
const ll inf         =   8e18;
const ll M           =   2e3 + 5;
const ll N           =   2e5 + 5;

void solve(){
    ll n,s=0;
    cin>>n;
    vl a(n);
    f(i,0,n) cin>>a[i], s ^= a[i];
    f(i,0,n) a[i] ^= s, cout<<a[i]<<" ";

}
signed main(){
    teevra_gati
    
    solve();

    //cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 4760
N,M = map(int,input().split())
S = input()

ans = []
i = N
while i > 0:
    for m in range(M,0,-1):
        if i-m <= 0:
            ans.append(i)
            i = 0
            break
        if S[i-m]=='0':
            ans.append(m)
            i -= m
            break
    else:
        print(-1)
        exit()
print(*ans[::-1])


Measured memory_bytes: 50416
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <vector>
#include <iterator>
#include <algorithm>
#include <cmath>
#include <limits>
#include <numeric>

using namespace std;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
    uint32_t N, *A;
    cin >> N;
    A = new uint32_t [N];
    vector<string> S(N);

    for(uint32_t i = 0;i<N;++i){
        string tmp;
        cin >> tmp;
        sort(tmp.begin(),tmp.end());
        S[i] = tmp;
        A[i] = 0;
    }

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

    uint64_t res = 0;
    uint64_t count = 0;
    string tmp = S[0];

    for(uint32_t i = 1; i < N;++i){
        if(S[i] == tmp){
            ++count;
        }else{
            res += count * (count + 1) / 2;
            tmp = S[i];
            count = 0;
        }
    }
    if(count) res += count * (count + 1) / 2;

    cout << res << endl;

	return 0;
}



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

int main(){
	int a, b;
	char temp;
	
	cin>>a>>b;
	
	if(a + b == 15)temp = '+';
	else if(a*b == 15) temp = '*';
	else temp = 'x';
	cout<<temp;
	
	return 0;
}

Measured memory_bytes: 384
ans=0
while True:
    try:
        b = input()
        a = list(b)
        c=len(a)
        if c==0:
            break
        c=int(c/2)
        e=0
        for i in range(c):
            d=i+1
            if a[i]==a[-d]:
                e+=1
            else:
                break
        if e==c:
            ans+=1
    except:
        break
print(ans)


Measured memory_bytes: 5560
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define INF 1<<30

int DP[40+1][401][401];


int main() {
    int N, Ma, Mb; cin >> N >> Ma >> Mb;
    vector<int> A(N), B(N), C(N);
    rep(i,N) {
        int a, b, c; cin >> a >> b >> c;
        A.at(i) = a;
        B.at(i) = b;
        C.at(i) = c;
    }

    for (int i = 0; i <= N; i++)
        for (int j = 0; j <= 400; j++)
            for(int k = 0; k <= 400; k++) DP[i][j][k] = INF;
    DP[0][0][0] = 0;
    for (int i = 0; i < N; i++) {
        for (int CA = 0; CA <= 400; CA++) {
            for (int CB = 0; CB <= 400; CB++) {
                if (DP[i][CA][CB] == INF) continue;
                // Case 1: Not use #i product
                DP[i+1][CA][CB] = min(DP[i+1][CA][CB], DP[i][CA][CB]);
                // Case 2: Use #i
                DP[i+1][CA+A[i]][CB+B[i]] = min(DP[i+1][CA+A[i]][CB+B[i]], DP[i][CA][CB]+C[i]);
            }
        }
    }

    int ans = INF;
    for (int CA = 1; CA < 401; CA++) {
        for (int CB = 1; CB < 401; CB++) {
            if (CA * Mb == CB * Ma) ans = min(ans, DP[N][CA][CB]);
        }
    }

    if (ans == INF) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}


Measured memory_bytes: 25984
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */
 
    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(ll i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(ll i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    #define te  ll ti;   cin >> ti;  while(ti--) solve();  
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<int> vi;
    const int maxN = 100100;

    void solve() {
        ll a, b, c, x, y, val = 1e17;
        cin >> a >> b >> c >> x >> y;
        c = 2*c;
        repA(i, 0, max(x, y)) val = min(val, i*c + max(0ll, x-i)*a + max(0ll, y-i)*b);
        cout << val << endl;
    }
 
    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
/*
        #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        #endif
*/      
      //te
      solve();
      return 0;
    } 

Measured memory_bytes: 256
#include <utility>
#include <iostream>
#include <cmath>
#include <deque>
#include <string>
#include <time.h>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <sstream>
#include <algorithm>
#include <bitset>

#define pii pair<ll,ll>
#define X first
#define Y second
#define mp make_pair

typedef long long ll;
using namespace std;
#define MAXN 10000007
#define MOD 998244353
#define N 1048576
ll n, x, k, z, m, pos, q, ans_v;
ll x1, p1, x2;
ll a[100500], b[100500];

int main() {
    cin >> n;
    if (n % 2) {
        cout << n/2 << endl;
    } else {
        cout << (n-1) / 2 << endl;
    }


    return 0;
}

Measured memory_bytes: 764
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

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

    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    bool f = true;
    ll maxi = 0;
    ll lcmAll = 1;

    set<ll> div;


    for(int i = 0; i < n; i++){
        maxi = max(maxi, a[i]);
        lcmAll = lcm(lcmAll, a[i] / 2);
        if((a[i] / 2) % 2 == 0){
            ll cnt = 0;
            ll tmp = a[i];
            while(true){
                if(tmp % 2 == 0){
                    tmp /= 2;
                    cnt++;
                } else {
                    break;
                }
            }
            div.insert(cnt);
        } else {
            div.insert(1);
        }
    }

    if(div.size() > 1){
        f = false;
    }

    if(!f){
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;


    ans = (m / lcmAll + 1) / 2;


    cout << ans << endl;


}

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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p.at(i);
    for(int i = 0;i < n;i++){
        for(int j = i;j < n;j++){
            vector<int> t = p;
            swap(t.at(i),t.at(j));
            bool is_syoujun = true;
            rep(k,n-1){
                if(t.at(k) > t.at(k+1)) is_syoujun = false;
            }
            if(is_syoujun){
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,k; cin >> n >> k;
	string s; cin >> s;
	int now=n;
	vector<int> ans;
	while(now){
		for(int i=k;i>=0;i--){
			if(now-i>=0&&s[now-i]=='0'&&i){
				ans.push_back(i);
				now-=i;
				break;
			}
			if(i==0){
				cout << -1 << endl;
				return 0;
			}
		}
	}
	reverse(ans.begin(),ans.end());
	for(int p:ans){
		cout << p << endl;
	}
}

Measured memory_bytes: 1096
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val sList = (1..n).map { readLine()!! }.sorted()
    val map = mutableMapOf<String, Int>()
    sList.forEach { map[it] = map.getOrDefault(it, 0) + 1 }
    val list = map.map { Pair(it.key, it.value) }.sortedBy { it.first }.sortedByDescending { it.second }

    val maxNum = list[0].second
    for (l in list) {
        if (maxNum == l.second) {
            println(l.first)
        } else {
            return
        }
    }
}

Measured memory_bytes: 88716
fun main(args: Array<String>) {
  val (n, x, y, z) = readLine()!!.split(" ").map { it.toInt() }
  val MOD = (1e9 + 7).toInt()
  val m = 1 shl (x + y + z - 1);
  val ng = (1 shl (z - 1)) or (1 shl (y + z - 1)) or (1 shl (x + y + z - 1))
  var dp = Array(n + 1) { LongArray(m) { 0L } }
  dp[0][0] = 1L
  for (i in 0 until n) {
    for (j in 1..10) {
      for (b in 0 until m) {
        var nb = ((b shl j) or (1 shl (j - 1)))
        if ((nb and ng) != ng) {
          nb = nb and (m - 1) 
          dp[i + 1][nb] = (dp[i + 1][nb] + dp[i][b]) % MOD
        }
      }
    }
  }
  var ans = 1L
  for (i in 0 until n) {
    ans = (ans * 10) % MOD
  }
  for (b in 0 until m) {
    ans = (ans - dp[n][b] + MOD) % MOD
  }
  println(ans)
}


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

int main() {
    string S;
    cin >> S;
    vector<string> divide = {"dream", "dreamer", "erase" ,"eraser"};

    reverse(S.begin(), S.end());
    rep(i, divide.size()) reverse(divide.at(i).begin(), divide.at(i).end());

    bool can = true;
    for (int i = 0; i < S.size();) {
        bool can2 = false;
        for (string d : divide) {            
            if (S.substr(i, d.size()) == d) {
                can2 = true;
                i += d.size();
                break;
            }
        }
        if (!can2) {
            can = false;
            break;
        }
    }
    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<algorithm>
using namespace std;
uint64_t sovle(){
    int n;
    cin>>n;
    vector<uint64_t> dp(62,0);
    uint64_t res = 0;
    vector<uint64_t> t(n,0);
    for(int i=0;i<n;i++){
        uint64_t x;
        cin>>x;
        t[i] = x;
        int j = 0;
        while(x){
            dp[j++]+=x%2;
            x/=2;
        }
    }
    const uint64_t MOD = 1e9+7;
    for(int i=0;i<62;i++){
        uint64_t cnt = dp[i];
        cnt = (cnt*(n-cnt))%MOD;
        res = (res+ (cnt * (((uint64_t)1<<i)%MOD))%MOD)%MOD;
    }
    return (res)%MOD;
}


int main(){
    int T = 1;
    while(T--){
        uint64_t re = sovle();
        cout<<re<<endl;
    }
    return 0;
}

Measured memory_bytes: 2560
fun main(args: Array<String>) {
    val readInt = { readLine()!!.toInt() }
    val ai = readInt()
    val bi = readInt()
    val ci = readInt()
    val x = readInt()
    var count = 0
    for (a in 0..ai) {
        for (b in 0..bi) {
            for (c in 0..ci) {
                val sum = a * 500 + b * 100 + c * 50
                if (sum == x) count++
            }
        }
    }
    print(count)
}

Measured memory_bytes: 31612
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
double x, w, h, n, r, min_r, t;
while(cin>>x>>w>>h, x||w||h){
t = max(max(x, w), h);
min_r = x*x+w*w+h*h-t*t;
cin>>n;
while(n--){
cin>>r;
r =r*r*4;
min_r<r ? cout<<"OK\n" : cout<<"NA\n";
}
} 
return 0;
} 

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main()
{
	char s[11];
	
	for(int i=0;i<10;i++){
		cin >> s[i];
	}
	
	for(int i=0;i<10;i++){
		if(s[i]=='1')s[i]=1;
		else if(s[i]=='2')s[i]=2;
		else if(s[i]=='3')s[i]=3;
		else if(s[i]=='4')s[i]=4;
		else if(s[i]=='5')s[i]=5;
		else if(s[i]=='6')s[i]=6;
		else if(s[i]=='7')s[i]=7;
		else if(s[i]=='8')s[i]=8;
		else if(s[i]=='9')s[i]=9;
		else if(s[i]=='0')s[i]=0;
	}
	
	if( 2020 > s[0]*1000 + s[1]*100 + s[2]*10 +s[3]){
		if(5 > s[5]*10 + s[6]){
			if(31 >s[8]*10 + s[9]){
					cout << "Heisei" << endl;
			}
			else cout << "TBD" << endl;
		}
		else cout << "TBD" << endl;
	}
	else cout << "TBD" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/c++io.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <vector>
using namespace std;

int main()
{
string s;int x=0,y=0;
cin>>s;
for(int i=0;i<s.size();i++)
{
    if(s[i]=='A')
    {
         x=i;
    break;
    }


}

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

cout<<abs(y-x)+1<<endl;
}


Measured memory_bytes: 3664
K = int(input())
ans = 1
count = 1
m = 10
if K%7 == 0:
  K //= 7
for j in range(K):
  if count % K == 0:
    print(ans)
    exit()
  else:
    count = (count + m)%K
    m = m*10%K
    ans += 1
print(-1)

Measured memory_bytes: 63248
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
int main() {
	string S;
	cin >> S;
	uint64_t sumCount = 0;
	uint64_t countW = 0;
	for (int k = 0;k < S.length();++k) {
		if (S[k] == 'W'){
			sumCount += countW;			
		}
		else {
			++countW;
		}
	}
	cout << sumCount << endl;
	system("pause");
}

Measured memory_bytes: 832
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
using namespace std;
const int N=1e6+10;
const int M=1e9+7;

int a[N];
int n;
int main(){Accel
	cin>>n;
	FOR(i,1,n)
		cin>>a[i];
		
	int r=n+1,l=n-1;
	LL xr=a[n],sm=a[n],ans=0;
	while(r>2){
		xr^=a[r];
		sm-=a[r];r--;
		while(l>=1&&sm+a[l]==(xr^a[l])){
			sm+=a[l];
			xr^=a[l];
			l--;
		}
		ans+=r-l-1;
		//cout<<l<<" "<<r<<endl;
	}
	cout<<ans+n<<endl;
}

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

#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main()
{
    int d;
    ll g;
    cin >> d >> g;
    int counter = (1<<d);
    vector<int> p(d+1);
    vector<int> c(d+1);
    for (int i = 1; i < d+1; i++)
    {
        cin >> p[i] >> c[i];
    }
    vector<int> bit(d);
    int ans = INF;
    rep(i, counter+1)
    {
        ll score = 0;//tempがgより大かどうか
        int temp_ans = 0;
        int prob = INF;
        int rest_max = -1;
        rep(j,d)
        {
            if((i >> j)&1)
            {
                score += 100*(j+1)*p[j+1]+c[j+1];
                temp_ans += p[j+1];
                continue;
            }
            rest_max = j;
        }
        if(score < g)
        {
            int s1 = 100*(rest_max+1);
            int need = ((g-score-1)/s1)+1;
            if(need>=p[rest_max+1])continue;
            temp_ans += need;
        }
        ans=min(ans, temp_ans);
    }
    cout << ans << endl;
}

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

signed main(){
    int N;cin>>N;
    vector<tuple<int,int,int>> V;
    REP(i,N){
        int x,y,h;
        cin>>x>>y>>h;
        V.push_back(tie(h,x,y));
    }
    sort(rbegin(V),rend(V));
    REP(cx,101) REP(cy,101){
        int h,x,y;
        tie(h,x,y) =V[0];
        int H=h+llabs(x-cx)+llabs(y-cy);
        bool ok=true;
        REP(i,N-1){
            tie(h,x,y)=V[i+1];
            if(max(H-llabs(x-cx)-llabs(y-cy),0LL)!=h)ok=false;
        }
        if(ok){
            cout<<cx<<" "<<cy<<" "<<H<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    int a[10];
    FOR(i,1,5){
        int x; cin >> x;
        if(x == 0) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
    ll W, H, x, y;
    double S;
    cin >> W >> H >> x >> y;

    S = (double)W*H/2.0;

    if (x == (double)W/2.0 && y == (double)H/2.0) {
        printf("%.6f %d\n", S, 1);
    } else {
        printf("%.6f %d\n", S, 0);
    }
}


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

using namespace std;
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
ll sum(ll n){

return ((n*(n+1))/2);

}
int main(){

fast();

int a,b;
cin>>a>>b;

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

return 0;
}



Measured memory_bytes: 3128
n=int(input())
s=list(input())
over=0
left=0
right=0
center=""
for i in s:
    if over==0 and i==")":
        left+=1
    elif over!=0 and i==")":
        over-=1
    else:
        over+=1
    center+=i
right=over
print("("*left+center+")"*right)

Measured memory_bytes: 3064
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>
#include <ratio>

#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n"
#define MOD 998244353

const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;

using namespace std;

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

    vector<int> a(n), b(n), c(n);

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

    vector<int> dp_a(n), dp_b(n), dp_c(n);

    dp_a[0] = a[0];
    dp_b[0] = b[0];
    dp_c[0] = c[0];

    for(int i = 1; i < n; i++)
    {
        dp_a[i] = max(dp_b[i - 1], dp_c[i - 1]) + a[i];
        dp_b[i] = max(dp_a[i - 1], dp_c[i - 1]) + b[i];
        dp_c[i] = max(dp_a[i - 1], dp_b[i - 1]) + c[i];
    }

    cout << max(max(dp_a[n - 1], dp_b[n - 1]), dp_c[n - 1]) << "\n";
}

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

    int T = 1;
    //cin >> T;

    while (T--)
    {
        solve();
    }

    return 0;
}



Measured memory_bytes: 5540
#!/usr/bin/env python
# coding: utf-8

# In[41]:


A,B,K = map(int, input().split())


# In[42]:


ans = []
for x in range(A, min(A+K,B+1)):
    ans.append(x)
for x in range(max(A,B-K+1), B+1):
    ans.append(x)
for x in sorted(list(set(ans))):
    print(x)


# In[ ]:






Measured memory_bytes: 3060
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i32,
        b: i32,
        c: i32,
        d: i32,
    }
    let mut ans = if a>=b{
        b
    } else{
        a
    };
    ans = ans + if c>=d{
        d
    } else{
        c
    };
    println!("{}",ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);++i)
#define reps(i,n) for(int i = 1;i <= (n);++i)
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a + b > c + d) cout << "Left\n";
  else if(a + b < c + d) cout << "Right\n";
  else cout << "Balanced\n";
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

import java.util.List;
import java.util.ArrayList;
import java.util.Collections;

class Main {
    public static boolean[] toBits(int number, int length) {
        boolean[] bits = new boolean[length];
        for (int i = 0; i < length; i++) {
            bits[length-1-i] = (1 << i & number) != 0;
        }
        return bits;
    }

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

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

        List<List<Integer>> bulbs = new ArrayList<>();

        for (int i = 0; i < M; i++) {
            List<Integer> bulb = new ArrayList<>();

            int K = sc.nextInt();
            for (int j = 0; j < K; j++) {
                bulb.add(sc.nextInt()-1);
            }

            bulbs.add(bulb);
        }

        // System.out.println(bulbs.toString());

        int[] P = new int[M];
        for (int i = 0; i < M; i++) {
            P[i] = sc.nextInt();
        }

        int answer = 0;
        for (int i = 0; i < (int)Math.pow(2, N); i++) {
            boolean[] bits = toBits(i, N);

            boolean allOn = true;
            for (int j = 0; j < M; j++) {
                int num = 0;
                for (Integer sw : bulbs.get(j)) {
                    if (bits[sw]) { num++; }
                }
                if (num % 2 != P[j]) {
                    allOn = false;
                    break;
                }
            }

            if (allOn) { answer++; }
        }

        System.out.println(answer);
    }
}


Measured memory_bytes: 23764
from sys import stdin
from copy import deepcopy
import queue

class Dice:
    def __init__(self, nums):
        self.labels = [None] + [ nums[i] for i in range(6) ]
        self.pos = {
            "E" : 3,
            "W" : 4,
            "S" : 2,
            "N" : 5,
            "T" : 1,
            "B" : 6
        }

    def rolled(dice, queries):
        d = deepcopy(dice)
        for q in queries:
            if q == "E":
                d.pos["T"], d.pos["E"], d.pos["B"], d.pos["W"] = d.pos["W"], d.pos["T"], d.pos["E"], d.pos["B"]
            elif q == "W":
                d.pos["T"], d.pos["E"], d.pos["B"], d.pos["W"] = d.pos["E"], d.pos["B"], d.pos["W"], d.pos["T"]
            elif q == "S":
                d.pos["T"], d.pos["S"], d.pos["B"], d.pos["N"] = d.pos["N"], d.pos["T"], d.pos["S"], d.pos["B"]
            elif q == "N":
                d.pos["T"], d.pos["S"], d.pos["B"], d.pos["N"] = d.pos["S"], d.pos["B"], d.pos["N"], d.pos["T"]
        else:
            return d

nums = [int(x) for x in stdin.readline().rstrip().split()]
q = int(stdin.readline().rstrip())
dice = Dice(nums)

# TとSに対応するクエリを記憶し, resをすぐに呼び出せるようにする
memo = [[False] * 7 for i in range(7)]
memo[dice.pos["T"]][dice.pos["S"]] = ""

# クエリとさいころの東面を記憶
res = { "" : dice.labels[dice.pos["E"]] }

# BFSで探索, 解を求めたらreturn Trueで抜け出す
# diceの中身をいじってはならない
def solve(T, S):
    if isinstance(memo[T][S], str):
        return memo[T][S]

    que = queue.Queue()
    que.put(dice)
    sol_q = ["E", "N", "S", "W"]
    
    while not que.empty():
        d = que.get()
        if d.pos["T"] == T and d.pos["S"] == S:
            break
        else:
            for i in sol_q:
                d_next = Dice.rolled(d, i)
                if memo[d_next.pos["T"]][d_next.pos["S"]] == False:
                    que.put(d_next)
                    memo[d_next.pos["T"]][d_next.pos["S"]] = memo[d.pos["T"]][d.pos["S"]] + i
                    res[memo[d_next.pos["T"]][d_next.pos["S"]]] = d_next.labels[d_next.pos["E"]]
    else:
        return memo[T][S]

for i in range(q):
    ts = [int(x) for x in stdin.readline().rstrip().split()]
    T = dice.labels.index(ts[0])
    S = dice.labels.index(ts[1])
    
    if solve(T, S) != False:
        print(res[memo[T][S]])


Measured memory_bytes: 7048
#include<iostream>
#include<vector>
#include<iomanip>
#include<string>
#include<string.h>
#include<cctype>
#include<algorithm>
using namespace std;
int main()
{
    int a;
    cin>>a;
    long long res=a+a*a+a*a*a;
    cout<<res;

















    return 0;
}



Measured memory_bytes: 3636
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define int long long
using namespace std;
signed main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	cout << min(A, B) + min(C, D) << endl;
}

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

const int INF = 1<<28;
const int MAXN = 11;

int n;
string a[MAXN], b[MAXN];
string src, dst;
int ans;

string change(const string &s, int k) {
  string t;
  for(int i = 0; i < s.size(); ++i) {
    if(s.substr(i, a[k].size()) == a[k]) {
      t += b[k];
      i += a[k].size() - 1;
    } else {
      t += s[i];
    }
  }
  return t;
}

void rec(string s, int w) {
  if(s == dst) {
    ans = min(ans, w);
    return;
  }
  if(s.size() >= dst.size()) return;
  if(w >= ans) return;
  for(int i = 0; i < n; ++i) {
    string t = change(s, i);
    if(s.size() == t.size()) continue;
    rec(t, w + 1);
  }
}

int main() {
  while(cin >> n && n) {
    for(int i = 0; i < n; ++i) {
      cin >> a[i] >> b[i];
    }
    cin >> src >> dst;
    ans = INF;
    rec(src, 0);
    if(ans == INF) ans = -1;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
import math
a,b,c=map(int,input().split())
x=((a*b*math.ceil(c/2)-a*b*(c//2)))
y=((b*c*math.ceil(a/2)-b*c*(a//2)))
z=((c*a*math.ceil(b/2)-c*a*(b//2)))
print(min([x,y,z]))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)

int main()
{
  int n;
  cin >> n;
  vector<string> s(n);
  int cnt = 0;
  rep(i, n)
  {
    cin >> s[i];
  }
  sort(s.begin(), s.end());
  rep(i, n)
  {
    if (s[i] != s[i + 1])
      cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 9600
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

int A, B, C;

int solve(){
  int a1, b1, c1, a2, b2, c2, a3, b3, c3;
  a1 = a2 = a3 = A;
  b1 = b2 = b3 = B;
  c1 = c2 = c3 = C;
  
  int res1 = 0, res2 = 0, res3 = 0;
  
  int minus1 = min(a1, min(b1, c1));
  a1 -= minus1, b1 -= minus1, c1 -= minus1;
  res1 += minus1;
  
  res1 += a1 / 3;
  res1 += b1 / 3;
  res1 += c1 / 3;
  

  res2 += a2 / 3;
  res2 += b2 / 3;
  res2 += c2 / 3;
  
  a2 %= 3;
  b2 %= 3; 
  c2 %= 3;
  
  int minus2 = min(a2, min(b2, c2));
  res2 += minus2;
  
  
  int minus3 = min(a3, min(b3, c3));
  if(minus3 > 0) minus3--;
  a3 -= minus3, b3 -= minus3, c3 -= minus3;
  res3 += minus3;
  
  res3 += a3 / 3;
  res3 += b3 / 3;
  res3 += c3 / 3;
  
  //cout << "res1 = " << res1 << ", res2 = " << res2 << endl;
  
  return max(res1, max(res2, res3));
}

int main(){
  int Math, Greedy, Geometry, DP, Graph, Other;
  while(cin >> Math >> Greedy >> Geometry >> DP >> Graph >> Other){
    //if(!Math && !Greedy && !Geometry && !DP && !Graph && !Other) break;
    if(Math == 0 && Greedy == 0 && Geometry == 0 && DP == 0 && Graph == 0 && Other == 0) break;
    
    A = Math + DP;
    B = Greedy + Graph;
    C = Geometry + Other;
    
    //cout << "A = " << A << ", B = " << B << ", C = " << C << endl;
    int ans = solve();
    cout << ans << endl;

  }      
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
vector<int> v[405];
int in[405];
int vis[405];
int sum=0;
void dfs(int x){
    if(vis[x])return ;
    vis[x]=1;
    sum+=v[x].size();
    for(auto it:v[x]){
        dfs(it);
    }
}
int main(){
    int n,h;
    scanf("%d %d",&n,&h);
    for(int i=0;i<n;i++){
        int a,b,c,d;
        scanf("%d %d %d %d",&a,&b,&c,&d);
        int x,y;
        if(c==0){
            x=2*a;
        }
        else{
            x=2*c+1;
        }
        if(d==0){
            y=2*b+1;
        }
        else{
            y=2*d;
        }
       // printf("%d %d\n",x,y);
        v[x].pb(y);
        in[y]++;
    }
    vector<int> st,out;
    for(int i = 2;i<=2*h+1;i++){
        if(v[i].size()>in[i]){
            //if(v[i].size()-in[i]==1)
            st.pb(i);
           // else{
            //    printf("NO\n");
            //    return 0;
            //}
        }
        if(v[i].size()<in[i]){
            //if(in[i]-v[i].size()==1)
            
            out.pb(i);
            //else{
            //    printf("NO\n");
            //    return 0;
            //}
        }
    }
    /*printf("?\n");
    for(auto it:st)
    printf("%d ",it);
    printf("\n");*/
    for(auto it:st){
        if(it%2==1){
            printf("NO\n");
            return 0;
        }
    }
    for(auto it:out){
        if(it%2==0){
            printf("NO\n");
            return 0;
        }
    }
  /*  if(st.size()!=1||st[0]%2==1){
        printf("NO\n");
        return 0;
    }
   // printf("!\n");
    if(out.size()!=1||out[0]%2==0){
        printf("NO\n");
        return 0;
    }*/
    for(auto it:st)
    dfs(it); 
   // printf("!\n");
    if(sum!=n){
        printf("NO\n");
    }
    else{
        printf("YES\n");
    }

}
/*
2 6
5 7
7 5
4 3
6 4
7 3
6 5
5 7
3 6
4 7
*/
//a+a+1=10a+1
//3a+2=10a+2

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace ConsoleApplication2
{
    class Program
    {
        public static string GetResult(int[] data)
        {
            if((data[0] == -1) ||
               (data[1] == -1))
            {
                return "F";
            }

            int sum = data[0] + data[1];
            if (sum >= 80)
            {
                return "A";
            }
            else if (sum >= 65)
            {
                return "B";
            }
            else if (sum >= 50)
            {
                return "C";
            }
            else if (sum >= 30)
            {
                return data[2] >= 50 ? "C" : "D";
            }
            else 
            {
                return "F";
            }
        }

        static void Main(string[] args)
        {
            string line = null;
            while ((line = Console.ReadLine()) != null)
            {
                int[] data = line
                    .Split(' ')
                    .Select(x => int.Parse(x))
                    .ToArray();
                bool isFinished = (data[0] == -1) && (data[1] == -1) && (data[2] == -1);
                if (isFinished)
                    break;
                Console.WriteLine(GetResult(data));
            }
        }
    }
}

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

int main(){
    string s,t;
    cin >> s >> t;
    map<char, vector<int>> mp1;
    map<char, bool> ed;
    map<char, vector<int>> mp2;
    rep(i,s.length()){
        mp1[s[i]].push_back(i);
        mp2[t[i]].push_back(i);
        ed[s[i]]=false;
    }
    vector<char> v;
    

    rep(i,s.length()){
        if(ed[s[i]]) continue;
        ed[s[i]]=true;
        if(mp1[s[i]]!=mp2[t[i]]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 2824
//
// ABC087B: Coins
//
//

#include <iostream>
using namespace std;

const int nMax=50;

int main() {
	int A,B,C,X;
	cin >>A >> B >> C >> X;

	int count1=0;
	for(int a=0; a<=A; a++)
		for(int b=0; b<=B; b++)
			for(int c=0; c<=C; c++)
				if( a*500 + b*100 + c*50 == X) count1++;

	cout << count1 << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
//#define int long long
using namespace std;
const int N=2e5+10;
int n,a[N],res[N],mx[N<<2],m;
vector<int> g[N],v;
inline void add(int a,int b){g[a].push_back(b),g[b].push_back(a);}
#define mid (l+r>>1)
void change(int p,int l,int r,int x,int v){
	if(l==r){mx[p]=v;	return ;}
	if(x<=mid)	change(p<<1,l,mid,x,v);
	else change(p<<1|1,mid+1,r,x,v);
	mx[p]=max(mx[p<<1],mx[p<<1|1]);
}
int ask(int p,int l,int r,int ql,int qr){
	if(ql>qr)	return 0;
	if(l==ql&&r==qr)	return mx[p];
	if(qr<=mid)	return ask(p<<1,l,mid,ql,qr);
	else if(ql>mid)	return ask(p<<1|1,mid+1,r,ql,qr);
	else return max(ask(p<<1,l,mid,ql,mid),ask(p<<1|1,mid+1,r,mid+1,qr));
}
void dfs(int x,int fa){
//	cout<<"x = "<<x<<endl;
	int pre=ask(1,1,m,a[x],a[x]);
	int val=max(ask(1,1,m,1,a[x]-1)+1,pre);
	res[x]=max(res[fa],val);	change(1,1,m,a[x],val);
//	puts("__________________________");
//	for(int i=1;i<=m;i++)	cout<<ask(1,1,m,i,i)<<' ';puts("");
//	puts("__________________________");
	for(auto to:g[x])	if(to!=fa)	dfs(to,x);
	change(1,1,m,a[x],pre);
	
//	cout<<"break = "<<x<<endl;
//	puts("__________________________");
//	for(int i=1;i<=m;i++)	cout<<ask(1,1,m,i,i)<<' ';puts("");
//	puts("__________________________");
}
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++)	scanf("%d",&a[i]),v.push_back(a[i]);
	for(int i=1,a,b;i<n;i++)	scanf("%d %d",&a,&b),add(a,b);
	sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end()); m=v.size();
	for(int i=1;i<=n;i++)	a[i]=lower_bound(v.begin(),v.end(),a[i])-v.begin()+1;
	dfs(1,1);	
	for(int i=1;i<=n;i++)	printf("%d\n",res[i]);
	return 0;
}


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

int main() {
  int n, s, b1, b2;
  cin >> n >> b1;
  s = b1;
  for(int i = 1;i < n-1;i++) {
    cin >> b2;
    s += min(b1, b2);
    b1 = b2;
  }
  s += b1;
  cout << s << endl;
}

Measured memory_bytes: 3596
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int h, w, k; cin >> h >> w >> k;
    vector<string> cake(h);
    rep(i, h) cin >> cake[i];

    vector<vector<int>> cut(h, vector<int>(w));
    int num = 0;
    rep(x, w){
        bool ichigo = false;
        rep(i, h) if(cake[i][x] == '#') ichigo = true;
        if(ichigo){
            num++;
            int cnt = 0;
            rep(i, h){
                if(cake[i][x] == '#'){
                    cnt++;
                    if(cnt >= 2) num++;
                }
                cut[i][x] = num;
            }
        }else{
            rep(i, h) cut[i][x] = 0;
        }
    }

    vector<int> val(h); int last = -1;
    rep(x, w){
        if(cut[0][x] != 0){
            rep(i, h) val[i] = cut[i][x];
            rep(i, h){
                for(int j=last+1; j<x; j++){
                   cut[i][j] = val[i];
                }
            }
            last = x;
        }
    }
    if(last != w-1){
        rep(i, h){
            for(int j=last+1; j<w; j++) cut[i][j] = val[i];
        }
    }

    rep(i, h){
        rep(j, w){
            cout << cut[i][j];
            if(j<w-1) cout << " ";
        }
        cout << ln;
    }
}

Measured memory_bytes: 1280
loop do
  line = gets.chomp.split
  h = line[0].to_i
  w = line[1].to_i

  break if h == 0 && w == 0

  for i in 1..h
    for j in 1..w
      if i == 1 || i == h || j == 1 || j == w
        print '#'
      else
        print '.'
      end
    end
    puts
  end

  puts
end

Measured memory_bytes: 6108
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		
		int ans = 0;
		
		while (true) {
			int a = Integer.parseInt(scan.next());
			String op = scan.next();
			int b = Integer.parseInt(scan.next());
			
			if (op.equals("?")) {
				break;
			} else if (op.equals("+")) {
				ans = a + b;
			} else if (op.equals("-")) {
				ans = a - b;
			} else if (op.equals("*")) {
				ans = a * b;
			} else if (op.equals("/")) {
				ans = a / b;
			}
			
			System.out.println(ans);
		}
		
	}
}

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


int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for(int i=0; i<=9; i++){
        for(int j=0; j<=9; j++){
            for(int k=0; k<=9; k++){
                int status = 0;
                for(int l=0; l<n; l++){
                    if(status==0 && s[l]==char('0'+i)){
                        status++;
                    }
                    else if(status==1 && s[l]==char('0'+j)){
                        status++;
                    }
                    else if(status==2 && s[l]==char('0'+k)){
                        ans++;
                        break;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3692
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
 
const long long mod =1000000007;

long long ppow(long long x, long long y){
    long long z;
    z = 1;
    long long i;
    for(i = 0; i < y; i ++){
        z = z * x%mod;
    }
    return z;
}

int main() {
    long long n;
    scanf("%lld", &n);
    long long a =(ppow(10, n)  - ppow(9, n) - ppow(9, n) + ppow(8, n))% mod;
    a = (a + mod)%mod;
    printf("%lld", a);
    return 0;
}


Measured memory_bytes: 1736