akhauriyash/Code-Regression huggingface dataset:
fn main() {
    let s = atcoder::read_single_string();
    let mut cs = s.chars().map(|c| c.to_digit(10).unwrap() ).collect::<Vec<u32>>();
    cs.reverse();

    let mut total: u64 = 0;

    for b in 0..2u32.pow((s.len() - 1) as u32) {
        let mut keta = 1;
        let mut stack = 0;

        for (i, c) in cs.clone().into_iter().enumerate() {
            if (b >> i) & 1 == 1 {
                stack += (c as u64) * keta;
                keta *= 10;
            } else {
                total += stack + (c as u64) * keta;
                stack = 0;
                keta = 1;
            }
        }
    }

    println!("{}", total);
}

#[allow(dead_code)]
mod atcoder {
    pub fn read_single_num<T: ::std::str::FromStr>() -> T
        where <T as ::std::str::FromStr>::Err: ::std::fmt::Debug {
            let mut buffer = String::new();
            ::std::io::stdin().read_line(&mut buffer).unwrap();
            buffer.trim().parse().unwrap()
    }

    pub fn read_multiple_num<T: ::std::str::FromStr>() -> Vec<T>
        where <T as ::std::str::FromStr>::Err: ::std::fmt::Debug {
            let mut buffer = String::new();
            ::std::io::stdin().read_line(&mut buffer).unwrap();
            buffer.split_whitespace().map(|i| i.parse().unwrap() ).collect()
    }

    pub fn read_single_string() -> String {
            let mut buffer = String::new();
            ::std::io::stdin().read_line(&mut buffer).unwrap();
            buffer.trim().to_string()
    }

    pub fn read_multiple_string() -> Vec<String> {
            let mut buffer = String::new();
            ::std::io::stdin().read_line(&mut buffer).unwrap();
            buffer.split_whitespace().map(|s| s.to_string() ).collect()
    }
}


Measured memory_bytes: 380
// g++ -std=gnu++1y -O2 xxx.cpp

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

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

    cout << pow(2, (int)log2(N)) << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
s = input()
for t0, t1 in ("SS", "SW", "WS", "WW"):
    t = [""] * N
    t[0] = t0
    t[1] = t1
    for i in range(2, N):
        if t[i-2] == t[i-1]:
            t[i] = "S" if s[i-1] == "o" else "W"
        else:
            t[i] = "W" if s[i-1] == "o" else "S"
    if t[-2] == t[-1]:
        if t[0] != ("S" if s[-1] == "o" else "W"):
            continue
    else:
        if t[0] != ("W" if s[-1] == "o" else "S"):
            continue
    if t[-1] == t[0]:
        if t[1] != ("S" if s[0] == "o" else "W"):
            continue
    else:
        if t[1] != ("W" if s[0] == "o" else "S"):
            continue
    print("".join(t))
    exit()
print(-1)


Measured memory_bytes: 4852
#include<iostream>
using namespace std;
int main(){
    int N,B=0;
    int X,A=0;
    cin >>N;
    while(B<=N){
        A++;
        X=1;
        for(int i=0;i<A;i++){
                X=X*2;
        }
        B=X;
    }
    X=1;
    for(int i=0;i<A-1;i++){
         X=X*2;
    }
    B=X;
    cout << B <<endl;
    return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}
vector<ll> primes(ll n){
  vector<ll> v(1,1);
  for (ll i = 2; n >= i * i; ++i) {
		if(!(n % i)){
      v.pb(i);
	  }
  }
  if(v.size()==1)v.pb(n);
  return v;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n,m;cin>>n;
  vector<int> v(n);rep(i,n)v[i] = i+1;
  vector<int> a(n),b(n);
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>b[i];
  
  int r,q;
  int cnt = 0;
  do {
    cnt++;
    rep(i,n){
      if(a[i] != v[i])break;
      if(i == n-1)r = cnt;
    }
    
    rep(i,n){
      if(b[i] != v[i])break;
      if(i == n-1)q = cnt;
    }
  } while( next_permutation(v.begin(), v.end()) ); 
  print(abs(r-q));
  return 0;
} 

