akhauriyash/Code-Regression huggingface dataset:
import bisect
n = int(input())
l = []
for _ in range(n):
    l.append(int(input()))

dp = [float('inf')]*n
# print()
for num in l:
    i = bisect.bisect_left(dp,num)
    # print(i)
    dp[i] = num
# print(dp)
for j in range(n):
    if dp[j] == float('inf'):
        print(j)
        exit()
print(n)


Measured memory_bytes: 10472
#include <cmath>
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>

int main(){
  long long N,T;
  std::cin >> N >> T;
  std::vector<std::tuple<long long, long long>> AB_arr;
  for(int i = 0; i < N; i++){
    long long A,B;
    std::cin >> A >> B;
    AB_arr.emplace_back(A,B);
  }

  std::sort(AB_arr.begin(), AB_arr.end());

  long long dp[3001][3001] = {};

  for(int i = 0; i < N; i++){
    long long A,B;
    std::tie(A,B) = AB_arr[i];
    for(int j = 0; j < T; j++){
      if(j-A < 0){
        dp[i+1][j] = dp[i][j];
      }else{
        dp[i+1][j] = std::max(dp[i][j], B+dp[i][j-A]);
      }
    }
  }

  long long tmax = dp[N][T-1];
  long long bmax = 0;
  for(int i = N-1; i >= 0; i--){
    bmax = std::max(bmax, std::get<1>(AB_arr[i]));
    tmax = std::max(tmax, dp[i][T-1]+bmax);
  }

  std::cout << tmax << std::endl;

  return 0;
}



Measured memory_bytes: 70656
#include<stdio.h>
#include <iostream>
#include<string>
#include<algorithm>
#include<sstream>
#include<math.h>
#include<queue>
#include<stack>
#include<list>
#include<vector>
#include<map>
#include<set>
#define FOR(i,a) for(int i=0;i<a;i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define ll long long
using namespace std;
string a;
string b;
int main() {
	cin >> a >> b;
	sort(a.begin(), a.end());
	sort(b.begin(), b.end(),greater<char>());
	if (a < b)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(void){
    double x1, x2, y1, y2;
    scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);
    printf("%lf", sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
    return 0;
}


Measured memory_bytes: 2080
#include <iostream>
#include <algorithm>
#include <utility>
#include <fstream>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <cmath>
#include <queue>

using namespace std;
using ll = long long;
using ull = unsigned long long;

//const double PI = acos(-1);



int main() {
    int n, ans = 0, x, mx;
    cin >> n >> x;
    mx = x;
    ans++;
    for (int i = 0; i < n - 1; i++) {
        cin >> x;
        if (x >= mx) {
            ans++;
            mx = x;
        }
    }
    cout << ans;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        String D = sc.nextLine();
        int n = S.length();
        D = D.substring(0, n);
        if (S.equals(D)) {
        	System.out.println("Yes");
        }else {
        	System.out.println("No");

        }

	}
}


Measured memory_bytes: 35800
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
 
int main(void){
    ll n;
    cin >> n;
    vector<ll> L;
    for(ll i=0; i<n; i++){
        ll x; cin >> x;
        L.push_back(x);
    }
 
    sort(L.begin(), L.end());
 
    ll ans = 0;
    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            ll c = L[i];
            ll b = L[j];

            ll ng_1 = j+1;
            ll ng_2 = L.end()-lower_bound(L.begin(), L.end(), c+b);

            ans += (n - ng_1 - ng_2);
        }
    }
 
    cout << ans;
    return 0;
}
// それぞれの探索で使える範囲を決めといたらだぶりなく数えられる

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };



signed main() {
	vector<int>list(3, 0);

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

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

	cout << list[0] + list[1] << endl;



	getchar();
	getchar();
	return 0;
}

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

using namespace std;
using ll = long long;


int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> fs(n + 1), bs(n + 1);
	for(int i = 0; i < n; i++)cin >> a[i];
	for(int i = 0; i < n; i++)fs[i + 1] = __gcd(fs[i], a[i]);
	for(int i = n; i >= 1;i--)bs[i - 1] = __gcd(bs[i], a[i - 1]);
	int nax = 0;

	for(int i = 0; i < n; i++) {
		nax = max(nax, __gcd(fs[i], bs[i + 1])); 
	//	cerr << __gcd(fs[i], bs[i + 1]) << endl;
	}
	cout << nax << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Test | diff Test.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Test.cpp && ./a.out

/*
 
 4/22/2020
 
 9:39-
 
 */

void solve() {
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  string S; cin>>S;
  int N=SZ(S);
  
  VI cnt(26);
  REP(i,N) cnt[S[i]-'a']++;
  LL x=0;
  REP(i,26) if(cnt[i]>1) {
    x+=(LL)cnt[i]*(cnt[i]-1)/2;
  }
  LL sum=(LL)N*(N-1)/2+1-x;
  cout<<sum<<endl;
  
/*  map<string,II> ss;
  ss[S]={0,0};
  int cnt=0;
  REP(i,N)FORE(j,i+2,N) {
    ++cnt;
    string x=S;
    reverse(x.begin()+i,x.begin()+j);
    if(ss.count(x)) {
      dump(i,j,x,ss[x].first,ss[x].second);
    } else {
      ss[x]={i,j};
    }
  }
  dump(cnt,SZ(ss));*/
  return 0;
}


