akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,K,sum=0;
  cin>>N>>K;
  vector<ll> A;
  REP(i,N){
    ll a;
    cin>>a;
    A.PB(a);
    sum+=a;
  }
  
  if(sum-N<=K){
    co(1);
    return 0;
  }
  
  ll ye=INF,no=0;
  while(abs(ye-no)>1){
    ll cnt=0,mid=(ye+no)/2;
    REP(i,N){
      cnt+=(A[i]-1)/mid;
    }
    if(cnt<=K) ye=mid;
    else no=mid;
  }
  
  co(ye);
  return 0;
}


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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X;
    cin >> X;
    if (X == 3 || X == 5 || X == 7)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = input()
t = [int(i) for i in input().split()]
m = int(input())
ans = []
for i in range(m):
    p,x = map(int,input().split())
    a = t[p-1]
    t[p-1] = x
    ans.append(sum(t))
    t[p-1] = a

for i in range(m):
    print(ans[i])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;

//const int MOD=998244353;
const double PI=3.14159265359;





int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n,m,q;
    cin>>n>>m>>q;
    
    vector<vector<int>> v(n+1, vector<int>(n+2));
    
    while(m--){
        int l,r;
        cin>>l>>r;
        
        for(int i=1; i<=l; i++){
            v[i][r]++;
            //v[i][r+1]--;
            
        }
    }
    
    for(int i=1; i<=n; i++){
        for(int j=2; j<=n; j++){
            v[i][j]+=v[i][j-1];
        }
        
    }
    
    while(q--){
        int l,r;
        cin>>l>>r;
        cout<<v[l][r]<<endl;
    }
    
    
    
    
    
    
    
   
    return 0;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const int N = 1e6+5;
string s,t = "Yes";
vector<int> v[N];
ll n,m,result;
int a[N];

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


  cout << (n+m+result > 21 ? "bust" : "win") << endl;
}


Measured memory_bytes: 25600
let rec power ( * ) e m n =
  if n <= 0 then e
  else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)

let m = 1000000007
let ( +^ ) x y = (x + y) mod m
let ( -^ ) x y = x +^ (m - y)
let ( *^ ) x y = (x * y) mod m

let inv x = power ( *^ ) 1 x (m - 2)
let perm n k =
  Array.fold_left ( *^ ) 1 @@
  Array.init k @@ ( + ) @@ n - k + 1

let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun i -> Scanf.scanf "%d " @@ fun a -> a in
  let ps = Array.make n 0 in
  for i = 0 to n - 1 do
    ps.(0) <- inv (1 + i) +^ ps.(0)
  done;
  for i = 1 to n - 1 do
    ps.(i) <- ps.(i - 1) +^ inv (1 + i) -^ inv (1 + n - i)
  done;
  Printf.printf "%d\n" @@
    ( *^ ) (perm n n) @@
      Array.fold_left ( +^ ) 0 @@
        Array.init n @@ fun i -> as_.(i) *^ ps.(i)


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

int main()
{
    int h,w;
    while(cin>>h>>w)
    {
        if(w==0)return 0;
        REP(i,h)
        {
            REP(j,w)cout<<"#";
            cout<<endl;
        }
        cout<<endl;
    }
}



Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vec;
//配列の添字ズレに注意
//=に注意
int main(){
  long mod=1000000007,ans=0,n; cin>>n;
  vector<long> a(n);
  rep(i,n) cin>>a[i];// a の入力

// 累積和
  vector<long> s(n+1,0);// s[0]=0になる
  rep(i,n) s[i+1]=(s[i]+a[i])%mod;

  
  
  for(int i=1;i<n+1;i++){
    ans=(ans+a[i-1]*s[i-1])%mod;
  
  }
  
  
  
  
  
  cout<< ans<<endl;
}


Measured memory_bytes: 6336
N, M, C = [int(_) for _ in input().split()]
B = [int(_) for _ in input().split()]
A = [[int(_) for _ in input().split()] for i in range(N)]

result = 0

for row in A:
    t = C + sum([x * y for x, y in zip(row, B)])
    if t > 0:
        result += 1

print(result)



Measured memory_bytes: 3060
#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;
int a,b,x[5],f;
int main(){
	cin>>a>>b;
	x[a]++;x[b]++;
	cin>>a>>b;
	x[a]++;x[b]++;
	cin>>a>>b;
	x[a]++;x[b]++;
	for (int i=1;i<=4;i++) if (x[i]>2) f=1;
	if (f==1)
		cout<<"NO"<<endl;
	else
		cout<<"YES"<<endl;
	return 0;
}

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

#define ll long long
#define ld long double

using namespace std;

const long long LINF = LLONG_MAX;
const int INF = INT_MAX;
const int MOD = 1000000007;

const ld PI = 3.14159265358979323;

const int N = 2e2 + 111;

ll x, k, d;

