akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#define ll              long long int
#define ull             unsigned long long
#define vi              vector<int>
#define vl              vector<ll>
#define vvi             vector<vector<int> >
#define pi              pair<int,int>
#define vii             vector<pi>

#define sz(v)           ((int)(v).size())
#define all(s)          s.begin(),s.end()
#define allr(s)         s.rbegin(),s.rend()
#define unq(c)          (sort(all(c)), c.resize(distance(c.begin(),unique(all(c)))))
#define get_pos(c,x)    (lower_bound(all(c),x)-c.begin())

#define MS0(v)          memset((v), 0, sizeof((v)))
#define MS1(v)          memset((v), -1, sizeof((v)))
#define LEN(v)          strlen(v)

#define MP              make_pair
#define pb              push_back
#define pob             pop_back
#define ff              first
#define ss              second
#define sc              scanf
#define pf              printf
#define endl            "\n"

#define TEST_CASE       int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define PRINT_CASE      printf("Case %d: ",cs)

#define vpf(v)          for(int i=0;i<v.size();i++){cout<<v[i];if(i!=v.size()-1)cout<<" ";else cout<<"\n";}
#define vsc(v)          for(int i=0;i<v.size();i++)cin>>v[i];

#define REP(i, n)       for (int i = 0; i < (n); i++)
#define REPP(i, a, b)   for (int i = (a); i < (b); i++)
#define FOR(i, a, b)    for (int i = (a); i <= (b); i++)
#define FORS(i, s)      for (int i = 0; s[i]; i++)

#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fileio          freopen("in.txt","r",stdin);freopen("out.txt","w",stdout)

#define intlim          2147483648
#define infinity        (1LL<<50)

#define gcd(a, b)       __gcd(a, b)
#define lcm(a, b)       ((a)*((b)/gcd(a,b)))


int on_bit(int N,int pos){return N = N | (1<<pos);}
int off_bit(int N,int pos){return N = N & ~(1<<pos);}
bool check_bit(ll N,int pos){return (bool)(N & (1<<pos));}


#define start_clock     clock_t tStart = clock()
#define end_clock       printf("\n>>Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC)



//____________________________________________________________________________________________________________