Measured memory_bytes: 256
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in1(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in1(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int N;
    in1(N);

    ll ans = 0;

    repse(c, 1, N)
    {
        int x = N - c;

        for (int i = 1; i * i <= x; i++)
        {
            if (x % i == 0)
            {
                ans++;
                if (x / i != i) ans++;
            }
        }
    }

    outl(ans);

    return 0;
}


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

struct RollingHash {
  long long Mod[2], Base[2];
  long long ssize, maxssize;
  string s;
  vector<long long> pow[2];
  vector<long long> hash[2];
  RollingHash(string inis = "") {
    Mod[0] = 1000000007;
    Mod[1] = 1000000009;
    Base[0] = 1009;
    Base[1] = 1007;
    maxssize = inis.size() + 10;
    for(int t = 0; t < 2; ++t) {
      pow[t].assign(maxssize, 0);
      pow[t][0] = 1;
      for(int i = 1; i < maxssize; ++i)
        pow[t][i] = pow[t][i - 1] * Base[t] % Mod[t];
    }
    init(inis);
  }
  void init(string inis = "") {
    s = inis;
    ssize = s.size();
    sethash();
  }
  void sethash() {
    ssize = s.size();
    for(int t = 0; t < 2; ++t) {
      hash[t].assign(ssize + 1, 0);
      for(int i = 0; i < ssize; ++i) {
        if(i != 0)
          hash[t][i + 1] = hash[t][i] * Base[t] % Mod[t];
        hash[t][i + 1] += s[i];
        hash[t][i + 1] %= Mod[t];
      }
    }
  }
  // [l,r),0-indexed
  pair<long long, long long> calchash(int l, int r) {
    long long ans[2];
    for(int t = 0; t < 2; ++t) {
      ans[t] = hash[t][r];
      ans[t] -= hash[t][l] * pow[t][r - l] % Mod[t];
      while(ans[t] < 0) ans[t] += Mod[t];
      ans[t] %= Mod[t];
    }
    return make_pair(ans[0], ans[1]);
  }
};

long long n, m, l = 0, r = 1;
string s, q;
RollingHash rh;
set<pair<long long, long long>> st;

long long solve();

int main() {
  cin >> n >> m >> s;
  rh = RollingHash(s);
  for(int i = 0; i < m; ++i) {
    cin >> q;
    if(q == "L++")
      ++l;
    else if(q == "L--")
      --l;
    else if(q == "R++")
      ++r;
    else
      --r;
    st.insert(rh.calchash(l, r));
  }

  cout << st.size() << endl;
  return 0;
}


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

dic = {}
for i in range(n):
  s = input()
  if s in dic:
    dic[s] += 1
  else:
    dic[s] = 1

_max = 0
for v in dic.values():
  if _max < v:
    _max = v
dic2 = sorted(dic.items())

for (k,v) in dic2:
  if v == _max:
    print(k)

Measured memory_bytes: 44124
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
      String s[]=line.split("",0);
      int a=Integer.parseInt(s[0]);
      int b=0;
      for(int i=0;i<s.length;i++){
      	b=b*10+a;
      }
      if(b<Integer.parseInt(line)){
      	b=0;
        if(a==9){
        for(int i=0;i<s.length+1;i++){
      	b=b*10+1;
      }
        }else
        for(int i=0;i<s.length;i++){
      	b=b*10+(a+1);
      }
      }
      
        System.out.println(b);
    }
}

Measured memory_bytes: 22996
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <cassert>
#include <stack> 

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define PI acos(-1.0)
#define MAXLEN 29

typedef std::pair <int, int> pii;
typedef long long ll;
typedef std::vector <ll> vll;

using namespace std;