int main() {
    #ifdef Vova
        freopen("input", "r", stdin);
    #else
        ios::sync_with_stdio(false);
        cin.tie(0);
    #endif
    cin >> x >> k >> d;
    x = abs(x);
    if ((x + d - 1) / d > k){
        cout << x - d * k;
    }
    else {
        k -= x / d;
        cout << (k & 1 ? d - (x%d) : x % d);
    }
}

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

typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define ii pair <int,int>
#define ever (;;)

const int N = 200100;

ll n,mod=1e9+7,ans,sub[N];
vector <int> adj[N];

void dfs1(int u,int v)
{
    sub[u] = 1;
    for(auto x:adj[u])
    {
        if( x == v )
            continue;

        dfs1(x,u);
        sub[u] += sub[x];
    }
}

ll po(ll x,ll os)
{
    if( os == 0 )
        return 1;

    ll z = po(x,os/2);

    if( os&1 )
        return z*z%mod*x%mod;

    return z*z%mod;
}

ll modInv(ll x) { return po(x,mod-2); }

void dfs2(int u,int v)
{
    ans = ( ans + po(2,n-1) )%mod;

    for(auto x:adj[u])
    {
        if( x == v )
        {
            ll sz = sub[1] - sub[u];

            ans = ( ( ans - po(2,sz) ) %mod + mod )%mod;
        }
        else
        {
            ll sz = sub[x];

            ans = ( ( ans - po(2,sz) ) %mod + mod )%mod;
            dfs2(x,u);
        }
    }

    ll sz = (int)(adj[u].size());

    ans = ( ( ans + sz - 1 )%mod +mod )%mod;
}

int main()
{
    scanf("%lld",&n);
    for(int i=0;i<n-1;i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    dfs1(1,0);
    dfs2(1,0);

    printf("%lld\n",ans*modInv(po(2,n))%mod);
}


Measured memory_bytes: 23936
#include<iostream>
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

int main(){
    cs
    int a,b,c,d,t=0;
    cin>>a>>b>>c>>d;
    while(1){
        t++;
        c-=b;
        if(c<=0) break;
        t++;
        a-=d;
        if(a<=0) break;        
    }
    t&1 ? cout<<"Yes" : cout<<"No";
}

Measured memory_bytes: 3644
/* */

#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <map>
#include <set>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;

#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
#else
	#define errp(...)
#endif
#define dbg(x) errp(" %s = %s\n", #x, to_string(x).data())
#define dbg_al(s, x) for(auto e:x)s+=to_string(e)+" "
#define dbg_rt(x) string s="[ ";dbg_al(s,x);s+="]";return s;
#define dbg_fd1 template<typename T>string to_string
#define dbg_fd2 template<typename U, typename V>string to_string
#define dbg_d1(c) dbg_fd1(c<T>);
#define dbg_d2(c) dbg_fd2(c<U, V>);
#define dbg_f1(c) dbg_fd1(c<T> v){dbg_rt(v);}
#define dbg_f2(c) dbg_fd2(c<U, V> v){dbg_rt(v);}
string to_string (char s) { return "\'"+string(1, s)+"\'"; }
string to_string (string s) { return "\"" + s + "\""; }
dbg_d1(vector) dbg_d1(set) dbg_d2(map)
dbg_fd2(pair<U, V> p) { return "("+to_string(p.first)+", "+to_string(p.second)+")"; }
dbg_f1(vector) dbg_f1(set) dbg_f2(map)
/* ==================== */ 
ll n, x, d, z;
map<ll, vector<pll>> mp;

ll floor (ll a, ll b) {
	return (ll)floor((double)a / b);
}

ll mod (ll a, ll p) {
	return a - (ll)floor(a, p) * p;
}

int main() {
	scanf("%lld%lld%lld", &n, &x, &d);
	if (d < 0) {
		x = -x;
		d = -d;
	}

	if (d == 0 && x == 0) {
		printf("%lld\n", 1LL);
		return 0;
	}
	if (d == 0) {
		printf("%lld\n", n + 1);
		return 0;
	}
	dbg(x); dbg(d);
	z = n * (n - 1) / 2;
	for (ll i = 0; i <= n; i++) {
		ll k = floor(i * x, d); 
		ll p = mod(i * x, d); 
		ll l = i * (i - 1) / 2;
		ll r = z - (n - i) * (n - i - 1) / 2;
		dbg(i); dbg(k); dbg(p); dbg(l + k); dbg(r + k);
		mp[p].push_back({l + k, r + k});
	}
	
	ll ans = 0;
	for (auto pv : mp) {
		vector<pll>& v = pv.second;
		sort(v.begin(), v.end());
		vector<pll> t;
		t.push_back(v[0]);
		for (int i = 1; i < (int)v.size(); i++) {
			if (v[i].first <= t.back().second)
				t.back().second = max(v[i].second, t.back().second);
			else
				t.push_back(v[i]);
		}
		for (int i = 0; i < (int)t.size(); i++)
			ans += (t[i].second - t[i].first + 1);
	}
	printf("%lld\n", ans);
}



Measured memory_bytes: 22144
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int main() {
    long long h;
    scanf("%lld", &h);

    int pow = (int)log2((double)h);
    long long ret = (1l << (pow + 1)) - 1;
    printf("%lld", ret);
    return 0;
}

Measured memory_bytes: 384
#include<cstdint>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<iterator>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>
#include<utility>
#include<initializer_list>


#define repi(i,start,end)for(int64_t (i)=(start);(i)<(end);++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x, v) for(auto& (x) : (v))
#define iterate(itr, v) for(auto (itr)=(v).begin();(itr)!=(v).end();++(itr))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vin(v) rep(i,(v).size()) cin >> (v)[i];
#define vpin(v) rep(i,(v).size()) cin >> (v)[i].first >> (v)[i].second

using namespace std;
using Int = int64_t;
using pint = pair<Int, Int>;
using vint = vector<Int>;
using vvint = vector<vint>;
using vpint = vector<pint>;
using vstr = vector<string>;

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<class T>void put_double(T a){cout<<setprecision(12);cout<<a<<"\n";}
template<class T>void println(T a){cout << a << "\n";}
template<class T>void put_line(T &v){iterate(itr,v){cout<<*itr<<((itr==--v.end())?"\n":" ");}}
// auto [x, y] = make_tuple(3, 4); => let (x, y) = (3, 4);

int main(void) {
    int n; cin >> n;
    vpint robots(n);
    rep(i, n) {
        int x, l; cin >> x >> l;
        pint t = pint(x - l, x + l);
        robots[i] = t;
    }
    sort(all(robots), [](pint x, pint y){if(x.second==y.second)return x<y;
            else return x.second<y.second;});

    int ans = 1;
    int pos = robots[0].second;
    rep(i, n - 1) {
        if(pos <= robots[i + 1].first) {
            ans++;
            pos = robots[i + 1].second;
        }
    }
    println(ans);

    return 0;
}


Measured memory_bytes: 1792
n = int(input())
a = list(map(int,input().split()))
ans = 0
 
l = [0]*100001
 
for i in a:
  l[i] += 1

for i in range(len(l)-2):
  ans = max(ans,l[i]+l[i+1]+l[i+2])
  
print(ans)

Measured memory_bytes: 20800
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};

