akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    string S; cin >> S;
    int N = (int)S.length();
    for(int i = 0; i < N; i++){
        res += S[i]!=S[N-1-i];
    }
    res /= 2;
    return res;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    //solve<ll>(0);
    cout << fixed << setprecision(12) << solve<ll>() << endl;
    return 0;
}

Measured memory_bytes: 3572
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

string s, t;
int counter;
int main(void){
    cin >> s;
    cin >> t;
    for (int i=0;i<s.length();i++){
        if(s[i] != t[i]) counter++;
    }
    cout << counter << endl;
    return 0;
}



Measured memory_bytes: 3792
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;

void solve() {
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        int a, b, h;
        cin >> a >> b >> h;
        cout << (a + b) * h / 2 << endl;

        solve();

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 384
def gcd_on_blackboard n, a
  a.unshift 0

  l = []
  l[1] = a[1]
  2.upto(n) do |i|
    l[i] = gcd(l[i-1], a[i])
  end

  r = []
  r[n] = a[n]
  (n-1).downto(1) do |i|
  r[i] = gcd(r[i+1], a[i])
  end

  m = []
  m[1] = r[2]
  m[n] = l[n-1]
  2.upto(n-1) do |i|
    m[i] = gcd(l[i-1], r[i+1])
  end
  m[1..n].max
end

def gcd a, b
  a, b = b, a if a < b
  r = a % b
  if r == 0
    b
  else
    gcd b, r
  end
end

n = gets.to_i
a = gets.split(' ').map{|x| x.to_i}
puts gcd_on_blackboard n, a


Measured memory_bytes: 11476
#pragma warning(disable:4996)
#include "bits/stdc++.h"
using namespace std;

//macro
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,a,b) for(int i=(int)(b) - 1;i>=(int)(a);i--)
#define rrep(i,n) RREP(i,0,n)
#define each(i, ctn) for (auto &&i : (ctn))
#define all(a) (a).begin(),(a).end()
#define mp make_pair
#define INFL 1145148100000000000LL
#define EPS (1e-8)
#define MOD 1000000007
#define PI 3.141592653589793
#define equals(a,b)(fabs((a)-(b))<EPS)

//alias
using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vs = vector<string>;
using P = pair<ll, ll>;
template<class T> using heap = priority_queue<T>;
template<class T> using minheap = priority_queue<T, vector<T>, greater<T>>;

//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H);	rep(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n)os << v[i] << (i == n - 1 ? "\n" : " "); return os; }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template<class T> inline void print(const T &x) { cout << x << '\n'; }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;

int main() {
	ull N;
	cin >> N;
	ull fx = 0;

	ull Nin = N;
	rep(i, 9) {
		fx += N % 10;
		N /= 10;
	}

	if (Nin%fx == 0) {
		print("Yes");
	}
	else {
		print("No");
	}
	return 0;
}


Measured memory_bytes: 256
/*

    author : s@if

*/

#include<bits/stdc++.h>
using namespace std;

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			99999999
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)


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

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hr[]={-2,-2,-1,+1,+2,+2,-1,+1};
int hc[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)1e5+9;

int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    int i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

  	cin>>n;

  int ara[n+9] , sum[n+9];
  	For(i,1,n)
    {
      cin>>ara[i];
    }

  sum[0] = 0;

  for(i=1; i<=n; i++)
  {
    sum[i] = sum[i-1]+ara[i];
  }

  int ans = INT_MAX;

  for(i=1; i<n; i++)
  {
    ans = min(ans , abs(sum[i]-(sum[n]-sum[i])));
  }

  cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
template<signed MOD = 1000000007>
struct Mint{
  signed v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(int k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }
  
  Mint inv(){return pow(MOD-2);}
  
  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}
  
  Mint operator+(Mint a){return Mint(v)+=a;};
  Mint operator-(Mint a){return Mint(v)-=a;};
  Mint operator*(Mint a){return Mint(v)*=a;};
  Mint operator/(Mint a){return Mint(v)/=a;};

  Mint operator-(){return v?MOD-v:v;}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  
  vector<Mint> fact(int n){
    vector<Mint> res(n+1,1);
    for(int i=1;i<=n;i++) res[i]=res[i-1]*Mint(i);
    return res;
  }
  
  vector<Mint> finv(int n){
    vector<Mint> res(n+1,1);
    for(int i=1;i<=n;i++) res[i]=res[i-1]*Mint(i);
    res[n]=Mint(1)/res[n];
    for(int i=n;i>=1;i--) res[i-1]=res[i]*Mint(i);
    return res;
  }

  vector<Mint> invs(vector<Mint> &a,vector<Mint> &b){
    int n=a.size()-1;
    vector<Mint> res(n+1,0);
    for(int i=1;i<=n;i++) res[i]=b[i]*a[i-1];
    return res;
  }
};
//END CUT HERE

