akhauriyash/Code-Regression huggingface dataset:
/*2019/09/13 */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
#define MIN 999999999
#define MAX -999999999
typedef long long int ll;
typedef unsigned long long int ull;
void llswap(ll *x,ll *y){ll tmp;tmp=*x;*x=*y;*y=tmp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}
int llasc(const void *a,const void *b){return *(ll*)a-*(ll*)b;}
int lldesc(const void *a,const void *b){return *(ll*)b-*(ll*)a;}
int gcd(int x,int y){if(y==0)return x;return gcd(y,x%y);}
/*
int asc_t(const void *a,const void *b){return ((struct_t*)a)->member - ((struct_t*)b)->member;}
int desc_t(const void *a,const void *b){return ((struct_t*)b)->member - ((struct_t*)a)->member;}
*/

int main(){
    int a,b,c,d,ans;
    char str[10];
    scanf("%s",str);
    a=str[0]-0x30;
    b=str[1]-0x30;
    c=str[2]-0x30;
    d=str[3]-0x30;
    ans=a+b+c+d;
    if(ans==7){
        printf("%d+%d+%d+%d=7\n",a,b,c,d);
        return 0;
    }
    ans=a+b+c-d;
    if(ans==7){
        printf("%d+%d+%d-%d=7\n",a,b,c,d);
        return 0;
    }
    ans=a+b-c+d;
    if(ans==7){
        printf("%d+%d-%d+%d=7\n",a,b,c,d);
        return 0;
    }
    ans=a+b-c-d;
    if(ans==7){
        printf("%d+%d-%d-%d=7\n",a,b,c,d);
        return 0;
    }
    ans=a-b+c+d;
    if(ans==7){
        printf("%d-%d+%d+%d=7\n",a,b,c,d);
        return 0;
    }
    ans=a-b+c-d;
    if(ans==7){
        printf("%d-%d+%d-%d=7\n",a,b,c,d);
        return 0;
    }
    ans=a-b-c+d;
    if(ans==7){
        printf("%d-%d-%d+%d=7\n",a,b,c,d);
        return 0;
    }
    ans=a-b-c-d;
    if(ans==7){
        printf("%d-%d-%d-%d=7\n",a,b,c,d);
        return 0;
    }
}

Measured memory_bytes: 128
import math
x = int(input())

# -100 ~ 100 ^ 5
pow5 = {}
for i in range(-1000, 1001):
    pow5[i] = int(math.pow(i, 5))

for i in range(-1000, 1001):
    a = x + pow5[i]
    for j in range(-1000, 1001):
        if a == pow5[j]:
            print(j, i)
            exit()


Measured memory_bytes: 67252
from collections import Counter
N,M=map(int,input().split())
H=list(map(int,input().split()))
ablist=[list(map(int,input().split())) for i in range(M)]
compare=[0]*N

for i in ablist:
    if H[i[0]-1] < H[i[1]-1]:
        compare[i[0]-1] += 1
    elif H[i[0]-1] > H[i[1]-1]:
        compare[i[1]-1] += 1
    else:
        compare[i[0]-1] += 1
        compare[i[1]-1] += 1

ans = Counter(compare)

print(ans[0])

Measured memory_bytes: 32384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  
  if(S == "Sunny"){
    cout << "Cloudy" << endl;
  }
  
  if(S == "Cloudy"){
    cout << "Rainy" << endl;
  }
  
  if(S == "Rainy"){
    cout << "Sunny" << endl;
  }
  
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,y = li()

yuki_max = y // 10000
ichi_max = y // 5000

ans_y = -1
ans_i = -1
ans_h = -1

for yukichi in range(yuki_max+1):
    for ichiyo in range(ichi_max+1):
        hideyo = (y - 10000*yukichi - 5000*ichiyo) // 1000
        if hideyo < 0:
            continue
        
        if yukichi + ichiyo + hideyo == n:
            ans_y = yukichi
            ans_i = ichiyo
            ans_h = hideyo
            break

print(ans_y, ans_i, ans_h)

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

int main() {
    std::ios::sync_with_stdio(false);
    std::string s;
    std::cin >> s;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == '7') {
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }

    std::cout << "No" << std::endl;


    return 0;
}


Measured memory_bytes: 3640
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    string s;
    int n;
    cin >>n;
    cin >> s;
    int count= 0;
    rep(i,n-2){
        if((s[i]=='A')&(s[i+1]=='B')&(s[i+2]=='C')){
            count ++ ;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  ll seq_cnt = 0, inter_cnt = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if (A[i] > A[j]) {
        seq_cnt++;
      }
    }
    for (int j = 0; j < N; j++) {
      if (A[i] > A[j]) {
        inter_cnt++;
      }
    }
  }
  ll ans = K * (K - 1) / 2;
  ans = ((ans % MOD) * inter_cnt) % MOD;
  ans += seq_cnt * K;
  cout << ans % MOD << endl;
  return 0;
}