int solve(vector<pii> a){
    vector<pii> v;
    for(pii p:a){
        v.pb(p.f,+1);
        v.pb(p.s+1,-1);
    }
    sort(v.begin(), v.end());
    int bal=0,pv=-1e18,res=0;
    for(pii p:v){
        if(bal)res+=p.f-pv;
        bal+=p.s;
        pv=p.f;
    }
    return res;
}

int32_t main(){
    int n,a,d;
    cin>>n>>a>>d;
    if(d==0){
        if(a==0)cout<<"1\n";
        else cout<<2*((n+1)/2)+(n%2==0)<<'\n';
    }else{
        if(d<0){
            int la=a+(n-1)*d;
            a=la;
            d=-d;
        }
        map<int,vector<pii>> m;
        int dd=d+d;
        for(int c=0;c<=n;++c){
            int x=c-(n-c);
            int f=x*a;
            int lmn=c*(c-1)/2;
            int rmn=n*(n-1)/2-lmn;
            int lmx=n*(n-1)/2-(n-c)*(n-c-1)/2;
            int rmx=n*(n-1)/2-lmx;
            int mn=(lmn-rmn)*d+f;
            int mx=(lmx-rmx)*d+f;
            if(mn>mx)assert(0);
            int rem=mn%dd;
            if(rem<0)rem+=dd;
            m[rem].pb((mn-rem)/dd,(mx-rem)/dd);
        }
        int ans=0;
        for(auto&p:m)ans+=solve(p.s);
        cout<<ans<<'\n';
    }
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    vector<double> e(n+1, 0);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
        e[i+1] = (double)(p[i] + 1) / 2.0;
    }
    for (int i = 0; i < n; ++i) {
        e[i+1] += e[i];
    }

    double res = 0;
    for (int i = k; i <= n; ++i) {
        chmax(res, e[i] - e[i-k]);
    }
    cout << fixed << setprecision(12) << res << endl;
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
#define endl '\n'
#include <math.h>
# define M_PIl 3.141592653589793238462643383279502884L
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long int R = 0;
    cin>>R;
    cout<<M_PIl*2LL*R<<endl;
    return 0;
}