template<typename T> 
map<T, int> factorize(T x){
  map<T, int> res;
  for(int i=2;i*i<=x;i++){
    while(x%i==0){
      x/=i;
      res[i]++;
    }
  }
  if(x!=1) res[x]++;
  return res;
}

//INSERT ABOVE HERE
signed main(){
  int n;
  Mint<> m;
  scanf("%d %d",&n,&m.v);
  
  auto fact=m.fact(n+100);
  auto finv=m.finv(n+100);
  
  auto C=[&](int n,int k){
	   if(n<k||k<0) return Mint<>(0);
	   return fact[n]*finv[n-k]*finv[k];
	 };
  auto H=[&](int n,int k){return C(n+k-1,n);};

  Mint<> ans(1);
  auto x=factorize(m.v);
  for(auto p:x) ans*=H(p.second,n);

  printf("%d\n",ans.v);
  return 0;
}


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

int main(void)
{
  int N, K;
  cin >> N >> K;

  int result = K * pow(K - 1, N - 1);

  cout << result << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a;
    cin>>n;
    int count=0,count2=0;
    for (int i=0;i<n;i++) {
        cin>>a;
        if (a%4==0) {
            count++;
        } else if (a%2==0) {
            if (count2==0) {
                count2++;
            } else {
                count++;
                count2--;
            }
        }
    }
    if (count>=n/2) {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }
}


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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
const ll mod = 1000000007;

vector<ll> E[100005];
ll ans[100005];
ll n,k;

void dfs(ll v, ll g, ll cnt) {
    if (g == 0) ans[g] = k;
    else if (v == 0) ans[g] = max(0ll, k-cnt-1);
    else ans[g] = max(0ll, k-cnt-2);
    int t = 0;
    for (ll x : E[g]) {
        if (x != v) {
            dfs(g, x, t);
            t++;
        }
    }
}

int main() {
    cin >> n >> k;
    ll u,v;
    rep(i,n-1) {
        cin >> u >> v;
        E[u-1].push_back(v-1);
        E[v-1].push_back(u-1);
    }
    dfs(-1,0,0);
    ll anss = 1;
    //rep(i,n) cout << ans[i] << endl;
    rep(i,n) {
        anss = anss * ans[i] % mod;
    }
    cout << anss << endl;
    return 0;
}


Measured memory_bytes: 13260
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const int N=510; 
int n,a;
ll S1[N][N],S2[N][N],f[N][N],ans;
void Mn(ll&x,ll y) {if(x>y)x=y;}
int main()
{
	cin>>n;
	fo(i,1,n) fo(j,1,n) if(i^j)
	{
		cin>>a;
		i<j?S1[i][j]=a:S2[j][i]=a;
	}
	fo(i,1,n)
	{
		fd(j,i-1,1) S1[j][i]+=S1[j+1][i];
		fo(j,1,i-1) S2[j][i]+=S2[j-1][i];
	}
	fo(i,1,n) fo(j,i+1,n) S1[i][j]+=S1[i][j-1], S2[i][j]+=S2[i][j-1];
	memset(f,127,sizeof f);
	fo(i,1,n) f[1][i]=S1[1][i];
	fo(i,1,n-1) fo(j,i,n-1) if(f[i][j]<f[0][0])
		fo(k,j+1,n) Mn(f[j+1][k],f[i][j]+S1[j+1][k]+S2[i-1][k]-S2[i-1][j]);
	ans=f[0][0];
	fo(i,1,n) Mn(ans,f[i][n]);
	cout<<ans;
}

Measured memory_bytes: 9628
S=input()

# グループに分ける
def make_group(S):
    group=[]
    start=0
    search=0
    for i in range(len(S)):
        if S[i]=="L":
            search=1
        if search==1 and S[i]=="R" :
            group.append(S[start:i])
            start=i
            search=0
    group.append(S[start:])
    #print("group",group)
    return group

# 収束するまでの移動回数
# = 'RL'の外側の文字の多いほう
def count_max_chr(s):
    lr=s.split('RL')
    times=max(len(lr[0]),len(lr[1]))
    #print("times, lr",times,lr)
    return times,lr

# RL の両端のRRR,LLLLなどを最終的な配置に振り分ける
# 2**100=even RRRなどの奇数個目は左に、偶数個目は右
def addlr(s,num):
    for i in range(2):
        num[i%2]+=len(s[i%2])//2
        num[(i+1)%2]+=(len(s[i%2])+1)//2
    #print("num",num)
    return num

newgroup=[]
group=make_group(S)
for s in group:
    #print("begin",s)
    subgroup=[0 for _ in range(len(s))]
    times,lr=count_max_chr(s)
    num=[1,1]
    num=addlr(lr,num)
    #print("num(not func)",num)
    subgroup[len(lr[0])]=num[0]
    subgroup[len(lr[0])+1]=num[1]
    #print("subgroup(not func)",subgroup)
    newgroup.append(subgroup)
    #print("newgroup",newgroup)