Measured memory_bytes: 3616
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x;
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

string N;
ll c = 1, maxc = 1;

int main() {
	rd(N);
	if ((N[0] == N[1] && N[1] == N[2]) || (N[2] == N[3] && N[1] == N[2]))wrln("Yes");
	else wrln("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    int n, x = 0, ans = 0;
    string s;
    cin >> n >> s;
    for(auto i : s){
        if(i == 'I'){
            x++;
        }else{
            x--;
        }
        ans = max(ans, x);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
मनस्वी म्रियते कामं कार्पण्यं न तु गच्छति ।
अपि निर्वाणमायाति नानलो याति शीतताम् ॥
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define p2d(v) for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v) for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v) for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
#define test3(x,y,z) cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define test4(w,x,y,z) cout << #w " = " << w << " " << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

        
    int n;
    cin>>n;

    string s;
    set<string> st;


    forn(i,0,n)
    {
        cin>>s;
        st.insert(s);
    }
        
    cout<<st.sze;    












    return 0;
}       

Measured memory_bytes: 19216
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in); 
    int N = sc.nextInt();
    for (int i =1; i<N+1; i++) {
      int count =0;
      for (int x =1; x<Math.sqrt(i); x++) {
        for (int y =x; y<Math.sqrt(i); y++) {
          double z = (-(x+y) + Math.sqrt(4 * i - 3 * x * x - 3 * y * y - 2 * x * y))/2;
          if (z % 1 != 0 || z < y) {
            continue;
          } else {
            if (x == y && y == z && z == x) {
              count++;
            } else if (x == y || y == z) {
              count+=3;
            } else {
              count+=6;
            }
          }
        }
      }
      System.out.println(count);
    }
  }
}

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

#define IO          ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int         long long
#define double      long double
#define vi          vector<int>
#define vvi         vector<vi>
#define pii         pair<int,int>
#define vii         vector<pii>
#define nl          '\n'
#define yy          "YES\n"
#define nn          "NO\n"
#define mp          map
#define ump         unordered_map
#define watch(x)    cerr << (#x) << " is " << (x)
#define pb          push_back
#define all(v)      (v).begin(), (v).end()
#define rall(v)     (v).rbegin(), (v).rend()
#define f           first
#define s           second
#define mod         1000000007
#define PI          3.1415926535897932

const int N = 1e6 + 5;
int freq[N];

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

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

        int ans = 0;
        for (int i = 1; i < N; i++) {
            int x = i;
            int x_ = freq[x];

            if (!x_)    continue;

            bool ok = true;

            for (int j = 2; j * j <= x; j++) {
                if (x % j)  continue;

                int f1 = x / j , f2 = j;
                if (freq[f1] || freq[f2]) {
                    ok = false;
                    break;
                }
            }
            if (ok && x_ == 1 && !freq[1]) {
                ans++;
            }
        }
        ans += (freq[1] == 1);
        cout << ans;
}


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