Measured memory_bytes: 3824
#include<bits/stdc++.h>
#define rep(i,start,lim) for(lld i=start;i<lim;i++)
#define repd(i,start,lim) for(lld i=start;i>=lim;i--)
#define scan(x) scanf("%lld",&x)
#define print(x) printf("%lld ",x)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define br printf("\n")
#define sz(a) lld((a).size())
#define YES printf("YES\n")
#define NO printf("NO\n")
#define all(c) (c).begin(),(c).end()
#define INF         1011111111
#define LLINF       1000111000111000111LL
#define EPS         (double)1e-10
#define MOD         1000000007
#define PI          3.14159265358979323
using namespace std;
typedef long double ldb;
typedef long long lld;
lld powm(lld base,lld exp,lld mod=MOD) {lld ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
lld ctl(char x,char an='a') {return (lld)(x-an);}
char ltc(lld x,char an='a') {return (char)(x+an);}
#define bit(x,j) ((x>>j)&1)
typedef vector<lld> vlld;
typedef pair<lld,lld> plld;
typedef map<lld,lld> mlld;
typedef set<lld> slld;
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mxm(a,b) a = max(a,b)
#define mnm(a,b) a = min(a,b)
#define endl '\n'
#define fre freopen("1.in","r",stdin); freopen("1.out","w",stdout);
#define N 1000005
int main()
{
    //sync;
    lld a,b,c,x,y;
    lld ans = LLINF;
    cin>>a>>b>>c>>x>>y;
    rep(i,0,N) {
        lld tmp1 = i;
        lld tmp2 = x-(i/2);
        lld tmp3 = y-(i/2);
        ans = min(ans, max(0LL,tmp1 * c) + max(0LL,tmp2 * a) + max(0LL,tmp3 * b));
    }
    cout<<ans;
    return 0;
}

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

long long N;
vector<long long> A;

void solve(){
    vector<long long> plus, minus;

    for(long long i = 0; i < N; i++){
        if(A[i] >= 0) plus.push_back(A[i]);
        else minus.push_back(A[i]);
    }

    sort(plus.begin(), plus.end(), greater<long long>());
    sort(minus.begin(), minus.end());

    if(minus.empty()) minus.push_back(plus.back()), plus.pop_back();
    if(plus.empty()) plus.push_back(minus.back()), minus.pop_back();

    vector<pair<long long, long long> > res;
    long long cur = minus[0];
    for(long long i = 0; i < plus.size()-1; i++){
        res.push_back(make_pair(cur, plus[i]));
        cur -= plus[i];
    }
    res.push_back(make_pair(plus.back(), cur));
    cur = plus.back() - cur;

    for(long long i = 1; i < minus.size(); i++){
        res.push_back(make_pair(cur, minus[i]));
        cur -= minus[i];
    }

    cout << cur << endl;

    for(long long i = 0; i < res.size(); i++){
        cout << res[i].first << " " << res[i].second << endl;
    }
}
int main(){
    cin >> N;
    A.resize(N);

    for(long long i = 0; i < N; i++) cin >> A[i];

    solve();
    return 0;
}

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

int compare_int(const void *b,const void *a){
  return *(long*)a-*(long*)b;
}

int max(int a,int b){
  if(a > b){
    return a;
  }
  return b;
}

int main(void){
  int N,H;
  scanf("%d%d",&N,&H);

  int a,b[N];
  int maximam = 0;
  for(int i = 0;i < N;i++){
    scanf("%d%d",&a,&b[i]);
    maximam = max(maximam,a);
  }
  qsort(b,N,sizeof(int),compare_int);

  int cnt;
  for(cnt = 0;H > 0 && cnt < N;cnt++){
    if(b[cnt] < maximam) break;
    H -= b[cnt];
  }
  if(H > 0) cnt += (H+maximam-1)/maximam;

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

  return 0;
}

Measured memory_bytes: 892
fn main() {
    let v = read_vec::<u32>();
    let a = v[0];
    let b = v[1];
    let x = {
        let c = a + b;
        if c % 2 == 0 {
            c / 2
        } else {
            c / 2 + 1
        }
    };
    println!("{}", x);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
int main(){
  int A, B, m;
  scanf("%d%d%d", &A, &B, &m);
  int a[A];
  int b[B];
  int min_a = 100000;
  int min_b = 100000;
  for(int i=0;i<A;i++){
    scanf("%d", &a[i]);
    if (a[i] < min_a) {
      min_a = a[i];
    }
  }
  for(int i=0;i<B;i++){
    scanf("%d", &b[i]);
    if (b[i] < min_b) {
      min_b = b[i];
    }
  }
  int ans = min_a + min_b;
  int x[m];
  int y[m];
  int c[m];
  for (int i=0; i<m; i++){
    scanf("%d%d%d", &x[i], &y[i], &c[i]);
    if (a[x[i] - 1] + b[y[i] - 1] - c[i] < ans) {
      ans = a[x[i] - 1] + b[y[i] - 1] - c[i];
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 2176
// HTTF.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b-1,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define int LL
#define pb emplace_back
#define eb pb

using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 1e6+1000;
const int SIZE2 = 2010;
const int SIZE3 = 400;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 998244353;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
typedef pair<ld, ut> pld;

#define endl "\n" //インタラクティブでは消す
ut N, M, K, L, Q, D, H, W;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE], maps2[SIZE2][SIZE2], answer = zero;
LL maps[SIZE2][SIZE2];
LL A[SIZE], B[SIZE];
LL solve() {
	cin >> N;
	if (N == 0) {
		cout << 0 << endl;
		return 0;
	}
	VI v;
	REP(i, 40) {
		if ((N+ (1LL << (i + 1))) % (1LL << (i + 1))) {
			N -= (1LL << i)*pow(-1, i % 2);
			v.pb(1);
		}
		else {
			v.pb(0);
		}
	}
	bool ans = false;
	RREP(i, v.size()) {
		if (v[i]) {
			ans = true;
		}
		if (ans) {
			cout << v[i];
		}
	}
	cout << endl;
	
	return	0;
}





//!!!!!!!!!!!!!!!!!!!実装を詰める!!!!!!!!!!!!!!!!!!!!!!!!!
signed main() {

	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(0);
	solve();
	cin >> N;
	return 0;

}

Measured memory_bytes: 24320
import sys
input = sys.stdin.readline
ri = lambda: int(input())
#rl = lambda: [int(x) if x.isdecimal() else x for x in input().split()]
#rl = lambda: list(input().split()))
rl = lambda: map(int,input().split())
rr = lambda N: [list(l) for l in zip(*[rl() for _ in range(N)])]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9+7

A,B,C,D=rl()

def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)

CD = lcm(C,D)

ans = B - (A-1) - (B//C - (A-1)//C) - (B//D - (A-1)//D) + (B//CD - (A-1)//CD)

print(ans)


Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(int a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
int main(){int N=IN(),X=IN(),T=IN();return OUT((N%X)?(N/X+1)*T:N/X*T),0;}

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

#define int long long

using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};




int n;
 
signed main(){
	cin>>n;
	int x=1,y=1;
	rep(i,0,n){
	    int a,b;
	    cin>>a>>b;
	    int z=max((a+x-1)/a,(b+y-1)/b);
	    x=a*z;
	    y=b*z;
	}
	cout<<x+y<<endl;
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
#[test]
fn test_solve() {
    assert_eq!(solve("redcoder\n"), "1\n");
    assert_eq!(solve("vvvvvv\n"), "0\n");
    assert_eq!(solve("abcdabc\n"), "2\n");
}

fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let s: Vec<_> = sc.get().chars().collect();
    let mut a = 0;

    for i in 0..s.len()/2 {
        if s[i] != s[s.len()-1-i] {
            a += 1;
        }
    }

    format!("{}\n", a)
}

fn main() {
    let mut buf = String::new();
    use std::io;
    use std::io::{Read, Write};
    io::stdin().read_to_string(&mut buf).unwrap();
    io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}

struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}

Measured memory_bytes: 4352
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
# Written by NoKnowledgeGG @YlePhan
 
#import math
#mod = 10**9+7
 
 
 
def main():
  n,a,b = map(int,input().split())
  
  ans = 0
  for t in range(1,n+1):
    tmp = 0
    v = t
    while True:
      tmp += t % 10
      if t // 10 != 0:
        t //= 10
      else:
        break
    if a <= tmp <= b:
      ans += v
  print(ans)
if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define PUT(x) cout << x << endl
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };

ll a[2][101] = {};

int main(void)
{

	int n;
	cin >> n;

	for (int k = 0; k < 2; k++)
		for (int i = 0; i < n; i++) {
			cin >> a[k][i];
		}

	for (int i = 0; i < n; i++) {
		a[0][i + 1] += a[0][i];;
	}

	for (int i = n; i > 0; i--) {
		a[1][i - 1] += a[1][i];;
	}

	ll answer = 0;

	for (int i = 0; i < n; i++) {
		CHMAX(answer, a[0][i] + a[1][i]);
	}

	cout << answer << endl;

	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())

wiring = []
for i in range(m):
    k, *s = map(int, input().split())
    
    for j in range(k):
        s[j] -= 1
    
    wiring.append(s)

p_i = [int(x) for x in input().split()]

ans = 0
for i in range(2**n):
    swiches = [-1] * n
    lamps = [0] * m
    for j in range(n):
        swiches[j] = (i >> j) & 1
        
    for j in range(m):
        cnt = 0
        for w in wiring[j]:
            if swiches[w] == 1:
                cnt += 1
        
        if cnt % 2 == p_i[j]:
            lamps[j] = 1
    
    if sum(lamps) == m:
        ans += 1
    
print(ans)

Measured memory_bytes: 8952
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i,s,n) for(int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(){
    int n, m;
    cin >> n >> m;
    int ans_r = 1, ans_l = n+1;
    rep(i, m) {
        int r,l;
        cin >> r >> l;
        if(r > ans_l || l < ans_r) {
            cout << 0 << endl;
            return 0;
        }
        if(ans_r < r && r <= ans_l)
            ans_r = r;
        
        if(ans_r <= l && l < ans_l)
            ans_l = l;
    }

    cout << ans_l - ans_r + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
total = 0
for i in range(0,n):
    if a[i]>=b[i]:
        total+=b[i]
    else:
        k=a[i+1]
        k=a[i]+k-b[i]
        if k>=1:
            total+=b[i]
            a[i+1]=k
        else:
            total+=a[i]+a[i+1]
            a[i+1]=0
print(total)


Measured memory_bytes: 18476
#include <bits/stdc++.h>
#include <unistd.h>
#define inf 1000000007LL
#define INF 1000000000000000007LL
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define st first
#define nd second
#define ll long long
#define ld long double
#define pii pair<int,int>
#define vi vector<int>
#define vll vector<long long>
#define vpii vector<pair<int,int>>
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define LOG(x) (63-__builtin_clzll(x))
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i, n) for(int i=1; i<=(n); ++i)
#define endr cerr<<'\n'
#define endl '\n'
#ifdef DEBUG
#define pv(...) cerr<<'\n',dbg(#__VA_ARGS__, __VA_ARGS__)
#define ps(x) {cerr<<'\n'<<#x<<":\n:";for(auto _q:(x)){cerr<<_q<<" ";}cerr<<'\n';}
#define pa(x, xs) {cerr<<'\n'<<#x<<":\n:";for(int _q=0; _q<=(xs); ++_q){cerr<<x[_q]<<" ";}cerr<<'\n';}
#define pal(x, xs) {cerr<<'\n'<<#x<<":\n";for(int _q=0; _q<=(xs); ++_q){cerr<<_q<<": "<<setw(_q? 3-(int32_t)log10(_q):3)<<x[_q]<<'\n';}cerr<<'\n';}
#define ppii(x, xs) {cerr<<'\n'<<#x<<":\n";for(int _q=0; _q<=(xs); ++_q){cerr<<_q<<": "<<setw(_q? 6-(int32_t)log10(_q):6)<<x[_q].first<<" "<<setw(5)<<x[_q].second<<'\n';}cerr<<'\n';}
#define pm(x, xn, xm) {cerr<<'\n'<<#x<<":\n";for(int _qa=0; _qa<=(xn); ++_qa){for(int _qb=0; _qb<=(xm); ++_qb){cerr<<setw(6)<<x[_qa][_qb]<<" ";}cerr<<'\n';}cerr<<'\n';}
#else
#define cerr if(0)cout
#define pv(...) if(0)endr
#define ps(x) if(0)endr
#define pa(x, xs) if(0)endr
#define pal(x, xs) if(0)endr
#define ppii(x, xs) if(0)endr
#define pm(x, xn, xm) if(0)endr
#endif
using namespace std;
template<class T> void dbg(const char* xn, T x){cerr<<xn<<": "<<x<<"\n";} template<class T, class... TA> void dbg(const char* xn, T x, TA... t){while(*xn!=',')cerr<<*xn++;cerr<<": "<<x<<",";dbg(xn+1, t...);}
template<class T> inline bool upd_max(T &x, T y){return y>x?x=y,true:false;} template<class T> inline bool upd_min(T &x, T y){return y<x?x=y,true:false;}
const int N = 1000007;
#define int long long

int n, m;


void solve()
{
  cin>>n>>m;

  if (n == 1 && m == 1)
  {
    cout<<1;
  }
  else if (n == 1)
  {
    cout<<m-2;
  }
  else if (m == 1)
  {
    cout<<n-2;
  }
  else
  {
    int l1 = 2, r1 = n-1;
    int l2 = 2, r2 = m-1;
    cout<<(r1-l1+1)*(r2-l2+1);
  }
}

int32_t main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
cout<<fixed<<setprecision(10);

  solve();

return 0;
}


Measured memory_bytes: 256
/**< Winter is Coming - Game Of Thrones */
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = 1e9 + 7;
const ll mode = 1e6 + 3;

ll min(ll a, ll b)
{
    if(a > b) return b;
    else return a;
}
ll min_third(ll a, ll b ,ll c)
{
    return min(min(a,b),c);
}
ll GCD(ll A, ll B) {
    if(B == 0)
        return A;
    else
        return GCD(B, A % B);
}

ll power(ll x, ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}
int fun(int x, int y)
{
    return x*y;
}
//4
//10 30 40 20

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

    ll N = 0;cin >> N;
    string str;
    string str1;
    cin >> str >> str1;
    string s;

    ll i = 0;
    while(i != N)
    {
        s += str[i];
        s += str1[i];
        i++;
    }
    cout << s << endl;
    return 0;
}


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