ans=""
for i in newgroup:
    for j in i:
        ans+=str(j)+" "
print(ans)

Measured memory_bytes: 12668
ans_list = []

while True:
    m,nmin,nmax = map(int,input().split())
    if (m,nmin,nmax) == (0,0,0):
        break
    P = sorted([int(input()) for _ in range(m)], reverse=True)
    d = -float("inf")
    # 最低点合格者を全探索
    for i in range(nmin-1,nmax):
        res = P[i] - P[i+1]
        if res >= d:
            d = res
            ans = i + 1
    ans_list.append(ans)    

for ans in ans_list:
    print(ans)


Measured memory_bytes: 5640
#include<algorithm>
#include<cmath>
#include<deque>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<tuple>
#include<utility>
typedef long long ll;
#define rep(i,n) for(ll i=0; i<n; i++)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
using namespace std;

int main(){
  int a;  cin >> a;
  string s;  cin >> s;
  if(3200 <= a){
    cout << s;
  }else{
    cout << "red";
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
int a[3500];

bool check(int a,int p)
{

    return bool(a&(1<<p));
}
int on(int a,int p)
{

    return (a|(1<<p));
}

void seive()
{

 int mx=sqrt(100000);
 for(int i=3;i<=mx;i+=2)
 {
     if(!check(a[i/32],i%32))
     for(int j=i*i;j<=1e5;j+=i*2)
     {
         a[j/32]=on(a[j/32],j%32);



     }
 }









}





int ans[100010];
struct tr
{

    int a,b, c;
};
int main()
{

int n;
cin>>n;
tr tt[n];
for(int i=1;i<n;i++)
{
    cin>>tt[i].a>> tt[i].b >>tt[i].c;
}
for(int i=1;i<n;i++)
{
    int ans=tt[i].a+tt[i].b;

    for(int j=i+1;j<=n;j++)
    {

        if(j==n)
        {
            cout <<ans<<endl;
        }
        if(tt[j].b>=ans)
            ans=tt[j].a+tt[j].b;
        else
        {

            int x=ans-tt[j].b;
            x=ceil(x/(double)(tt[j].c));
            ans=tt[j].b+(tt[j].c*x)+tt[j].a;
        }

    }
}
cout <<0<<endl;

}


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

using namespace std;

struct DATA{
  string Team;
  int Score;
};

bool compare(const DATA&, const DATA&);

int main(){
  int i, n, win, draw, lose, count=0;
  string s;
  DATA one;
  vector<DATA> data;

  while(1){
    cin >> n;
    if(n == 0) break;
    else if(count != 0) cout << endl;

    for(i=0; i<n; ++i){
      cin >> s >> win >> lose >> draw;
      one.Team = s;
      one.Score = win * 3 + draw;
      data.push_back(one);
    }

    sort(data.begin(), data.end(), compare);

    for(i=0; i<data.size(); ++i)
      cout << data[i].Team << "," << data[i].Score << endl;

    data.clear();
    ++count;
  }

  return 0;
}

bool compare(const DATA& x, const DATA& y){
  return x.Score > y.Score;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1300005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int power(int x, unsigned int y, unsigned int m)
{
    if (y == 0)
        return 1;
    int p = power(x, y/2, m) % m;
    p = (p * p) % m;
    return (y%2 == 0)? p : (x * p) % m;
}
        int dp[100001];
signed main()
{
    ios_base::sync_with_stdio(0);
    int TESTS=1;
    // cin>>TESTS;
    while(TESTS--)
    {   
        string s,t;
        cin>>s>>t;
        int dp[sz(s)+1][sz(t)+1];
        dp[0][0] = 0;
        rep(i,0,sz(s)+1)
        rep(j,0,sz(t)+1)
        dp[i][j] = 0;
        pair<int,int> par[sz(s)+1][sz(t)+1];
        rep(i,0,sz(s)+1)
            rep(j,0,sz(t)+1)
                par[i][j] = {-1,-1};
        rep(i,0,sz(s)){
            rep(j,0,sz(t)){
                if(s[i]==t[j]){
                    dp[i+1][j+1] = dp[i][j]+1;
                    par[i+1][j+1] = {i,j};
                }
                else dp[i+1][j+1] = 0;
                if(dp[i+1][j+1]<dp[i][j+1]){
                    dp[i+1][j+1] = dp[i][j+1];
                    par[i+1][j+1] = {i,j+1};
                }
                if(dp[i+1][j+1]<dp[i+1][j]){
                    dp[i+1][j+1] = dp[i+1][j];
                    par[i+1][j+1] = {i+1,j};
                }
            }
        }
        // rep(i,1,sz(s)+1){
        //     rep(j,1,sz(t)+1) cout<<dp[i][j]<<" ";
        //     cout<<endl;
        // }
        int curx = sz(s),cury = sz(t);
        string ans;
        while(curx!=-1&&cury!=-1){
            int px = par[curx][cury].fr;
            int py = par[curx][cury].sc;
            if(px+1==curx&&py+1==cury && curx!=0){
                ans.pb(s[curx-1]);
            }
            curx = px;
            cury = py;
        }
        reverse(all(ans));
        cout<<ans;
    }       
}     

Measured memory_bytes: 211456
def main():
    n,m=map(int,input().split())
    c=list(map(int,input().split()))
    dp=list(range(n+1))
    k=0
    while k<len(c):
        for i in range(n+1-c[k]):
            dp[i+c[k]]=min(dp[i+c[k]],dp[i]+1)
        k+=1
    print(dp[n])

if __name__=="__main__":
    main()


Measured memory_bytes: 7516
from bisect import *
from collections import defaultdict
def solve():
  T = int(input())
  ans = [0]*T
  for t in range(T):
    N = int(input())
    left = defaultdict(lambda: [])
    right = defaultdict(lambda: [])
    for i in range(N):
      k,l,r = map(int, input().split())
      if k==N:
        ans[t] += l
      else:
        if l>r:
          insort_right(left[k],l-r)
        elif l<r:
          insort_right(right[k+1],r-l)
        ans[t] += min(l,r)
    lis = []
    for i in range(N,0,-1):
      for l in left[i]:
        insort_right(lis,l)
      if len(lis):
        ans[t] += lis.pop(-1)
    lis = []
    for i in range(2,N+1):
      for r in right[i]:
        insort_right(lis,r)
      if len(lis):
        ans[t] += lis.pop(-1)
  return ans
print(*solve(),sep='\n')

Measured memory_bytes: 81968
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;

int a[100010];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n,i,cnt=0,ans=0,tp;
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    tp=a[1];
    for(i=1;i<=n;i++)
    {
        if(a[i]!=tp)
        {
            if(cnt>=tp)
                ans+=cnt-tp;
            else
                ans+=cnt;
            cnt=1;
            tp=a[i];
        }
        else
            cnt++;
    }
    if(cnt>=tp)
        ans+=cnt-tp;
    else
        ans+=cnt;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define loop(i,s,e) for(ll i=s; i<e; i++)
#define endl '\n'
#define vll vector<ll>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define N 100001
#define pb push_back
#define INF LLONG_MAX
#define inf INT_MAX
#define minusinf INT_MIN

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

string s, t;
ll s_size, t_size;	

// ll util(ll i, ll j){
// 	if(i>=s_size or j>=t_size) return 0;

// 	if(dp[i][j].ff != -1) return dp[i][j].ff;

// 	ll b=minusinf, c=minusinf;

// 	if(s[i]==t[j]) {
// 		dp[i][j] = {1+util(i+1, j+1),1};
// 		return dp[i][j].ff;
// 	}
// 	else{
// 		b = util(i+1, j);
// 		c = util(i, j+1);

// 		if(b>=c){
// 			dp[i][j] = {b,2};
// 			return dp[i][j].ff;
// 		}
// 		else
// 		{
// 			dp[i][j] = {c,3};
// 			return dp[i][j].ff;
// 		}
// 	}
// }

void alpha(){

	cin>>s>>t;

	s_size = s.size();
	t_size = t.size();

	s = " "+s;
	t = " "+t;

	ll dp[s_size+1][t_size+1];

	memset(dp, 0, sizeof(dp));

	for(ll i=1; i<=s_size; i++){
		for(ll j=1; j<=t_size; j++){
			if(s[i]==t[j]) dp[i][j] = dp[i-1][j-1] + 1;
			else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
		}
	}

	ll i=s_size, j=t_size;
	char ans[dp[s_size][t_size]];

	ll index=dp[s_size][t_size]-1;

	while(i > 0 and j > 0){
		if(s[i]==t[j]){
			ans[index]=s[i];
			i--;
			j--;
			index--;
		}
		else if(dp[i-1][j] > dp[i][j-1]) i--;
		else j--;
	}

	for(auto i: ans) cout<<i;
	cout<<endl;

}

int main(){

	ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);



    ll t=1;
	//cin>>t;

  	while(t--) alpha();

	return 0;

}

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

#ifdef HOME
#define db(x) cerr << #x << " = " << x << endl
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")" << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
#define dbv(a) cerr << #a << " = "; for (auto xxx: a) cerr << xxx  << " "; cerr << endl
#else
#define db(x) ;
#define db3(x, y, z) ;
#define db2(x, y) ;
#define dbv(a) ;
#endif

using namespace std;
typedef long long ll;
typedef double dbl;


const int INF = 1.01e9;
const int MOD = (int)1e9 + 7;


int main() {
#ifdef HOME
    assert(freopen("in", "r", stdin));
#endif

    int n;
    while (scanf("%d", &n) == 1) {
        static char buf[(int)1.1e6];
        scanf("%s", buf);
        string s = buf;

        vector<int> cnt(26);
        for (char c : s) cnt[c - 'a']++;

        int ans = 1;
        for (int i = 0; i < 26; i++) {
            ans = 1LL * ans * (cnt[i] + 1) % MOD;
        }
        cout << (ans - 1 + MOD) % MOD << endl;
    }

#ifdef HOME
    cerr << "time: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#endif
}


Measured memory_bytes: 1020
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Main main = new Main();
        main.solve();
    }
    public void solve() throws Exception {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String S = scan.next();
        char[] d = S.toCharArray();
        long[] dp = new long[13];
        dp[0] = 1;
        int base = 1;
        for (int i = d.length - 1; 0 <= i; i--) {
            long[] next_dp = new long[13];
            if (d[i] == '?') {
                for (int k = 0; k < 10; k++) {
                    for (int j = 0; j < 13; j++) {
                        next_dp[(k * base + j) % 13] += dp[j];
                        next_dp[(k * base + j) % 13] %= 1000000007;
                    }
                }
            } else {
                int k = d[i] - '0';
                for (int j = 0; j < 13; j++) {
                    next_dp[(k * base + j) % 13] += dp[j];
                    next_dp[(k * base + j) % 13] %= 1000000007;
                }
            }
            dp = next_dp;
            base *= 10;
            base %= 13;
        }
        System.out.println(dp[5]);
    }
}