int main() {
	int N;
	cin >> N;
	int ans = 1;
	vector<int> A(1,0);
	cin >> A[0];
	for (int i = 1; i < N; i++) {
		int buf;
		cin >> buf;
		if (A.back() != buf) A.push_back(buf);
	}
	N = A.size();
	int i = 0;
	while (i < N - 2) {
		if (((A[i + 2] < A[i + 1]) && (A[i + 1] > A[i])) || ((A[i + 2] > A[i + 1]) && (A[i + 1] < A[i]))) {
			ans++;
			i++;
		}
		i++;
	}
	cout << ans;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
 
 
using namespace std;
 
string s,ss="Cloudy",sss="Rainy",ssss="Sunny";

int main(){
	cin>>s;
	if(s==ss){
    	cout<<sss;
    }
  	else if(s==sss){
   		cout<<ssss;
    }
	else
       	cout<<ss;
 
}

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

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

const int N = 1e5+5;
const int mo = 1e9+7;

char s[N];
int n;
int a[N];
int suf[N][3];
int w[N];
int f[N];

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	bool pd=1;
	fo(i,2,n)pd&=(s[i]!=s[i-1]);
	if (pd)return printf("1\n"),0;
	fo(i,1,n){
		a[i]=s[i]-'a'+1;
	}
	fo(i,1,n)a[i]=(a[i]+a[i-1])%3;
	fd(i,n,0){
		suf[i][0]=w[0];
		suf[i][1]=w[1];
		suf[i][2]=w[2];
		w[a[i]]=i;
	}
	f[0]=1;
	fo(i,0,n-1){
		//a
		int v=(a[i]+1)%3;
		if (suf[i][v])f[suf[i][v]]=(f[suf[i][v]]+f[i])%mo;
		v=(a[i]+2)%3;
		if (suf[i][v])f[suf[i][v]]=(f[suf[i][v]]+f[i])%mo;
	}
	int ans=0;
	bool ext=0;
	fo(i,1,n)
	if (a[i]==a[n])ans=(ans+f[i])%mo;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<ll> cs(5);
    for(int i = 0; i < 5; ++i){
        cin >> cs.at(i);
    }
    ll mincity = *min_element(cs.begin(), cs.end());
    ll ans = (ll)ceil((long double)n / mincity) + 4;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define MAX 10000005
#define ll long long
#define MOD 998244353
ll po[MAX];
ll C[MAX];
ll sum[MAX];

ll bigMod(ll a, ll p)
{
    if(p == 0) return 1LL;
    if(p == 1) return a;
    ll ret = bigMod(a, p/2);
    ret = (ret*ret)%MOD;
    if(p & 1) ret = (ret*a)%MOD;
    return ret;
}

ll dv(ll a, ll b)
{
    b = bigMod(b, MOD-2);
    ll ret = (a*b)%MOD;
    return ret;
}

int main()
{
    po[0] = 1;
    for(int i=1; i<MAX; i++){
        po[i] = (po[i-1]*2)%MOD;
    }
    ll n;
    scanf("%lld", &n);
    ll m = n/2;
    C[0] = 1;
    C[1] = m;
    for(int i=2; i<=m; i++){
        C[i] = (C[i-1]*(m-i+1))%MOD;
        C[i] = dv(C[i], i);
    }
    ll tot = 0;
    for(int i=0; i<=m; i++){
        tot += (C[i]*po[m-i])%MOD;
        tot = tot%MOD;
        sum[i] = tot;
    }
    ll ans = 0;
    for(int i=0; i<=m; i++){
        ll cur1 = (C[i]*po[m-i])%MOD;
        ll cur2 = (sum[m]-sum[m-i])%MOD;
        if(cur2 < 0) cur2 += MOD;
        ans += (cur1*cur2)%MOD;
        ans = ans%MOD;
    }
    ans = (ans*2)%MOD;
    ll all = 1;
    for(int i=1; i<=n; i++){
        all = (all*3)%MOD;
    }
    ans = (all-ans)%MOD;
    if(ans < 0) ans += MOD;
    cout << ans;
}

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;


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

	int n,k;cin>>n>>k;
	string s; cin>>s;

	int score =0;
	for(int i=0; i<n-1; i++){
		if(s[i] == s[i+1])score++;
	}
	int ans = min(score+2*k,n-1);

	writeln(ans);

}




Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {
	int temp[4];
	char c[5];
	cin >> c;
	for (int i = 0; i < 4; i++) {
		temp[i] = c[i] - 48;
	}
	if (temp[0] + temp[1] + temp[2] + temp[3] == 7)
		cout << temp[0] << "+" << temp[1] << "+" << temp[2] << "+" << temp[3] << "=" << "7" << endl;
	else if (temp[0] + temp[1] + temp[2] - temp[3] == 7)
		cout << temp[0] << "+" << temp[1] << "+" << temp[2] << "-" << temp[3] << "=" << "7" << endl;
	else if (temp[0] + temp[1] - temp[2] + temp[3] == 7)
		cout << temp[0] << "+" << temp[1] << "-" << temp[2] << "+" << temp[3] << "=" << "7" << endl;
	else if (temp[0] + temp[1] - temp[2] - temp[3] == 7)
		cout << temp[0] << "+" << temp[1] << "-" << temp[2] << "-" << temp[3] << "=" << "7" << endl;
	else if (temp[0] - temp[1] + temp[2] + temp[3] == 7)
		cout << temp[0] << "-" << temp[1] << "+" << temp[2] << "+" << temp[3] << "=" << "7" << endl;
	else if (temp[0] - temp[1] + temp[2] - temp[3] == 7)
		cout << temp[0] << "-" << temp[1] << "+" << temp[2] << "-" << temp[3] << "=" << "7" << endl;
	else if (temp[0] - temp[1] - temp[2] + temp[3] == 7)
		cout << temp[0] << "-" << temp[1] << "-" << temp[2] << "+" << temp[3] << "=" << "7" << endl;
	else if (temp[0] - temp[1] - temp[2] - temp[3] == 7)
		cout << temp[0] << "-" << temp[1] << "-" << temp[2] << "-" << temp[3] << "=" << "7" << endl;

	return 0;

	
}



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