int solve(int curr, int op, int k)
{
  	if(!op)
    return curr;
	return min(solve(curr*2,op-1,k),solve(curr+k,op-1,k));
}

int main()
{
  	int op,k;
  	cin>>op>>k;
  	cout<<solve(1,op,k)<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	var n int
	fmt.Scan(&n)

	texts := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&texts[i])
	}

	var num int
	ans := make([]string, 0)
	maps := make(map[string]int, n)
	// mapで同じものをカウント
	for i := 0; i < n; i++ {
		maps[texts[i]]++
		num = max(num, maps[texts[i]])
	}

	// value(数値)とmaxのカウント数が同じなのであれば、ansに追加
	for key, value := range maps {
		if value == num {
			ans = append(ans, key)
		}
	}
	sort.Strings(ans)

	for _, text := range ans {
		fmt.Println(text)
	}
}


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

int main() {
  double pi = acos(-1);
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double th = double(60 * h + m) / 720 * pi *2;
  double tm = double(m) / 60 * pi * 2;
  double hx = a * cos(th), hy = a * sin(th);
  double mx = b * cos(tm), my = b * sin(tm);
  double dx = abs(hx - mx);
  double dy = abs(hy - my);
  double res = sqrt(dx * dx + dy * dy);
  printf("%.10f\n",res);
}