Measured memory_bytes: 720
n = int(input())

l = [0 for _ in range(81)]
for k in range(1, n + 1):
    i = int(str(k)[0])
    j = int(str(k)[-1])
    if i != 0 and j != 0:
        idx = 9 * (i - 1) + (j - 1)
        l[idx] += 1
    # print("k = " + str(k))
    # print(i, j, idx)
ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        idx = 9 * (i - 1) + (j - 1)
        idx2 = 9 * (j - 1) + (i - 1)
        ans += l[idx] * l[idx2]
        # print("(" + str(i) + str(j) + ") * (" + str(j) + str(i) + ") = " + str(l[idx]) + "*" +  str(l[idx2]) + " = " +  str(l[idx] * l[idx2]))
# print(l)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

ll		cmb(int n)
{
	ll ret = (ll)n * (n-1) / 2;
	return (ret);
}

int		main(void)
{
	map<string, int> S;
	int N;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		string tmp;
		cin >> tmp;
		sort(all(tmp));
		if (S.count(tmp))
			S[tmp]++;
		else
			S[tmp] = 1;
	}
	ll ans = 0;
	for (auto p : S)
		ans += cmb(p.second);
	cout << ans << endl;
}



Measured memory_bytes: 11136
n,d=map(int,input().split())
x=[list(map(int,input().split())) for _ in range(n)]
m=0
for i in range(n):
    for j in range(i+1,n):
        if i==j:continue
        c=0
        for k in range(d):
            c+=(x[i][k]-x[j][k])**2
        c=c**0.5
        if c.is_integer():
            m+=1
print(m)


Measured memory_bytes: 38484
$c=<>=~$";($\+=($_[$_-1]-$_[-$_])*$c)%=$%=1e9+7,$c=$c*$_%$%*($i[$j]=$j++?$%-($%/$j|0)*$i[$%%$j]%$%:1)%$%for$'..(@_=sort{$a-$b}glob<>);print

Measured memory_bytes: 31728
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

const inf = math.MaxInt64
const size = 100000000

var a, b, c, d int
var dp map[int]int

func solve(n int) int {
	if n == 0 {
		return 0
	}
	if n == 1 {
		return d
	}
	// out(n)
	if dp[n] != 0 {
		return dp[n]
	}
	// out(n)
	var r, x int
	r = n % 5
	x = n - r
	ret := solve(x/5) + c + d*r
	if x != n && x != 0 {
		x += 5
		ret = min(ret, solve(x/5)+c+(5-r)*d)
	}

	r = n % 3
	x = n - r
	ret = min(ret, solve(x/3)+b+d*r)
	if x != n && x != 0 {
		x += 3
		ret = min(ret, solve(x/3)+b+(3-r)*d)
	}
	r = n % 2
	x = n - r
	ret = min(ret, solve(x/2)+a+d*r)
	if x != n && x != 0 {
		x += 2
		ret = min(ret, solve(x/2)+a+(2-r)*d)
	}

	if n*d/d == n {
		ret = min(ret, n*d)
	}
	dp[n] = ret
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	T := getInt()
	for i := 0; i < T; i++ {
		n := getInt()
		a, b, c, d = getInt(), getInt(), getInt(), getInt()
		dp = make(map[int]int)
		out(solve(n))
	}
}


Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define for0(n) for(i=0; i<(n); i++)
#define for1(n) for(i=1; i<=(n); i++)


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll _,i,j,n,a,b,e,k,u,t,x=1,m,y,q,f=1,c=0,d=0,l,p,z,o,r,g;
    string ss,s;
    cin>>n;
    if(n>=400&&n<600)cout<<8<<endl;
    else if(n>=600&&n<800)cout<<7<<endl;
    else if(n>=800&&n<1000)cout<<6<<endl;
    else if(n>=1000&&n<1200)cout<<5<<endl;
    else if(n>=1200&&n<1400)cout<<4<<endl;
    else if(n>=1400&&n<1600)cout<<3<<endl;
    else if(n>=1600&&n<1800)cout<<2<<endl;
    else if(n>=1800&&n<2000)cout<<1<<endl;
}



Measured memory_bytes: 3668
x, y = map(int, input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
    print("Yes")
else:
    print("No")

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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
    string ans;
    ans.push_back(S[0]);
    ans.push_back(S[1]);
    ans.push_back(S[2]);
    cout << ans << "\n";
}

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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */

int n, m;
vi cnt(100, 0);
void in(){
    cin >> n >> m;
    rep(i,0,n){
        int t = input();
        rep(i,0,t){
            cnt[input() - 1]++;
        }
    }
}

void solve(){

    int ans = 0;
    rep(i,0,m){
        if(cnt[i] == n) ans++;
    }
    print(ans);


}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 256
#include <stdio.h>