using namespace std;
typedef long long ll;

inline int at(ll x, int k){ return (x >> k) & 1; }
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)


int main() {
	ll n,k;
	cin >> n >> k;
	pair<ll,ll> a[n];
	rep(i,0,n){
		ll temp;
		cin >> temp;
		a[i].first = temp-1;
		a[i].second = -1;
	}

	ll to=0;
	int flag=0;
	ll from=0;
	rep(i,0,k){
		if(a[to].second!=-1&&flag==0){
			i=k-(k-i)%(i-a[to].second)-1;
			flag = 1;
		}
		a[to].second = i;
		from = to;
		to = a[to].first;
	}
	if(flag==1){
		cout << from+1 << endl;
	}
	else{
		cout << to+1 << endl;
	}

}


Measured memory_bytes: 6712
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

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

    int a, b, c;
    int ans;

    cin >> a >> b >> c;

    if (a != b && b != c && c != a) {
        ans = 3;
    } else if (a == b && b == c) {
        ans = 1;
    } else {
        ans = 2;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  int a, b, c, d, e; cin >> a >> b >> c >> d >> e;
  c--; d += 60; cout << (c-a)*60+d-b-e << endl;
  return 0;
}

Measured memory_bytes: 3636
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    return (A - 1) * (B - 1)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    print(solve(A, B))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 2940
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
  float A,B;
  cin>>A>>B;
  
  int c=1;
  int a=A,b=B;
  
  float ans=ceil((B-1)/(A-1));
  
  cout<<int(ans)<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	long long A,B;
	long long x, y;

	int K;
	cin >> A >> B >> K;
	x = A;
	y = B;

	for (int i = 0; i < K; ++i) {
		if (i % 2 == 0) {
			if (x % 2 == 0) {
				x = x;
			}
			else {
				x = x - 1;
			}
			y = y + x / 2;
			x = x / 2;
		}
		else {
			if (y % 2 == 0) {
				y = y;
			}
			else {
				y = y - 1;
			}

			x = x + y / 2;
			y = y / 2;

		}


	}


	cout << x <<" "<<y<< endl;
	return 0;
}

Measured memory_bytes: 256
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

ll h[MAXn];
lf eps = 1e-9;