Measured memory_bytes: 4064
#include<iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <string.h>
using namespace std;
struct node
{
    int x;
    string c;
    int p;
}a[105];
int cmp(node a,node b)
{
    if(a.c==b.c)
    return a.p>b.p;
        else return a.c<b.c;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i].c>>a[i].p;
        a[i].x=i+1;
    }
    sort(a,a+n,cmp);
    for(int i=0;i<n;i++)
        printf("%d\n",a[i].x);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

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

    vector<int> v(N);
    for (int i = 0; i < N; i++) cin >> v[i];

    sort(v.begin(), v.end());

    double sum = v[0];
    for (int i = 1; i < N; i++) {
        sum = (sum + v[i]) / 2;
    }

    cout << fixed << setprecision(6) << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	 ll n;cin>>n;ll b[n-1],a[n];
  	for(ll i=0;i<n-1;i++)cin>>b[i];a[0] = b[0];
  	for(ll i=1;i<n-1;i++)a[i] = min(b[i-1],b[i]);
  	a[n-1] = b[n-2];
  ll sum = 0;
  for(ll i=0;i<n;i++)sum+=a[i];
  cout<<sum<<endl;
  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define print(x) cout << (x) << endl;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    string Snew = "";
    char Li, Lip;
    long long answer = 0;
    bool bbb = false; 
    for (int i = 1; i < S.size(); i++) {
        Lip = S.at(i - 1);
        Li = S.at(i);
        if (Lip == 'A') {
            Snew.append("A");
        }
        else if (Lip == 'B') {
            if (Li == 'C') {
                Snew.append("D");
                i++;
            }
            else {
                Snew.append("B");
            }
        }
        else if (Lip == 'C') {
            Snew.append("C");
        }
    }
    for (int i = 0; i < Snew.size(); i++) {
        if (Snew.at(i) == 'A') {
            int count = 0;
            for (int j = 1; j < Snew.size() - i; j++) {
                if (Snew.at(i + j) == 'D') {
                    answer += (j - count); 
                    count++;
                }
                else if ((Snew.at(i + j) == 'B') || (Snew.at(i + j) == 'C')) {
                    i += (j - 1);
                    break;
                }
                if (i + j + 1 == Snew.size()) {
                    bbb = true;
                }
            }
        }
        if (bbb == true) {
            break;
        }
    }
    print(answer);
}