int main(){ 
    int n, m, x, sum=0;
    cin>>n>>m;
    vi v(n);

    for(int i=0;i<n;i++){
        cin >> v[i];
        sum += v[i];
    }

    long double ter = (1.0 / (4.0*m)) + 1e-7;
    ll a = (ter * 100000000000.0);
    int cnt=0;

    for(int i=0;i<n;i++){
        long double x = ((v[i]*1.0) / (sum * 1.0)) + 1e-7;
        ll b = (x * 100000000000.0);

        if(b >= a)cnt++;
    }

    if(cnt >= m)cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat Mar  2 01:07:09 2019

@author: yuta
"""

A,B,C,D,E,F = map(int,input().split())
"""
def melt(a,b,c,d,e,f):
    max_sugar = 0
    for i in range(int(0.01*f/a)+1):
        for j in range(int(0.01*f/b)+1):
            for k in range(int((f*e*0.01)/c)+1):
                for l in range(int((f*e*0.01)/d)+1):
                    if i+j+k+l == 0:
                        break
                    else:
                        den = (100*(k*c+l*d))/(100*i*a+100*j*b+k*c+l*d)
                        if den > 100*e/(100+e):
                            den = 0
                        else:
                            if den >= max_sugar and 100*i*a+100*j*b+k*c+l*d <= f:
                                max_sugar = den
                                amount = 100*i*a + 100*j*b + k*c + l*d
                                sugar = 0.01 * den * amount
    print(amount,sugar)

melt(A,B,C,D,E,F)
"""
def melt(a,b,c,d,e,f):
    water = []
    sugar = []
    for i in range(int(0.01*f/a)+1):
        for j in range(int(0.01*f/b)+1):
            water.append(100*(a*i+b*j))
    water = list(set(water))
    
    for k in range(int((f*e*0.01)/c)+1):
        for l in range(int((f*e*0.01)/d)+1):
            sugar.append(c*k+d*l)
    sugar = list(set(sugar))
    
    max_sugar = 0
    for m in range(len(water)):
        for n in range(len(sugar)):
            if water[m]+sugar[n] == 0:
                break
            else:
                den = 100*sugar[n]/(water[m]+sugar[n])
                if den > 100*e/(100+e):
                    den = 0
                else:
                    if den >= max_sugar and water[m]+sugar[n] <= f:
                        max_sugar = den
                        amount = water[m]+sugar[n]
                        sugar_amount = sugar[n]
    print(amount,sugar_amount)
melt(A,B,C,D,E,F)

Measured memory_bytes: 22572
#include <iostream>
#include <cmath>

using namespace std;

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (abs(a - b) <= d && abs(b - c) <= d || abs(a - c) <= d) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

int calc(int num) {
  int count = 0;
	for(int i = 1; i <= num; i++){
    	if(num % i == 0){
        	count++;
        }
    }
  return count;
}

int main(){
  int N, count = 0;
  cin >> N;
  if(N < 105){
  	cout << 0 << endl;
    return 0;
  }
  
  for(int i = 105; i <= N; i++){
  	if(i % 2 == 1 && calc(i) == 8){
    	count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
#include<iomanip>
using namespace std;

int N, Q;

int main() {
    cin >> N >> Q;
    vector<pair<pair<long long, bool>, long long>> event;
    long long s, t, x;
    for (int i = 0; i < N; i++) {
        cin >> s >> t >> x;
        event.push_back({{s - x, true}, x});
        event.push_back({{t - x, false}, x});
    }
    long long d;
    for (int i = 0; i < Q; i++) {
        cin >> d;
        event.push_back({{d, true}, 1e9 + 1});
    }
    sort(event.begin(), event.end());
    set<long long> S;
    for (auto e : event) {
        x = e.second;
        if (x > 1e9) {
            cout << (S.empty()? -1 : *S.begin()) << endl;
            continue;
        }
        if (e.first.second) {
            S.insert(x);
        } else {
            S.erase(x);
        }
    }
}


Measured memory_bytes: 26984
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
typedef long long LL;
#define ms(a,b) memset(a,b,sizeof(a))

int main()
{
    char S[55],T[55];
    cin>>S>>T;
    int len=strlen(S);
    int len2=strlen(T);
    int p=-1;
    for(int i=0;i<len;i++){
        int j=0;
        if(S[i]==T[j]||S[i]=='?'){
            for(j=1;j<len2;j++){
                    if(i+j>=len) break;
                    if(S[i+j]==T[j]||S[i+j]=='?') continue;
                    else{
                        break;
                    }
            }
            if(j>=len2) p=i;
        }
    }
    if(p==-1) cout<<"UNRESTORABLE"<<endl;
    else{
        for(int i=0;i<len;i++){
            if(i>=p&&i<p+len2){
                S[i]=T[i-p];
            }else if(S[i]=='?'){
                S[i]='a';
            }
        }
        cout<<S<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
program bounding
implicit none
integer n, x, i, res, d
integer,allocatable,dimension(:) :: l
read*, n, x
allocate(l(n))
read*, l
res=1
d=0
do i=1, n
 d=d+l(i)
 if(d.le.x) then
 res=res+1
 else if(d.gt.x) then
 else
 end if
end do
print*, res
end program

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N,T,A;
int main(){
    cin>>N>>T>>A;
    int H[N],J[N];
    int sum=222222222,k=0;
    for(int i=0;i<N;i++) cin>>H[i];
    for(int i=0;i<N;i++){
        int b=T*1000-H[i]*6-A*1000;
        if(b<0)b=-b;
        if(sum>b) sum=b,k=i+1;
    }
    cout<<k<<endl;
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
  if (input < 1200) {
    console.log('ABC');
    return;
  }

  if (input < 2800) {
    console.log('ARC');
    return;
  }

  console.log('AGC');
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) (1e9 + 7);
//const ll MOD = 998244353;
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

//------------------------------------------------------

ll mod_pow(ll a, ll n) { //a^n
    bitset<50> bs(n);
    ll p = a;
    ll res = 1;

    rep(i, 50) {
        if (bs[i]) res = res * p % MOD;
        p = p * p % MOD;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << setiosflags(ios::fixed);

    ll m, n;
    cin >> m >> n;
    cout << mod_pow(m, n) << endl;

    return 0;
}




Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define endl "\n"
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

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

  int A,B;cin>>A>>B;
  int res = 0;
  reps(i,A,B+1){
    string s = to_string(i);
    string t = s;
    reverse(ALL(s));
    if(s == t)res++;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	fmt.Scan(&s)
	
	sint := make([]int,len(s))
	for i := range sint {
		sint[i],_ = strconv.Atoi(string(s[i]))
	}
	
	ans := 0
	if len(s) > 1 {
		bef := sint[0]
		for i := 1; i < len(s); i++ {
			if bef == sint[i] {
				sint[i] = 1 - sint[i]
				ans++
			}
			bef = sint[i]
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
//author wjl

using namespace std;
#define LL long long
#define Rint register int
#define U unsigned
#define forn(i,a,b) for(int i = a;i <= b;++i)
#define nfor(i,a,b) for(int i = a;i >= b;--i)
#define pii pair<int ,int>
#define MS0(X) memset(X,0,sizeof(X))
#define MSf(X) memset(X,false,sizeof(X))
#define MS1(X) memset(X,-1,sizeof(X))
#define BR printf("--------------------\n")
#define pb push_back
#define rep(i,a,b) for(Rint i=a;i<=b;++i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
const double PI=atan(1.)*4.;
const int maxn=1e6+5;
const int inf = 0x3f3f3f3f;
const LL mod=1e9+7;
const double e=2.71828182845904523536;
int dirx[8]={1,0,-1,0,1,-1,-1,1};
int diry[8]={0,1,0,-1,1,1,-1,-1};
int cx,cy;

LL qpow(LL a, LL b ,LL mod)
{
    LL res=1;
    while(b!=0)
    {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

vector<LL> fac, facinv, inv;
void facInit(int nmax)
{
    fac = facinv = inv = vector<LL>(nmax + 1, 1);
    for (int i = 2; i <= nmax; i++)
    {
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        facinv[i] = facinv[i-1] * inv[i] % mod;
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>cx>>cy;
    if((cx+cy)%3!=0)
    {
        cout<<0;
        return 0;
    }
    int res=(cx+cy)/3;
    int n=cx-res;
    int m=cy-res;
    if(n<0||m<0)
    {
        cout<<0;
        return 0;
    }
    if(n<m)
        swap(n,m);
    facInit(n+m);
    cout<<(fac[m+n]*facinv[n])%mod*facinv[m]%mod<<endl;
    return 0;
}

Measured memory_bytes: 15872
a, b, c, k = gets.split.map(&:to_i)
sum = 0
if k >= a
  sum += 1 * a
  k = k - a
else
  sum += 1 * k
  k = 0
end
if k >= b
  sum += 0 * b
  k = k - b
else
  sum += 0 * k
  k = 0
end
if k >= c
  sum += -1 * c
  k = k - c
else
  sum += -1 * k
  k = 0
end
puts sum


Measured memory_bytes: 14372
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    ll x;
    cin>>x;
    ll cnt = 0;
    ll now = 100;
    while(1){
        now+=(now*0.01);
        cnt++;
        if(now>=x) break;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout(n) cout << fixed << setprecision(n)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acosl(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<pair<int, int>>;
using VTIII = vector<tuple<int, int, int>>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> inline bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int N, M;


signed main(){
    cin >> N >> M;
    rep(i, 0, M){
        int A;
        cin >> A;
        N -= A;
    }

    if(N >= 0) cout << N << endl;
    else cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>
#define N 50

int w, h, c[N][N];
int dy[8]={-1,-1,-1,0,0,1,1,1};
int dx[8]={-1,0,1,-1,1,-1,0,1};

void dfs(int y, int x){

  int i, ny, nx;
  
  c[y][x]=0;

  for(i=0;i<8;i++){
    
    ny=y+dy[i];
    nx=x+dx[i];

    if(ny<0||nx<0||h<=ny||w<=nx) continue;
    
    if(c[ny][nx]==1) dfs(ny, nx);
  }
  
}

int main(){
  
  int i, j, ans;

  while(1){
    
    scanf("%d %d", &w, &h);
    
    if(!w&&!h) break;

    ans=0;
    
    for(i=0;i<h;i++)
      for(j=0;j<w;j++) scanf("%d", &c[i][j]);
  
    for(i=0;i<h;i++)
      for(j=0;j<w;j++)
	
	if(c[i][j]==1){
	  
	  dfs(i, j);

	  ans++;
	}

    printf("%d\n", ans);

  }
  
  return 0;
}

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

long long count (long long &n, long long z, bool &isPrime) {
    long long cnt = 0;
    // cout << "z is "<< z << endl;
    while (n%z == 0) {
        n /= z;
    // cout << "n is "<< n << endl;
        cnt ++;
        isPrime = false;
    }
    long long ans = 0;    
    while (ans<cnt && cnt != 0){
    // cout << "cnt is " << cnt << endl;
        ans ++;
        cnt -= ans;
    }

    return ans;
}
int main() {
    long long n;
    cin >> n;
    long long ans = 0;

    if (n==1) {
        cout << ans << endl;
        return 0;
    }

    bool isPrime = true;
    long long z = 2;
    ans += count(n, z, isPrime);
    
    for (z=3; z*z<=n; z+=2){
        if (n%z != 0) continue;
        // cout << z * z << " " << n << endl; 
        ans += count(n,z, isPrime);
    }

    if (n != 1) ans += 1;
    if (isPrime) ans = 1; 
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3604
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

func sSort(s string) string {
	b := []byte(s)
	res := make([]int, len(s))
	for i := 0; i < len(s); i++ {
		res[i] = int(b[i])
	}
	sort.Ints(res)
	for i := 0; i < len(s); i++ {
		b[i] = byte(res[i])
	}

	return string(b)
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	m := make(map[string]int)

	for i := 0; i < n; i++ {
		s := sSort(next())
		m[s]++
	}

	res := 0
	for _, c := range m {
		if c < 2 {
			continue
		}

		res += c*(c-1)/2
	}
	fmt.Println(res)
}

Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,s;
  cin >> N;
  int m=1000000;
  vector<int> a(N);
  for(int i=1;i<=N;i++){cin >> a[i];}
  for(int i=-100;i<=100;i++){
    s=0;
    for(int j=1;j<=N;j++){
      s+=(i-a[j])*(i-a[j]);
    }
    if(m>s){m=s;}
  }
  cout << m << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        // input
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();

        int ab = Integer.parseInt(String.valueOf(Math.max(a, b)) + String.valueOf(Math.min(a, b)));
        int bc = Integer.parseInt(String.valueOf(Math.max(b, c)) + String.valueOf(Math.min(b, c)));
        int ca = Integer.parseInt(String.valueOf(Math.max(c, a)) + String.valueOf(Math.min(c, a)));

        // 比較
        int max = ab + c;
        max = Math.max(max, bc + a);
        max = Math.max(max, ca + b);

        // output
        System.out.println(max);

    }
}


Measured memory_bytes: 22868
#include <iostream>
#include <algorithm>
//#include <iomanip>
using namespace std;
int main() {

	int t[2], b[2];
	cin >> t[0] >> t[1] >> b[0] >> b[1];
	sort(t, t + 2);
	sort(b, b + 2);
	cout << t[0] + b[0] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
     float n;
 
     cin >> n;
  
     float s = n/2;

  
   if((int)n%2==0){
     
  
     float a = s/n;
     printf("%f\n", a);
    
     
   }else{
      int b = n/2;
     
      float ss = b+1;
     
      float a = ss/n;
     
      printf("%f\n", a);
     
     
     
   }
    
  
   
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
template<class T>
void dump(vector<T> &vec){
	for(int i=0;i<vec.size();i++){
		cout << vec[i];
		if(i+1<vec.size())cout << ' ';
		else cout << endl;
	}
	return;
}
int N;
ll E,T;
ll x[100100];
ll dp[100100];
priority_queue<ll,vector<ll>,greater<ll> > q;
int main(){
	cin >> N >> E >> T;
	for(int i=0;i<N;i++){
		cin >> x[i];
	}
	for(int i=0;i<=N;i++){
		dp[i] = LLINF;
	}
	dp[0] = 0ll;
	dp[1] = T;
	int p = -2ll;
	for(int i=0;i<N;i++){
		while(p+1<i&&2*(x[i]-x[p+2])>T){
			p++;
			q.push(dp[p+1]-2*x[p+1]);
		}
		if(!q.empty())chmin(dp[i+1],2*x[i]+q.top());
		if(p<i-1)chmin(dp[i+1],dp[p+2]+T);
		// cout << i << ' ' << p << ' ' << dp[i] << endl;

	}
	cout << E+dp[N] << endl;
	return 0;
}


Measured memory_bytes: 2936
#include<cstdio>
#include<cstring>
#include<algorithm>
const int maxn=5e5+10,inf=0x3f3f3f3f;
int n;
char s[maxn];
int f[maxn][3],mxa;
int suml[maxn],sumr[maxn];
using std::max;
int main(){
	scanf("%d",&n);
	scanf("%s",s+1);
	f[1][1]=f[2][1]=-1*inf;
	f[1][0]=f[2][0]=0;
	int first=0,cnt=0;
	for(int i=1;i<=n;i++){
		if (s[i]=='1') first++;
		else cnt++,suml[i]=first,first=0;
	}
	first=0;
	for(int i=n,tot=cnt;i>=1;i--){
		if (s[i]=='1') first++;
		else sumr[i]=first,first=0;
	}
	f[0][0]=0;f[0][1]=f[0][2]=-inf;
	int last=0,sum=0;
	for (int i=1;i<=n;i++)if(s[i]!='1'){
		f[i][0]=max(f[last][0],max(f[last][1],f[last][2]));
		if(suml[i]&&sumr[i])f[i][1]=max(f[last][0]+suml[i],f[last][1]+suml[i]-1);
		else f[i][1]=-inf;
		if(suml[i]&&sumr[i])f[i][2]=max(max(f[last][0]+sumr[i],suml[i]>=2?f[last][1]+sumr[i]:0),f[last][2]+sumr[i]-1);
		else f[i][2]=-inf;
		mxa=max(f[i][0],max(f[i][1],f[i][2]));
		sum=max(sum,mxa);
		last=i;
	}
	printf("%d\n",sum);
	return 0;
}

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


#define DEBUG

using namespace std;

const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;


#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

typedef pair<int, int> P;

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

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


ll N, M, K;
ll A[1000000];
ll Mount[1000000];

signed main() {

    cin >> N;

    rep(i,N){
        ll a; cin >> a;
        A[i] = a;
    }

    Mount[0] = 0;
    rep(i,N-1){
        Mount[i + 1] = (A[i] - Mount[i]/2)*2; 
    }

    ll diff = A[N-1] - (Mount[N-1]/2);

    Mount[0] = diff;
    rep(i,N-1){
        Mount[i + 1] = (A[i] - Mount[i]/2)*2; 

    }

    rep(i,N) cout << Mount[i] << endl;

    return 0;
}


Measured memory_bytes: 6144
from sys import stdin
#from collections import deque
#from math import sqrt, floor, ceil, log, log2, log10, pi, gcd
def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return [x for x in mi()]
def si(): return stdin.readline()
n=int(input())
print(n*n)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <stack>

using namespace std;

struct Counter
{
    int radix;
    vector<int> value;
    vector<int> index;

    Counter(int radix)
    {
        this->radix = radix;
        value.push_back(0);
        index.push_back(0);
    }

    void offset(int b)
    {
        if (b > index.back())
        {
            index.push_back(b);
            value.push_back(0);
            return;
        }
        while (b < index.back())
        {
            index.pop_back();
            value.pop_back();
        }
        if (index.back() != b)
        {
            index.push_back(b);
            value.push_back(0);
        }
        inc();
    }

    void inc()
    {
        if (radix == 1)
        {
            value[0]++;
            return;
        }

        while (++value.back() == radix && value.size() > 1)
        {
            int carried_base = index.back();
            index.pop_back();
            value.pop_back();

            if (carried_base - 1 != index.back())
            {
                index.push_back(carried_base - 1);
                value.push_back(0);
            }
        }
    }

    bool is_valid() const
    {
        return value[0] == 0;
    }
};

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

    vector<int> a(n);
    for (int &v : a)
    {
        cin >> v;
    }

    auto ok = [&a](int mid) {
        Counter counter(mid);
        for (int v : a)
        {
            counter.offset(v);
        }
        return counter.is_valid();
    };

    int low = 0, high = n;
    while (high - low > 1)
    {
        int mid = (low + high) / 2;

        (ok(mid) ? high : low) = mid;
    }

    cout << high << endl;

    return 0;
}


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

int main() {
  int n, k, a, b, c, d, e, f, g, h, i, z, x;
  cin >> n >> k;
  a = 1;
 for (int i = 0; i < n; i++)
 {
   if(a * 2 <= a + k ){
   a = a * 2; }
   else { a += k; }
 }  
  
  cout << a << endl;
}


Measured memory_bytes: 256
#include <cstdio>
int n, m, k, a[35], s;
int main(){
	scanf("%d%d", &n, &m);
	for (register int i = 1; i <= n; ++i){
		scanf("%d", &k);
		for (register int j = 1, x; j <= k; ++j)
			scanf("%d", &x), ++a[x];
    }
	for (register int i = 1; i <= m; ++i) s += a[i] == n;
	printf("%d\n", s);
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 数値
		int n1 = sc.nextInt();
		int nn1 = n1;
		int n2 = sc.nextInt();
		int nn2 = n2;

		int n;

		int count = 1;
		for (;;) {
			n = n1 / n2;
			n1 = n;
			if (n1 < n2) {
				break;
			}
			count++;
		}

		if (nn1 < nn2) {
			System.out.println(1);
		} else {
			System.out.println(count + 1);
		}
	}
}


Measured memory_bytes: 21204
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define all(x) (x).begin() , (x).end()
#define in insert
#define int ll
using namespace std;
using namespace __gnu_pbds;
 
const ll N =(3e5+5);
const ll MOD = 998244353;
const ll INF = 1e16;
const ll LOG = 25;
 
 
long long binpow(long long a, long long b) {
    // a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a ;
        a = a * a ;
        b >>= 1;
    }
    return res;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    ll n,m;
    cin >> n >> m;
    cout << ((n*(n-1))/2)+ ((m*(m-1))/2) << endl;

}
/*
for(int i =1;i<=m;i++){
        for(int j = 1;j<=i;j++){
            cout<<"ELEMENTS : " << i << " , " << "ROUNDED DOWN : " << j << " DP VALUE : "<< dp[i][j] << endl;
        }
    }
*/

Measured memory_bytes: 256
n, m = map(int, input().split(' '))
a = [0]*m
b = [0]*m
for i in range(m):
    a[i], b[i] = list(map(int, input().split(' ')))

c = [-1]*(m+2)

def find(num):
    if c[num] < 0:
        return num
    else:
        k = find(c[num])
        c[num] = k
        return k

result = [int(n*(n-1)/2)]
for i in range(m-1, 0,-1):
    x = find(a[i])
    y = find(b[i])

    if x != y:
        result.append(result[-1]-c[x]*c[y])
        x, y = sorted([x,y])
        c[x] += c[y]
        c[y] = x
    else:
        result.append(result[-1])

for i in result[::-1]:
    print(int(i))


Measured memory_bytes: 17688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

  ll a, b;
  cin >> a >> b;

  ll g = __gcd(a, b);

  ll ans = 1;

  ll num = g;
  for (ll j = 2; j*j <= g; j++) {
    bool isUniq = true;
    while (num % j == 0) {
      num /= j;
      if (isUniq) {
        ans++;
        isUniq = false;
      }
    }

    if (num == 1) break;
  }
  if(g != 1 && num != 1)ans++;

  cout << ans << endl;

  return 0;
}


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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

void we_r_done(){cout<<"NO"; exit(0);}

void debug(string mssg){cout<<mssg; exit(0);}


int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    ///FastIO;
    int n;
    lli k;
    scn(n);
    scnll(k);

    vector<pii>v;

    for(int i=0; i<n; i++){
        int a,b;
        scn2(a,b);
        v.pb({a,b});
    }

    sort(atoz(v));

    for(int i=0; i<v.size(); i++){

        if(v[i].se>=k){
            cout<<v[i].fi;
            break;
        }
        k -= v[i].se;
    }


    return 0;
    ///return main();
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///priority_queue< int, vector< int >, greater< int > > minHeap;
///using bs = bitset<MX>; // how many distinct number can be form?


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

map<ll, ll> pd;

void primediv(ll p){
    for(ll i = 2; i*i <= p; i++){
        if(p%i == 0){
            pd[i]++;
            p /= i;
            i = 1;
        }
    }
    pd[p]++;
}

void pr(ll n){
    cout << n << endl;
    exit(0);
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    
    ll n, p;
    cin >> n >> p;
    
    if(p == 1){
        pr(1);
    }
    if(n == 1){
        pr(p);
    }
    
    primediv(p);
    dump(pd);
    
    ll ans = 1;
    for(auto&& e: pd){
        ans *= powint(e.first, (e.second/n));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a-1; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};



int main(){
    ll n, m;    cin >> n >> m;
    vector<vector<ll>> g(n);
    vector<ll> dp(n, 0), v(n, 0);
    rep(i, m){
        ll a, b;    cin >> a >> b;
        a--, b--;
        g[b].push_back(a);
        v[a] += 1;
    }
    queue<ll> que;
    rep(i, n){
        if(!v[i]) que.push(i);
    }
    while(!que.empty()){
        ll nv = que.front(); que.pop();

        for(auto x: g[nv]){
            v[x] -= 1;
            if(!v[x]){
                dp[x] = max(dp[x], dp[nv]+1);
                que.push(x);
            }
        }
    }
    ll res=0;
    rep(i, n) res = max(res, dp[i]);
    cout << res << endl;
}


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

typedef long long ll;


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

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

    vector<vector<char> > S(H, vector<char>(W));
    vector<vector<pair<int, int> > > B(H, vector<pair<int, int> >(W));

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> S[i][j];
        }
    }

    vector<int> c(H * W * 3);

    int num = 0;
    int count = 0;

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if(S[i][j] == '#') {
                c[num] = count;
                count = 0;
                num++;
            } else {
                count++;
                B[i][j].first = num;
            }
        }

        c[num] = count;
        count = 0;
        num++;
    }


    for(int i = 0; i < W; i++) {
        for(int j = 0; j < H; j++) {
            if(S[j][i] == '#') {
                c[num] = count;
                count = 0;
                num++;
            } else {
                count++;
                B[j][i].second = num;
            }
        }
        
        c[num] = count;
        count = 0;
        num++;
    }

    int max = 0;

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            int x = c[B[i][j].first] + c[B[i][j].second];
            if(x > max)
                max = x;
        }
    }

    cout << max - 1 << endl;
}

Measured memory_bytes: 82432
let () =
  let open Queue in
  let (n:int),(quantum:int) = Scanf.scanf "%d %d\n" (fun a b -> a,b) in
  let (q:(string * int) t) = create () in
  for i=1 to n do
    push (Scanf.scanf "%s %d\n" (fun a b -> a,b)) q
  done;
  let (sum:int ref) = ref 0 in
  while not (is_empty q) do
    match pop q with
      p,t when t <= quantum ->
      sum := !sum + t;
      Printf.printf "%s %d\n" p !sum
    | p,t ->
      push (p,t-quantum) q;
      sum := !sum+quantum
  done

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

vector<bool> seen(60,false);

void dfs(vector<vector<int>> &g,int v,pair<int,int> &p) {
    seen[v]  = true;
    for(auto c : g[v]) {
        if(seen[c]) {
            continue;
        }
        if(v == p.first && c == p.second) {
            continue;
        }
        if(v == p.second && c == p.first) {
            continue;
        }
        dfs(g,c,p);
    }
}

int main() {
    int n,m;
    cin >> n >> m;
    vector<vector<int>> g(n+1);
    vector<pair<int,int>> p;
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
        p.push_back(make_pair(a,b));
    }
    int ans = 0;
    rep(i,m) {
        dfs(g,1,p[i]);
        for(int j = 1; j <= n; j++) {
            if(!seen[j]) {
                ans++;
                break;
            }
        }
        for(int j = 1; j <= n; j++) {
            seen[j] = false;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        
        
        String s = sc.next();
        if((s.equals("AAA"))||(s.equals("BBB"))){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
    
}

Measured memory_bytes: 22228
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	num, _ := strconv.Atoi(sc.Text())
	return num
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()

	ans := make([]int, n+1)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
		ans[a[i]]++
	}

	total := 0
	for i := 0; i < n; i++ {
		if ans[i+1] != 0 {
			total += ans[i+1] * (ans[i+1] - 1) / 2
		}
	}

	wb := bufio.NewWriter(os.Stdout)
	defer wb.Flush()
	for i := 0; i < n; i++ {
		if ans[a[i]] == 0 {
			fmt.Fprintln(wb, 0)
		} else {
			temp := ((ans[a[i]] - 1) * (ans[a[i]] - 2) / 2) - (ans[a[i]] * (ans[a[i]] - 1) / 2)
			fmt.Fprintln(wb, total+temp)
		}
	}

}


Measured memory_bytes: 7424
#!/usr/bin/env python3
import string
s = input()
rem = set(string.ascii_lowercase).difference(set(s))
answer = -1
for r in reversed(range(len(s) + 1)):
    if r < len(s):
        rem.add(s[r])
    for c in rem:
        t = s[: r] + c
        if s < t and (answer == -1 or t < answer):
            answer = t
print(answer)


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

using namespace std;
  vector<long long int> DP;
  vector<int> h;
  int k;
long long int DP_function(int i){
	if(i<0)return 999999999;
	if(DP[i] == -1)
  		//DP[i] = min(abs(h[i -2] - h[i]) + DP_function(i - 2), abs(h[i - 1] - h[i]) + DP_function(i - 1));
 {  long long int a=abs(h[i - 1] - h[i]) + DP_function(i - 1);
        int j=i-2;
         while(j>=0&&i-j<=k)
         {
             a=min(a,abs(h[j]-h[i])+DP_function(j));
             j--;
         }
         DP[i]=a;
 }
	return DP[i];
}

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

	h.resize(N);
	for(int index = 0; index < N; index++)
		cin >> h[index];

	 DP.resize(N, -1);
   DP[0]=0;
	cout << DP_function(N-1);

	return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < (n); ++i )
#define rep_rev(n,i) for(ll i = n; i >= 0; --i )
using namespace std;
using P = pair<int, int>;
const long long INF = 1LL << 60;

int main(){
  int N; cin >> N;
  vector<int> X(N,0);
  double ave;
  int sum = 0, ans = 0;
  rep(i,N){
    cin >> X[i];
    sum += X[i];
  }
  ave = (double)sum / (double)N;
  int floor_ave = round(ave);
  rep(i,N){
    ans += pow(X[i]-floor_ave,2);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int n,m,sum=0,i;
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++)
  {
    sum+=i;
  }
  for(i=0;i<m;i++)
  {
    sum+=i;
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll MOD = 1e9+7;
ll N;
map<pll, ll> memo;

ll func(ll s, ll x) {
  //cout << "s = " << s << ", x = " << x << endl
  if (x == 0) return s/2+1;
  if (s == 0) return 1;
  if (s == 1) return 2;



  ll res = 0;
  if (memo.find(pll(s/2, x/2)) != memo.end()) {
    res += memo[pll(s/2, x/2)];
  } else {
    int t = func(s/2, x/2);
    memo[pll(s/2, x/2)] = t;
    res += t;
  }

  if (memo.find(pll((s-1)/2, (x-1)/2)) != memo.end()) {
    res += memo[pll((s-1)/2, (x-1)/2)];
  } else {
    int t = func((s-1)/2, (x-1)/2);
    memo[pll((s-1)/2, (x-1)/2)] = t;
    res += t;
  }

  if (memo.find(pll((s-2)/2, x/2)) != memo.end()) {
    res += memo[pll((s-2)/2, x/2)];
  } else {
    int t = func((s-2)/2, x/2);
    memo[pll((s-2)/2, x/2)] = t;
    res += t;
  }

  //cout << "s = " << s << ", x = " << x << ", res = " << res << endl;
  return res % MOD;
}

int main() {
  cin >> N;

  cout << func(N, N) << endl;

}


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

#ifdef TESTING
  #include "dump.hpp"
#else
  #define DUMP(...)
  #define DEBUG(...)
#endif

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define INT(n) int n;assert(0<scanf("%d",&n))
#define VI(v,n) vector<int> v(n);REP(i,n){assert(0<scanf("%d",&v[i]));}

int main(){
  INT(n); VI(as, n);
  vector<ll> ss = {0};
  REP(i, n){
    ss.PB(ss[i]);
    ss[i + 1] += as[i];
  }
  map<ll, int> mp; mp[0] = 1;
  ll ans = 0;
  REP(i, n){
    if (mp.count(ss[i + 1])){
      ans += mp[ss[i + 1]];
      mp[ss[i + 1]]++;
    } else {
      mp[ss[i + 1]] = 1;
    }
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 15088
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int A, B;
    cin >> A >> B;
    int diff = abs(A - B);
    if (diff % 2 == 1) cout << "IMPOSSIBLE" << '\n';
    else cout << (A + B) / 2 << '\n';
    return 0;
}

Measured memory_bytes: 3568
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_right().to_owned()
}

fn div_n(source: u64, n: u64) -> Option<(u64, u64)> {
    let mut x = source;
    let mut count = 0;
    while x % n == 0 {
        x /= n;
        count += 1;
    }
    
    if count == 0 { None } else { Some((x, count)) }
}

fn factorize(source: u64) -> Vec<u64> {
    let mut x = source;
    let mut v = Vec::new();

    if let Some((divided, count)) = div_n(source, 2) {
        x = divided;
        v.extend(vec![2; count as usize]);
    }

    let mut i = 3;
    while (x / 3 + 3) > i {
        if let Some((divided, count)) = div_n(x, i) {
            x = divided;
            v.extend(vec![i; count as usize]);
        }
        i += 2;
    }
    
    if i != 1 {
        v.push(x);
    }
    v
}

fn least_common_multiple(a: u64, b: u64) -> u64 {
    let afs = factorize(a);
    let mut bfs = factorize(b);

    let mut x = 1;
    for af in afs {
        x *= af;
        if let Some(bf_index) = bfs.iter().position(|&bf| bf == af) {
            bfs.remove(bf_index);
        }
    }
    
    bfs.into_iter().fold(x, |total, bf| total * bf)
}

fn main() {
    let v: Vec<u64> = read_line().split_whitespace().map(|x| x.parse().unwrap()).collect();
    let (a, b, c, d) = (v[0], v[1], v[2], v[3]);
    let len = b - a + 1;
    let offset_c = (a - 1) % c;
    let offset_d = (a - 1) % d;
    let lcm = least_common_multiple(c, d);
    let offset_lcm = (a - 1) % lcm;
    
    let c_count = (len + offset_c) / c;
    let d_count = (len + offset_d) / d;
    let lcm_count = (len + offset_lcm) / lcm;
    println!("{}", len - (c_count + d_count - lcm_count));
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>

int main(void){
        std::string N, A, B;
        std::cin >> N >> A >> B;
        long g_size = std::stol(A) + std::stol(B);
        long over_size = std::stol(N) % g_size;
        if (over_size > std::stol(A))
                std::cout << (std::stol(N) / g_size + 1) * std::stol(A);
        else
                std::cout << (std::stol(N) / g_size) * std::stol(A) + over_size;
        return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <cmath>
#define PI 3.14159265358979323846264338327950L
int main(){
    int A,  B, H, M;
    long double a_x, a_y, b_x, b_y;
    long double a_sita, b_sita;
    long double result;
    std::cin >> A >> B >> H >> M;
    //a_sita = (2*M_PI)/12/60*(H*60+M);
    a_sita = (2*M_PI)/12/60*(H*60+M);
    //b_sita = (2*M_PI)/60*(H*60+M);
    b_sita = (2*PI)/60*(H*60+M);
    a_x = A*sin(a_sita+M_PI/2);
    a_y = A*cos(a_sita+M_PI/2);
    b_x = B*sin(b_sita+M_PI/2);
    b_y = B*cos(b_sita+M_PI/2);

    result = sqrt(pow(a_x - b_x, 2) + pow(a_y - b_y, 2));
    printf("%.20Lf\n", result);
    //printf("%.20lf\n", M_PI);
    //printf("%.20Lf\n", PI);
    return 0;
}

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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

inline ll combi2(const ll n) {
    return n * (n - 1) / 2;
}



int main() {
    int n;
    cin >> n;
    set<string> st;
    map<string, int> mp;
    ll ans = 0;
    REP(i, n) {
        string buf;
        cin >> buf;
        sort(ALL(buf));
        mp[buf]++;
    }
    for(auto e : mp) {
        ans += combi2(e.second);
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 11264
import numpy
X,Y=map(int,input().split())

if Y%2 != 0:
    print("No")

else:
    N_max = int(Y/2)
    for n in numpy.array(range(N_max, -1, -2)):
        if X == n + (N_max - n)/2:
            print("Yes")
            break
    else:
        print("No")

Measured memory_bytes: 27172
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>

const int N = 200000;

char s[N + 1];

int main()
{
#ifdef LOCAL_JUDGE
    freopen("B.in", "r", stdin);
#endif
    while (scanf("%s", s) == 1) {
        int n = strlen(s);
        int cnt[26];
        memset(cnt, 0, sizeof(cnt));
        long long result = 1;
        for (int i = 0; i < n; ++ i) {
            cnt[s[i] - 'a'] ++;
        }
        for (int a = 0; a < 26; ++ a) {
            for (int b = 0; b < a; ++ b) {
                result += (long long)cnt[a] * cnt[b];
            }
        }
        printf("%lld\n", result);
    }
}



Measured memory_bytes: 384