int main()
{
    IOS();
    ll n,T,A;
    cin>>n>>T>>A;
    REP1(i,n)cin>>h[i];
    lf mn = INF;
    REP1(i,n)mn = min(mn,fabs(T - h[i] * 0.006 - A));
    REP1(i,n)if(fabs(T - h[i] * 0.006 - A) <= mn + eps)
    {
        cout<<i<<endl;
        return 0;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

double A,B,C,D,E,F;
int main(){
    cin>>A>>B>>C>>D>>E>>F;
    
    double res = 0;
    pair<double,double> ans;
    
    rep1(k,30) rep(i,3001) rep(j,3001){
            double sug = C*i + D*j;
            if(sug <= E*A*k && 100*k*A + sug <= F) if(100*sug/(sug+100*A*k) >= res) res = 100*sug/(sug+100*A*k), ans = mp(sug+100*A*k,sug);
        }
        
    pr(to_s((int)ans.first)+" "+to_s((int)ans.second));
    
}

Measured memory_bytes: 256
n,m = map(int,input().split())
ans = cnt = 0
ab = []
for i in range(n):
    a,b = map(int,input().split())
    ab.append([a,b])
ab.sort(key=lambda x:x[0])
i=0
while cnt<m:
    buy = min(ab[i][1],m-cnt)
    ans += ab[i][0]*buy
    cnt += buy
    i += 1
print(ans)

Measured memory_bytes: 21216
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <bitset>

using namespace std;
using ll = long long;

const int MAX = 61;
const int MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> count(MAX);
    for (auto &v : a) {
        cin >> v;
        for (int i = 0; i < MAX; ++i) {
            count[i] += 1 & (v >> i);
        }
    }
    vector<ll> powers(MAX, 1);
    for (int i = 1; i < MAX; ++i) {
        powers[i] = 2 * powers[i - 1] % MOD;
    }
    ll res = 0;
    for (int i = 0; i < MAX; ++i) {
        ll inc = (count[i] * (n - count[i]) % MOD) * powers[i] % MOD;
        res += inc;
        res %= MOD;
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using i64 = long long;

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

    std::vector<std::vector<int>> g(n);
    for (int i = 0; i < n; i++) {
        std::string in;
        std::cin >> in;
        for (int j = 0; j < n; j++) if (in[j] == '1') g[i].push_back(j);
    }

    int ret = 0;
    for (int s = 0; s < n; s++) {
        std::deque<int> q { s };
        std::vector<int> done(n);
        done[s] = 1;

        bool flg = true;
        while (flg && !q.empty()) {
            int v = q.front();
            q.pop_front();
            for (int to : g[v]) {
                if (done[to]) {
                    if (abs(done[to] - done[v]) == 1) continue;
                    flg =false;
                    break;
                } else {
                    done[to] = done[v] + 1;
                    q.push_back(to);
                }
            }
        }

        if (!flg) continue;

        int l = *std::max_element(done.begin(), done.end());
        ret = std::max(ret, l);
    }

    std::cout << (ret ? ret : -1) << std::endl;

    return 0;
}


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

int main(void){
    int a, b;
    cin >> a >> b;
    if(a > b){
        if(b == 1) cout << "Bob" << endl;
        else cout << "Alice" << endl;
    }else if(a < b){
        if(a == 1) cout << "Alice" << endl;
        else cout << "Bob" << endl;
    }
    else cout << "Draw" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define REV(v) reverse(v.begin(), v.end());
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, start, stop) for (ll i = start; i < stop; i++)
#define FORR(i, start, stop) for (ll i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<ll>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<ll>());
#define REMOVE(v,n) remove(vector<ll> v,v+v.size(),ll n)
#define ERASE(v,n) v.erase(v.begin()+n);
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
const int MOD = 1000000007;
void chmin(int &a, int b) { if (a > b) a = b; }

//vector< vector<int> > v (size1, vector<int>(size2) );

//累乗 a**n%mod
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll D,G;
    cin>>D>>G;
    vector<LP> pc(D); 
    FOR(i,0,D)cin>>pc[i].first>>pc[i].second;
    ll ans=INF;

    FOR(i,0,modpow(2,D,MOD)){
        ll point=0;
        ll temp=0;
        FOR(j,0,D){
            if((i & 1<<j)== 1<<j){
                point+=pc[j].first*(j+1)*100+pc[j].second;
                temp+=pc[j].first;
            }
        }
        //cout<<temp<<' '<<point<<endl;
        ll rmd=G-point;
        FORR(j,D-1,-1){
            if(rmd<0)break;
            else if((i & 1<<j)!= 1<<j){
                temp+=min(pc[j].first,rmd/(j*100+100));
                rmd-=(j*100+100)*min(pc[j].first,rmd/(j*100+100));
            }
        }
        //cout<<i<<' '<<ans<<' '<<temp<<endl;
        ans=min(ans,temp);
    }
    
    cout<<ans<<endl;
    

    return 0;
}
//666?601??

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define all(v) (v).begin(),(v).end()
#define pb push_back
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/

signed main(){
  int n,m;
  cin>>n>>m;
  int ans=n*(n-1)/2+m*(m-1)/2;
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
	int A, P;
	cin >> A >> P;
	P += A * 3;
	cout << P / 2 << endl;
	return 0;
}


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

int main(){
	while(true){
		int n,x,y,h,w,ans=0;
		cin >> n;
		if(!n)
			return 0;
		for(int i=0; i<n; i++){
			cin >> x >> y >> h >> w;
			x += y+h;
			ans += 600;
			if(x>60 || w>2)
				ans += 200;
			if(x>80 || w>5)
				ans += 200;
			if(x>100 || w>10)
				ans += 200;
			if(x>120 || w>15)
				ans += 200;
			if(x>140 || w>20)
				ans += 200;
			if(x>160 || w>25)
				ans -= 1600;
		}
		cout << ans << endl;
	}
}

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

using namespace std;

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;

#define rep(i,a,b) for(int i =(a);i<(int)(b);i++)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

typedef long long ll;

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

    int idx =-1; 
    int ans =0;
    char h= 'A';
    rep(i, 0, 3){
       char c; 
       cin>>c; 
       if(c== 'R'){
            
           if(h == c){
               ans++;
           }
           else{
               ans = 1;
               h =c;
           }
       }
       else{
           h = 'A';
       }

    }

    cout<<ans<<endl;



    return 0 ;
}



Measured memory_bytes: 3636
#include <stdio.h>

int main(void){
  int D;
  scanf("%d", &D);
  if(D == 25){
    printf("Christmas\n");
  }
  else if(D == 24){
    printf("Christmas Eve\n");
  }
  else if(D == 23){
    printf("Christmas Eve Eve\n");
  }
  else{
    printf("Christmas Eve Eve Eve\n");
  }
  return 0;
}


Measured memory_bytes: 128
"use strict";

