akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
LL rsum2[N];
LL rsum1[N];
LL a[N];
int v[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	LL c;
	cin >> n >> c;
	for (int i = 1; i <= n; i++) cin >> a[i] >> v[i];
	LL sum = 0;
	LL ans = 0;
	for (int i = 1; i <= n; i++)
	{
		sum += v[i];
		ans = max(ans, sum - a[i]);
	}
	sum = 0;
	for (int i = n; i > 0; i--)
	{
		sum += v[i];
		ans = max(ans, sum - (c - a[i]));
		rsum2[i] = sum - 2 * (c - a[i]);
		rsum2[i] = max(rsum2[i], rsum2[i + 1]);
		rsum1[i] = sum - (c - a[i]);
		rsum1[i] = max(rsum1[i], rsum1[i + 1]);
	}
	sum = 0;
	for (int i = 1; i <= n; i++)
	{
		sum += v[i];
		ans = max(ans, sum - 2 * a[i] + rsum1[i + 1]);
		ans = max(ans, sum - a[i] + rsum2[i + 1]);
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
    int a, b;
    scanf("%d %d", &a, &b);

    printf("%d\n", max(2 * a - 1, max(a + b, 2 * b - 1)));
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;

bool flag[100][10];
int val[100][11];
int main()
{
    cin >> N;
    rep(i, N){
        rep(j, 10){
            cin >> flag[i][j];
        }
    }
    rep(i, N){
        rep(j, 11){
            cin >> A;
            val[i][j] = A;
        }
    }
    ll ans = INF;
    rep(i, pow(2, 10)){
        if(i == 0) continue;
        ll profit = 0;
        rep(j, N){
            int curr = i;
            int cnt = 0;
            rep(k, 10){
                if(curr%2 == 1 && flag[j][k] == 1) cnt++;
                curr /= 2;
            }
            profit += val[j][cnt];
        }
        ans = max(ans, profit);
    }
    cout << ans;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    int c = 0;
    
    for (int i = a; i <= b; i++) {
        int m = i;
        int r = 0;
    
        while (m > 0) {
            r *= 10;
            r += m % 10;
            m /= 10;
        }
        
        if (r == i) c++;
    }
    
    cout << c << endl;
}


Measured memory_bytes: 256
import numpy as np
import copy
D=int(input())

c_list=list(map(int,input().split()))
c_list=np.array(c_list)
c_ll=np.array([0]*26)

d_list=[]
for i in range(D):
    dl=list(map(int,input().split()))
    d_list.append(np.array(dl))

# score
score=0

#expect
exp=[0]*26
for d in range(D):
    c_ll+=1
    for i in range(26):
        exp[i]+=d_list[d][i]
        c_ll2=copy.deepcopy(c_ll)
        c_ll2[i]=0
        exp[i]-=sum(c_list*c_ll)

    j=exp.index(max(exp))
    c_ll[j]=0
    print(j+1)


Measured memory_bytes: 27212
#include <algorithm>
#include <bitset>
//#include <boost/multiprecision/cpp_int.hpp>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
//namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
// using ll = boost::multiprecision::cpp_int;
using ll = long long;
#define FORi(N) for(ll i = 0; i < N; ++i)
#define FORj(N) for(ll j = 0; j < N; ++j)
#define FORk(N) for(ll k = 0; k < N; ++k)

#define ALL(v) v.begin(),v.end()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}

int main() {
    ll N;
    cin >> N;
    map<ll,ll> a;
    bool flag = true;
    FORi(N) {
        ll tmp;
        cin >> tmp;
        if(a.find(tmp)==a.end()){
            a[tmp] = 1;
        }else{
            a[tmp]++;
        }
        if(a.size()>3){
            flag = false;
            break;
        }
    }
    if(flag){
        if(a.size()==3){
            auto i0 = a.begin();
            auto i1 = i0;
            auto i2 = i0;
            i1++;
            i2++;
            i2++;
            //cout << i0->first;
            //cout << i1->first;
            //cout << i2->first;
            if((ll)(i1->first^i2->first)!=i0->first){
                //cout << (ll)(i1->first^i2->first);
                flag = false;
            }
            if((i0->second == i1->second && i1->second==i2->second)){
                
            }else{
                flag = false;
            }
        }else if(a.size()==2){
            auto i0 = a.begin();
            auto i1 = i0;
            i1++;
            if(i0->first==0||i1->first==0){

            }else{
                flag = false;
            }
            if(i0->second!=i1->second){
                if(i0->first==0){
                    if(i0->second*2!=i1->second){
                        flag = false;
                    }else{

                    }
                }
                if(i1->first==0){
                    if(i1->second * 2 != i0->second) {
                        flag = false;
                    }
                }
            }
        }else{
            if(a.begin()->first!=0){
                flag = false;
            }
        }
    }
    if(!flag){

    }
    putYN(flag);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin >>n>>k;
	bool d[10]={};
	for(int i=0;i<k;i++)
	{
		int j;
		cin >>j;
		d[j]=true;
	}
	string s;
	bool f;
	char c[10];
	for(int i=0;i<10;i++)
	{
		c[i]='0'+i;
//		cout <<c[i]<<" "<<d[i]<<endl;
	}
	for(int i=n;i<n*100;i++)
	{
		stringstream ss;
		ss <<i;
		s=ss.str();
		f=true;
		for(int j=0;j<10;j++)
		if(d[j]&&s.find(c[j])!=-1)
		{
			f=false;
			break;
		}
		if(f)
		{
			cout <<i<<endl;
			break;
		}
	}
	return 0;
}

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

typedef long long ll;

ll N;
int res;

int main()
{
    cin >> N;
    for (ll i = 2; i * i <= N; i++) if (N % i == 0) {
        int cnt = 0;
        while (N % i == 0) {
            N /= i;
            cnt++;
        }
        for (int j = 1; 2 * j + 1 <= cnt; j++) {
            res++;
            cnt -= j;
        }
        res++;
    }
    if (N > 1) res++;
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 3724
#define NguyenDangQuan the_author

#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define mset(x, i) memset(x,i,sizeof(x))
#define elif else if
#define heap priority_queue
#define fi first
#define se second
#define pb push_back
#define ld long double
#define ll long long
#define ull unsigned long long
#define task "codejam"
using namespace std;

int typetest;
template<class T>
void read(T &x){
    register int c;
    T neg = 1;
    x = (T)0;
    while ((c = getchar()) <= 47 || c >= 58)
		if(c == '-') neg = -1;
    for (; (c > 47 && c < 58); c = getchar()){
        x = (x << 3) + (x << 1) + (T)(c - 48);
    }
	x *= neg;
}
inline void fastIOfileinput(){
	ios:: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
//	freopen(task".INP", "r", stdin);
//	freopen(task".OUT", "w", stdout);
//	freopen(task".in", "r", stdin);
//	freopen(task".out", "w", stdout);
	typetest = 0;
}

const int N = 2e5 + 2;
int m, n, k;
vector<int> ker[N], kel[N];
int ltr[N], ltl[N];

void Enter(){
	read(n); read(m); read(k);
	while(m--){
		int a, b;
		read(a); read(b);
		ker[a].pb(b);
		ker[b].pb(a);
	}
	while(k--){
		int a, b;
		read(a); read(b);
		kel[a].pb(b);
		kel[b].pb(a);
	}
}

void BFS(int i, int lt[], vector<int> ke[]){
	++m;
	lt[i] = m;
	queue<int> open;
	open.push(i);
	while(open.size()){
		int c = open.front();
		open.pop();
		for(auto i : ke[c]){
			if((!lt[i]))
				open.push(i), lt[i] = m;
		}
	}
}

void solve(){
	m = 0;
	for(int i = 1; i <= n; ++i)
		if(ltr[i] == 0)
			BFS(i, ltr, ker);
	m = 0;
	for(int i = 1; i <= n; ++i)
		if(ltl[i] == 0)
			BFS(i, ltl, kel);
	map<int, map<int, int> > s;
	for(int i = 1; i <= n; ++i){
		++s[ltr[i]][ltl[i]];
//		cerr << ltr[i] << " " << ltl[i] << "\n";
	}
	for(int i = 1; i <= n; ++i){
		int& v = s[ltr[i]][ltl[i]];
		cout << v << " ";
	}
}

signed main(){
	fastIOfileinput();
	if(typetest){
		int t;
		cin >> t;
		int v = t;
		while(t--){
			Enter();
			cout << "Case #" << v - t << ": ";
			solve();
		}
	}
	else{
		Enter();
		solve();
	}
}


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

long g(long x)
{
  if (x % 4 == 0)
    return x;
  else if (x % 4 == 1)
    return 1;
  else if (x % 4 == 2)
    return x + 1;
  else
    return 0;
}

int main()
{
  long A, B;
  cin >> A >> B;
  // f(A, B) = f(0, A - 1) XOR f(0, B)
  // f(0, x) = g(x)とするとf(A, B) = g(A - 1) XOR g(B)
  cout << (g(A - 1) ^ g(B)) << endl;
  return 0;
}

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

int main() {
  int x=0;
  int A,B;
   cin >> A >> B;
    for (int i=A;i<=B;i++){
     int a = i/10000;
     int b = i/1000 - 10*a;
     int e = i % 10;
     int d = ((i % 100)-e)/10;
      if (a==e&&d==b){
        x+=1;
      }
    }
  cout << x << endl;      

}

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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

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

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;

  int N;
  cin >> N;
  vi A(N);
  cin >> A;

  while (1) {
    sort(all(A));

    // REP(i, N) cout << A[i] << " ";
    // cout << endl;

    if (A[N - 2] == 0)
      break;

    int mi = N - 1;
    REP(i, N) {
      if (A[i] > 0) {
        mi = i;
        break;
      }
    }

    REP(i, N) {
      if (i == mi)
        continue;
      else
        A[i] %= A[mi];
    }
  }

  cout << A[N - 1] << endl;
  return 0;
}


Measured memory_bytes: 640
a,b,c,d = input().split()
a = int(a)
b = int(b)
c = int(c)
d = int(d)
if d < 0 and b > 0:
    if d > 0:
        d = c
    else:
        b = a
if d > 0 and b < 0:
    if d > 0:
        d = c
    else:
        b = a
if a < 0 and c < 0:
    if d * b < a * c:
        d = c
        b = a
print(b * d)

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

using namespace std;
using Int = long long;

signed main(){
    Int n, l;
    cin >> n >> l;

    Int sum = 0;
    Int tmp = 10000;
    for (Int i = 1; i <= n; i++){
        Int taste = l + i - 1;
        sum += taste;
        if (abs(taste) < abs(tmp)) {
            tmp = taste;
        }
    }

    cout << sum - tmp << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=2e6;
long long a[200005],sum[200005],n,ans,maxv;
signed main(){
	cin>>n;
	for(int i=1,x;i<=n;i++){
		cin>>x;
		a[i]=x-i;
	}
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++){
		maxv+=a[n]-a[i];
	}
	ans=maxv;
	for(int i=n-1;i>=1;i--){
		maxv=maxv+(n-2*i)*(a[i+1]-a[i]);
	
		ans=min(ans,maxv);
	}
	cout<<ans;
}

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

int main() {
    int n, card[4][13] = {};

    cin >> n;
    for (int i = 0; i < n; i++) {
        char suit;
        int rank;
        cin >> suit >> rank;
        switch (suit) {
            case 'S':
                card[0][rank - 1] = 1;
                break;
            case 'H':
                card[1][rank - 1] = 1;
                break;
            case 'C':
                card[2][rank - 1] = 1;
                break;
            case 'D':
                card[3][rank - 1] = 1;
                break;
        }
    }

    char SHCD[] = "SHCD";
    for (int i = 0; i < 52; i++) {
        int suit = i / 13;
        if (!card[suit][i % 13]) {
            cout << SHCD[suit] << " " << i % 13 + 1 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3088
import math as ma
N = int(input())
a = list(map(int, input().split()))
s = sum(a)
A = 0
diff = 9999999999
for i in range(N-1):
    A += a[i]
    if diff > (ma.fabs(2*A - s)):
        diff = ma.fabs(2*A -s)
print(int(diff))

Measured memory_bytes: 23800
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int a[100005];
int main()
{
	int n;
	cin>>n;

	for(int i=0;i<n;i++)
	cin>>a[i];
	
	if(n==1)
	{
		cout<<a[0];
		return 0;
	}
	
	int x=a[0];
	long double ans=0, y=a[0];

	for(int i=1;i<n;i++)
	{
		x=__gcd(x,a[i]);
		y=y*a[i];
	}
	
	y=y/x;

	for(int i=0;i<n;i++)
	ans+=(y)/a[i];

	cout<<setprecision(12)<<(y)/ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <fstream>
#include <functional>

using namespace std;
using ll = long long;

#define PRI(n) cout << n << " "<<endl;
#define PRI2(n, m) cout << n << " " << m << " "<<endl;

#define REP(i, n)  for(int i = 0; i < (int)n; ++i)
#define FOR(i, t, n)  for(int i = t; i <= (int)n; ++i)

const char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                           's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
const ll MOD = 1e9 + 7;

struct edge;
struct UnionFind;

bool isPrime(ll x);

ll GCD(ll a, ll b);

ll LCM(ll a, ll b);

ll nCr(int n, int r);


struct UnionFind {
    vector<int> par;
    vector<int> rank;

    UnionFind(int N) {
        for (int i = 0; i < N; ++i) {
            par.push_back(i);
            rank.push_back(0);
        }
    }

    int find(int x) {
        if (par[x] == x)return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)return;
        if (rank[x] < rank[y])par[x] = y;
        else {
            par[y] = x;
            if (rank[x] == rank[y])rank[x]++;
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

ll N, M;
string S;

ll sum = 0;

ll solve(ll x) {
    return x % 2 == 1 ? (x + 1) / 2 % 2 : ((x + 2) / 2 % 2) ^ (x + 1);
}

int main() {
    cin >> N >> M;
    PRI((solve(N - 1) ^ solve(M)))
    return 0;
}

struct edge {
    int to, cost;
    bool flag = false;
};

bool isPrime(ll x) {
    if (x == 0)return 0;
    if (x == 1)return 0;
    if (x == 2)return 1;
    if (x % 2 == 0)return 0;
    FOR(i, 3, x - 1) {
        if (x % i == 0)return 0;
    }
    return 1;
}

ll GCD(ll a, ll b) {
    if (b == 0)return a;
    return GCD(b, a % b);
}

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

ll nCr(int n, int r) {
    vector<ll> C(r + 1);
    C[0] = 1;
    FOR(i, 1, n) for (int j = min(i, r); j < 1; --j)C[j] = (C[j] + C[j - 1]) % MOD;
    return C[r];
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, k;
	cin>>n>>k;
	vector<int> arr;
	for(int i=0;i<n;i++)
	{
		int a;
		cin>>a;
		arr.push_back(a);
	}
	bool dp[k+1];
	memset(dp,false,sizeof(dp));
	for(int i = 0 ; i <= k; ++i)
	{
		for(auto take : arr)
		{
			if(i >= take && !dp[i - take])
				dp[i] = true;
		}
	}
	if(dp[k]==true)
		cout<<"First"<<endl;
	else
		cout<<"Second"<<endl;
	
	return 0;
	
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int main(){
    string s;
    cin>>s;
    for(int bit=0;bit<(1<<3);bit++){
        int sum=s[0]-'0';
        string ans="";
        ans+=s[0];
        rep(i,3){
            if(bit & (1<<i)){
                sum+=s[i+1]-'0';
                ans+='+';
                ans+=s[i+1];
            }
            else{
                sum-=s[i+1]-'0';
                ans+='-';
                ans+=s[i+1];
            } 
        }
        ans+="=7";
        if(sum==7){
                cout<<ans<<endl;
                return 0;
        }
    }
 }

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

long long int N, A[524288];

struct segtree{
    long long int s;
    long long int val[1048576];

    segtree(long long int _s){
        s = 1;
        while(s < _s)s <<= 1;
        fill(val, val + 2 * s, 0);
        for(int i = 0; i < s; ++i){
            val[i + s] = A[i];
        }
        for(int i = s - 1; i >= 0; --i){
            val[i] = val[i * 2] | val[i * 2 + 1];
        }
    }

    long long int query(int l, int r){
        long long int ret = 0;
        l += s;
        r += s;
        while(l < r){
            if(l & 1){
                ret |= val[l];
                ++l;
            }
            if(r & 1){
                ret |= val[r - 1];
            }
            l >>= 1;
            r >>= 1;
        }
        return ret;
    }
};

int main(){
    scanf("%lld", &N);
    ++N;
    A[0] = 2097151;
    for(int i = 1; i < N; ++i){
        scanf("%lld", A + i);
    }
    segtree sgt = segtree(N);
    int left = 0, right, mid;
    for(int i = 1; i < N; ++i){
        right = i;
        while(right - left > 1){
            mid = (left + right) / 2;
            if(sgt.query(mid, i) & A[i]){
                left = mid;
            }else{
                right = mid;
            }
        }
        A[200202] += i - left;
    }
    cout << A[200202] << endl;
    return 0;
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int N; 
  cin >> N;
  vector<int> h(N);
  rep(i, N) cin >> h[i];
  int length=0;
  int ans = 0;
  
  rep(i, N-1){
    if(h[i] >= h[i+1])length++;
    else{
    	if(length >= ans){
        	ans = length;
          	length = 0;
        }else{
        	length = 0;
        }
    }
  }
  
  if(length >= ans) cout << length << endl;
  else cout << ans << endl;
  
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    ll F[100][14];
    ll P[100][15];
    rep(i, N)
    {
        rep(j, 10)
        {
            cin >> F[i][j];
        }
    }
    rep(i, N)
    {
        rep(j, 11)
        {
            cin >> P[i][j];
        }
    }
    ll res = -(1 << 30);
    for (int bit = 1; bit < (1 << 10); ++bit) {
        ll x = 0;
        rep(i, N)
        {
            ll cnt = 0;
            rep(j, 10)
            {
                if ((bit >> j & 1) && F[i][j]) {
                    cnt++;
                }
            }
            x += P[i][cnt];
        }
        res = max(res, x);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		sc.close();
		// aがnより大きいパタン
		if (a > n) {
			System.out.println(n);
		}
		// a+bがnより以上のパタン
		else if ((a + b) >= n) {
			System.out.println(a);
		}
		// a+bがn以下のパタン
		else {
			long ab = a + b;
			long count = n / ab;
			long remainder = n % ab;
			long ans = a * count;
			if (remainder >= a) {
				ans = ans + a;
			} else {
				ans = ans + remainder;
			}
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 23636
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
const long long MOD = static_cast<long long>(1e6) + 3LL;
const long long INF = 1234567891234567890LL;
ll pow(ll a, ll n, ll mod=1000003){
    ll res = 1LL;
    while(n){
        if(n%2==1) res = (res*a)%mod;
        a = (a*a)%mod;
        n >>= 1;
    }
    return res%mod;
}
vector<ll> fac;
void init(){
    fac.resize(MOD+1);
    fac[0] = fac[1] = 1;
    for(int i=1; i<=MOD; i++){
        fac[i] = (fac[i-1] * i) %MOD;
    }
}
void solve(ll x, ll d, ll n) {
    ll res;
    if(d==0){
        res = pow(x, n, MOD);
    }
    else{
        ll y =(x * pow(d, MOD-2, MOD))%MOD;
        if(y+n-1 >= MOD) res = 0;
        else{
            res = (fac[y+n-1] * pow(fac[y-1], MOD-2, MOD))%MOD;
            res = (res * pow(d, n, MOD))%MOD;
        }
    } 

    cout << res << endl;
}
signed main(){
    ll Q; cin >> Q;
    init();
    REP(i, Q){
        ll x, d, n; cin>>x>>d>>n;
        solve(x, d, n);
    }
}

Measured memory_bytes: 8704
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	int N,M,a,b,cnt;
	int points[101];
	for(int i=0;i<101;i++){
		points[i]=0;
	}
	vector<int> A,B[101];
	cin>>N>>M;
	for(int i=0;i<M;i++){
		cin>>a;
		A.push_back(a);
	}
	for(int i=0;i<M;i++){
		cnt=0;
		for(int j=0;j<N;j++){
			cin>>b;
			if(b==A[i])points[j]++;
			else cnt++;
		}
		points[A[i]-1]+=cnt;
	}
	for(int i=0;i<N;i++){
		cout<<points[i]<<endl;
		
	}
	
}

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

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
int main() {
	int n;
	std::cin >> n;
	std::vector<std::pair<int, int>>r(n), b(n);
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < n; j++) {
			if (i)std::cin >> b[j].first >> b[j].second;
			else std::cin >> r[j].first >> r[j].second;
		}
	}
	std::sort(r.begin(), r.end(), [](const auto a, const auto b) {return a.second > b.second; });
	std::sort(b.begin(), b.end(), [](const auto a, const auto b) {return a.first < b.first; });
	std::vector<bool>flags(n, 0);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (r[i].first < b[j].first&&r[i].second < b[j].second && !flags[j]) {
				flags[j] = true;
				break;
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++)ans += flags[i];
	printf("%d\n", ans);
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int h, w; std::cin >> h >> w;
  vector<string> grid(h); rep(i, h) std::cin >> grid[i];
  vector<bool> dh(h, true), dw(w, true);
  rep(i, h) {
    int cnt = 0;
    rep(j, w) {
      if (grid[i][j] == '.') cnt++;
    }
    if (cnt == w) dh[i] = false;
  }
  rep(i, w) {
    int cnt = 0;
    rep(j, h) {
      if (grid[j][i] == '.') cnt++;
    }
    if (cnt == h) dw[i] = false;
  }
  rep(i, h) if (dh[i]) {
    rep(j, w) if (dw[j]) std::cout << grid[i][j];
    std::cout << "\n";
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include<set>
#include<bitset>
#include<stdio.h>
#include<deque>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
 
int main()
{
    int r;
    cin >> r;
    cout << 3*r*r << endl;
    return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn._
import scala.annotation.tailrec
import scala.collection._

object Main {

  def makeSoE_PrimesTo(top: Int) = {
    val topNdx = (top - 3) / 2 + 1
    val (cmpsts, sqrtLmtNdx) = (new Array[Int]((topNdx >>> 5) + 1), (Math.sqrt(top).toInt - 3) / 2)

    @inline def isCmpst(ci: Int): Boolean =
      (cmpsts(ci >>> 5) & (1 << (ci & 31))) != 0

    @inline def setCmpst(ci: Int): Unit =
      cmpsts(ci >>> 5) |= 1 << (ci & 31)

    @tailrec def forCndNdxsFrom(cndNdx: Int): Unit =
      if(cndNdx <= sqrtLmtNdx){
        if(!isCmpst(cndNdx)){
          val p = cndNdx + cndNdx + 3

          @tailrec def cullPrmCmpstsFrom(cmpstNdx: Int): Unit =
          if(cmpstNdx <= topNdx){
            setCmpst(cmpstNdx)
            cullPrmCmpstsFrom(cmpstNdx + p)
          }
          cullPrmCmpstsFrom((p * p - 3) >>> 1)
        }
        forCndNdxsFrom(cndNdx + 1)
      }
      forCndNdxsFrom(0)

    @tailrec def getNxtPrmFrom(cndNdx: Int): Int =
      if ((cndNdx > topNdx) || !isCmpst(cndNdx)) cndNdx + cndNdx + 3
      else getNxtPrmFrom(cndNdx + 1)

    Iterator.single(2) ++ Iterator.iterate(3)(p => getNxtPrmFrom(((p + 2) - 3) >>> 1)).takeWhile(_ <= top)
  }

  @tailrec
  def loop(s: String){
    if(s != null){
       val Array(n,_*) = s.split(" ").map(_.toInt)
       if(n<2) println(0)
       else println(makeSoE_PrimesTo(n).size)
       loop(readLine)
    }
  }

  def main(args: Array[String]): Unit ={
    loop(readLine)
  }
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

struct Acc {
  vector<lli> sum;
  Acc(vector<lli> v) {
    sum.push_back(0);
    each (i, v) {
      sum.push_back(sum.back() + i);
    }
  }
  lli query(lli begin, lli end) {
    return sum[end] - sum[begin];
  }
};

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  const int N = 1e5 + 5;
  bool prime[N];
  fill(prime, prime + N, true);
  prime[0] = prime[1] = false;
  for (int i = 2; i * i < N; ++i) {
    for (int j = 2; i * j < N; ++j) {
      prime[i * j] = false;
    }
  }

  vector<lli> v;
  for (int i = 0; i < N; ++i) {
    int j = (i + 1) / 2;
    v.push_back(i % 2 && prime[i] && prime[j]);
  }
  Acc acc(v);
  
  int q;
  while (cin >> q) {
    while (q--) {
      int a, b;
      cin >> a >> b;
      cout << acc.query(a, b + 1) << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c; cin >> a >> b >> c;
    if (a+b+c>=22) cout << "bust" << endl;
    else cout << "win" << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Node {
	int x;
	int y;
	
	public Node(int x, int y) {
		this.x = x;
		this.y = y;
	}
}

public class Main {
	public static int floodFill(char[][] maze, int[][] visited, int i, int j) {
		int[] dx = new int[]{0,0,1,-1};
		int[] dy = new int[]{1,-1,0,0};
		int tempMax = 0;
		visited[i][j] = 0;
		Queue<Node> q = new LinkedList<>();
		q.add(new Node(i,j));
		while(q.peek() != null) {
			Node now = q.remove();
			for(int a = 0; a < 4; a++) {
				int newI = now.x + dx[a];
				int newJ = now.y + dy[a];
				if(newI >= 0 && newI < maze.length && newJ >= 0 && newJ < maze[0].length && maze[now.x][now.y] == '.') {
					if(visited[newI][newJ] == -1 && maze[newI][newJ] == '.') {
						visited[newI][newJ] = 1 + visited[now.x][now.y];
						tempMax = Math.max(visited[newI][newJ], tempMax);
						q.add(new Node(newI, newJ));
					}
				}
			}
		}
		return tempMax;
	}
	public static void resetVisit (int[][] visited) {
		for(int i = 0; i < visited.length; i++) {
			for(int j = 0; j < visited[0].length; j++) {
				visited[i][j] = -1;
			}
		}
	}
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		int h = in.nextInt();
		int w = in.nextInt();
		int ans = 0;
		char[][] maze = new char[h][w];
		int[][] visited = new int[h][w];
		for(int i = 0; i < h; i++) {
			String input = in.next();
			for(int j = 0; j < w; j++) {
				maze[i][j] = input.charAt(j);
				visited[i][j] = -1;
			}	
		}
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				if(maze[i][j] == '.') {
					ans = Math.max(floodFill(maze, visited, i, j), ans);
					resetVisit(visited);
				}
			}
		}
		System.out.println(ans);	
	}
}


Measured memory_bytes: 29364
import sys
sys.setrecursionlimit(10**8)
n = int(input())
a = list(map(int,input().split()))

a_data = [0]
now = 0
for i in a:
    now += i
    a_data.append(now)

dp = [[10**18 for _ in range(n+1)] for i in range(n)]
#print(a_data)
def solve(i,j):
    if dp[i][j] != 10**18:
        return dp[i][j]
    if i+1 == j:
        dp[i][j] = 0
        return dp[i][j]
    dp[i][j] = a_data[j] - a_data[i]
    x = 10**18
    for k in range(i+1,j):
        s = solve(i,k)
        t = solve(k,j)
        x = min(x,s+t)
    dp[i][j] += x
    return dp[i][j]

ans = solve(0,n)
print(ans)

Measured memory_bytes: 43500
#include <stdio.h>
 int main()
{ 
int j,s_length = 0;
 char s[101],p[101];
 scanf("%s",s); scanf("%s",p); 
for(int i = 0; s[i] != '\0';i++) s_length++; 
for(int left = 0;s[left] != '\0';
left++){ for(j = 0;p[j] != '\0' && p[j] == s[(left+j)%s_length];
j++); 
if(p[j] == '\0'){ printf("Yes\n");
 return 0; 
} 
} 
printf("No\n");
 return 0; 
} 



Measured memory_bytes: 2604
def msb(x):
    cnt = 0
    while x:
        x >>= 1
        cnt += 1
    return cnt


def solve(n, a, s):
    # dp[i] = (i回目時点で最終的に0にできる数の集合)
    dp = [[] for _ in range(n + 1)]
    # dp[n] = [0]
    for i in reversed(range(n)):
        if s[i] == '0':
            x = a[i]
            dp[i] = dp[i + 1].copy()
            dp[i].sort(reverse=True)
            for j in range(len(dp[i])):
                x = min(x, x ^ dp[i][j])
            if x != 0:
                dp[i].append(x)
        else:
            x = a[i]
            dp[i + 1].sort(reverse=True)
            for j in range(len(dp[i + 1])):
                x = min(x, x ^ dp[i + 1][j])
            if x == 0:
                dp[i] = dp[i + 1].copy()
            else:
                return '1'
        # print(i, a[i], s[i], dp[i])
    # print(n, a, s)
    # print(*dp, sep='\n')
    if len(dp[0]) != 0:
        return '0'
    else:
        return '1'


t = int(input())
for _ in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    s = input()
    ans = solve(n, a, s)
    print(ans)


Measured memory_bytes: 9204
def main():
    n = int(input())
    array = [int(input()) for _ in range(n)]
    count = 0
    gs = make_margins(n)
    m = len(gs)
    for g in gs:
        count += insertionSort(array, n, g)
    print(m)
    print(' '.join(map(str, gs)))
    print(count)
    for e in array:
        print(e)


def make_margins(n):
    gs = [1]
    while 3*gs[-1] + 1 < n:
        gs.append(3*gs[-1] + 1)
    return list(reversed(gs))


def insertionSort(array, n, g):
    cnt = 0
    for i in range(g, n):
        v = array[i]
        j = i - g
        while j >= 0 and array[j] > v:
            array[j+g] = array[j]
            j = j - g
            cnt += 1
        array[j+g] = v
    return cnt


if __name__ == '__main__':
    main()



Measured memory_bytes: 45520
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	ll A[200001];
	ll Asum[200001]={};
	scan(N);
	rep(i,N){
		scan(A[i]);
		Asum[i+1]=Asum[i]+A[i];
	}
	ll ans=INFl;
	rep1(i,N-1){
		ans=min(ans,abs(Asum[N]-2*Asum[i]));
	}
	prin(ans);
	return 0;
}


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

int main(){
    int c;
    int cnt[4] = {0};
    while(c = getchar()){
        if(c == '\n') break;
        if(c == 'K') ++cnt[0];
        if(c == 'U') ++cnt[1];
        if(c == 'P') ++cnt[2];
        if(c == 'C') ++cnt[3];
    }
    int min = 10000;
    for(int i=0; i<4; ++i)
        if(min > cnt[i]) min = cnt[i];
    cout << min << endl;
    return 0;
}

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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}


int main(int argc, char const* argv[])
{
    int n;
    cin >> n;

    int d,x;
    cin >> d >> x;
    
    int count=0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        count += (d-1)/a + 1;
    }
    
    cout << count + x << endl;
    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector


// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

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

const ll mod = 1000000007;

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

  double a, b, x;
  cin >> a >> b >> x;

  constexpr double pi = 3.14159265358979323846264;

  double levelHeight = x / (a * a);
  double cornerAngle = atan(levelHeight / (a / 2.0));

  double eps = 1e-10;
  double left = 0.0;
  double right = pi / 2.0;
  while (right - left > eps) {
    double center = (left + right) / 2.0;
    double waterHeight;
    if (center < cornerAngle) waterHeight = levelHeight + (a / 2.0) * tan(center);
    else waterHeight = sqrt((2.0 * (x / a)) / tan(center)) * tan(center);
    if (waterHeight < b) left = center;
    else right = center;
  }

  double ans = ((left + right) / 2.0) * (180 / pi);
  
  cout << setprecision(16) << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        a: f64,
        b: f64,
    }
    let f: f64 = (a + b) / 2.;
    let ans: i32 = f.ceil() as i32;
    println!("{:?}", ans);
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


//ABC090_b
int main() {
	int A, B;
	cin >> A >> B;

	int cnt = 0;
	for (int i=A; i<=B; i++) {
		string num = to_string(i);
		string rev_num ="";
		for (int j=num.length()-1; j>=0; j--) {
			rev_num += num.at(j);
		if (rev_num == num) {
			cnt += 1;
		}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

template <class T>void Sort(vector<T> & a) { sort(a.begin(), a.end()); }
template <class T>void ReSort(vector<T>& a) { sort(a.rbegin(), a.rend()); }
template <class T>void Reverse(vector<T>& a) { reverse(a.begin(), a.end()); }
template <class T>void Unique(vector<T>& a) { a.erase(unique(a.begin(), a.end()), a.end()); }
template <class T>T Sum(vector<T> a, T init = 0) { return accumulate(a.begin(), a.end(), init); }

//INPUT//
void CINPUT() {}
template<class H, class ...T> void CINPUT(H&& h, T&& ...t) { cin >> h; CINPUT(forward<T>(t)...); }
#define in(...) int __VA_ARGS__; CINPUT(__VA_ARGS__);
#define In(T,...) T __VA_ARGS__; CINPUT(__VA_ARGS__);
#define Vin(T,name,n) int n; cin>>n; vector<T> name(n); rep(i,n)cin>>name[i];
#define VIn(T,name,n) vector<T> name(n); rep(i,n)cin>>name[i];
#define VIn2(T,name,name2,n) vector<T> name(n),name2(n); rep(i,n)cin>>name[i]>>name2[i];

//OUTPUT//
void print() { cout << endl; }
template <class H> void print(H&& h) { cout << h << endl; }
template <class H, class... T> void print(H&& h, T&& ... t) { cout << h << " "; print(forward<T>(t)...); }
template<class T>void out(T n) { cout << n << endl; }
template<class T>void out(vector<T> a, string sep = " ", string end = "\n") { for (int i = 0; i < (int)a.size(); ++i)cout << a[i] << (i == (int)a.size() - 1 ? end : sep); }
void yes(bool f) { puts(f ? "yes" : "no"); }
void Yes(bool f) { puts(f ? "Yes" : "No"); }
void YES(bool f) { puts(f ? "YES" : "NO"); }
void poss(bool f) { puts(f ? "possible" : "impossible"); }
void Poss(bool f) { puts(f ? "Possible" : "Impossible"); }
void POSS(bool f) { puts(f ? "POSSIBLE" : "IMPOSSIBLE"); }

int main() {
	in(n, k);
	VIn(int, l, n);
	ReSort(l);
	int ans = 0;
	rep(i, k)ans += l[i];
	out(ans);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long i64;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main(){
  int m,f,b;
  cin >> m >> f >> b;
  if(m + f < b){
    cout << "NA" << endl;
    return 0;
  }
  cout << max(b - m,0) << endl;
}



Measured memory_bytes: 3088
def chk_stable(re):
    for i in range(N-1):
        re_chk = list()
        re_chk.append(re[i])
        for j in range(i+1, N):
            if int(re[i][1]) == int(re[j][1]):
                re_chk.append(re[j])
        if len(re_chk) >= 2:
            for j in range(1, len(re_chk)):
                if A.index(re_chk[j]) < A.index(re_chk[j-1]):
                    return 'Not stable'
    return 'Stable'


def bubble():
    b_list = [i for i in A]
    flag = True
    while flag:
        flag = False
        for i in reversed(range(1, N)):
            if int(b_list[i][1]) < int(b_list[i-1][1]):
                tmp = b_list[i]
                b_list[i] = b_list[i-1]
                b_list[i-1] = tmp
                flag = True
    print(' '.join(b_list))
    return chk_stable(b_list)


def selection():
    s_list = [i for i in A]
    for i in range(N):
        min_i = i
        for j in range(i, N):
            if int(s_list[min_i][1]) > int(s_list[j][1]):
                min_i = j
        tmp = s_list[i]
        s_list[i] = s_list[min_i]
        s_list[min_i] = tmp
    print(' '.join(s_list))
    return chk_stable(s_list)


N = int(input())
A = list(input().split())

print(bubble())
print(selection())



Measured memory_bytes: 5612