int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);	
	string str;
	cin >> str;
	int len = str.length();
	int ans = 0;
	for (int i = 0; i < len; i++) {
		ans += str[i] - '0';
	}
	//cout << ans << " " << len << endl;
	for (int i = 0; i < len; i++) {
		if (str[i] != '0') {
			ans = max(ans, (len - 1) * 9 + str[i] - '0' - 1);
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 10e-10;

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    ll n,m;
    cin >> n >> m;
    ll ans = m/n;
    while(ans){
        if(m % ans == 0){
            break;
        }
        ans--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int a, b, m;
    char c;
    
    cin>> a >> c >> b;
    if (c == '+'){
       m = a+b;
   }
    if (c == '-'){
        m = a - b;
    }
    cout << m;    
    return 0;
}

Measured memory_bytes: 256
fun main(args:Array<String>) {
    val n = readLine()!!.toInt()
    val s = readLine()!!
    var ans = 0
    var num = 0
    for(i in s) {
        if(i == 'I') {
            num++
        } else {
            num--
        }
        ans = Math.max(ans, num)
    }
    println(ans)
}

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


def m():
    abs_A = [abs(a) for a in A]
    mines_cnt = 0
    for a in A:
        if a < 0:
            mines_cnt += 1
    if mines_cnt % 2 == 0:
        return sum(abs_A)
    return sum(abs_A) - min(abs_A)*2


print(m())


Measured memory_bytes: 65184
import sys
L = []
for l in sys.stdin:
    L.append(l)
N, K = map(int, L[0].split())
p_N_list = list(map(int, L[1].split()))
p_N_list.sort()
sum = 0
for n in range(0, K):
  sum += p_N_list[n]
print(sum) 

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

using namespace std;

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

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

    int r=max(a,b);
    int x=1;
    while(r<n)
    {
        x++;
        r+=max(a,b);
    }
    cout<<x;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define f first
#define s second
#define pb push_back
#define PII pair<ll,ll>
ll const MOD = 1000000007;
ll const N = 1000005;
ll const LN = 20;
ll const inf = 8e18;
using namespace std;

ll n, m, a[N];

ll fn (ll n)
{
	if (n % 4 == 0) { return n; }
	if (n % 4 == 2) { return n + 1; }
	if (n % 4 == 1) { return 1; }
	if (n % 4 == 3) { return 0; }
}

int main()
{
	ios::sync_with_stdio (false);
	cin.tie (NULL);
	ll a, b;
	cin >> a >> b;
	cout << (fn (b) ^fn (a - 1));
	return 0;
}


Measured memory_bytes: 256
// delete when handing in
//#define DEBUG
// delete when proceedig next 
#define EXE
#ifdef EXE
// -------------------------------------------------------
#include <iostream>
#include <string>
#include <stdio.h>
#include <cassert>
#include <vector>
#include <algorithm>
#include <map>
#include <bitset>
using namespace std;

vector<vector<string>> a;
int H, W, K;
int result_num = 0;
;

vector<pair<int, int>> find_reverse(vector<pair<int, int>> map, int i) {
	vector<pair<int, int>> out_vec;
	int index = 0;
	for (auto m : map) {
		if (m.second == i) {
			out_vec.push_back(make_pair(index, m.first));
		}
		index++;
	}
	return out_vec;
}

vector<pair<int, int>> find(vector<pair<int, int>> map, int i) {
	vector<pair<int, int>> out_vec;
	int index = 0;
	for (auto m : map) {
		if (m.first == i) {
			out_vec.push_back(make_pair(index, m.second));
		}
		index++;
	}
	return out_vec;
}

void b(int k, vector<vector<string>> painted, vector<bool> debug_a) {
	int i = -1, j = -1;
	if (k < H)i = k;
	else j = k - H;


	vector<vector<string>> when_no_painted = painted;
	vector<bool> when_no_painted_debug_a = debug_a;

	// when paint
	if (i != -1) {
		for (int jj = 0; jj < W; jj++) {
			painted[i][jj] = ".";
		}
	}
	else if (j != -1){
		for (int ii = 0; ii < H; ii++) {
			painted[ii][j] = ".";
		}
	}
	else {
		assert(0);
	}
	debug_a[k] = true;



	// select = false;
	k++;
	if (k >= H + W) {
		int black_num = 0;
		for (int kk = 0; kk < H; kk++) {
			for (int ll = 0; ll < W; ll++) {
				if (when_no_painted[kk][ll] == "#") {
					black_num++;
				}

			}
		}
		if (black_num == K) {
			result_num++;
		}

		black_num = 0;
		for (int kk = 0; kk < H; kk++) {
			for (int ll = 0; ll < W; ll++) {
				if (painted[kk][ll] == "#") {
					black_num++;
				}

			}
		}
		if (black_num == K) {
			result_num++;
		}
		return;
	}
	b(k, when_no_painted, when_no_painted_debug_a);
	b(k, painted, debug_a);
}



int main() {

	vector<string> s;
#ifdef DEBUG
	N = 9445;

#else
	cin >> H >> W >> K;

	for (int i = 0; i < H; i++) {
		string in;
		cin >> in;
		vector<string> s;
		for (int j = 0; j < W; j++) {
			string l{ in[j] };
			s.push_back(l);
		}
		a.push_back(s);
	}
#endif
	vector<bool> debug_a(H + W, false);
	// for (int i = 0; i < H + W; i++) {
	//	assert(i != H + W);
		b(0, a, debug_a);
	// }

	cout << result_num << endl;


#ifdef DEBUG
	int z;
	cin >> z;
#endif
	return 0;
}


// -------------------------------------------------------
#endif

Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
ll N, M;
ll A[105000];
ll g = 0;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    for(int i = 0; i < N; i++) cin >> A[i];
    M *= 2;
    g = A[0];
    for(int i = 1; i < N; i++) {
        ll now = __gcd(g, A[i]);
        g /= now;
        if(g > 2e9) continue;
        g *= A[i];
    }
    cerr << g << endl;
    for(int i = 0; i < N; i++) {
        if(g % A[i] != 0) {
            cout << 0 << endl;
            return 0;
        }
        if((g / A[i]) % 2 == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    ll num = M / g;
    cout << (num + 1) / 2;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	double w,h,x,y;
	cin>>w>>h>>x>>y;
	printf("%6f",w*h/2);
	cout<<' ';
	if (x==w/2&&y==h/2) cout<<1;
	else cout<<0;
}

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

#define HASH 200003

typedef struct List {
	struct List *next;
	char *s;
	int l;
} list;

long long div_mod(long long x, long long y, long long z)
{
	if (x % y == 0) return x / y;
	else return (div_mod((1 + x / y) * y - x, (z % y), y) * z + x) / y;
}

int hash_string(char* s)
{
	int i, x = 0;
	for (i = 0; s[i] != 0; i++) x = ((x << 5) + s[i] - 'a') % HASH;
	return x;
}

int lex_smaller(char* s1, char* s2)
{
	int i;
	for (i = 0; s1[i] != 0 && s2[i] != 0; i++) {
		if (s1[i] < s2[i]) return 1;
		else if (s1[i] > s2[i]) return -1;
	}
	if (s1[i] == s2[i]) return 0;
	else if (s1[i] == 0) return 1;
	else return -1;
}

int main()
{
	int i, j, l[200001], N;
	char *S[200001], T[1000001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%s", T);
		for (l[i] = 0; T[l[i]] != 0; l[i]++);
		S[i] = (char*)malloc(sizeof(char) * (l[i] + 1));
		for (j = 0; j <= l[i]; j++) S[i][j] = T[j];
	}
	
	int h[200001];
	list *p, *hash[HASH], d[200001];
	for (i = 1; i <= N; i++) {
		h[i] = hash_string(S[i]);
		d[i].s = S[i];
		d[i].l = l[i];
		d[i].next = hash[h[i]];
		hash[h[i]] = &(d[i]);
	}
	
	int k, dp[26];
	long long ans = 0, tmp, pow[32];
	const long long inv = div_mod(1, 32, HASH);
	for (k = 1, pow[0] = 32; k < 32; k++) pow[k] = pow[k-1] * pow[k-1] % HASH;
	for (i = 1; i <= N; i++) {
		if (l[i] <= 1) continue;
		for (j = 0; j <= l[i]; j++) T[j] = S[i][j];
		for (j = l[i] - 1, k = 0, tmp = 1; j > 0; j >>= 1, k++) if ((j & 1) == 1) tmp = tmp * pow[k] % HASH;
		h[i] = (h[i] - tmp * (T[0] - 'a') % HASH + HASH) % HASH;
		tmp = tmp * inv % HASH;
		h[i] = (h[i] - tmp * (T[1] - 'a') % HASH + HASH) % HASH;
		for (j = 0; j < 26; j++) dp[j] = 0;
		dp[S[i][0] - 'a'] = 1;
		for (j = 1; j < l[i]; j++) {
			dp[S[i][j] - 'a'] = 1;
			for (k = 0; k < 26; k++) {
				if (dp[k] == 0) continue;
				T[j] = 'a' + k;
				h[0] = (tmp * k + h[i]) % HASH;
				for (p = hash[h[0]]; p != NULL; p = p->next) if (p->l == l[i] - j && p->s[0] == T[j] && p->s[p->l - 1] == T[l[i] - 1] && lex_smaller(p->s, &(T[j])) == 0) break;
				if (p != NULL) ans++;
			}
			tmp = tmp * inv % HASH;
			h[i] = (h[i] - tmp * (S[i][j+1] - 'a') % HASH + HASH) % HASH;
		}
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 17252
N,D=map(int,input().split())
X=[0]*N
Y=[0]*N
for i in range(N):
    X[i],Y[i]=map(int,input().split())
ans=0
for i in range(N):
    if((X[i]**2+Y[i]**2)**(1/2)<=D):
        ans=ans+1

print(ans)


Measured memory_bytes: 73788
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  string N;
  cin >> N;

  if(N[0] ==  N[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int n,a;
    cin>>n>>a;
    if(n%500<=a) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main(){

	long A, B;
	long C, D;

	long A1,B1,A2,B2,A3,B3;

	cin >> A >> B >> C >> D;

	// A未満でCで割り切れる数の個数
	A1 = (A-1) / C;
	// B以下でCで割り切れる数の個数
	B1 = B / C;
	// A未満でDで割り切れる数の個数
	A2 = (A-1) / D;
	// B以下でDで割り切れる数の個数
	B2 = B / D;

	long x = C * D;
 
  /* 自然数 a > b を確認・入替 */
  if(C<D){
    int tmp = C;
    C = D;
    D = tmp;
  }
 
  /* ユークリッドの互除法 */
  long r = C % D;
  while(r!=0){
    C = D;
    D = r;
    r = C % D;
  }
  // 最小公倍数
  long y = x/D;
  
  // A未満でyで割り切れる数の個数
  A3 = (A-1) / y;
  // B以下でyで割り切れる数の個数
  B3 = B / y;

  // A未満でCでもDでも割り切れない数
  long ans1 = (A-1) - A1 - A2 + A3;
  // B以下でCでもDでも割り切れない数
  long ans2 = B - B1 - B2 + B3;



  cout << ans2 - ans1 << endl;



	return 0;
}



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

int main() {

    int H, W;
    cin >> H >> W;

    vector<string> S(H);
    for (int i = 0; i< H; i++) {
        cin >> S.at(i);
    }

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

    int x;
    int y;
    bool ok = true;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S.at(i).at(j) != '#') {
                continue;
            }

            for (int k = 0; k < 4; k++) {
                ok = false;
                x = i + dx[k];
                y = j + dy[k];
                if (x >= 0 && x < H && y >= 0 && y < W) {
                    if (S.at(x).at(y) == '#') {
                        ok = true;
                        break;
                    }
                }
            }

            if (!ok) {
                break;
            }
        }

        if (!ok) {
            break;
        }
    }

    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 3616
import sys
input=sys.stdin.readline
n,ma,mb=map(int,input().split())
med=[]
for i in range(n):
    a,b,c=map(int,input().split())
    med.append((a,b,c))
INF=10000
dp=[[[INF]*401 for j in range(401)] for i in range(n+1)]
dp[0][0][0]=0
for i in range(n):
    for a in range(401):
        for b in range(401):
            if dp[i][a][b]!=INF:
                dp[i+1][a+med[i][0]][b+med[i][1]]=min(dp[i+1][a+med[i][0]][b+med[i][1]],dp[i][a][b]+med[i][2])
                dp[i+1][a][b]=min(dp[i+1][a][b],dp[i][a][b])
minc=INF
for a in range(1,401):
    for b in range(1,401):
        if a*mb==b*ma:
            minc=min(dp[n][a][b],minc)
if minc==INF:
    print(-1)
else:
    print(minc)


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

int main() {
    double L;
    cin >> L;
    double res=L/3;
    cout << fixed << setprecision(6) << res*res*res;
    return 0;
}

Measured memory_bytes: 3748
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define nmax_def 2000000
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	ll N;
	cin >> N;
	ll ans = 0;
	ll Ktmp = 2;
	if (N == 2)
		ans = 1;
	else {
		while (1) {
			if (N % Ktmp == 0) {
				ll n = N;
				while (1) {
					if (n % Ktmp != 0)
						break;
					n /= Ktmp;
				}
				if (n % Ktmp == 1) {
					ans++;
				}

				if (N != Ktmp * Ktmp) {
					n = N;
					while (1) {
						if (n % (N / Ktmp) != 0)
							break;
						n /= (N / Ktmp);
					}
					if (n % (N / Ktmp) == 1) {
						ans++;
					}
				}
			}
			Ktmp++;
			if (Ktmp * Ktmp > N)
				break;
		}
		Ktmp = 2;
		N--;
		while (1) {
			if (N % Ktmp == 0) {
				ans++;
				if (N != Ktmp * Ktmp) {
					ans++;
				}
			}
			Ktmp++;
			if (Ktmp * Ktmp > N)
				break;
		}
		ans += 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int A, B, C;
    int X, Y;
    cin >> A >> B >> C >> X >> Y;

    long long res = 1LL << 60;
    for (int i = 0; i <= 2 * X || i <= 2 * Y; i += 2) {
        long long ans = i * 1LL * C;
        ans += max(0, X - i / 2) * 1LL * A;
        ans += max(0, Y - i / 2) * 1LL * B;
        res = min(res, ans);
    }

    cout << res << '\n';


    return 0;
}

Measured memory_bytes: 256
import time
from random import randrange
start = time.time()

D=int(input())
c=list(map(int,input().split()))
def compare(d,q):
  score=maxscore
  changebefore=currentans[d]-1
  changeafter=q-1
  r=contests[changebefore]
  score-=s[d][changebefore]
  score+=s[d][changeafter]
  for j in range(len(r)-1):
    if r[j]==d:
      score-=c[changebefore]*((r[j+1]-r[j-1]-1)*(r[j+1]-r[j-1]))//2
      score+=c[changebefore]*((r[j+1]-d-1)*(r[j+1]-d))//2
      score+=c[changebefore]*((d-r[j-1]-1)*(d-r[j-1]))//2
      break
  r=contests[changeafter]
  for j in range(len(r)-1):
    if r[j+1]>d:
      score+=c[changeafter]*((r[j+1]-r[j]-1)*(r[j+1]-r[j]))//2
      score-=c[changeafter]*((r[j+1]-d-1)*(r[j+1]-d))//2
      score-=c[changeafter]*((d-r[j]-1)*(d-r[j]))//2
      break
  if score>maxscore:
    return score
  else:
    return maxscore

s=[0]
last=[0]*26
currentans=[0]*(D+1)
for i in range(D):
  s.append(list(map(int,input().split())))
contests=[]
for i in range(26):
  contests.append([])
  contests[-1].append(0)
  contests[-1].append(D+1)

#Donyoku
for i in range(1,D+1):
  score=0
  t=0
  score+=s[i][t]
  lasttemp=last[t]
  last[t]=i
  for j in range(26):
    score-=c[j]*(i-last[j])
  maxscore=score
  bestans=1
  last[t]=lasttemp
  for t in range(1,26):
    score=0
    score+=s[i][t]
    lasttemp=last[t]
    last[t]=i
    for j in range(26):
      score-=c[j]*(i-last[j])
    if maxscore<score:
      bestans=t+1
      maxscore=score
    last[t]=lasttemp
  last[bestans-1]=i
  currentans[i]=bestans
lastchangeq=0
for i in range(1,D+1):
  contests[currentans[i]-1].append(i)
counter=0
breakflag=0
lastchanged=0
continueflag=0
while True:
  counter+=1
  if counter%100==0:
    now=time.time()
    if now-start>1.75:
      break
  q=randrange(26)+1
  d=randrange(D)+1
  if lastchangeq==q:
    continue
  if lastchanged<=d:
    if randrange(2)==0:
      continue
  if currentans[d]==q:
    continue
  score2=compare(d,q)
  if score2>maxscore:
    changebefore=currentans[d]-1
    changeafter=q-1
    contests[changebefore].remove(d)
    contests[changeafter].append(d)
    contests[changeafter].sort()
    currentans[d]=q
    maxscore=score2
    lastchanged=d
    lastchangeq=q
for i in range(1,D+1):
  print(currentans[i])

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

int main(){
  int N;
  scanf("%d", &N);
  vector<int> A(N, 0);
  for (int i = 0; i < N; i++){
    scanf("%d", &(A[i]));
  }
  int even = 0;
  int odd = 0;
  for (int i = 0; i < N; i++){
    if ((A[i] % 2) == 0){
      even++;
    }else{
      odd++;
    }
  }
  if ((odd % 2) == 0){
    cout << "YES";
  }else if (even == 0){
    cout << "YES";
  }else{
    cout << "NO";
  }
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s1,s2;
  int i,cnt=0,j;
  cin>>s1>>s2;
  for(i=0;i<3;i++){
    if(s1[i]==s2[i]){
      cnt++;
    }
  }
  cout<<cnt<<endl;
  return 0;
}

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

int main(){
	int A, B, N = 100, i, j;
	scanf("%d%d", &A, &B);
	char **C = (char **)malloc(sizeof(char *) * N);
	for(i = 0; i < N; i++){
		C[i] = (char *)malloc(sizeof(char) * (N + 1));
		for(j = 0; j < N; j++){
			if(i < N / 2){
				C[i][j] = '.';
			}
			else{
				C[i][j] = '#';
			}
		}
		C[i][N] = '\0';
	}
	A--;
	B--;
	for(i = 0; i < N / 2; i++){
		for(j = 0; j < N; j++){
			if(i % 2 == 0 && j % 2 == 0 && B > 0){
				C[i][j] = '#';
				B--;
			}
		}
	}
	for(i = N - 1; i >= N / 2; i--){
		for(j = 0; j < N; j++){
			if(i % 2 == 0 && j % 2 == 0 && A > 0){
				C[i][j] = '.';
				A--;
			}
		}
	}
	printf("%d %d\n", N, N);
	for(i = 0; i < N; i++){
		printf("%s\n", C[i]);
	}
	return 0;
}

Measured memory_bytes: 128
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::collections::VecDeque;
use std::usize::MAX;

fn main() {
    input! {
        h: usize,
        w: usize,
        ch: Usize1,
        cw: Usize1,
        dh: Usize1,
        dw: Usize1,
        board: [Chars; h] // h*wのグリッドを Vec<Vec<char>> として読み込
    }

    let mut que = VecDeque::new();
    que.push_front((ch, cw, 0));
    let mut arrived: Vec<Vec<usize>> = vec![vec![MAX; w]; h];

    while let Some((y1, x1, d)) = que.pop_back() {
        if arrived[y1][x1] != MAX {
            continue;
        } else {
            arrived[y1][x1] = d;
            for &(dy, dx) in &[(-1, 0), (1, 0), (0, -1), (0, 1)] {
                let mut y = y1 as i32;
                y += dy;
                let mut x = x1 as i32;
                x += dx;
                if 0 <= y && y < (h as i32) && 0 <= x && x < (w as i32) {
                    let y = y as usize;
                    let x = x as usize;
                    if board[y][x] == '.' && arrived[y][x] == MAX {
                        que.push_back((y, x, d));
                    }
                }
            }
            for i in -2..=2 {
                for j in -2..=2 {
                    let y = (y1 as i32) + i;
                    let x = (x1 as i32) + j;
                    if 0 <= y && y < (h as i32) && 0 <= x && x < (w as i32) {
                        let y = y as usize;
                        let x = x as usize;
                        if board[y][x] == '.' && arrived[y][x] == MAX {
                            que.push_front((y,x,d+1));
                        }
                    }
                }
            }
        }
    }

    println!("{}",if arrived[dh][dw] == MAX {-1} else {arrived[dh][dw] as i32})
}


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

using namespace std;

typedef short sho;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str; 
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef pair<ld,ld> pld;
 
typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;

#define LOCAL
#define MP make_pair 
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define begin(x) (x).begin() 
#define end(x) (x).end()
#define rbegin(x) (x).rbegin()
#define rend(x) (x).rend()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define PF push_front 
#define PB push_back
#define PP push
#define lb lower_bound 
#define ub upper_bound
#define lowbit(x) x&(-x)
#define testbit(x,i) x&(1<<i)

inline void checkmin(int &x,int y){x=min(x,y);}
inline void checkmax(int &x,int y){x=max(x,y);}

long long a,b,n;

int main() 
{
	#ifndef LOCAL
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /* start code */
    cin>>a>>b>>n;
    cout<<max(min(b-1,n)*a/b,a*(n/b*b)/b-a*((n/b*b)/b))<<endl;
    /* end code */
	return 0;
}

Measured memory_bytes: 3612
/*
    Don’t practice until you get it right. Practice until you can’t get it wrong.
*/

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld double
#define pii pair<ll,ll>
#define vl vector<ll>
#define vb vector<bool>
#define vs vector<string>
#define vp vector<pii>
#define pb push_back
#define mp make_pair
#define sc(a) scanf("%lld",&a);
#define sd(a) scanf("%lf",&a);
#define test() ll tt;cin>>tt;for(ll testcase=1;testcase<=tt;testcase++)
#define all(v) v.begin(),v.end()
#define vivek_ghosh ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX 1000055
#define mod 1000000007
#define ff first
#define ss second
const int INF=0x3f3f3f3f;
const ll int inf = LLONG_MAX;

ll power(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

ll modinv(ll a,ll m)
{
    ll g =__gcd(a, m);
    ll res=power(a, m-2, m);
    return res;
}

vb prime(MAX,true);
vl prm;
void sieve()
{
	prime[0] = prime[1] = false;
	for(ll p=2;p*p<MAX;p++)
	{
		if(prime[p])
		{
			for(ll i=p*p;i<MAX;i+=p)
				prime[i] = false;
		}
	}
	for(ll p=2;p<MAX;p++)
	{
		if(prime[p])
			prm.pb(p);
	}
}

ll n,m,t,i,j,k,q,x,y,ans=0,cnt=0,sum=0,mx=-1,mn=INT_MAX;
string s;

int main()
{
    vivek_ghosh;

        vl vec{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};

    cin>>k;
    cout<<vec[k-1]<<endl;





    return 0;
}








Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include <fstream>
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int mod = 1e9+7;
const int maxn = 200005;
int a[maxn];
vector<pair<int,int> >v;
int main() {
	string s;
	cin>>s;
	if(s=="SAT") cout<<1<<endl;
	else if(s=="SUN") cout<<7<<endl;
	else if(s=="MON") cout<<6<<endl;
	else if(s=="TUE") cout<<5<<endl;
	else if(s=="WED") cout<<4<<endl;
	else if(s=="THU") cout<<3<<endl;
	else if(s=="FRI") cout<<2<<endl;
    return 0;
}



Measured memory_bytes: 256
n=int(input())
s=sorted([input() for i in range(n)])
ans = ['']
x=1
max=0
for k in range(n):
    if k<n-1:
        if s[k]==s[k+1]:
            x+=1
        else:
            if max<x:
                ans=[s[k]]
                max=x
            elif max==x:
                ans.append(s[k])
            x=1
    else:
        if max<x:
            ans=[s[k]]
            max=x
        elif max==x:
            ans.append(s[k])

    

for j in range(len(ans)):
    print(ans[j])

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/

int main()
{
    double R; cin >> R;
    printf("%.5f\n", 2.0*R*M_PI);
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  for (auto &p : P) {
    cin >> p;
  }
  vector<int> Q(N);
  for (auto &q : Q) {
    cin >> q;
  }
  vector<int> R(N);
  for (int i = 0; i < N; i++) {
    R[i] = i + 1;
  }
  int a, b;
  int count = 0;
  do {
    if (R == P) {
      a = count;
    }
    if (R == Q) {
      b = count;
    }
    count++;
  } while (next_permutation(R.begin(), R.end()));

  cout << abs(b - a) << endl;

  return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CSumOfGcdOfTuplesEasy {
public:
    int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

    void solve(std::istream& cin, std::ostream& cout) {
        int K;
        cin >> K;
        int res = 0;
        FOR(a, 1, K) FOR(b, 1, K) FOR(c, 1, K) {
            res += gcd(a, gcd(b, c));
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CSumOfGcdOfTuplesEasy solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string S;
  int  q, cnt = 0;
  cin >> S >> q;
  vector<int> t(q), f(q);
  vector<string> c(q);
  
  for(int i = 0; i < q; i++){
    cin >> t[i];
    if(t[i] == 2){
      cin >> f[i] >> c[i];
    }
  }
  
  
  for(int i = 0; i < q; i++){
    if(t[i] == 1 && i != q - 1){
      cnt++;
    }else if(t[i] == 1 && i == q - 1){
      cnt++;
      if(cnt%2 == 1){
        reverse(S.begin(), S.end());
      }
    }else if(t[i] == 2 && i != q - 1){
      if( (cnt%2 == 1 && f[i] == 2) || (cnt%2 == 0 && f[i] == 1) ){
        S.insert(0, c[i]);
      }else{
        S += c[i];
      }
    }else if(t[i] == 2 && i == q - 1){
      if(cnt%2 == 0){
        if(f[i] == 1){
          S.insert(0, c[i]);
        }else{
          S += c[i];
        }
      }else{
        reverse(S.begin(), S.end());
        if(f[i] == 1){
          S.insert(0, c[i]);
        }else{
          S += c[i];
        }
      }
    }
    
  }
  
 
  
  cout << S <<endl;
}


Measured memory_bytes: 14208
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <random>

#include <fstream>
#include <vector>
#include <algorithm>

#define ll long long int

using namespace std;

int main(void)
{

    
    ll a, b, v, w, t;
    
    cin >> a >> v >> b >> w >> t;
    
    if(v <= w)
    {
        cout << "NO";
        return 0;
    }
    
    if(abs(a - b) <= (v - w)*t)
    {
        cout << "YES";
        return 0;
    }
    
        cout << "NO";
}

Measured memory_bytes: 3632
<?php
fscanf(STDIN, "%d %d %d %d", $a, $b, $c, $d);
if($a + $b == $c + $d) {
    echo "Balanced\n";
} elseif($a + $b > $c + $d) {
    echo "Left\n";
} else {
    echo "Right\n";
}

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

int main(){
  string S, T;
  cin >> S >> T;
  bool can = false; bool same = true;
  sort(S.begin(), S.end());
  sort(T.begin(), T.end());
  reverse(T.begin(), T.end());
  int N = min(S.size(), T.size());
  rep(i, N){
    if(S[i] > T[i]){
      same = false;
      break;
    }
    if(S[i] < T[i]) {
      can = true;
      same = false;
      break;
    }
  }
  if(!(can) && (same)){
    if(N < T.size()) can = true;
  }
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, a, b, c, d);
    Cout(c/a*b);
}

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

using namespace std;
int main (){

   int N;
cin>>N;
int H[N];
for(int i=0;i<N;i++)
    cin>>H[i];
int cnt=1;
int r=H[0];
for(int i=1;i<N;i++){
    if(r<=H[i]){
    cnt++;
    r=H[i];
    }
}
cout<<cnt;
return 0;
}

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;


ll calc(ll _n){
    if(_n == 1) return 1;
    else return calc(_n/2)*2+1;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll h; cin >> h;

    ll ans = calc(h);
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE RecordWildCards       #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Exception
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.Trans.State.Strict
import           Data.Array.Base
import           Data.Array.ST                    (STUArray, runSTUArray)
import           Data.Bits
import           Data.Bool
import qualified Data.ByteString.Char8            as B
import           Data.Char
import           Data.Coerce
import qualified Data.Foldable                    as F
import           Data.Function
import           Data.Int
import qualified Data.IntMap.Strict               as IM
import qualified Data.IntSet                      as IS
import qualified Data.List                        as L
import qualified Data.Map.Strict                  as M
import           Data.Monoid
import           Data.Ord
import qualified Data.Set                         as S
import           Data.STRef
import           Data.Tuple
import           Data.Word
import           Debug.Trace
import           GHC.Arr                          (Array, Ix (..), STArray)
import           GHC.Exts
import           System.Exit
import           System.IO

main :: IO ()
main = do
    !n <- readLn :: IO Int
    print $ solve n

lim :: Int
lim = 1000000

modulus :: Int
modulus = 1000000007

infixl 7 *%, /%
infixl 6 +%, -%

(+%), (-%), (*%), (/%) :: Int -> Int -> Int
x +% y = case x + y of xy -> if xy < modulus then xy else xy - modulus
x -% y = case x - y of xy -> if xy >= 0  then xy else xy + modulus
x *% y = x * y `rem` modulus
x /% y = go y modulus 1 0
   where
     go !a !b !u !v
       | b > 0 = case a `quot` b of q -> go b (a-q*b) v (u-q*v)
       | otherwise = x * u `mod` modulus
{-# INLINE (+%) #-}
{-# INLINE (-%) #-}
{-# INLINE (*%) #-}
{-# INLINE (/%) #-}

factCache :: UArray Int Int
factCache = runSTUArray $ do
    fact <- newArray (0, lim) 1
    F.for_ [2..lim] $ \i ->
        unsafeRead fact (i - 1) >>= unsafeWrite fact i . (*% i)
    return fact

solve :: Int -> Int
solve n = F.foldl' (\x y->(x+y)`rem`modulus) 0 $ zipWith3 (\i x y -> (x -% y) *% i) is fs $ 0:fs
  where
    is = [div (n + 1) 2 .. n - 1]
    fs = map f is
    f k = unsafeAt factCache k *% unsafeAt factCache (k - 1)
      /% unsafeAt factCache (2 * k - n)



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

a = list(map(int,input().split()))

b = {}

for i in a:
    if i in b:
        b[i] += 1
    else:
        b[i] = 1
c = []
for i in b:
    if b[i] >= 4:
        c.append(i)
        c.append(i)
    elif b[i] >= 2:
        c.append(i)
c.sort()
c.reverse()
c.append(0)
c.append(0)
print(c[0]*c[1])

Measured memory_bytes: 18316
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		String s = in.next();
		char[] s_chars = s.toCharArray();
        Arrays.sort(s_chars);
        String s_asc = new String(s_chars);
		
		String t = in.next();
		char[] t_chars = t.toCharArray();
		Arrays.sort(t_chars);
		String t_asc = new String(t_chars);
		String t_desc = new StringBuilder(t_asc).reverse().toString();
		
		if (s_asc.compareTo(t_desc) < 0)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

Measured memory_bytes: 23252
#include<stdio.h>

int main(void)
{
  int h,w,ans[50][50],i,j;
  char array[51][51];
  scanf("%d %d",&h,&w);
  for(i=0;i<h;i++) 
    {
      scanf("%s",array[i]);
      for(j=0;j<w;j++)
	{
	      ans[i][j] = 0;
	}
    }
  for(i=0;i<h;i++)
    {
      for(j=0;j<w;j++)
	{
	  if(array[i][j] == '#')
	    {
	      if(i-1 >= 0 && j-1 >= 0)
		{
		  ans[i-1][j-1]++;
		}
	      if(i+1 < h && j+1 <w)
		{
		  ans[i+1][j+1]++;
		}
	      if(i-1 >= 0)
		{
		  ans[i-1][j]++;
		}
	      if(j-1 >= 0)
		{
		  ans[i][j-1]++;
		}
	      if(i+1 < h)
		{
		  ans[i+1][j]++;
		}
	      if(j+1 < w)
		{
		  ans[i][j+1]++;
		}
	      if(i-1 >= 0 && j+1 < w)
		{
		  ans[i-1][j+1]++;
		}
	      if(i+1 < h && j-1 >= 0)
		{
		  ans[i+1][j-1]++;
		}
	    }
	}
    }

  for(i=0;i<h;i++)
    {
      for(j=0;j<w;j++)
	{
	  if(array[i][j] == '#')
	    {
	      printf("#");
	    }
	  else
	    {
	      printf("%d",ans[i][j]);
	    }
	  if(j == w-1)
	    {
	      printf("\n");
	    }
	}
    }
  return 0;
}


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

using namespace std;
typedef long long ll;

ll memo[1010][1010];
ll H, W;
string tab[1010];

const ll MODD = 1e9 + 7;
ll dp(ll h, ll w) {
	if (h < 0 || w < 0) return 0;
	if (tab[h][w] == '#') return 0;
	if (h == 0 && w == 0) return 1;
	ll &ans = memo[h][w];
	if (ans != -1) return ans;
	ans = dp(h - 1, w) + dp(h, w - 1);
	ans %= MODD;
	return ans;
}
int main() {
	memset(memo, -1, sizeof(memo));
	cin >> H >> W;
	for (ll i = 0; i < H; i++) {
		cin >> tab[i];
	}

	cout << dp(H - 1, W - 1) << endl;
	return 0;
}

Measured memory_bytes: 9344