function Main(input) {
    var time=input.split("\n")[0];
    var h=time/3600;
    var m=time%3600/60;
    var s=time%60;
    console.log([Math.floor(h),Math.floor(m),Math.floor(s)].join(":"));
}

function debug(){
	var input = document.getElementById("input").value;
	Main(input);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 15552
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

#define rep(X,Y) for(int (X) = 0; (X) < (Y) ; ++(X))
#define all(X) (X).begin,(X).end
#define reps(i,j,k) for(inti=(j); i <= (k); ++(i))
#define sz size()
#define in(i,j,k) ((i) >= (j) && (i) <= (k))

using namespace std;

typedef pair<int,int> pii;

int d[2000000];
int dd[2000000];

int main(){
    
    vector<int> t;
    vector<int> k;
    int i = 0;
    rep(i, 2000000)d[i]=dd[i]=1000000000;
    while((i*(i+1)*(i+2))/6 <= 1000000){
        ++i;
        t.pb(i*(i+1)*(i+2)/6);
        if((i*(i+1)*(i+2)/6)%2) k.pb(i*(i+1)*(i+2)/6);
    }

    d[0] = dd[0] = 0;

    rep(i, 1000000){
        rep(j, t.sz){
            int tmp = i+t[j];
            if(tmp < 1000001)d[tmp] = min(d[tmp], d[i]+1);
        }
        rep(j, k.sz){
            int tmp = i+k[j];
            if(tmp < 1000001)dd[tmp] = min(dd[tmp], dd[i]+1);
        }
    }
    int n;

    while(scanf("%d", &n), n){
        printf("%d %d\n", d[n], dd[n]);
    }
    
    return 0;
}

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

int main() {
    int N,K;
    cin >> N >> K;
    vector<int> vec(N);
    for(int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }
    int counter = 0;
    for(int i = 0; i < N; i++) {
        if(vec.at(i) >= K) {
            ++counter;
        }
    }
    cout << counter << endl;
}

Measured memory_bytes: 640
def f_d():
    n, k = map(int, input().split())
    *s, = map(int, list(input()))
    l, t, c = [], 1, 0
    for i in range(n):
        if s[i]==t:
            c += 1
        else:
            l.append(c)
            c, t = 1, t^1
    if c!=0:
        l.append(c)
    if len(l)%2==0:
        l.append(0)

    r, cs = 2*k, [l[0]]

    for i in range(1, len(l)):
        cs.append(cs[i-1]+l[i])
    a = cs[0]
    for i in range(0, len(l), 2):
        tmp = cs[min(i+r, len(l)-1)]-cs[i]+l[i]
        a = max(a, tmp)
    print(a)

if __name__ == "__main__":
    f_d()

Measured memory_bytes: 9236
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=1e5+50;
ll num[MAXN];
int main()
{
    int a,b;
    cin>>a>>b;
    if(a*500>=b)
        puts("Yes");
    else puts("No");
	return 0;
}


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

using namespace std;

int main() {
    int n, m, s, c, num[3];
    for(int i = 0; i < 3; ++i) num[i] = -1;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> s >> c;
        if (s == 1 && c == 0 && n != 1) {
            cout << "-1" << endl;
            return 0;
        }
        s += 3 - n;
        if (num[s-1] != -1 && num[s-1] != c) {
            cout << "-1" << endl;
            return 0;
        }
        num[s-1] = c;
    }
    for (int i = 0; i < 3; ++i) {
        if (num[i] == -1) {
            num[i] = 0;
        }
    }
    if (m == 0 && n == 3) num[0] = 1;
    if (m == 0 && n == 2) num[1] = 1;
    if (n == 3 && num[0] == 0) num[0] = 1;
    if (n == 2 && num[1] == 0) num[1] = 1;
    cout << num[0] * 100 + num[1] * 10 + num[2] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;


int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	vector<set<int>> a(26);
	int n;
	cin >> n;
	for (int i = 0; i < 26; i++)a[i].insert(n);
	string s;
	cin >> s;
	for (int i = 0; i < n; i++) {
		a[s[i] - 'a'].insert(i);
	}
	int q;
	cin >> q;
	while (q--) {
		int type;
		cin >> type;
		if (type == 1) {
			int pos;
			char k;
			cin >> pos >> k;
			char cur = s[pos - 1];
			a[cur - 'a'].erase(pos - 1);
			s[pos - 1] = k;
			a[k - 'a'].insert(pos - 1);
		}
		else {
			int l, r;
			cin >> l >> r;
			l--;r--;
			int ans = 0;
			for (int j = 0; j < 26; j++) {
				int k = *a[j].lower_bound(l);
				if (k <= r)ans++;
			}
			cout << ans << "\n";
		}
	}
}

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