Measured memory_bytes: 916
#include<iostream>
 #include<algorithm>
 #include<cmath>
 #include<iomanip>
 #include<string.h>
 #include<cmath>
 #include<map>
 #include<vector>
using namespace std;
typedef long long ll;
char s[4005];
int main()
{

ll a,b,n;
ll mid;
cin>>a>>b>>n;
if(n<b) mid=n;
else mid=b-1;
cout<<a*mid/b;

}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
#define MAX  1e18
#define ss 1e15
#define pb push_back

int main() {
    int n,m;
    cin>>n>>m;
    char arr[n][m];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>arr[i][j];
        }
    }
    int a[n][m],b[n][m],c[n][m],d[n][m];
    // Up
    for(int i=0;i<m;i++){
        if(arr[0][i] == '#')a[0][i] = 0;
        else a[0][i] = 1; 
    }
    for(int i=1;i<n;i++){
        for(int j=0;j<m;j++){
            if(arr[i][j] == '#')a[i][j] = 0;
            else a[i][j] = a[i-1][j] + 1;
        }
    }
    //Down

    for(int i=0;i<m;i++){
        if(arr[n-1][i] == '#')b[n-1][i] = 0;
        else b[n-1][i] = 1; 
    }

    for(int i=n-2;i>=0;i--){
        for(int j=0;j<m;j++){
            if(arr[i][j] == '#')b[i][j] = 0;
            else b[i][j] = b[i+1][j] + 1;
        }
    }

    //left

    for(int i=0;i<n;i++){
        if(arr[i][0] == '#')c[i][0] = 0;
        else c[i][0] = 1; 
    }
    for(int i=0;i<n;i++){
        for(int j=1;j<m;j++){
            if(arr[i][j] == '#')c[i][j] = 0;
            else c[i][j] = c[i][j-1] + 1;
        }
    }

    //Right
        for(int i=0;i<n;i++){
                if(arr[i][m-1] == '#')d[i][m-1] = 0;
                else d[i][m-1] = 1; 
            }
            for(int i=0;i<n;i++){
                for(int j=m-2;j>=0;j--){
                    if(arr[i][j] == '#')d[i][j] = 0;
                    else d[i][j] = d[i][j+1] + 1;
                }
            }
    int ans = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(arr[i][j] == '.'){
                int val = a[i][j] + b[i][j] + c[i][j] + d[i][j] - 3;
                if(val > ans){
                    ans = val;
                }
            }
        }
    }
    cout<<ans<<"\n";
   return 0;
}