int main(){

    int x, y;
	while(1){
		scanf("%d %d", &x, &y);
		if(x == 0 && y == 0)
		break;
		
		if(x < y){
			printf("%d %d\n", x, y);
			
		}else{
			printf("%d %d\n", y, x);
			
		}
	}	
	return 0;
	
}

Measured memory_bytes: 600
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;
typedef long long ll;

const int    INF = 1000000000;
const int    MOD = 1000000007;
const double EPS = 1e-8;

int nextcomb(int S){
    int x = S & -S;
    int y = S + x;
    S = ((S & ~y) / x >> 1) | y;
    return S;
}

int main(){
    for(int N, M, first = 1; cin >> N >> M && N; first = 0){
        if(!first) cout << endl;

        vector<string> lang(N);
        map<string, int> lang_dic;
        REP(i, N){
            string s; cin >> s;
            lang[i] = s;
            lang_dic[s] = i;
        }

        bool have[30][30] = {};
        for(int i = 0; i < M; i++){
            int K; cin >> K;
            while(K--){
                string s;
                cin >> s;
                have[i][ lang_dic[s] ] = true;
            }
        }

        vector<int> ans;

        bool b[30][30] = {};
        REP(i, N) REP(j, N) REP(k, M)
            b[i][j] |= have[k][i] & have[k][j];

        for(int K = 1; K < 6; K++){
            if(ans.size() > 0) break;
            int S = (1 << K) - 1;
            while(S < 1 << N){
                vector<int> v;
                for(int i = 0; i < N; i++) if(S >> i & 1) v.push_back(i);
                S = nextcomb(S);
                bool ok = true;

                REP(i, M) if(none_of(v.begin(), v.end(), [&](int vi){ return have[i][vi]; })) ok = false;

                if(not ok) continue;

                bool bb[30][30] = {};
                for(auto vi : v) for(auto vj : v) bb[vi][vj] = b[vi][vj];
                for(auto vk : v) for(auto vi : v) for(auto vj : v) bb[vi][vj] |= bb[vi][vk] & bb[vk][vj];

                REP(i, M) REP(j, i){
                    bool talk = false;
                    for(auto vi : v) for(auto vj : v) if(bb[vi][vj] && have[i][vi] && have[j][vj]){
                        goto NEXT;
                    }
                    ok = false;
                    goto NEXT2;

                    NEXT:;
                }

                if(ok) ans = v;
                NEXT2:;

            }
        }
        if(ans.empty()){
            cout << "Impossible" << endl;
            continue;
        }
        cout << ans.size() << endl;
        for(auto ai : ans){
            cout << lang[ai] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
#define int long long int
#define db double
#define ull unsigned long long
#define vii vector <int>
#define pii pair <int, int>
#define fi first
#define se second
#define rep(i,a,n)		for(int i=a;i<n;i++)
#define endl '\n'
#define mem(a,b) memset(a, b, sizeof a)
#define mkp make_pair
#define pb push_back
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
using namespace std;
double pi=3.1415926535;
double eps=0.000001;
int mod=1000000007; 
void print(vector <int> &arr){
	for(int i=0;i<arr.size();i++)
		cout<<arr[i]<<" ";
	
	cout<<endl;
}
int ncr(int n, int r)
{
    r=min(r,n-r);
    int A[r],i,j,B[r];
    iota(A,A+r,n-r+1);  //initializing A starting from n-r+1 to n
    iota(B,B+r,1);      //initializing B starting from 1 to r

    int g;
    for(i=0;i<r;i++)
    for(j=0;j<r;j++)
    {
        if(B[i]==1)
            break;
        g=__gcd(B[i], A[j] );
        A[j]/=g;
        B[i]/=g;
    }
    long long ans=1;
    for(i=0;i<r;i++)
        ans=(ans*A[i]%mod);
    return ans;
}
int32_t main(){
/////////////////////////////////////////////////////////////////////
//	ios_base::sync_with_stdio(false);
//	cin.tie(NULL);
//	cout.tie(NULL);
//	cerr.tie(NULL);
//For fast IO
///////////////////////////////////////////////////////////////////// 
//	std::cout.unsetf ( std::ios::floatfield );  // floatfield not set
//    std::cout.precision(10);
	string s;
  	cin>>s;
  	if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes"<<endl;
  	else cout<<"No"<<endl;
	return 0;
	}

Measured memory_bytes: 256
def combination(n, x, mod=10**9+7):
    # nCx, a=n!, b=x!, c=(n-x)!
    # ex) combination(5, 2) = 10
    _factorial = [1] * (n+1)
    tmp = 1
    for i in range(1, n+1):
        tmp = (tmp * i) % mod
        _factorial[i] = tmp

    tmp = _factorial[n]
    tmp = (tmp * pow(_factorial[x], mod-2, mod)) % mod
    tmp = (tmp * pow(_factorial[n-x], mod-2, mod)) % mod
    return tmp

n, m = map(int, input().split())

if m > 1 and n > 1:
    M = combination(m, 2)
    N = combination(n, 2)
elif m <= 1 and n > 1:
    M = 0
    N = combination(n,2)
elif m > 1 and n <= 1:
    M = combination(m, 2)
    N = 0
else:
    M, N = 0, 0

print(M+N)

Measured memory_bytes: 3064
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]
edges = lines[1].sort

ans = 0
for i in 1..(N-2) do
  for j in (i+1)..(N-1) do
    for k in (j+1)..N do
      if edges[i-1] != edges[j-1] and edges[j-1] != edges[k-1] and edges[k-1] != edges[i-1] then
        if edges[i-1] + edges[j-1] > edges[k-1] then
          ans += 1
        end
      end
    end
  end
end
puts ans

Measured memory_bytes: 14348
#include <cstdio>
#include <vector>
using namespace std;

struct die{
	int top, front, left;

	die(int t, int f, int l): top(t), front(f), left(l) {}

	void north(){
		*this = die(front, 7 - top, left);
	}
	void south(){
		*this = die(7 - front, top, left);
	}
	void east(){
		*this = die(left, front, 7 - top);
	}
	void west(){
		*this = die(7 - left, front, top);
	}
};

int main(){
	int n;
	char cmd[16] = "";

	while(scanf("%d", &n), n){
		die d(1, 5, 3);
		for(int i = 0; i < n; ++i){
			scanf("%s", cmd);
			switch(cmd[0]){
			case 'n':
				d.north();
				break;
			case 'e':
				d.east();
				break;
			case 'w':
				d.west();
				break;
			case 's':
				d.south();
				break;
			}
		}
		printf("%d\n", d.top);
	}
}

Measured memory_bytes: 1032
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


N = int(input())
S = []
for i in range(N):
    S.append(input())

m = sum([name[0] == 'M' for name in S])
a = sum([name[0] == 'A' for name in S])
r = sum([name[0] == 'R' for name in S])
c = sum([name[0] == 'C' for name in S])
h = sum([name[0] == 'H' for name in S])

print(m * (a * (r + c + h) + r * (c + h) + c * h) + a * (r * (c + h) + c * h) + r * c * h)


Measured memory_bytes: 10528
#include <bits/stdc++.h>
#define int long long
#define rint register int
#define fo(i, n) for(rint i = 1; i <= (n); i ++)
#define out(x) cerr << #x << " = " << x << "\n"
#define type(x) __typeof((x).begin())
#define foreach(it, x) for(type(x) it = (x).begin(); it != (x).end(); ++ it)
using namespace std;
// by hjnan
template<typename tp> inline void read(tp &x) {
  x = 0;char c = getchar(); bool f = 0;
  for(; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
  for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if(f) x = -x;
}
int T, a, b, c, d;
map<int, int> mp;
main(void) {
  for(read(T); T --;) {
    read(a); read(b); read(c); read(d);
    mp.clear();
    if(b > d || a < b) puts("No");
    else {
      int ok = 0;
      int p = __gcd(d, b);
      int ta = (a - c) % p + c;
      if(ta == c) ta += p;
      if(ta < b) puts("No");
      else puts("Yes");
    }
  }
}


Measured memory_bytes: 256
module Main where

import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Control.Monad
import Data.List
import Data.Ord

powerset :: [a] -> [[a]]
powerset = filterM (const [True, False])

conv::[[Int]]->[Int]
conv [] = []
conv (x:[]) = x
conv (x:xx:[]) = zipWith (+) x xx
conv (x:xx:xs) = conv ((zipWith (+) x xx):xs)

main :: IO ()
main = do
    [n,m,x] <- map (fst.fromJust.BS.readInt).BS.words <$> BS.getLine
    as <- replicateM n $ map (fst.fromJust.BS.readInt).BS.words <$> BS.getLine :: IO[[Int]]
    -- let n = 3
    -- let m = 3
    -- let x = 10
    -- let as = [[60,2,2,4],[70,8,7,9],[50,2,3,9]]
    -- let ac = powerset as
    let result = sort $ map head $ filter ( \e -> not (null e) && all ( \t -> t >= x ) (tail e)) $ map conv (powerset as)
    putStr $ if null result then "-1" else show (head result)

Measured memory_bytes: 5220
import sys
sys.setrecursionlimit(1000000)
N = int(input())
e = [ [] for i in range(N+1)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    e[u].append((v,w))
    e[v].append((u,w))

col = [ -1 for i in range(N+1)]

def dfs(x,c):
    col[x] = c
    for v,w in e[x]:
        if col[v] == -1:
            dfs(v , c+w)

dfs(1,0)



for i in range(1,N+1):
    print(col[i] % 2)


Measured memory_bytes: 162848
n=int(input())
s=input()
ce=s.count('E')
cw=0
ans=n
for i in range(n):
    if s[i]=='E':
        ce-=1
        ans=min(ans,ce+cw)
    else:
        ans=min(ans,ce+cw)
        cw+=1
print(ans)

Measured memory_bytes: 3676
import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0:
        a, b = b, a % b
    return b

mod = 7 + 10 ** 9

def solve():
    N = int(single_input())
    A = [int(a) for a in line_input()]

    DP = [[0, 1] for i in range(2 ** 20)]
    memo = [0] * (2 ** 20)
    cumulative_xor = 0
    zeros = 0
    for i in range(N):
        cumulative_xor ^= A[i]
        if cumulative_xor == 0: zeros += 1  
        else:
            DP[cumulative_xor][1] += DP[cumulative_xor][0] * (zeros - memo[cumulative_xor])
            DP[cumulative_xor][1] %= mod
            DP[cumulative_xor][0] += DP[cumulative_xor][1]
            DP[cumulative_xor][0] %= mod
            memo[cumulative_xor] = zeros

    if cumulative_xor > 0: print(DP[cumulative_xor][1])
    else:
        ans = pow(2, zeros - 1, mod)
        for i in range(2**20): 
            ans += DP[i][0]
            ans %= mod
        print(ans)
        
    return 0
  
if __name__ == "__main__":
    solve()

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;


int main(void) {
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    int ans = abs(a[0] - x);
    rep(i, n) {
        ans = __gcd(ans, abs(a[i] - x));
    }
    cout << ans << endl;

    return 0;
}


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

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s, t; cin >> s >> t;
    int cnt =0;
    for(int i=0; i<s.size(); ++i)
    {
        if(s[i] != t[i]) cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3800
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <ctype.h>
using namespace std;

typedef long long ll;

int dx[4] = { 0, -1, 1, 0 };
int dy[4] = { -1, 0, 0, 1 };

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int maxval = max(a, max(b, c));
  int res = a + b + c - maxval;
  for (int i = 0; i < k; ++i) {
    maxval *= 2;
  }
  res += maxval;
  cout << res << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

#define endl "\n"

const ll INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);

    int n, k;
    cin >> n >> k;

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

    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < k; ++i)
        ans += a[i];
    cout << ans << endl;
}

Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
   

    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll numal[26] = {};
    for (ll i=0;i<n;i++){
        numal[s[i]-'a']++;
    }
    ll ans = 1;
    for (ll i=0;i<26;i++){
        ans *= numal[i]+1;
        ans %= mop;
    }
    cout << ans-1 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 2001
#define MOD 1000000007
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define RER(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin() v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, k, tree[MAX_N+1], a[MAX_N];

ll sum(ll i){
	ll ret = 0;
	while(i > 0){
		ret += tree[i];
		i -= i & -i;
	}
	return ret;
}

void add(ll i, ll x){
	while(i <= n){
		tree[i] += x;
		i += i & -i;
	}
}

ll rev_solve(){
	ll ans = 0;
	for(ll j=0; j<n; j++){
		ans += j - sum(a[j]);
		add(a[j], 1);
	}
	return ans;
}

ll rev_solve2(){
	ll ans = 0;
	for(ll i=0; i<n-1; i++){
		for(ll j=i+1; j<n; j++){
			if(a[i] > a[j]) ans++;
		}
	}
	return ans;
}


ll ord_solve2(){
	ll ans = 0;
	for(ll i=0; i<n-1; i++){
		for(ll j=i+1; j<n; j++){
			if(a[i] < a[j]) ans++;
		}
	}
	return ans;
}

signed main(){
	cin >> n >> k;
	REP(i, n) cin >> a[i];
	ll ret1 = rev_solve2();
	if(k % 2 == 0){
		ret1 *= k / 2;
		ret1 %= MOD;
		ret1 *= k + 1;
		ret1 %= MOD;
	}else{
		ret1 *= k;
		ret1 %= MOD;
		ret1 *= (k + 1)/2;
		ret1 %= MOD;
	}
	ll ret2 = ord_solve2();
	if(k % 2 == 0){
		ret2 *= k / 2;
		ret2 %= MOD;
		ret2 *= k - 1;
		ret2 %= MOD;
	}else{
		ret2 *= k;
		ret2 %= MOD;
		ret2 *= (k - 1)/2;
		ret2 %= MOD;
	}
	cout << (ret1 + ret2) % MOD << endl;
    return 0;
}

Measured memory_bytes: 256
// AOJ 2447 A Two Floors Dungeon
// 2018.2.2 bal4u

#include <stdio.h>
#include <ctype.h>
#include <string.h>

#define QMAX 800000
typedef struct { short s; char f, r, c; } Q;
Q q[QMAX+10]; int top, end;

int W, H, S;
char map[53][53];
char sw[11][53][53];
int mov[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
int memo[1024][2][53][53];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int check(int s, int f, int r, int c)
{
	int i, g;

    if (map[r][c] == '|') return 1;
    g = map[r][c] == '^' || isupper(map[r][c]);
    for (i = 0; i < S; ++i) if ((s >> i) & 1) g ^= sw[i][r][c];
    return f == g;
}

void enq(int ns, int nf, int nr, int nc, int s, int f, int r, int c)
{
	int k;

	if (memo[ns][nf][nr][nc] >= 0) return;
	memo[ns][nf][nr][nc] = k = memo[s][f][r][c] + 1;
	q[end].s = ns, q[end].f = nf, q[end].r = nr, q[end++].c = nc;
}

int calc(int sr, int sc)
{
	int k, s, f, r, c, nr, nc;

	memset(memo, -1, sizeof memo);
	q[0].s = q[0].f = 0, q[0].r = sr, q[0].c = sc, top = 0, end = 1;
	memo[0][0][sr][sc] = 0;
    while (top != end) {
		if (end >= QMAX) break;
		s = q[top].s, f = q[top].f, r = q[top].r, c = q[top++].c;
		if (map[r][c] == '&') return memo[s][f][r][c];
		if (map[r][c] == '|') enq(s, f ^ 1, r, c, s, f, r, c);
		if (isalpha(map[r][c])) {
			k = tolower(map[r][c]) - 'a';
			enq(s ^ (1 << k), f ^ sw[k][r][c], r, c, s, f, r, c);
        }
        for (k = 0; k < 4; k++) {
            nr = r + mov[k][0], nc = c + mov[k][1];
			if (map[nr][nc] == '#') continue;
			if (!check(s, f, nr, nc)) continue;
			enq(s, f, nr, nc, s, f, r, c);
		}
	}
	return -1;
}

int main()
{
	int i, r, c, sr, sc; 
	char buf[53];

	W = in(), H = in();
	sr = -1;
	for (r = 0; r < H; r++) {
		fgets(map[r], 53, stdin);
		if (sr >= 0) continue;
		for (c = 0; c < W; c++) {
			if (map[r][c] == '%') sr = r, sc = c;
        }
	}

	S = in();
	for (i = 0; i < S; i++) {
		for (r = 0; r < H; r++) {
			fgets(buf, 53, stdin);
			for (c = 0; c < W; c++) {
				if (buf[c] == '*') sw[i][r][c] = 1;
			}
		}
	}
	printf("%d\n", calc(sr, sc));
    return 0;
}


Measured memory_bytes: 28856
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;


#define REP(i, n) for(ll i = 0; i < n; i++)






























int main(){
    ll n;
    cin >> n;
    vector<ll> L(n);
    REP(i, n){
        cin >> L[i];
    }
    sort(L.begin(), L.end());
    ll ans = 0;
    REP(i, n - 2){
        for(ll j = i + 1; j < n - 1; j++){
            for(ll k = j + 1; k < n; k++){
                if(L[i] != L[j] && L[j] != L[k] && L[i] + L[j] > L[k]){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;

  while (n != 0 || x != 0) {
    int sum = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = i + 1; j <= n; j++) {
        if ((x - i - j) <= n && (x - i - j) > j) {
          sum++;
        }
      }
    }
    cout << sum << endl;
    cin >> n >> x;
  }
  return 0;
}



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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

int l, i;
vii adj[22];

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> l;
	for (i = 1; (1 << i) <= l; i++) {
		adj[i-1].emplace_back(i, 0);
		adj[i-1].emplace_back(i, 1 << (i - 1));
	}
	i--;

	for (int j = 0, k = (1 << i); j < i; j++)
		if ((l - (1 << i)) & (1 << j)) {
			adj[j].emplace_back(i, k);
			k += (1 << j);
		}

	int m = 0;
	for (int j = 0; j <= i; j++)
		m += adj[j].size();

	cout << i + 1 << " " << m << endl;
	for (int j = 0; j <= i; j++)
		for (ii &e : adj[j])
			cout << j + 1 << " " << e.fi + 1 << " " << e.se << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
  std::string str;
  std::cin >> str;
  int ans;
  if (str.at(0) == 'R')
  {
    if (str.at(1) == 'R')
    {
      if (str.at(2) == 'R')
      {
        ans = 3;
      }
      else
      {
        ans = 2;
      }
    }
    else
    {
      ans = 1;
    }
  }
  else
  {
    if (str.at(1) == 'R')
    {
      if (str.at(2) == 'R')
      {
        ans = 2;
      }
      else
      {
        ans = 1;
      }
    }
    else
    {
      if (str.at(2) == 'R')
      {
        ans = 1;
      }
      else
      {
        ans = 0;
      }
    }
  }
  std::cout << ans;
  return 0;
}

Measured memory_bytes: 3620
#!/usr/bin/env python3
import copy

H, W = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
grid = [list(map(int, input().split())) for _ in range(H)]

d = dict()
nums = [i for i in range(10) if i != 1]
d["-1_1"] = 0

q = [[[1], 0]]

while q:
    tmp = q.pop()
    num, cost = tmp[0], tmp[1]
    key = str(num[-1]) + "_1"
    if d.get(key):
        d[key] = min(d[key], cost)
    else:
        d[key] = cost
    if len(num) < 10:
        for n in nums:
            num_tmp = copy.copy(num)
            if n not in set(num_tmp):
                num_tmp.append(n)
                q.append([num_tmp, cost + c[num_tmp[-1]][num_tmp[-2]]])

ans = 0
for i in range(H):
    for j in range(W):
        tmp = grid[i - 1][j - 1] 
        ans += d[str(tmp) + "_1"]
print(ans)

Measured memory_bytes: 46300
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

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

  int n; cin >> n;
  vector<int> a(n);
  ll sum = 0;
  rep(i, n) {
    cin >> a.at(i);
    sum += a.at(i);
  }

  ll stone = (ll)n*(n+1)/2;
  if (sum % stone != 0) {
    cout << "NO" << endl;
    return 0;
  }

  ll cnt = sum/stone;

  rep(i, n) {
    ll tmp = a.at(i) + cnt - a.at((i+1)%n);
    if (tmp % n != 0 || tmp < 0) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;

}

Measured memory_bytes: 640
import java.util.*;

class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	List<Double> list = new ArrayList<>();
    	int n = sc.nextInt();
    	double sum = 0;
    	for(int i = 0; i < n; i++) {
    		double m = (double) sc.nextInt();
    		sum+=(1/m);
    	}
    	
    	System.out.println(1/sum);
    }
}

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

int happ(int N)
{
	if(N < 500)
      return (N/5)*5;
  	return 1000*(N/500) + happ(N%500);
}

int main()
{
	int n;
    cin>>n;
    cout<<happ(n);

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
using namespace std;
typedef long long LL;
const int N=4010;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
int ans=1<<30;
char a[N],b[N];
int sum[N],pre[N],suf[N];
inline void work(int n) {
	int i,d,s,t,one,R;
	sum[n]=0;
	for (i=n-1;i>=0;i--) sum[i]=sum[i+1]+(b[i]=='1');

	pre[0]=b[0]=='1'?0:1<<28;
	suf[n]=1<<28;
	for (i=1;i<n;i++) pre[i]=b[i]=='1'?0:pre[i-1]+1;
	for (i=n-1;i>=0;i--) suf[i]=b[i]=='1'?0:suf[i+1]+1;
	for (d=0;d<n;d++) {
		vector< pair<int,int> >pr;
		s=0;
		for (i=0;i<n;i++) {
			t=(i+d)%n;
			if (a[i]==b[t]) continue;
			s++;
			if (a[i]=='1') {
				one=i<=t?sum[i]-sum[t+1]:sum[i]+sum[0]-sum[t+1];
				if (one) continue;
				pr.push_back(make_pair(pre[i]<=(1<<25)?pre[i]:pre[n-1]+i+1,suf[t]<=(1<<25)?suf[t]:suf[0]+n-t));
			}
		}
		pr.push_back(make_pair(0,0));
		sort(pr.begin(),pr.end());
		R=0;
		for (i=pr.size()-1;i>=0;i--) {
			ans=min(ans,(pr[i].first+R)*2+s+d);
			R=max(R,pr[i].second);
		}
	}
}
int main()
{
	int i,n;
	scanf("%s",a);
	scanf("%s",b);
	n=strlen(a);
	for (i=0;i<n;i++) if (b[i]=='1') break;
	if (i==n) {
		for (i=0;i<n;i++) if (a[i]=='1') break;
		if (i<n) return puts("-1"),0;
	}
	work(n);
	reverse(a,a+n);
	reverse(b,b+n);
	work(n);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  string s;
  int cnt=0;
  cin>>s;
  for(int i=0;i<s.size();i++){
   if(s.at(i)=='U') cnt++;
    if(s.at(i)=='D') cnt++;
    if(i%2==0&&s.at(i)=='R') cnt++;
    else if(i%2==1&&s.at(i)=='L') cnt++;
  }
  if(cnt==s.size()) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
    
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9 + 7;

ll gcd(ll x, ll y){
	if(x > y) swap(x, y);
	while(x != 0){
		y %= x;
		swap(x, y);
	}
	return y;
}

int main(){
	ll A, B; cin >> A >> B;
	cout << A*B/gcd(A, B) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <map>

#define P 998244353

using namespace std;

typedef long long ll;

map <ll, ll> F[2];

string operator & (string X, string Y) {
    string Z;
    for(int i = 0; i < X.size(); i++) Z += char('0' + ((X[i] - '0') & (Y[i] - '0')));
    return Z;
}

ll gethsh(string A) {
    ll ans = 0;
    for(int i = 0; i < A.size(); i++) ans = (ans * 131 + A[i]);
    return ans;
}

ll Solve(string A, int op) {
    ll ans = 0;
    if(ans = F[op][gethsh(A)]) return ans;
    if(op == 1) {
        ll ans = 0;
        for(int i = 1; i <= A.size(); i++) ans = (ans + Solve(A.substr(0, i), 0) * Solve(A.substr(i, A.size() - i), 1)) % P;
        return F[op][gethsh(A)] = ans;
    }
    for(int i = 1; i < A.size(); i++) if(A.size() % i == 0) {
        string X = A.substr(0, i);
        for(int j = i; j < A.size(); j += i) X = X & A.substr(j, i);
        ans = (ans + Solve(X, 1)) % P;
    }
    return F[op][gethsh(A)] = ans;
}

int main() {
    string A;
    F[1][gethsh("")] = 1;
    F[0][gethsh("0")] = 1;
    F[0][gethsh("1")] = 2;
    cin >> A;
    printf("%lld\n", Solve(A, 1));
    return 0;
}

Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
if(a%2==0&&b%2==0){
    cout<<"No"<<endl;
}
else if(a%2==0&&b%2!=0){
    cout<<"No"<<endl;
}
else if(a%2!=0&&b%2==0){
    cout<<"No"<<endl;
}
else if(a%2!=0&&b%2!=0){
    cout<<"Yes"<<endl;
}
return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n, val;
    cin >> n;
    vector<int> arr(n, 0);
    for(auto& val: arr) {
        cin >> val;
    }
    int ans = __gcd(arr[0], arr[1]);
    for(int i = 2; i < n; i++)
        ans = __gcd(ans, arr[i]);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 640
#include <iostream>

using namespace std;

int h, w, n, xact, yact, i, j;
int x, M[105][105];

int main()
{
    cin>>h>>w;
    cin>>n;
    xact=1;
    yact=1;
    for (i=1; i<=n; i++)
    {
        cin>>x;
        while (x)
        {
            M[xact][yact]=i;
            x--;
            if (xact%2==1)
            {
                yact++;
                if (yact>w)
                {
                    yact--;
                    xact++;
                }
            }
            else
            {
                yact--;
                if (yact<1)
                {
                    yact++;
                    xact++;
                }
            }
        }
    }
    for (i=1; i<=h; i++)
    {
        for (j=1; j<=w; j++)
            cout<<M[i][j]<<" ";
        cout<<'\n';
    }
    return 0;
}


Measured memory_bytes: 384
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        BufferedReader bu = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        int n = Integer.parseInt(bu.readLine());
        if(n>= 400 && n <= 599)
            sb.append(8);
        else if (n>=600 && n <= 799)
            sb.append(7);
        else if (n>=800 && n<=999)
            sb.append(6);
        else if (n>=1000 && n <= 1199)
            sb.append(5);
        else if (n>=1200 && n<= 1399)
            sb.append(4);
        else if (n>=1400 && n<=1599)
            sb.append(3);
        else if (n>=1600 && n<= 1799)
            sb.append(2);
        else
            sb.append(1);
        System.out.print(sb);
    }
}


Measured memory_bytes: 32612
import java.util.*;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String S = sc.next();
		int a = S.length();
		StringBuilder B = new StringBuilder();
		
		for(int i=0; i<a; i++) {
			B.append("x");
		}
		System.out.println(B);
	}
	}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
template<class T, class Func = function<T(T, T)>>
class segtree {
    vector<T> obj;
    int offset;
    Func updater;
    T e;
    int bufsize(int num) {
        int i = 1;
        for (; num >i; i <<= 1);
        offset = i - 1;
        return (i << 1) - 1;
    }
    T query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l)return e;
        if (a <= l && r <= b)return obj[k];
        else return updater(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
    }
public:
    T query(int a, int b) {//[a,b)
        return query(a, b, 0, 0, offset + 1);
    }
    void updateall(int l = 0, int r = -1) {
        if (r < 0)r = offset + 1;
        l += offset, r += offset;
        do {
            l = (l - 1) >> 1, r = (r - 1) >> 1;
            for (int i = l; i < r; i++)obj[i] = updater(obj[i * 2 + 1], obj[i * 2 + 2]);
        } while (l);
    }
    void update(int k, T a) {
        k += offset;
        obj[k] = a;
        while (k) {
            k = (k - 1) >> 1;
            obj[k] = updater(obj[k * 2 + 1], obj[k * 2 + 2]);
        }
    }
    segtree(int n, T e, const Func &updater = Func()) :obj(bufsize(n), e), e(e), updater(updater) {}
    segtree(vector<T> &vec, T e, const Func &updater = Func()) :obj(bufsize(vec.size()), e), e(e), updater(updater) {
        copy(vec.begin(), vec.end(), obj.begin() + offset);
        updateall();
    }
    typename vector<T>::reference operator[](int n) {
        return obj[n + offset];
    }
};
signed main(){
    int n,q; cin >> n >> q;
    const ll inf = (1LL << 31 ) - 1;
    segtree<int>sgt(n,(ll)inf,[](auto const a,auto const b){
        return min(a,b);
    });
    rep(_,q){
        int isFind,a,b; cin >> isFind >> a >> b;
        if(isFind){
            ++b;
            cout << sgt.query(a,b) << endl;
        } else {
            sgt.update(a,b);
        }
    }
}





Measured memory_bytes: 4964
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<ll, ll>;
using iii = pair<ii, ll>;
#define vt vector
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)
const ll MOD = 1e9 + 7;
const ll INF = 2e9;
const ll N = 1e2 + 5;

ll n, m, temp, ans;
priority_queue<ll> pq;

void solve() {
    cin >> n >> m;
    for(ll i = 1, x; i <= n; i++) {
        cin >> x;
        pq.push(x);
    }
    while(m--) {
        temp = pq.top(); pq.pop();
        pq.push(temp / 2);
    }
    ans = 0;
    while(pq.size()) {
        ans += pq.top(); pq.pop();
    }
    cout << ans << "\n";
}

int main() {
    
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    solve();
    
}

Measured memory_bytes: 4240