using namespace std;

const int max_n = -1, inf = 1000111222;

int triv(int n) {
    int res = 0;
    for (int i = 1; i <= n; ++i) {
        if (n % i == n / i) {
            res += i;
        }
    }
    return res;
}

long long solve(long long n) {
    long long cur = 1, res = 0;
    while (cur <= n) {
        long long x = n / cur;
        if ((n - x) % x == 0) {
            long long m = (n - x) / x;
            if (m && n % m == n / m) {
                res += m;
            }
        }
        cur = n / x + 1;
    }
    return res;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    long long n;
    cin >> n;
    cout << solve(n) << endl;
    return 0;
}


Measured memory_bytes: 384
def resolve():
    n = int(input())
    vs = list(map(int, input().split()))
    sorted_vs = sorted(vs)

    for i in range(n-1):
        last = (sorted_vs[i] + sorted_vs[i+1]) / 2
        sorted_vs[i+1] = last

    print(sorted_vs[n-1])
resolve()

Measured memory_bytes: 38384
//ABC043B
 
#include <iostream>
#include <string>
#include <stack>
#include <list>
#include <algorithm>
 
using namespace std;
 
int main(){
    string s;
    list<char> li;
    cin>>s;
 
    for(int i=0;i<s.size();i++){
        if(s[i]=='0'||s[i]=='1'){
            li.push_back(s[i]);
        }else if(s[i]=='B'){
            if(!li.empty()){
                li.pop_back();
            }
        }
    }
    
    while(!li.empty()){
        cout<<li.front();
        li.pop_front();
    }
 
    cout<<endl;
 
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	string s;
	int n,x,y,a,b;
	cin>>s;
	bool f = false;
	for(int i = 0;i < s.size();i++){
		if(s[i] == 'C')f = true;
		if(f && s[i] == 'F'){
			cout <<"Yes"<<endl;
			return 0;
		}
	}
	cout <<"No" <<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

const int L = 30;

int main() {
#ifdef ELEGIA
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  vector<tuple<char, int, int, int>> opt;

  int top = 2;

  auto cmp = [&](int i, int j) {
    opt.emplace_back('<', i, j, ++top);
    return top;
  };
  auto sum = [&](int i, int j) {
    opt.emplace_back('+', i, j, ++top);
    return top;
  };
  auto CMP = [&](int i, int j, int k) { opt.emplace_back('<', i, j, k); };
  auto SUM = [&](int i, int j, int k) { opt.emplace_back('+', i, j, k); };
  auto MOV = [&](int i, int j) { opt.emplace_back('+', 2, i, j); };

  int ONE, ZERO = 2;
  {
    int x0 = cmp(2, 0);
    int x1 = cmp(2, 1);
    int m1 = sum(x0, x1);
    ONE = cmp(2, m1);
  }

  vector<int> power(L);
  power[0] = ONE;
  for (int i = 1; i < L; ++i)
    power[i] = sum(power[i - 1], power[i - 1]);
  vector<int> m1(L);
  m1[0] = ZERO;
  for (int i = 1; i < L; ++i)
    m1[i] = sum(m1[i - 1], power[i - 1]);

  auto getbit = [&](int i) {
    vector<int> ret(L);
    int csum = ZERO;
    for (int j = L - 1; j >= 0; --j) {
      int tmp = cmp(sum(csum, m1[j]), i);
      MOV(tmp, ++top);
      ret[j] = top;
      for (int rep = 0; rep < j; ++rep) SUM(tmp, tmp, tmp);
      csum = sum(csum, tmp);
    }
    return ret;
  };

  auto ga = getbit(0), gb = getbit(1);

  auto mul1 = [&](int i, int j) {
    return cmp(ONE, sum(i, j));
  };

  vector<int> tot(L * 2 - 1);
  for (int i = 0; i < L * 2 - 1; ++i) tot[i] = ++top;
  for (int i = 0; i < L; ++i)
    for (int j = 0; j < L; ++j)
      SUM(tot[i + j], mul1(ga[i], gb[j]), tot[i + j]);
  for (int i = L * 2 - 2; i >= 0; --i) {
    SUM(2, 2, 2);
    SUM(tot[i], 2, 2);
  }

  cout << opt.size() << '\n';
  for (auto [c, i, j, k] : opt) {
    cout << c << ' ' << i << ' ' << j << ' ' << k << '\n';
  }

#ifdef ELEGIA
  vector<ll> a(200000);
  cin >> a[0] >> a[1];
  for (auto [c, i, j, k] : opt) {
    if (c == '<')
      a[k] = a[i] < a[j];
    else
      a[k] = a[i] + a[j];
  }
  cout << a[2] << '\n';
#endif

#ifdef ELEGIA
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 3256
// AtCoder Beginner Contest 130 - Problem C: Rectangle Cutting (https://atcoder.jp/contests/abc130/tasks/abc130_c) 
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using di = pair<double, int>;

di solve(ll W, ll H, ll x, ll y)
{
    // Um reta que divide um polígono no meio deve passar pelo seu centro
    // Se (x, y) é o centro, há mais de uma solução, caso contrário há uma única
    int sols = (2*x == W and 2*y == H) ? 1 : 0;

    return { W*H/2.0, sols };
}

int main()
{
    ios::sync_with_stdio(false);

    ll W, H, x, y;
    cin >> W >> H >> x >> y;

    auto ans = solve(W, H, x, y);

    cout << fixed << ans.first << ' ' << ans.second << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] num = new int[N - 1];
		for(int i = 0; i < N - 1; i++) {
			num[i] = sc.nextInt();
		}
		int sum = 0;
		for(int i = 0; i < N; i++) {
			if(i == 0) {
				sum += num[i];
			}else if(i == N - 1) {
				sum += num[i - 1];
			}else {
				sum += Math.min(num[i], num[i - 1]);
			}
		}
		System.out.println(sum);

	}


}


Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#define _USE_MATH_DEFINES
#include <cmath>