Measured memory_bytes: 66688
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  while (true) {
    int n, p; cin >> n >> p;
    if (!n) break;
    V<> a(n);
    int c = p;
    for (int i = 0; ; i = (i + 1) % n) {
      if (p) --p, ++a[i];
      else p += exchange(a[i], 0);
      if (a[i] == c) {
        cout << i << '\n';
        break;
      }
    }
  }
}


Measured memory_bytes: 3048
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

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

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



Measured memory_bytes: 256
sank=0
eik=0
tyok=0
donk=0
while True:
    p=[]
    l=input().split()
    p.append(int(l[0]))
    p.append(int(l[1]))
    p.append(int(l[2]))

    a=max(p)
    p.remove(a)
    b=p[0]
    c=p[1]
    if b+c<=a:
        break
    elif b*b+c*c==a*a:
        tyok+=1
        sank+=1
    elif b*b+c*c>a*a:
        eik+=1
        sank+=1
    else:
        sank+=1
        donk+=1

print(str(sank)+" "+str(tyok)+" "+str(eik)+" "+str(donk))


Measured memory_bytes: 5600
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll comb(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
int c[3];
int main(void) {
	int a, n, x;
	ll ans = 1;
	cin >> n;
	rep(i, 0, n) {
		cin >> a;
		x = 0;
		if (c[0] == a)x++;
		if (c[1] == a)x++;
		if (c[2] == a)x++;
		ans *= x;
		ans %= mod;
		if (c[2] == a)c[2]++;
		else if (c[1] == a)c[1]++;
		else c[0]++;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.List
import Data.Array
strToInt s = (read :: String -> Int) s

main = do
   [a,b] <- (map read . words) <$> getLine
   let c = a * b
   if (even c) == True
   then putStrLn "Even"
   else putStrLn "Odd"

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

using namespace std;
using ll = long long;
using ld = long double;

#define all(collection) (collection).begin(), (collection).end()  // begin to end
#define ceil(a, b) ceil((ld) a / (ld) b);                         // div ceiling
#define each(e, collection) for(auto& e: collection)              // for each
#define rep(i, begin, end) for (ll i = begin; i < end; i++)       // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)      // repeat reverse
#define size(collection) ((ll) (collection).size())               // collection size

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

	vector<ll> stick(n);
	each(e, stick)
		cin >> e;

	ll ans = 0;
	sort(all(stick));
	rep(b, 0, n)
	{
		rep(c, 0, n)
		{
			if (b == c)
				continue;

			auto it_a = lower_bound(all(stick), stick[b] + stick[c]);
			ll end_a = it_a - stick.begin();
			it_a = upper_bound(all(stick), abs(stick[b] - stick[c]));
			ll begin_a = it_a - stick.begin();

			ans += (end_a - begin_a);
			if (begin_a <= b && b < end_a)
				ans--;
			if (begin_a <= c && c < end_a)
				ans--;

		}
	}

	cout << ans / 6;
	return 0;
}


Measured memory_bytes: 256
package main
import (
  "fmt"
)

func find(numMap map[int]int) (int, int, int, int) {
  fKey, fCnt, sKey, sCnt := 0, 0, 0, 0
  for key, cnt := range numMap {
    if fCnt < cnt {
      sKey = fKey
      sCnt = fCnt
      fKey = key
      fCnt = cnt
    } else if sCnt < cnt {
      sKey = key
      sCnt = cnt
    }
  }
  return fKey, fCnt, sKey, sCnt
}

func min(a, b int)int {
  if a < b {
    return a
  }
  return b
}

func main() {
  var n int
  fmt.Scan(&n)
  vs := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&vs[i])
  }
  evenMap := make(map[int]int)
  oddMap := make(map[int]int)
  for i, v := range vs {
    if i%2 == 0 {
      evenMap[v]++
    } else {
      oddMap[v]++
    }
  }
  
  evenFKey, evenFCnt, _, evenSCnt := find(evenMap)
  oddFKey, oddFCnt, _, oddSCnt := find(oddMap)
  
  if evenFKey != oddFKey {
    fmt.Println(n-evenFCnt-oddFCnt)
  } else {
    fmt.Println(min(n-evenSCnt-oddFCnt, n-evenFCnt-oddSCnt))
  }
  
}

Measured memory_bytes: 6656