Measured memory_bytes: 36308
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

const int maxn = 305;
const int mod = 1000000007;

struct TJ
{
	int l, x;
	TJ (int ll = 0, int xx = 0)
	{
		l = ll, x = xx;
	}
};

vector<TJ> ve[maxn];
int dp[maxn][maxn][maxn];

int n, m;

int main()
{
	scanf("%d%d", &n, &m);
	for(int i = 1, l, r, x; i <= m; ++i)
	{
		scanf("%d%d%d", &l, &r, &x);
		ve[r].push_back(TJ(l, x));
	}
	dp[0][0][0] = 1;
	for(int i = 0; i <= n; ++i)
	{
		for(int j = 0; j <= i; ++j)
		{
			for(int k = 0; k <= j; ++k)
			{
				if(dp[i][j][k])
				{
					bool flg = true;
					for(unsigned kk = 0; kk < ve[i].size(); ++kk)
					{
						if((ve[i][kk].l <= j) + (ve[i][kk].l <= k) + 1 != ve[i][kk].x)
						{
							flg = false;
							break;
						}
					}
					if(flg)
					{
						dp[i + 1][j][k] += dp[i][j][k];
						if(dp[i + 1][j][k] >= mod)
							dp[i + 1][j][k] -= mod;
						dp[i + 1][i][k] += dp[i][j][k];
						if(dp[i + 1][i][k] >= mod)
							dp[i + 1][i][k] -= mod;
						dp[i + 1][i][j] += dp[i][j][k];
						if(dp[i + 1][i][j] >= mod)
							dp[i + 1][i][j] -= mod;
					}
					else
						dp[i][j][k] = 0;
				}
			}
		}
	}
	int ans = 0;
	for(int i = 0; i <= n; ++i)
	{
		for(int j = 0; j <= i; ++j)
		{
			ans += dp[n][i][j];
			if(ans >= mod)
				ans -= mod;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

int main(){
  ll h,w;
  cin >>h >>w;
  ll ans = (h*w+1)/2;
  if(h==1 || w==1) cout << 1 << endl;
  else cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int i,n,m,count[1000001],res;
  char s[1000001];
  
  while(scanf("%d",&n),n){
    scanf("%d %s",&m,s);
    
    for(i=0;i<1000001;count[i]=0,i++);
    
    for(i=m-1;i>1;i--)
      if(s[i]=='I' && s[i-1]=='O' && s[i-2]=='I')
        count[i-2]=count[i]+1;
    
    for(i=0,res=0;i<m;i++)if(count[i]>=n)res++;
    
    printf("%d\n",res);
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef std::vector<ll> lls;
#define MIN(a, b) ( ((a)<(b)) ? (a) : (b) )
#define MAX(a, b) ( ((a)>(b)) ? (a) : (b) )

void cinv(lls& llVec, ll n) {
	ll val;
	llVec.reserve((size_t)(n));
	for (ll i = 0; i < n; i++) {
		cin >> val;
		llVec.push_back(val);
	}
}


int main()
{
	ll A, B;
	//std::string S;
	cin >> A >> B;

	ll m = MAX(MAX(A + B, A - B), A * B);

	cout << m << '\n';
	
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
    int n, i, a, min, max;
    long sum;
    scanf("%d %d", &n, &min);
    max = min;
    sum = min;
    for(i = 1; i < n; i++){
        scanf("%d", &a);
        if(min > a){
            min = a;
        }
        if(max < a){
            max = a;
        }
        sum += a;
    }
    printf("%d %d %ld\n", min, max, sum);
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll> ans;
ll A,B,C,D;
ll solve(ll x){
	// cerr << x << endl;
	if(!x)return 0;
	if(ans.find(x)!=ans.end())return ans[x];
	ll j=(x+2)/3*3,j2=x/3*3;
	ans[x] = min((__int128)D*x,(__int128)5000000000000000000);
	ans[x]=min(ans[x], solve(j/3)+D*abs(x-j)+B),ans[x]=min(ans[x], solve(j2/3)+D*abs(x-j2)+B*(j2>0));
	
	j=(x+4)/5*5,j2=x/5*5;
	ans[x]=min(ans[x],solve(j/5)+D*abs(x-j)+C),ans[x]=min(ans[x], solve(j2/5)+D*abs(x-j2)+C*(j2>0));
 
	j=(x+1)/2*2,j2=x/2*2;
	ans[x]=min(ans[x],solve(j/2)+D*abs(x-j)+A),ans[x]=min(ans[x], solve(j2/2)+D*abs(x-j2)+A*(j2>0));
	// cerr << x << ":" << ans[x] << ":" << endl;
	return ans[x];
}
 
int main()
{
	int T;cin >> T;
	while(T--){
		ll n;cin >> n >> A >> B >> C >> D;
		ans.clear();
		printf("%lld\n",solve(n));
	}
}

Measured memory_bytes: 4496
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N , K , A = 1;
  cin >> N >> K;
 for (int i = 0; i < N ; i++ ) {
   if (A < K){
     A*=2;
   }
   else {
     A+=K ;
   }
 }  
  cout << A;
}
   

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

int main() {
  int N;
  cin >> N;
  vector<int>S(N);
  int ans=1;
  for(int i=0;i<N;i++){
    cin>>S[i];
  }
  int s=S[0];
  for(int i=1;i<N;i++){
    if(s>S[i]){
      ans++;
      s=S[i];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
dict = {}
N, M = input().split(" ")

ACList = []
WAdict = {}
statusDict = {}
i = 1
while i <= int(M):
    key, ans = input().split(" ")
    if (ans == "AC"):
        ACList.append(key)
        statusDict[str(key)] = "OK"
    elif (ans == "WA" and key not in WAdict and key not in statusDict):
        WAdict[key] = 1
    elif (ans == "WA" and key in WAdict and key not in statusDict):
        WAdict[key] += 1

    i += 1

ACList = set(ACList)

penaList = []
for ACListItem in ACList:
    if (ACListItem in WAdict):
        penaList.append(WAdict[ACListItem])
print(len(set(ACList)), sum(penaList))


Measured memory_bytes: 26452
#include<iostream>
#include<set>
#include<vector>
#include<string>

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<string> str(N);
    set<string> num;
    for(int i = 0; i < N ; i++){ 
        cin >> str.at(i);
        num.insert(str.at(i));
    }
    cout << num.size() << endl;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  int ans = N * 100 + M * 1800;
  for (int i=0; i<M; i++) {
    ans *= 2;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
integer N,M
integer X,Y
integer EDGE(100000,1000)
integer Nindex(100000)
integer DP(100000)
integer ans
!読み込み
read*,N,M
EDGE(:,:)= 0
Nindex = 0
do i=1,M
  read*,X,Y
  Nindex(X)=Nindex(X)+1
  EDGE(X,Nindex(X))=Y
end do
!読み込み終了

DP = -1
!DP[i]とはノードiからのびる経路のうち最短のもの
!まだ調べていない状態は-1とする
ans = 0
do i=1,N
  if( DP(i)== -1)DP(i)=DFS(i)
  ans=max(ans,DP(i) )
end do

print"(I0)",ans

contains

recursive function DFS(u)result(res)
integer u,res

if(DP(u) >= 0)then
  res=DP(u)
else
  DP(u)=0
  do j=1,Nindex(u)
    DP(u)=max(DP(u),DFS(EDGE(u,j))+1)
  end do
  res=DP(u)
endif
end function DFS
end

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

int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    while(1){
        if(a >= b){
            b *= 2;
            k--;
        }
        else break;
    }
    while(1){
        if(b >= c){
            c *= 2;
            k--;
        }
        else break;
    }
    if(k >= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3636
list = raw_input().split()

A = int(list[0])

B = int(list[1])

K = int(list[2])

count = 0

for n in range(A, 0 , -1):
    if A % n == 0:
        if B % n == 0:
            count += 1
    if count == K:
        break

print n


Measured memory_bytes: 2568
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.NoSuchElementException;

public class Main {

	public void solve() {
		int N = nextInt();

		for(int i = 0;i < N;i++){
			String first = next();
			String second = next();


			BigInteger f = new BigInteger(first);
			BigInteger s = new BigInteger(second);

			BigInteger res = f.add(s);

			String ans = res.toString();

			if(first.length() > 80 || second.length() > 80 || ans.length() > 80){
				out.println("overflow");
			}else{
				out.println(ans);
			}
		}
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 24404
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

m = int(input())
#a = [int(i) for i in readline().split()]

keta = 0
wa = 0

for i in range(m):
    d,c = [int(i) for i in readline().split()]
    keta += c
    wa += d*c

#print(keta,wa)
print(keta-1 + (wa-1)//9)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define N 500005
using namespace std;
int n,x,ans,a[N],b[N],tmp[N];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),tmp[i]=a[i];
	sort(tmp+1,tmp+n+1);
	for (int i=1;i<=n;i++) a[i]=lower_bound(tmp+1,tmp+n+1,a[i])-tmp;
	for (int i=1;i<=n;i++) b[a[i]]=i;
	for (int i=1;i<=n;i++)
		if (abs(b[i]-i)&1) ans++;
	printf("%d\n",ans/2);
	return 0;
}

Measured memory_bytes: 2944
import sys
def input():
  return sys.stdin.readline().rstrip()

N,P=map(int,input().split())
A=list(map(int,input().split()))

temp=0
for i in range(N):
  if A[i]%2==1:
    temp+=1
if temp==0:
  print(1<<N if P == 0 else 0)
else:
  print(1<<(N-1))


Measured memory_bytes: 61960
import java.util.*;
import java.io.*;

public class Main {


    public Main(FastScanner in, PrintWriter out, int test) {
        int N = in.nextInt();

        int[] A = new int[N];
        int x = 0;
        for (int i = 0; i < N; i++) {
            A[i] = in.nextInt();
            x ^= A[i];
        }

        StringBuilder res = new StringBuilder();
        for (int i = 0; i < N; i++) {
            res.append(A[i] ^ x).append(' ');
        }
        out.println(res);
    }

    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        // Scanner in = new Scanner(
                // new BufferedReader(new InputStreamReader(System.in)));
        FastScanner in = new FastScanner(System.in);

        // int T = in.nextInt();
        for (int t = 1; t <= 1; t++) {
            Main sol = new Main(in, out, t);
        }

        out.close();
    }
}


class FastScanner{
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public FastScanner(InputStream stream)
    {
        this.stream = stream;
    }

    int read()
    {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars){
            curChar = 0;
            try{
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    boolean isSpaceChar(int c)
    {
        return c==' '||c=='\n'||c=='\r'||c=='\t'||c==-1;
    }

    boolean isEndline(int c)
    {
        return c=='\n'||c=='\r'||c==-1;
    }

    int nextInt()
    {
        return Integer.parseInt(next());
    }

    long nextLong()
    {
        return Long.parseLong(next());
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    String next(){
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isSpaceChar(c));
        return res.toString();
    }

    String nextLine(){
        int c = read();
        while (isEndline(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isEndline(c));
        return res.toString();
    }
}


Measured memory_bytes: 53112
# -*- coding: utf-8 -*-
"""
Created on Sun May 17 20:16:43 2020

@author: Kanaru Sato
"""

s = list(input())
acgt= set(["A","C","G","T"])
ans = 0
for i in range(len(s)):
    for j in range(i+1,len(s)+1):
        flag = 1
        t = s[i:j]
        for moji in t:
            if moji not in acgt:
                flag = 0
                break
        if flag == 1:
            ans = max(ans,len(t))
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define hell 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long int
#define pi 3.1415926536
using namespace std;

void dfs(ll x,ll y,ll r,ll c,vector<string> &v,vector<vector<ll>> &v1)
{  
	if(x>=r||y>=c||x<0||y<0||v[x][y]=='#'||v1[x][y])
	return;
	v1[x][y]++;
	dfs(x+1,y,r,c,v,v1);
	dfs(x,y+1,r,c,v,v1);
	return;
}
void rdfs(ll x,ll y,ll r,ll c,vector<string> &v,vector<vector<ll>> &v2)
{  
	if(x>=r||y>=c||x<0||y<0||v[x][y]=='#'||v2[x][y])
	return;
	v2[x][y]++;
	rdfs(x-1,y,r,c,v,v2);
	rdfs(x,y-1,r,c,v,v2);
	return;
}
void solve()
{ll t,n,m=-1,k,z,x,y,l=INT_MIN,mini=1000000,maxi=INT_MAX,prev;
    cin>>n;
    vector<ll> a(n,INT_MAX),b(n-1);
    for(ll i=0;i<n-1;i++)
    {
    	cin>>b[i];
    	if(a[i]>b[i])
    	a[i]=b[i];
    	a[i+1]=b[i];
	}
    x=0;
    for(ll i=0;i<n;i++)
    x+=a[i];
    cout<<x;
}

int main()
{
  fast
ll t=1;

while(t--)
{solve();
 //cout<<ma<<endl;
}
return 0;}
/*
ll bfs(ll x)
{
	vector<ll> vis(100001,-1),papa(100001,-1);
	vis[x]=0; queue<ll> q;
	q.push(x);
	//cout<<"ok"<<endl;
	ll len=INT_MAX;
	while(!q.empty())
   { ll y=q.front();
     q.pop();
 	for( auto j:adj[y])
	{
		if(vis[j]==-1)
		{   //cout<<"ok"<<endl;
			vis[j]=vis[y]+1;
			papa[j]=y;
			q.push(j);
		}
		else if(j!=papa[y])
		{   //cout<<"chk"<<endl;
			len=min(len,vis[j]+vis[y]+1);
			break;
		}
	}
   }
   //cout<<len<<endl;
   return len;
}*/

Measured memory_bytes: 256
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

fn main() {
    // 入力
    let (X, Y) = get!(i64, i64);

    let ans = X + Y / 2;

    // 出力
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef struct node
{
	int color,x,y;
	bool operator < (const struct node t) const
	{
		return y<t.y;	
	}
}NODE,*PNODE;
NODE a[202];
list<NODE> redlist;
bool mycmp(const NODE a,const NODE b)
{
	return a.x<b.x;	
} 
int main()
{
	int n,i,ans=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&a[i].x,&a[i].y);
		a[i].color=0;
	}
	for(i=n;i<2*n;i++)
	{
		scanf("%d %d",&a[i].x,&a[i].y);
		a[i].color=1;
	}
	sort(a,a+2*n,mycmp);
	for(i=0;i<2*n;i++)
	{
		//printf("%d %d %d\n",a[i].x,a[i].y,a[i].color);
		if(a[i].color==0)
		{
			redlist.insert(lower_bound(redlist.begin(),redlist.end(),a[i]),a[i]);
		}
		else
		{
			if(redlist.empty())
				continue;
			list<NODE>::iterator iter=lower_bound(redlist.begin(),redlist.end(),a[i]);
			if(iter!=redlist.begin())
			{
				redlist.erase(--iter);
				ans++;
				
			}
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
//---------------------------------------------------
//library zone!!!!!
typedef long long ll;
typedef long double ld;
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld mod_pow(ld x, ll n, ll p) {
	ld res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int n;
int a[2000];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int sum = -Inf;
	int st = 0, end = 0;
	//答え
	for (int i = 0; i < n; i++) {
		int res = a[i];
		if (sum < res) {
			sum = res;
			st = i; end = i;
		}
		for (int j = i + 2; j < n; j += 2) {
			res += a[j];
			if (sum < res) {
				sum = res;
				st = i; end = j;
			}
			if (a[j] < 0) {
				res -= a[j];
			}
		}
	}
	cout << sum << endl;
	int r = n - end - 1;
	vector<int>ans;
	for (int i = 0; i < r; i++) {
		ans.push_back(n--);
	}
	for (int i = 0; i < st; i++) {
		ans.push_back(1);
	}
	n = end - st + 1;
	//1~n
	r = 0;
	for (int i = st + 2; i <= end; i += 2) {
		if (a[i] < 0) {
			ans.push_back(i - st - r + 1);
			r += 2;
		}
		else {
			ans.push_back(i - st - r);
			r += 2;
		}
	}
	cout << ans.size() << endl;
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
 
    ll n,x;
    cin>>n>>x;
    ll l[n];
    for(int i=0;i<n;i++){
        cin>>l[i];
    }
    int ans=1;
    int now=0;
    for(int i=0;i<n;i++){
        now += l[i];
        if(now<=x){
            ans++;
        }
    }
    cout <<ans<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
A = [int(x) for x in input().split()]
cnt = [0] * N
for i in range(N-1):
    cnt[A[i]-1] += 1
for i in range(N):
    print(cnt[i])

Measured memory_bytes: 91600
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rd3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define rl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf 10000000000000
#define mod 1000000007
#define maxn 100009
#define maxr 100009
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	ll a,b,c;
	rl3(a,b,c);
	ll ans=a+b+c;
	ll mx=max(max(a,b),c);
	ans-=mx;
	wl(ans);
	NL;
	return 0;
}

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

namespace _0270
{
    class Program
    {
        const int LMT = 300000;
        static void Main(string[] args)
        {
            int[] nq = RArInt();
            int[] cards = RArInt();
            int[] MaxCards = new int[LMT + 1];
            for (int i = 0; i < cards.Length; i++) MaxCards[cards[i]] = cards[i];
            for (int i = 1; i <= LMT; i++) MaxCards[i] = Math.Max(MaxCards[i], MaxCards[i - 1]);
            for (int i = 0; i < nq[1]; i++)
            {
                int q = RInt();
                int res = 0;
                for (int j = q; j < MaxCards.Length; j += q)
                {
                    res = Math.Max(res, MaxCards[j - 1] % q);
                    if (res == q - 1) break;
                }
                Console.WriteLine(res);
            }
        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



Measured memory_bytes: 45172
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
const int INF = 1e9;
int main()
{
    int n;
    cin>>n;
    vector <int> h(n);
    long long dp[n];

    rep(i,n)
    {
        cin>>h[i];
    }
   
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1408