#define rep(i, n)     for (int (i) = 0; (i) < (n); (i)++)
#define rep1(i, n)    for (int i = 1; i <= (int)(n); i++)

using namespace std;
typedef long long ll;

struct Node {
   int   key;
   Node *l, *r, *p;
};

Node *root, *NIL;

void insert(int k) {
   Node *y = NIL;
   Node *x = root;
   Node *z;

   z = (Node *)malloc(sizeof(Node));
   z->key = k;
   z->l = NIL;
   z->r = NIL;

   while (x != NIL) {
      y = x;
      if (z->key < x->key) x = x->l;
      else x = x->r;
   }
   z->p = y;
   if (y == NIL)
      root = z;
   else{
      if (z->key < y->key)
         y->l = z;
      else
         y->r = z;
   }
}

void inorder(Node *u) {
   if (u == NIL) return;

   inorder(u->l);
   printf(" %d", u->key);
   inorder(u->r);
}

void preorder(Node *u) {
   if (u == NIL) return;

   printf(" %d", u->key);
   preorder(u->l);
   preorder(u->r);
}

int main() {
   int  n, x;
   char s[10];

   cin >> n;
   rep(i, n) {
      scanf("%s", s);
      if (s[0] == 'i') {
         scanf("%d", &x);
         insert(x);
      }
      else{
         inorder(root);
         printf("\n");
         preorder(root);
         printf("\n");
      }
   }
   return(0);
}



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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
ll MAX_V = 2e5 + 5;
vector<ll>t(MAX_V);//訪問したかどうか
vector<ll>ret(MAX_V);
void dfs(ll k,ll col,vector<vector<P>>&g){
  t[k]=1;
  ll cnt=0;
  if(col==0)cnt=1;
  for(ll i=0;i<g[k].size();i++){
    if(t[g[k][i].fi]==0){
      dfs(g[k][i].fi,cnt,g);
      ret[g[k][i].se]=cnt;
      cnt++; 
    }
    if(cnt==col)cnt++;
  }
}

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout<<fixed<<setprecision(10);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<vector<P>>g(n);
  vector<ll>div(n);
  rep(i,0,n-1){
    ll a,b;cin>>a>>b;
    a--;b--;
    g[a].EB(b,i);
    div[a]++;
    div[b]++;
  }
  ll col=*max_element(ALL(div));
  dfs(0,-1,g);
  cout<<col<<endl;
  rep(i,0,n-1){
    cout<<ret[i]+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 10752
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val cards = readLine()?.split(" ")?.map { it.toInt() }?.toMutableList() ?: return

    cards.sort()
    cards.reverse()

    var aSum = 0
    var bSum = 0

    for (i in 0 until cards.size) {
        if (i % 2 == 0) {
            aSum += cards[i]
        } else {
            bSum += cards[i]
        }
    }
    println(aSum - bSum)
}

Measured memory_bytes: 36152
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	long long n, k;
	string s;
	cin >> n >> k >> s;
	long long p = 0, d = 0;
	for (int i = 0; i < n - 1; ++i)
		if (s[i] == s[i + 1]) ++p;
		else ++d;
	if (k >= d / 2) p += d / 2 * 2, p += d % 2 == 1 && k >= d / 2 + 1 ? 1 : 0;
	else p += k * 2;
	cout << p;
	return 0;
}




Measured memory_bytes: 512