akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

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

using namespace std;
const int INF = 1 << 30;
const long long LINF = 1LL << 60;
const long long MOD = 1000000000 + 7;
const double PI = acos(-1);

int main() {
	string S, T; cin >> S >> T;
	int ans = 0;
	rep(i, S.size()) {
		if (S[i] != T[i])++ans;
	}
	cout << ans;
}



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

int main()
{
    int n;
    cin >> n;
    rep(i, 9) rep(j, 9)
    {
        if ((i + 1) * (j + 1) == n)
        {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
}

Measured memory_bytes: 3600
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const int mod=1e9+7;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int h,w;
	cin>>h>>w;
	string s[h+1];
	for(int i=1;i<=h;i++)
	{
		cin>>s[i];
		s[i]='0'+s[i];
	}
	int dp[h+1][w+1];
	bool flag=0;
	for(int i=h-1;i>=1;i--)
	{
		if(s[i][w]=='#')
		{
			flag=1;
		}
		if(flag==0)
		{
			dp[i][w]=1;
		}
		else
		{
			dp[i][w]=0;
		}	
	}
	flag=0;
	for(int i=w-1;i>=1;i--)
	{
		if(s[h][i]=='#')
		{
			flag=1;
		}
		if(flag==0)
		{
			dp[h][i]=1;
		}
		else
		{
			dp[h][i]=0;
		}	
	}
	for(int i=h-1;i>=1;i--)
	{
		for(int j=w-1;j>=1;j--)
		{
			if(s[i][j]=='#')
			{
				dp[i][j]=0;
			}
			else
			{
				dp[i][j]=(dp[i+1][j]+dp[i][j+1])%mod;
			}
		}
	}
	cout<<dp[1][1];
}

Measured memory_bytes: 8544
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long
typedef pair<ll,ll> P;
int N,X,D;
//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> N >> X >> D;
  
  if(D == 0){
  	if(X == 0){
  		cout << 1 << endl;
  	}
  	else{
  		cout << N + 1 << endl;
  	}
  	return 0;
  }

  map<int,vector<P>> mp;
  for(int i = 0 ; i < N + 1 ; i++){
  	int s = X * i;
  	int l = (ll)i * (i - 1) / 2;
  	int r = l + (ll)i * (N - i);
  	s += l * D;
  	r -= l;
  	mp[(s%D + D) % D].emplace_back(s,r);
  }

  ll ans = 0;
  for(auto p : mp){
  	auto a = p.second;
  	int m = a.size();
  	for(int i = 0 ; i < m ; i++){
  		a[i].first = (a[i].first - p.first)/D;
  	}
  	vector<P> ev;
  	for(int i = 0 ; i < m ; i++){
  		ev.emplace_back(a[i].first, 1);
  		ev.emplace_back(a[i].first + a[i].second + 1 , -1);
  	}
  	sort(ev.begin(),ev.end());

  	int cnt = 0, pre = mllINF;

  	for(auto e : ev){
  		int len = e.first - pre;
  		if(cnt) ans += len;
  		cnt += e.second;
  		pre = e.first;
  	}
  }
  cout << ans << endl;
  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 22144
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
char A[SZ],B[SZ]; int n,ans;
int mi[SZ],ma[SZ],mx[SZ];
void work()
{
	for(int i=0;i<n;++i)
	{
		mi[i]=ma[i]=0;
		while(B[(i+ma[i])%n]!='1') ++ma[i];
		while(B[(i+mi[i]+n)%n]!='1') --mi[i];
	}
	for(int s=0;s<n;++s)
	{
		for(int r=0;r<n;++r) mx[r]=0;
		int dif=0;
		for(int r=0;r<n;++r) if(A[r]!=B[(r+s)%n])
			mx[-mi[r]]=max(mx[-mi[r]],ma[r]-s),++dif;
		int ly=0,ca=1e9;
		for(int r=n-1;r>=0;--r)
			ca=min(ca,ly+r), ly=max(ly,mx[r]);
		ans=min(ans,2*ca+s+dif);
	}
}
int main()
{
	scanf("%s%s",A,B);
	n=strlen(A); ans=1e9;
	bool ha=0,hb=0;
	for(int i=0;i<n;++i)
		if(A[i]=='1')ha=1;
	for(int i=0;i<n;++i)
		if(B[i]=='1')hb=1;
	if(!hb)
	{
		if(ha) puts("-1");
		else puts("0");
		return 0;
	}
	work(); reverse(A,A+n);
	reverse(B,B+n); work();
	printf("%d\n",ans);
}


Measured memory_bytes: 6528
#include <cmath>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <iostream>
#include <algorithm>


using namespace std;


int main() {
	int n = 0, a = 0, b = 0;
	cin >> n;
	if(n == 1) {
		cout << "Hello World" << endl;
	} 
	else {
		cin >> a >> b;
		int val = a + b;
		cout << val << endl;	
	}	

    return 0; 
} 

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define vll vector<ll>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool a)
{
    if (a == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

ll gcd(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

int main()
{
    ll n, k;
    cin >> n >> k;

    ll cnt0 = n / k;
    ll cntk = (n + k / 2) / k;

    if (k % 2 == 0)
    {
        cout << cnt0 * cnt0 * cnt0 + cntk * cntk * cntk << endl;
    }
    else
    {
        cout << cnt0 * cnt0 * cnt0 << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>

using namespace std;

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


Measured memory_bytes: 256
import sys
import collections
import bisect


def main():
    n = int(input())
    A, B = [0] * n, [0] * n
    cnt = 0
    for i in range(n):
        [A[i], B[i]] = list(map(int, input().split()))
    for i in range(n):
        a = n - i - 1
        k = B[a] - (((A[a] + cnt) % B[a]))
        cnt += 0 if k == B[a] else k
    print(cnt)


if __name__ == '__main__':
    main()


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

/* 繰り返し自乗法. */
int modPow(long long a, long long n, long long p) {
	if (n == 0) return 1; // 0乗にも対応する場合.
	if (n == 1) return a % p;
	if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
	long long t = modPow(a, n / 2, p);
	return (t * t) % p;
}

signed main() {
    char S;
    cin >> S;
    if (('A' <= S) && (S <= 'Z')) cout << 'A' << endl;
    else cout << 'a' << endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f(z) for(int i=1;i<=z;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define vi vector<int>
#define pb push_back
#define si set<int>
#define mod  1000000007
#define cl(n,m) (n-1)/m  + 1 ;
#define T() int TT; cin>>TT; while(TT--)
#define P pair<int,int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 2e5 + 5 , inf = 1e13;
int a[N] ;
signed main(){
	int n ; 
	cin >>n  ;
	f(n) cin >> a[i] ;
	f(n) a[i] = a[i] * 2 ;
	int ans = 0 ;
	for ( int i =1 ; i <n ; i++){
		if(i&1) ans+= a[i] ;
		else ans -= a[i] ;
	}
	//cout << t << endl; 
	int t = (ans + a[n])/2 ;
	cout << t <<" ";
	for ( int i = 1 ; i<n ; i++){
		cout << a[i] -t <<" ";
		t = a[i] - t ;
	}
}

Measured memory_bytes: 2048
#include <stdio.h>

typedef struct {
	int left, right, count[26];
} seg_node;

void init_node(seg_node v[], int p[], int k, int l, int r)
{
	int i;
	v[k].left = l;
	v[k].right = r;
	for (i = 0; i < 26; i++) v[k].count[i] = 0;
	if (l < r) {
		init_node(v, p, k * 2, l, (l + r) / 2);
		init_node(v, p, k * 2 + 1, (l + r) / 2 + 1, r);
	} else p[l] = k;
}

void count_sum(seg_node v[], int flag[], int k, int l, int r)
{
	int j;
	if (v[k].right < l || v[k].left > r) return;
	else if (v[k].left >= l && v[k].right <= r) {
		for (j = 0; j < 26; j++) flag[j] += v[k].count[j];
	} else {
		count_sum(v, flag, k * 2, l, r);
		count_sum(v, flag, k * 2 + 1, l, r);
	}
}

int main()
{
	int N, Q;
	char S[500001];
	scanf("%d", &N);
	scanf("%s", S);
	scanf("%d", &Q);
	
	int i, j, p[500001];
	seg_node v[2000000];
	init_node(v, p, 1, 0, N - 1);
	for (i = 0; i < N; i++) {
		for (j = p[i]; j >= 1; j /= 2) v[j].count[S[i] - 'a']++;
	}
	
	int q, l, r, type, flag[26], ans;
	char c;
	for (q = 0; q < Q; q++) {
		scanf("%d", &type);
		if (type == 1) {
			scanf("%d %c", &i, &c);
			for (j = p[i-1]; j >= 1; j /= 2) {
				v[j].count[S[i-1] - 'a']--;
				v[j].count[c - 'a']++;
			}
			S[i-1] = c;
		} else {
			scanf("%d %d", &l, &r);
			for (j = 0; j < 26; j++) flag[j] = 0;
			count_sum(v, flag, 1, l - 1, r - 1);
			for (j = 0, ans = 0; j < 26; j++) if (flag[j] > 0) ans++;
			printf("%d\n", ans);
		}
	}
	
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 118824
#include<bits/stdc++.h>
using namespace std;
float func(int[] ,int);
int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	float c=func(a,n);
	cout<<1/c;
	return 0;
}

  float func(int a[],int n)
  {
  	int i;
  	float sum;
  	for(i=0;i<n;i++)
  	{
  		sum+=(float)1/a[i];
	  }
	  return sum;
  }

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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 10;

int x;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> x;
    cout << 1 - x;
    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    long long n,t; cin>>n>>t;
    long long a[n]; rep(i,n) cin>>a[i];
    map<long long,long long> mp;
    long long mini=INF;
    rep(i,n){
        mini=min(mini,a[i]);
        mp[abs(mini-a[i])]++;
    }
    long long ans;
    for(auto i:mp){
        ans=i.second;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 7296
#include<stdio.h>
main(){
  int tmp,i,j,a[5];

  scanf("%d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4]);

  for(i=0;i<=4;i++){
    for(j=4;j>i;j--){
      if(a[i]<a[j]){
	tmp=a[i];
	a[i]=a[j];
	a[j]=tmp;
      }
    }
  }

  printf("%d %d %d %d %d\n",a[0],a[1],a[2],a[3],a[4]);

  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define all(v) v.begin(), v.end()
//
int main(){
   int X,N; cin>>X>>N;
   vector<int> v;
   rep(i,N) {
       int c;
       cin>>c;
       v.push_back(c);
   }
   vector<int> vv;
   rep(i,301){
      vv.push_back(i-100);
   }
   rep(i,N){
      vv[v[i]+100]=10000;
   }
   int ans=100;
   rep(i,vv.size()){
      ans=min(ans,abs(vv[i]-X));
   }
 //  for(auto e:vv) cout<<e;
   if(find(all(vv),X-ans) !=vv.end()){
      cout<<X-ans<<endl;
      return 0;
   }
   cout<<X+ans<<endl;
}



Measured memory_bytes: 3604
# -*- coding: utf-8 -*-
import math

[a, b, x] = [int(i) for i in input().split()]

# 台形の場合の短辺yを求める
y = (2*x / a**2) - b

if y >= 0:
    # yがプラスなら台形の場合で角度を計算
    theta = math.atan((b-y)/a)
else:
    # yがマイナスなら三角形の計算で高さyを求める
    y = (2*x) / (a*b)
    # 三角形の倍の角度を計算
    theta = math.atan(b / y)

print(math.degrees(theta))


Measured memory_bytes: 3060
import sys, math
def input(): return sys.stdin.readline().strip()


def func(R, G, B, lR, lG, lB):
    pG = lG - 1
    pB = lB - 1
    sumR = 0
    sumG = 0

    for i in range(lR - 1, -1, -1):
        while pG >= 0 and R[i] < G[pG]:
            while pB >= 0 and G[pG] < B[pB]:
                pB -= 1
            sumG += (lB - pB - 1)
            pG -= 1
        sumR += sumG
    return sumR


def main():
    N = int(input())
    S = input()
    
    R = []
    G = []
    B = []
    lR = 0
    lG = 0
    lB = 0
    for i in range(N):
        if S[i] == "R":
            R.append(i)
            lR += 1
        elif S[i] == "G":
            G.append(i)
            lG += 1
        else:
            B.append(i)
            lB += 1
    
    ans = 0
    ans += func(R, G, B, lR, lG, lB)
    #print("RGB->{}".format(func(R, G, B, lR, lG, lB)))
    ans += func(R, B ,G, lR, lB, lG)
    #print("RBG->{}".format(func(R, B ,G, lR, lB, lG)))
    ans += func(G, R, B, lG, lR, lB)
    #print("GRB->{}".format(func(G, R, B, lG, lR, lB)))
    ans += func(G, B, R, lG, lB, lR)
    #print("GBR->{}".format(func(G, B, R, lG, lB, lR)))
    ans += func(B, R, G, lB, lR, lG)
    #print("BRG->{}".format(func(B, R, G, lB, lR, lG)))
    ans += func(B, G, R, lB, lG, lR)
    #print("BGR->{}".format(func(B, G, R, lB, lG, lR)))

    subtract = 0
    for i in range(N):
        for j in range(i + 1, N):
            k = j * 2 - i
            if k < N and (S[i] != S[j] and S[j] != S[k] and S[k] != S[i]):
                subtract += 1

    print(ans - subtract)
    


if __name__ == "__main__":
    main()


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

int main() {
    int T;
    cin >> T;
    while (T--) {
        ll n;
        cin >> n;
        vector<ll> as(n);
        rep(i,n) cin >> as[i];
        string s;
        cin >> s;

        bool one = false;
        vector<ll> bs;
        for (ll i = n - 1; i >= 0; i--) {
            ll a = as[i];
            for (ll b : bs){
                a = min(a, a ^ b);
            }
            if (s[i] == '0') {
                if (a != 0) bs.emplace_back(a);
            }

            if (s[i] == '1') {
                if (a != 0) {
                    one = true;
                    break;
                }
            }
        }
        cout << (one ? 1 : 0) << endl;
    }
}


Measured memory_bytes: 3628
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	res := 0.0
	for i := 0; i < n; i++ {
		tmp := 0.0
		fmt.Scan(&tmp)
		res += 1 / tmp
	}
	fmt.Println(1 / res)
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
 
int main(void){
  int N, M, u;
  long int modulo = 1000000007;
  vector<int> un_used;
  cin >> N >> M;
  vector<long int> dp(N+1, -1);
  dp[0] = 1;
  dp[1] = 1;
  
  for(int i = 0; i < M; i++){
    int input;
    cin >> input;
  	dp[input] = 0;
  }
  
  
  u = 0;  
  for(int i = 2; i <= N; i++){
    if(dp[i] == -1){
      dp[i] = dp[i-2] + dp[i-1];
      dp[i] %= modulo;
    }
  }
  
  cout << dp[N];
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	string S;
	cin >> N >> S;
	int cnt = 0;
	int ans = 1;
	rep(i,N){
		ans *= i+1;
		ans %= MOD;
	}
	rep(i,N*2){
		if(cnt % 2 == 1){
			if(S[i] == 'B'){
				ans *= cnt;
				--cnt;
			}
			else{
				cnt++;
			}
		}
		else{
			if(S[i] == 'B'){
				cnt++;
			}
			else{
				ans *= cnt;
				--cnt;
			}
		}
		if(cnt < 0){
			cout << 0 << endl;
			return 0;
		}
		ans %= MOD;
	}
	if(cnt != 0){
		cout << 0 << endl;
		return 0;
	}
	cout << ans << endl;
}

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

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

	int ans = 105;
	rep(i,26){
		int d = 0;
		int d_max = 0;
		rep(j,s.size()){
			if (s[j]-'a' != i) d++;
			else {
				d_max = max(d_max, d);
				d = 0;
			}
		}
		d_max = max(d_max, d);
		ans = min(ans, d_max);
	}

	cout << ans << endl;
return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'

const int N = 2e5 + 10;
int a[N];

int32_t main() {                                                                                                                        
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      ans^= a[i];
    }
    for (int i = 0; i < n; i++) {
      int cur = ans ^ a[i];
      cout << cur << " ";
    }
}  

Measured memory_bytes: 5104
#include <iostream>
using std::cout;
using std::endl;
using std::cin;

template<typename T>
void insertion_sort(T in[],size_t size){
  T key;
  int j;
  auto show = [=]{
    for(int i=0;i<size-1;i++)cout << in[i] << ' ';
    cout << in[size-1] << endl;
  };
  for(int i=1;i<size;i++){
    show();
    key = in[i];
    j=i-1;
    while((j>=0)&&(in[j]>key)){
      in[j+1] = in[j];
      j--;
    }
    in[j+1] = key;
  }
  show();
}

int main(){
  int n;
  int in[100];

  cin >> n;
  for(int i=0;i<n;i++){
    cin >> in[i];
  }
  insertion_sort(in,n);
}

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

typedef vector<int> vi;
typedef pair<int, int> pi;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define pb push_back
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

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

    int ans =  N * N * N;
    cout << ans << endl;

    return 0;
}


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

int main(){
    while(1){
        int n, m;
        cin >> n >> m;
        if (!n) break;
        vector<int> a(n);
        for(int i = 0; i < n; i++) cin >> a[i];
        int ans = 0;
        for(int i = 0; i < n; i++){
            for (int j = 0; j < n; j++){
                if (i != j && a[i] + a[j] <= m) ans = max(ans, a[i] + a[j]); 
            }
        }
        if (!ans) cout << "NONE" << endl;
        else cout << ans << endl;    
    }
}


Measured memory_bytes: 3088
S=input()
k=int(input())
if S[0]!="1":
    print(S[0])
else:
    cnt=0
    for i in range(len(S)):
        if S[i]=="1":
            cnt+=1
        else:
            break
    if cnt>=k:
        print(1)
    else:
        print(S[i])

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

struct P{
  int x,y;
};

int main(){
  int n,m;
  P p[101];

  cin >> n >> m;
  for(int i = 0 ; i < m ; i++)
    cin >> p[i].x >> p[i].y;
  
  bool flg = true;
  int d = 1,a = 0;

  for(int i = 0 ; i < m ; i++){
    int t = -1;
    
    for(int j = 0 ; j < m ; j++){
      if(p[j].x <= d){
	t = max(t,p[j].y);
      }
    }

    if(t == -1){
      flg = false;
      break;
    }
    
    a++;
    d = t + 1;
    if(d > n) break;
  }

  if(d > n) cout << a << endl;
  else cout << "Impossible" << endl; 

  return 0;
}

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

int main() {
	int N;
	string  S, T;
	cin >> N >> S >> T;
	string ans;
	for (int i=0; i<N; i++){
	    ans+=S.at(i);
	    ans+=T.at(i);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 #define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second


using namespace __gnu_pbds;
using namespace std;
const int mod=1e9+7;
 // const int mod=998244353;
 // const int mod=1e9+9;
const int INF=4e18+10;
// const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i;


typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

template<typename T1,typename T2>
void set_min(T1& a, T2 b)
{
    a=min(a, (T1)b);
}


int multiply(int a, int b, int in_mod){return (a*b)%in_mod;}
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}


void precomp()
{
}

void solve()
{
    string s;
    string t;;
    cin>>s>>t;
    int a =0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i] !=t[i])
            a++;
    }
    cout<<a<<endl;
}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen("INPUT.txt", "r", stdin);
        freopen("OUTPUT.txt", "w", stdout);
    }
#endif
    auto clk = clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------
    precomp();
    int t = 1;
    // cin>>t;

    for (int test = 1; test <= t; test++)
    {
        // cout<<"Case #"<<test<<": ";
        // cout<<endl;
        solve();
        // cout<<endl;
    }

    // -------------------------------------Code ends here------------------------------------------------------------------

    clk = clock() - clk;
    // cerr << fixed << setprecision(6) << "Time: " << ((long double)clk) / CLOCKS_PER_SEC << "\n";
    return 0;
}


Measured memory_bytes: 3868
a,b,c= gets.split(" ").map(&:to_f)
rad = (c*Math::PI/180)

puts (a*b*Math::sin(rad)*1.0/2.0)
puts  a+b + Math::sqrt(a**2 + b**2 - 2*a*b* Math::cos(rad))
puts  b*Math::sin(rad)

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  int h,w; cin>>h>>w;
  vector<string> ans;
  rep(i,h) {
    string c; cin>>c;
    ans.push_back(c);
    ans.push_back(c);
  }
  for (auto t:ans) {
    cout << t << endl;
  }

}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a,b,c;
	int cou=0;
	int sp=0;
	cin>>a>>b>>c;
	char car[a][b];
	for (int i=0;i<a;i++){
		for (int j=0;j<b;j++) cin>>car[i][j];
	}
	for (int j=0;j<a;j++){
		for (int i=0;i<b;i++){
			if (car[j][i]=='.') sp++;
			if (car[j][i]=='#') sp=0;
			if (sp==c){
				cou++;
				sp--;
			}
		}
		sp=0;
	}
	sp=0;
	for (int j=0;j<b;j++){
		for (int i=0;i<a;i++){
			if (car[i][j]=='.') sp++;
			if (car[i][j]=='#') sp=0;
			if (sp==c){
				cou++;
				sp--;
			}
		}
		sp=0;
	}
	cout<<cou<<endl;
	return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

string data[500];
bool sumi[500][500];
int nx,ny,ansx,ansy;
int main(){
	int h,w;
	while(1){
		cin >> h >> w;
		if(h==0&&w==0) break;
		REP(i,h) cin >> data[i];
		REP(i,500) REP(j,500) sumi[i][j] = false;
		nx = 0; ny = 0;
		bool flg = true;
		sumi[nx][ny] = true;
		while(flg){
			if(data[nx][ny]=='>') ny++;
			if(data[nx][ny]=='<') ny--;
			if(data[nx][ny]=='^') nx--;
			if(data[nx][ny]=='v') nx++;
			if(data[nx][ny]=='.'){
				ansx = nx;
				ansy = ny;
				flg = false;
			}
			if(sumi[nx][ny]&&flg==true){
				ansx = -1;
				flg = false;
			}
			sumi[nx][ny] = true;
		}
		if(ansx==-1) cout << "LOOP" << endl;
		else cout << ansy << " " << ansx << endl;
	}
}

Measured memory_bytes: 1484
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 2510;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,t,ans = 1;
    cin >> n;
    rep(i,n){
        cin >> t;
        ans = ans/gcd(ans,t)*t;
    }
    PRINT(ans);
}


Measured memory_bytes: 256
#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 digit(int n){
  int d = 0;
  while(n > 0){
    n /= 10;
    d++;
  }
  return d;
}
 
int main() {
  int N, A, B;
  string S;
  cin >> N >> A >> B >> S;
  int q = A + B;
  int i = 0;
  while(N > i){
    if(S[i] == 'a' && q > 0){
      cout << "Yes" << endl;
      q--;
    }else if(S[i] == 'b' && B > 0 && q > 0){
      cout << "Yes" << endl;
      B--;
      q--;
    }else{
      cout << "No" << endl;
    }
    i++;
  }
}

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

int main(){
    
    string str,str1,str2,str3;
    int q;
    int a, b;
    
    cin >> str;
    cin >> q;
    for ( int i = 0; i < q; i++ ){
        cin >> str1 >> a >> b;
        if ( str1 == "replace" ){
            cin >> str2;
            str.replace(a, b-a+1, str2);
        }
        if ( str1 == "reverse"){
            for ( int j = b; j >= a; j--){
                str3 = str3 + str[j];
            }
                str.replace(a,b-a+1,str3);
                str3 = "";
        }
        if ( str1 == "print") cout << str.substr(a, b-a+1) << endl;
    }
    return 0;
}



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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

long long p2(int k) {
  return 1LL << min(k, 62);
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for (auto&& e : a) cin >> e;
  reverse(begin(a), end(a));
  auto res = 0LL, cur = 0LL;
  for (int k = 0; k <= n; ++k) {
    cur += a[k];
    if (cur > p2(n - k)) {
      cout << "-1\n";
      exit(0);
    }
    cur = (cur + 1) / 2;
  }
  vector<long long> cum(begin(a), end(a));
  for (int k = 0; k < n; ++k) {
    cum[k + 1] += cum[k];
  }
  long long r = 1;
  for (int k = n; k >= 0; --k) {
    auto t = min(cum[k], r);
    res += t;
    r -= a[k];
    r *= 2;
    r = min(r, 1LL << 60);
  }
  cout << res << '\n';
}


Measured memory_bytes: 4516
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int to26gram(long long N) {
    if( N < 26 ) {
        printf("%c", 'a' + (int)N );
        return 0;
    }

    to26gram( (N / 26) - 1 );
    printf("%c", 'a' + (int)(N % 26) );
    return 0;
}

int main(void) {
    long long N;
    bool chk = false;

    scanf("%lld", &N);
    N--;

    to26gram( N );
    printf("\n");

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  int n1, n2;
  n1 = n / 10;
  n2 = n % 1000;
  if(n1 % 111 == 0 || n2 % 111 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main(){
  int a, b;
  cin >> a >> b;
  while (a >= 2){
    a = a - 2;
  }
  if (a == 0){
    cout << "Even";
  }
  else {
    while (b >= 2){
      b = b - 2;
    } 
    if (b == 0){
      cout << "Even";
    }
    else{
      cout << "Odd";
    }
  }
}



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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 62;


class Solver {
  public:
    bool solve() {
        int N; cin >> N;
        vector<ll> A(N); cin >> A;
        vector<ll> acc(N + 1);
        rep(i, N) {
            acc[i + 1] = acc[i] + A[i];
        }
        ll ans = INFL;
        rep(m, N) {
            // [0, m), [m, N)
            if(m - 0 < 2 or N - m < 2) continue;
            ll s1 = acc[m], s2 = acc[N] - s1;

            int lm = lower_bound(begin(acc) + 1, begin(acc) + m + 1, s1 / 2) - begin(acc) - 1;
            int rm = lower_bound(begin(acc) + m + 1, end(acc), s1 + s2 / 2) - begin(acc) - 1;
            assert(0 <= lm and lm <= m);
            assert(m <= rm and rm <= N);
            repeat(i, max(0, lm - 5), min(lm + 5, m)) {
                repeat(j, max(m, rm - 5), min(rm + 5, N)) {
                    // [0, i) [i, m) [m, j) [j, N)
                    if(i - 0 < 1 or m - i < 1 or j - m < 1 or N - j < 1) continue;
                    assert(0 < i and i < m and m < j and j < N);
                    auto v = { acc[i], acc[m] - acc[i], acc[j] - acc[m], acc[N] - acc[j] };
                    set_min(ans, abs(max(v) - min(v)));
                }
            }
        }
        assert(ans < INFL);
        cout << ans << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main()
{
    ll n;
    cin>>n;
    int v[n][3];
    for(ll i=0;i<n;i++)
    {
        
        cin>>v[i][0]>>v[i][1]>>v[i][2];
    }
    int arr[n][3];
    arr[0][0]=v[0][0];
    arr[0][1]=v[0][1];
    arr[0][2]=v[0][2];
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            arr[i][j]=max(v[i][j]+arr[i-1][(j+2)%3],v[i][j]+arr[i-1][(j+1)%3]);
        }
    }
    ll max = arr[n-1][0]; 
    for(int i=0;i<3;i++)
    {
        if(max<arr[n-1][i])
        {
            max = arr[n-1][i];
        }
    }
    cout<<max<<endl;
 
}

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

int main(void)
{
	ios_base::sync_with_stdio(false);    
	cin.tie(NULL);
	cout.tie(NULL);
	
	int k,a,b;
	cin>>k;
	cin>>a>>b;
	bool ctr=0;
	for(int i=k;i<=b;i+=k)
	{
		if(i>=a&&i<=b)
		{
			ctr=1;
			break;
		}
	}
	if(ctr)
		cout<<"OK \n";
	else cout<<"NG \n";
	return 0;
}

Measured memory_bytes: 3652
# Dice and Coin
N, K = map(int,input().split())
# N サイコロの面
# K 得点
K3 = []
ans = 0
count = 0  #コイン振る回数 MAX

for i in range(1, N+1):
    K1 = i
    K2 = 0
    count = 0
    while K1 < K:
        K1 = 2 * K1
        count = count + 1
    K2 = 1/N * (1/2)**count
    K3.append(K2)

for k in range(N):
    ans = ans + K3[k]
print(ans)

Measured memory_bytes: 6296
#include<iostream>
unsigned gcd(unsigned a, unsigned b) {
	if (a < b) return gcd(b, a);
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
using namespace std;
int main() {
	long a, b, c, d,g,l;
	cin >> a >> b >> c >> d;
	g = gcd(c, d);
	l = c * d / g;
	cout << (b - a + 1) - ((b / c - (a-1) / c) + (b / d - (a-1) / d) - (b / l - (a-1) / l)) << endl;
}

Measured memory_bytes: 256
S = input()
N = len(S)
rCount = 0
lCount = 0
flag = 1
Right = []
Left = []

for i in range(N):
    if flag:
        if S[i] == 'L':
            Right.append(rCount)
            flag = 0
            rCount = 0
            lCount = 1
        else:
            rCount += 1
    
    else:
        if S[i] == 'R':
            Left.append(lCount)
            flag = 1
            rCount = 1
            lCount = 0
        else:
            lCount += 1
Left.append(lCount)

ans = [0]*N
s = len(Right)
idx = 0
for i in range(s):
    r = Right[i]
    l = Left[i]
    idx += r 
    ans[idx-1] += (r+1)//2
    ans[idx] += r-(r+1)//2

    ans[idx] += (l+1)//2
    ans[idx-1] += l-(l+1)//2
    idx += l 

print(*ans)

Measured memory_bytes: 7144
#include<bits/stdc++.h>;
using namespace std;
//#define LOCAL
typedef long long ll;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'


int main(){
#ifdef LOCAL
     freopen("in.txt", "r", stdin);
     //freopen("out.txt", "w", stdout);
#else
 fastIO;
#endif
//***************************//**************************//******************************

string s;
cin>>s;
map<char,int> m;
for(int i=0;i<s.size();i++){
    m[s[i]]++;
}
bool flag=1;
for(auto &x:m){
 if(x.second&1){
    flag=0;
    break;
 }
}
if(flag){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}
}



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



int main(){
    double t, x;
    cin >> t >> x;
    cout << setprecision(25) << double(t/x) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(void){
    // Here your code !
int n,a=0,b=0,o=0,ab=0;
char c;
string d;

while(cin>>n>>c>>d){
    if(d=="B\0") b++;
    else if (d=="A\0") a++;
     else if (d=="O\0") o++;
      else if (d=="AB\0") ab++;
}
cout<<a<<endl<<b<<endl<<ab<<endl<<o<<endl;
return 0;
}

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

static class Program
{
    static int Search1(int N, long[] A, long n)
    {
        if (A[N - 1] >= n) { return N; }
        if (A[0] < n) { return 0; }
        int a = 0;
        int b = N - 1;
        while (b - a >= 2)
        {
            int m = (a + b) / 2;
            if (A[m] < n) { b = m; } else { a = m; }
        }
        return b;
    }

    static long Search2(int N, long[] A, long n)
    {
        return A.Sum(a => (long)Search1(N, A, n - a));
    }

    static long Search3(int N, long M, long[] A)
    {
        if (Search2(N, A, 0) < M) { return 0; }
        long a = 0;
        long b = A[0] * 2 + 1;
        while (b - a >= 2)
        {
            long m = (a + b) / 2;
            if (Search2(N, A, m) < M) { b = m; } else { a = m; }
        }
        return a;
    }

    static long Solve(int N, long M, long[] A)
    {
        long n = Search3(N, M, A);
        var B = new long[N + 1];
        for (int i = 0; i < N; ++i) { B[i + 1] = A[i] + B[i]; }
        long cnt = 0;
        long sum = 0;
        long min = long.MaxValue;
        for (int i = 0; i < N; ++i)
        {
            int j = Search1(N, A, n - A[i]);
            cnt += j;
            sum += A[i] * j + B[j];
            if (j > 0) { min = Math.Min(A[i] + A[j - 1], min); }
        }
        return sum - min * (cnt - M);
    }

    static void Main(string[] args)
    {
        var V = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        var A = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        Array.Sort(A, (a, b) => (b.CompareTo(a)));
        Console.WriteLine(Solve((int)V[0], V[1], A));
    }
}


Measured memory_bytes: 20320
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ull  unsigned long long
#define pb push_back

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 200000;
multiset < int > s[N];
vector < int > g[N];
int used[N], a[N];
int k;
void dfs(int v){
    s[k].insert(a[v]);
    used[v] = 1;
    for (auto u: g[v]){
        if (!used[u]) dfs(u);
    }
}
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w", stdout);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= m; i++){
        int u, v;
        cin >> u >> v;
        u++;
        v++;
        g[u].pb(v);
        g[v].pb(u);
    }
    for (int i = 1; i <= n; i++) if (!used[i]){
        k++;
        dfs(i);
    }
    multiset < int > t;
    for (int i = 1; i <= n; i++){
        t.insert(a[i]);
    }
    int ans = 0;
    if (k == 1){
        cout << ans;
        return 0;
    }
    for (int i = 1; i <= k; i++){
        ans += *s[i].begin();
        t.erase(t.find(*s[i].begin()));
    }
    int e = (n - 1 - m) * 2 - k;
    if (t.size() < e){
        cout << "Impossible";
        return 0;
    }
    for (int i = 0; i < e; i++){
        ans += *t.begin();
        t.erase(t.begin());
    }
    cout << ans;
}


Measured memory_bytes: 29696
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        x: i32,
        a: i32,
        b: i32,
    }
    let ans = (x - a) % b;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    string S;
    cin >> S;
    vector<int> count(26, 0);
    rep(i,4) count[S[i] - 'A']++;
    int ans = 0;
    rep(i,26) if (count[i] == 2) ans++;
    cout << (ans == 2 ? "Yes" : "No") << endl;
    
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc050/tasks/abc050_b
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    int N;
    cin >> N;
    vector<int> T(N);
    int sum = 0;
    REP(i, N) 
    {
        cin >> T[i];
        sum += T[i];
    }
    int M;
    cin >> M;
    vector<int> P(M), X(M);
    REP(i, M)
    {
        cin >> P[i] >> X[i];
        --P[i];
    }

    vector<int> res(M);
    REP(i, M)
    {
        int idx = P[i];
        res[i] = sum - T[idx] + X[i];
    }

    REP(i, M)
    {
        cout << res[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
package main

import "fmt"

func main() {
	var a, b, c, d, sum int
	fmt.Scan(&a, &b, &c, &d)
	if a < b {
		sum += a
	} else {
		sum += b
	}
	if c < d {
		sum += c
	} else {
		sum += d
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
import math

def main():
    A,B,C,X,Y = [int(x) for x in input().split()]
    ans = 0
    if A+B <= C*2:
        # print('b')
        ans = A*X + B*Y
    else:
        if X<=Y:
            # print('c')
            ans = C*X*2 + min(B,C*2)*(Y-X)
        elif X>Y:
            # print('d')
            ans = C*Y*2 + min(A,C*2)*(X-Y)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 62128
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    ArrayList<Integer> ar = new ArrayList<>();
    int plus[][] = new int[5][2];
    for (int i = 0; i < 5; i++) {
      int set = sc.nextInt();
      ar.add(set);
      plus[i][0] = set;
      plus[i][1] = plus[i][0] % 10;
    }
    Arrays.sort(plus, (a, b) -> Integer.compare(a[1], b[1]));
    int ans = 0;
    for (int i = 0; i < 5; i++) {
      if (plus[i][1] == 0) {
        ans += plus[i][0];
        ar.remove(ar.indexOf(plus[i][0]));
      }
    }
    Arrays.sort(plus, (a, b) -> Integer.compare(b[1], a[1]));
    for (int i = 0; i < ar.size(); i++) {
      if (ans % 10 == 0) {
        ans += plus[i][0];
      } else {
        while (ans % 10 != 0) {
          ans += 1;
        }
        ans += plus[i][0];
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 26576
#include <bits/stdc++.h>
#define int long long
#define ii pair < int , int >
#define fi first
#define se second

using namespace std;
const int N=3e3+55;
double p[N];
double dp[N][N];

main()
{
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>p[i];
	dp[n][0]=1.0;
	for(int i=n-1;i>=0;i--)
	{
		for(int j=0;j<=n;j++)
		{
			if(j>0)
			dp[i][j]=dp[i+1][j-1]*p[i];
			dp[i][j]+=dp[i+1][j]*(1.0-p[i]);
		}
	}
	double ans=0;
	for(int i=n/2+1;i<=n;i++)
		ans+=dp[0][i];
	cout<<fixed<<setprecision(9)<<ans<<endl;
	return 0;
}


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

int main() {
  long long int X;
  cin >> X;
  vector<long long int> Y;
  for (long long int i = 1; i * i <= X; i++) {
    if (X % i == 0) {
      Y.push_back(i);
      if (X / i != i) Y.push_back(X / i);
    }
  }
  sort(Y.begin(), Y.end());
  bool finished = false;
  for (long long int i = 0; i < Y.size(); i++) {
    long long int A = 0, B = A - Y.at(i);
    while (true) {
      if (A * A * A * A * A - B * B * B * B * B == X) {
        cout << A << " " << B << endl;
        finished = true;
        break;
      }
      else if (B > 0 && A * A * A * A * A - B * B * B * B * B > X) break;
      A++;
      B++;
    }
    if (finished) break;
  }
}

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

int GCD(ll a, ll b){
  ll t;
  while(b){
    t = a % b;
    a = b;
    b = t;
  }
  return a;
}
int main(){
  ll a, b;
  while(cin >> a >> b){
    ll gcd = GCD(a, b);
    cout << gcd << " " << a * b / gcd << "\n";
  }
  return 0;
}


Measured memory_bytes: 2976
#include<bits/stdc++.h>
using namespace std;
long long n,k,ans,C[4003][4003],mo=1e9+7;
int main() {
	scanf("%lld %lld",&n,&k);
	C[0][0]=1;
	for(int i=1; i<=3000; i++) {
		C[i][0]=1;
		for(int j=1; j<=i; j++)
			C[i][j]=(C[i-1][j]+C[i-1][j-1])%mo;
	}//k-1  i-1
	for(int i=1; i<=k; i++)printf("%lld\n",C[n-k+1][i]*C[k-1][i-1]%mo);
	return 0;
}

Measured memory_bytes: 92672