akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string.h>
using namespace std;

int main()
{
bool ok[31];
memset(ok,false,sizeof(ok));
ok[0]=true;
for(int i=0;i<28;i++){
int t;
cin>>t;
ok[t]=true;
}

for(int i=0;i<=30;i++)
if(!ok[i])
cout<<i<<endl;

}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <map>
 
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
typedef long long ll;
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

ll n, m, l, r, idx_l, idx_r, ans;
int ID[112345];
int f = 1;

int main(){
	cin >> n >> m;
	
	REP(i,m){
		cin >> l >> r;
		
		if (ID[l-1] == -1) f = 0;
		else ID[l-1] = 1;
		if (ID[r] == 1) f = 0;
		else ID[r] = -1;
	}
	
	REP(i,n+1){
		if (ID[i] == 1) idx_l = i;
		if (ID[n-i] == -1) idx_r = n-i;
	}
	
	if (f) ans = idx_r - idx_l;
	
	if (ans > 0) cout << ans << endl;
	else cout << 0 << endl;
	
	return 0;
}

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

int main() {

    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;

    int min = a*x + b*y;
    for(int i = 0; i <= max(x,y)*2; i++){
        
        int ap = (x-i/2 > 0) ? (x-i/2)*a : 0;
        int bp = (y-i/2 > 0) ? (y-i/2)*b : 0;

        if( min > ap+bp+c*i )
          min = ap+bp+c*i;
    }

    cout << min << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define REP(i, a, b) for(int i = a; i < b; i++)

int main(void) {
    int n;
    scanf("%d", &n);
    int t[n];
    REP(i, 0, n) {
        scanf("%d", &t[i]);
    }
    int m;
    scanf("%d", &m);
    int p[m], x[m];
    REP(i, 0, m) {
        scanf("%d%d", &p[i], &x[i]);
    }
    int count = 0;
    REP(i, 0, m) {
        REP(j, 0, n) {
            if (p[i] - 1 == j) {
                count += x[i];
            } else {
                count += t[j];
            }
        }
        printf("%d\n", count);
        count = 0;
    }
    return 0;
}

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

using namespace std;

#define f0r(a, b) for (long long a = 0; a < b; a++)
#define f1r(a, b, c) for (long long a = b; a < c; a++)
#define f0rd(a, b) for (long long a = b; a >= 0; a--)
#define f1rd(a, b, c) for (long long a = b; a >= c; a--)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define f first
#define s second

#define ao(a, n) {for (int ele = 0; ele < n; ele++) { if (ele) cout << " "; cout << a[ele]; } cout << endl;}

typedef long long ll;
typedef double ld;
typedef long double lld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

const ll inf = 1e17;
const ll mod = 1e9 + 7;

typedef tuple<long long, int, int> ti;

ll n;

ll bit[100005];

ll query(ll i) {
  ll ret = 0;
  for (; i>0; i-=i&-i)
    ret = min(inf, bit[i] + ret);
  return ret;
}

void update(ll i, ll val) {
  for (; i<=n; i+=i&-i)
    bit[i] = min(inf, bit[i] + val);
}

void supdate(ll i, ll val) {
    update(i, val);
    update(i + 1, -val);
}

//inclusive
void rupdate(int l, int r, int val) {
    update(l, val);
    update(r + 1, -val);
}

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

    cin >> n;
    n++;

    ll arr[n];

    f0r(i, n) cin >> arr[i];

    if (arr[0] > 1) {
        cout << -1 << endl;
        return 0;
    }

    if (arr[0] == 1) {
        if (n != 1)
            cout << -1 << endl;
        else {
            cout << 1 << endl;
        }
        return 0;
    }

    ll ret = 1;
    ll cur_ind = 1;
    bool pos = true;

    supdate(1, 2);


    for (int i = 1; i < n; i++) {
        /*for (int j = 1; j <= n; j++) {
            cout << query(j) << " ";
        }*/


        while (arr[i] > 0) {
            ll q = query(cur_ind);

            if (cur_ind > i) {
                pos = false;
                break;
            }

            if (q >= arr[i]) {
                ret += (i + 1 - cur_ind) * arr[i];
                supdate(cur_ind, -arr[i]);
                rupdate(cur_ind + 1, i, arr[i]);

                arr[i] = 0;
            } else {
                ret += (i + 1 - cur_ind) * q;
                supdate(cur_ind, -q);
                rupdate(cur_ind + 1, i, q);

                arr[i] -= q;

                cur_ind++;
            }
        }

        if (!pos) break;
    }

    if (!pos) {
        cout << -1 << endl;
    } else {
        cout << ret << endl;
    }








}


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

using namespace __gnu_pbds;
using namespace std;
using namespace std::chrono;

#define ll long long
#define ld long double
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(c) ((ll)c.size())
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#ifdef LL
const ll inf = 1e9;
#else 
const ll inf = 1e18;
#endif

const int mod = 1e9 + 7;
const int mod2 = 998244353;

typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

high_resolution_clock::time_point curTime() { return high_resolution_clock::now(); }
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);} //Just add this as a third argument to sort() while sorting an array of pairs; NO NEED FOR ANY ARGUMENTS;
template <typename T>
T fact(T a, T mod){ int res = 1, i; for (i = 2; i <= a; i++){ res *= i; res%=mod;} return res; }
template <typename T>
ll powmod(T a,T b,ll m){ ll ans=1; while(b>0){if(b&1){ans*=a;ans%=m;}a*=a;a%=m;b>>=1;} return ans; }
template <typename T>
ll power(T a, T b){ ll ans=1; while(b>0){if(b&1){ans*=a;}a*=a;b>>=1;}return ans;}
template <typename T>
T gcd(T a,T b){ return (b?__gcd(a,b):a); }
template <typename T>
T lcm(T a, T b){ return (a*(b/gcd(a,b))); }
template <typename T>
T cl(T a, T b){ return (a+b-1)/b; }
template <typename T>
T set_bits(T a)
{ return __builtin_popcount(a); }
template <typename T>
T add_self(T& a, T b, T mod){ a+=b; if(a>=mod){ a-=mod; } }
template <typename T>
T to_upper(T s){ transform(s.begin(), s.end(), s.begin(), ::toupper); return s; }
template <typename T>
T to_lower(T s){ transform(s.begin(), s.end(), s.begin(), ::tolower); return s; }



int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    auto startTime = curTime();

    string s,t;
    cin>>s>>t;
    int n = sz(s);
    int m = sz(t);

    vvi dp(n+1,vi(m+1));
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(s[i-1]==t[j-1])
            {
                dp[i][j] = dp[i-1][j-1]+1;
            }
            else
            {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }

    vector<char> ans;
    int tot = dp[n][m];
    if(tot==0) return 0;
    for(int i=n;i>0;i--)
    {
        for(int j=m;j>0;j--)
        {
            if(dp[i][j]==tot && s[i-1]==t[j-1])
            {
                ans.pb(s[i-1]);
                i--;
                tot--;
            }
            if(tot==0) break;
        }
    }

    reverse(all(ans));
    for(int i=0;i<sz(ans);i++) cout<<ans[i];
    cout<<endl;

    auto stopTime = curTime();
    auto duration = duration_cast<microseconds>(stopTime - startTime);
    //cout<<"Program ran for "<<(ld)duration.count()/1e6<<" "<<"seconds"<<endl;
}


Measured memory_bytes: 73572
import bisect
def count_generate(h,w,a):
    count = [[0]*w for j in range(h)]
    count[0][0] = a[0][0]
    for i in range(1,w):
        count[0][i] = count[0][i-1]+a[0][i]
    for i in range(1,h):
        cnt_w = 0
        for j in range(w):
            cnt_w += a[i][j]
            count[i][j] = count[i-1][j]+cnt_w
    return count

def da_calc(p,q,x,y, da):
    if p > x or q > y:
        return 0
    if p == 0 and q == 0:
        return da[x][y]
    if p == 0:
        return da[x][y]-da[x][q-1]
    if q == 0:
        return da[x][y]-da[p-1][y]
    return da[x][y]-da[p-1][y]-da[x][q-1]+da[p-1][q-1]

N, K = map(int, input().split())
a = []
b = []
for i in range(N):
    ai, bi = map(int, input().split())
    a.append(ai)
    b.append(bi)
    
a_sorted = sorted(set(a))
b_sorted = sorted(set(b))
h = len(a_sorted)
w = len(b_sorted)

Map = [[0]*w for _ in range(h)]

for i in range(N):
    ai = bisect.bisect_left(a_sorted, a[i])
    bi = bisect.bisect_left(b_sorted, b[i])
    Map[ai][bi]+=1

count = count_generate(h, w, Map)
ans = float('inf')
for i in range(h):
    for j in range(i+1, h):
        for k in range(w):
            for l in range(k+1, w):
                #print(i, j, k, l, da_calc(i, k, j, l, count))
                if da_calc(i, k, j, l, count)>=K:
                    #print(i, j, k, l)
                    ans = min(ans, (a_sorted[j]-a_sorted[i])
                              *(b_sorted[l]-b_sorted[k]))
print(ans)

Measured memory_bytes: 46956
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}


int main(void) {
  ll N, H;
  cin >> N >> H;
  ll i;
  
  priority_queue<P> q;
  for(i=0; i<N; i++) {
    ll a, b;
    cin >> a >> b;
    
    q.push({a, 0});
    q.push({b, 1});
  }
  
  ll ans=0;
  ll h=H;
  
  while(1) {
    P u=q.top();
    if(u.sc==1) {
      h-=u.ft;
      ans++;
      q.pop();
    }else {
      ans+=(h+u.ft-1)/u.ft;
      break;
    }
    
    if(h<=0) break;
    
  }
  
  pt(ans);
}


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

int32_t main()
{
    int a,b,c;
    int count=0;
    cin>>a>>b>>c;
    if(a%2==1 or b%2==1 or c%2==1)
    {
        cout<<0;
    }
    else if(a==b and b==c  and c==a)
    {
        cout<<-1<<endl;
    }
    else
    {
        while(1)
        {
            int A=b/2+c/2;
            int B=a/2+c/2;
            int C=a/2+b/2;
            ++count;
            a=A;
            b=B;
            c=C;
            
             if(a%2==1 or b%2==1 or c%2==1)
                break;
        }
    cout<<count<<endl;
    }
}

Measured memory_bytes: 3596
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    int X,Y,Z; cin>>X>>Y>>Z;
    int ans=0;

    cout<<(X-Z)/(Y+Z)<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
   
int main(){
    int r, c;
    scanf("%d %d", &r, &c);
    int a[r + 1][c + 1] ;
    fill(a[0], a[r + 1], 0);
    for(int i = 0; i < r; ++i){
        for(int j = 0; j < c; ++j){
            scanf("%d", &a[i][j]);
            a[i][c] += a[i][j];
            a[r][j] += a[i][j];
            a[r][c] += a[i][j];
            printf("%d ", a[i][j]);
        }
        printf("%d\n", a[i][c]);
    }
    for(int i = 0; i < c; ++i){
        printf("%d ", a[r][i]);
    }
    printf("%d\n", a[r][c]);
   
    return 0;
}

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

int main(){
  int n,i,array[100001];
  long long c=1;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>array[i];
  }
  sort(array,array+n);
  if(n%2==1){
    if(array[0]!=0){
      cout<<0<<endl;
      return 0;
    }
    for(i=1;i<n;i+=2){
      if(array[i]!=array[i+1]){
        cout<<0<<endl;
        return 0;
      }
    }
  }else if(n%2==0){
    for(i=0;i<n;i+=2){
      if(array[i]!=array[i+1]){
        cout<<0<<endl;
        return 0;
      }
    }
  }
  for(i=0;i<n/2;i++){
    c*=2;
    c%=1000000007;
  }
  cout<<c<<endl;
  return 0;
}



Measured memory_bytes: 640
import math
a,b,h,m=map(int,input().split())
deg_a=6*m
deg_b=30*h+m/2
deg_c=abs((deg_a)-(deg_b))
rad=math.radians(deg_c)
c=a**2+b**2-2*a*b*math.cos(rad)
print(c**0.5)


Measured memory_bytes: 9360
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<Pll> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define SORT(x) sort(all(x))
#define RSORT(x) sort(all(x),greater<ll>())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
	
	ll N;
	cin >> N;
	
	vll p(N);
	rep(i,0,N) cin >> p[i];
	
	vll sort_p = p;
	SORT(sort_p);
	
	ll cnt = 0;
	rep(i,0,N){
		if(p[i] != sort_p[i]) cnt++;
	}
	
	if(cnt == 2 || cnt == 0) print("YES");
	else print("NO");
	
 return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	unsigned long long s=1;//数据开大一点 
	int n,k;
	cin>>n>>k;
	s*=k;//第一个球的情况 
	for(int i=1;i<n;i++)
	{
		s*=k-1;//不能和之前重复，每个有k-1种 
	}
	cout<<s<<endl;
 	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
int n;
cin>>n;
vector<int> h(n);
for(int i=0;i<n;i++)cin>>h[i];
int cnt = 1;
int m = h[0];
for(int i=1;i<n;i++){
	if(m<=h[i]){
		m = h[i];
		cnt++;
	}
}
cout<<cnt<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;
const int MAXN = 2505;
typedef pair<int, int> pii;
struct KM { LL W[MAXN][MAXN]; int V;
  LL mx[MAXN], my[MAXN]; LL lx[MAXN], ly[MAXN];
  bool x[MAXN], y[MAXN];
  void init(int _V) { V = _V; memset(W, 0, sizeof(W)); }
  bool augment(int u) { x[u] = 1;
    for (int i = 0 ; i < V ; i++)
      if (!y[i] && W[u][i] == lx[u]+ly[i] && (y[i]=1))
         if (!~my[i] || augment(my[i]))
          return my[i] = u, true;
    return false;
  }
  LL run() { memset(mx, -1, sizeof(mx));
    memset(my, -1, sizeof(my));
    for (int i = 0 ; i < V ; i++)
      lx[i] = -INF, ly[i] = 0;
    for (int i = 0 ; i < V ; i++)
      for (int j = 0 ; j < V ; j++)
        lx[i] = max(lx[i], W[i][j]);
    for (int i = 0 ; i < V ; i++) { while (1) {
        memset(x, false, sizeof(x));
        memset(y, false, sizeof(y));
        if (augment(i)) break; LL d = INF;
        for (int j = 0 ; j < V ; j++) {
          if (!x[j]) continue;
          for (int k = 0 ; k < V ; k++) {
            if (y[k]) continue;
            d = min(d, lx[j] + ly[k] - W[j][k]);
          }
        }
        if (d == INF) break;
        for (int j = 0 ; j < V ; j++) {
          if (x[j]) lx[j] -= d; if (y[j]) ly[j] += d;
        }
      }
    }
    LL ret = 0; for (int i = 0 ; i < V ; i++)
      if (~my[i]) ret += W[my[i]][i];
    return ret;
  }
} solver;
int dx[] = {0, 1};
int dy[] = {1, 0};
vector<vector<LL>> go(auto &G, pii s) {
    int n = G.size(), m = G[0].size();
    vector<vector<LL>> d(n, vector<LL>(m, -INF));
    queue<pii> q; q.push(s); d[s.F][s.S] = 0; while (q.size()) {
        pii p = q.front(); q.pop();
        for (int _ = 0 ; _ < 2 ; _++) {
            pii nx = {p.F + dx[_], p.S + dy[_]};
            if (nx.F < 0 || nx.F >= n || nx.S < 0 || nx.S >= m)
                continue;
            if (G[nx.F][nx.S] == '#')
                continue;
            if (d[nx.F][nx.S] != -INF)
                continue;
            d[nx.F][nx.S] = d[p.F][p.S] + 1;
            q.push(nx);
        }
    }
    return d;
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m; cin >> n >> m;
    solver.init(n * m);
    vector<vector<char>> G(n, vector<char>(m));
    for (auto &vv : G)
        for (auto &v : vv)
            cin >> v;
    for (int i = 0 ; i < n ; i++) {
        for (int j = 0 ; j < m ; j++) {
            if (G[i][j] != 'o')
                continue;
            auto res = go(G, {i, j});
            for (int x = 0 ; x < n ; x++) {
                for (int y = 0 ; y < m ; y++) {
                    int uid = i * m + j;
                    int vid = x * m + y;
                    solver.W[uid][vid] = res[x][y];
//                    cout << "add " << uid << ' ' << vid << ' ' << res[x][y] << '\n';
                }
            }
        }
    }
    cout << solver.run() << '\n';
}

Measured memory_bytes: 52928
n = gets.chomp.to_i

bs = n.times.map { gets.split.map(&:to_i) }

r = 100
n.times do |i|
  n.times do |j|
    next if i == j
    x = bs[i][0] - bs[j][0]
    y = bs[i][1] - bs[j][1]
    next if x == 0 && y == 0
    bh = bs.reduce({}) { |h, b| h[b] = true; h }
    rr = 0
    n.times do |k|
      next unless bh[bs[k]]
      rr += 1
      t = bs[k]
      bh[t] = false
      while bh[[t[0]+x, t[1]+y]]
        t = [t[0]+x, t[1]+y]
        bh[t] = false
      end
      t = bs[k]
      while bh[[t[0]-x, t[1]-y]]
        t = [t[0]-x, t[1]-y]
        bh[t] = false
      end
    end
    r = r < rr ? r : rr
  end
end
r = 1 if n == 1

puts r

Measured memory_bytes: 1916
// https://beta.atcoder.jp/contests/abc076
// status:

#define SUBMIT
//#define DEBUG

#include <utility>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <queue>
#include <numeric>
#include <limits>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

string S, T;

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    auto program_input = std::string(R"(?tc????
coder
)");
    stringstream stream(program_input);
#endif
    stream >> S >> T;

    int str_length = S.length();
    int key_length = T.length();

    string ans = "~";
    for (int i = 0; i <= str_length - key_length; ++i) {
        bool ok = true;
        for (int j = 0; j < key_length; ++j) {
            if (S[i + j] != '?' && S[i + j] != T[j]) ok = false;
        }

        if (ok) {
            string s2 = S;
            s2.replace(i, T.length(), T);
            for (int j = 0; j < s2.length(); ++j) if (s2[j] == '?') s2[j] = 'a';
            ans = min(ans, s2);
        }
    }

    if (ans == "~") cout << "UNRESTORABLE" << endl;
    else cout << ans << endl;
    return 0;
}

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

int main(){
  double r;
  cin >> r;
  const double PI = acos(-1);
  printf("%.2f\n", 2*r*PI);
}

Measured memory_bytes: 3792
N = int(input())
a = []
for _ in range(N):
    a.append(list(map(int, input().split())))

dp = [[0]*3 for _ in range(N+1)]

for i in range(N):
    dp[i+1][0] = max(dp[i+1][0], dp[i][1]+a[i][1], dp[i][2]+a[i][2])
    dp[i+1][1] = max(dp[i+1][1], dp[i][0]+a[i][0], dp[i][2]+a[i][2])
    dp[i+1][2] = max(dp[i+1][2], dp[i][0]+a[i][0], dp[i][1]+a[i][1])
print(max(dp[N]))

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

int main(){
int n;
  cin >> n;
map<int,int> a;
for(int i=1;i<=n;i++) cin >> a[i] ;
bool flag=false;  
int num=0;
int i=1;  
int j=1;  
while(a[i]>0){
  num++;
  j=i;
if(a[j]==2){
            flag=true;
            break;
            }
else {
  j=a[i];
  a[i]=-1;
  i=j;
     }
}  
  if(flag) cout << num << endl;
  else cout << -1 << endl;
}  




Measured memory_bytes: 8292
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int a,b,c,d;
	cin>>a>>b>>c>>d;
  cout<<max(max(a*1LL*c,a*1LL*d),max(b*1LL*c,b*1LL*d))<<endl;
	
	return 0;
}

Measured memory_bytes: 3644
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        int r = sc.nextInt();

        int lm = l % 2019;
        int rm = r % 2019;

        if(lm < rm){
            if(l + (2019-lm) <= r){
                System.out.println("0");
            } else {
                int ans = Integer.MAX_VALUE;
                for(int i = lm; i <= rm;i++) {
                    for (int j = i + 1; j <= rm; j++) {
                        ans = Math.min(ans, i * j % 2019);
                    }
                }
                System.out.println(ans);
            }
        } else{
            System.out.println("0");
        }
    }
}



Measured memory_bytes: 23764
N = int(input())

A,B = map(int,input().split(' '))

P = list(map(int, input().split(" ")))

#P = p.strip(' ')

#P = map(int,p.split(' '))

#print(P[0])

P.sort()

kazu = len(P)

#print(P)

A_cnt = 0
B_cnt = 0

for j in range(N):
    if P[j] <= A:
        A_cnt = A_cnt +1
    if P[j] >= B+1:
        B_cnt = B_cnt + 1

AB_cnt = kazu - A_cnt - B_cnt

print(min(A_cnt,B_cnt,AB_cnt))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    char s;
    cin >> s;
    if (s - 'a'>= 0) cout << "a" << endl;
    else cout << "A" << endl;
    return 0;
}


Measured memory_bytes: 3644
n, m, k = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
s = 0
ans = 0
ca = 0
for i in range(n):
  if k >= s + a[i]:
    s += a[i]
    ans += 1
    ca += 1
  else:
    break
cb = 0
for i in range(m):
  if k >= s + b[i]:
    s += b[i]
    ans += 1
    cb += 1
  else:
    break
if ans == n + m or ans == 0:
  print(ans)
else:
  l = []
  l.append(ans)
  for i in range(m):
    if ca > 0:
      s -= a[ca - 1]
      ca -= 1
      ans -= 1
    while k >= s + b[cb]:
      s += b[cb]
      cb += 1
      ans += 1
      l.append(ans)
      if cb >= m:
        break
    if cb >= m:
      break
  print(max(l))

Measured memory_bytes: 41964
#include<stdio.h>
 int prime[1000000];
 int main(){ prime[0]=-1; 
prime[1]=-1; for(int i=2;i<1000000;i++){
 if(prime[i]==0){ prime[i]=1;
 for(int j=i*2;j<1000000;j+=i)prime[j]=-1;
 } 
} 
int now;
 while(~scanf("%d",&now)){ 
int ans=0; for(int i=1;i<now+1;i++)if(prime[i]==1)ans++;
 printf("%d\n",ans); 
}
 } 


Measured memory_bytes: 6660
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define F first
#define S second
#define all( x ) x.begin() , x.end()
#define pb push_back
#define mp make_pair
#define uniq( x ) sort( all( x ) ) , x.resize( unique( all( x ) ) - x.begin())
 
const int maxn = 2e5 + 10 ;
const int INF = 1e18 ;
 
int n , a , b , c , d , t , dp[ maxn ] ;
vector< int > vv ;
 
void solve()
{
 cin >> n >> a >> b >> c >> d ;
 
 for(int i = 1 ; i <= n ; i *= 2){
   for(int j = i ; j <= n ; j *= 3){
      for(int k = j ; k <= n ; k *= 5){
         vv.pb( n/k ) ;
         vv.pb( (n+k-1)/k ) ;
      }
   }
 }
 
 
 uniq( vv );
 
// cout << vv.size() << "\n" ;
 
 dp[ 0 ] = d ;
 for(int i = 1 ; i < vv.size() ; i ++){
   int x = vv[ i ];
 
   dp[ i ] = 9*INF ;
 
   long double xx = x , dd = d , check = 9e18 ;
   long double val = xx*dd ;
   if( val < check ){
     dp[ i ] = x*d ;
   }
 
   int x1 = x/2 , y1 = (x+1)/2 , dx1 = x%2 , dy1 = (2-(x%2))%2 ;
   int x2 = x/3 , y2 = (x+2)/3 , dx2 = x%3 , dy2 = (3-(x%3))%3;
   int x3 = x/5 , y3 = (x+4)/5 , dx3 = x%5 , dy3 = (5-(x%5))%5;
 
   int indx1 = lower_bound( all( vv ) , x1 ) - vv.begin() ;
   int indx2 = lower_bound( all( vv ) , x2 ) - vv.begin() ;
   int indx3 = lower_bound( all( vv ) , x3 ) - vv.begin() ;
   int indy1 = lower_bound( all( vv ) , y1 ) - vv.begin() ;
   int indy2 = lower_bound( all( vv ) , y2 ) - vv.begin() ;
   int indy3 = lower_bound( all( vv ) , y3 ) - vv.begin() ;
 
 //  if( indx1 == vv.size() || indx2 == vv.size() || indx3 == vv.size()|| indy1 == vv.size()|| indy2 == vv.size()|| indy3 == vv.size())
 //     cout << "NOOOOOOOo\n" ;
 
   dp[ i ] = min( dp[ i ] , dp[ indx1 ] + dx1*d + a ) ;
   dp[ i ] = min( dp[ i ] , dp[ indx2 ] + dx2*d + b ) ;
   dp[ i ] = min( dp[ i ] , dp[ indx3 ] + dx3*d + c ) ;
   dp[ i ] = min( dp[ i ] , dp[ indy1 ] + dy1*d + a ) ;
   dp[ i ] = min( dp[ i ] , dp[ indy2 ] + dy2*d + b ) ;
   dp[ i ] = min( dp[ i ] , dp[ indy3 ] + dy3*d + c ) ;
 
 }
 
// cout << vv[ vv.size()-1 ] << "\n" ;
 
 cout << dp[ vv.size()-1 ] << "\n" ;
}
 
signed main()
{
 ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
 
 cin >> t ;
 
 while( t -- ){
  solve();
 }
 
    return 0;
}

Measured memory_bytes: 3808
#include <algorithm>
#include <iostream>
#include <list>
#include <string>

using namespace std;

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

	list<int> l;
	string s;
	int x;
	while (n--)
	{
		cin >> s;
		if (s == "deleteFirst") { l.pop_front(); continue; }
		else if (s == "deleteLast") { l.pop_back(); continue; }

		cin >> x;
		if (s == "insert") l.push_front(x);
		else if (s == "delete")
		{
			list<int>::iterator it = find(l.begin(), l.end(), x);
			if (it != l.end())
				l.erase(it);
		}
	}

	cout << l.front(), l.pop_front();
	for (auto it = l.begin(); it != l.end(); ++it)
		cout << " " << *it;
	cout << endl;

	return 0;
}

Measured memory_bytes: 34364
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		String N =scanner.nextLine();
		char[] Ns = N.toCharArray();
		
		String ans = "No";
		if (Ns[0]==Ns[2]) {
			ans="Yes";
		}
		
		System.out.println(ans);
		
		scanner.close();

	}

}

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

// Macros
#define F  first
#define S  second
#define PB push_back

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m, y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// HELPERS
//  Tedious Grid Movements
vector<pii> moves_grid = { {0,1} , {0,-1} , {1,0} , {-1,0} };
inline bool move_okay(int x, int y, int n, int m) { return 0 <= x and x < n and 0 <= y and y < m; }
//  Remember:
//   * vec.assign() GOOD; vec.resize() BAD
//   * comparator uses <

// Output, Common Containers
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream& os, const set<T>& v)    { for (T i : v) os << i << ' '; return os; }
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) { os << "(" << v.F << "=>" << v.S << ") "; return os; }
template <typename T, typename S> ostream& operator << (ostream& os, const map<T,S>& v)  { for (auto i : v) os << i << ' '; return os; }

// Debugging
#ifdef SANYAM1101
	#define trace(args...) do{ cerr << "TRACE ON! (Line: " << __LINE__ << ")\n"; auto _stream = istringstream{string{#args}}; d_f(_stream, args); } while(0)
	void d_f(__attribute__((unused)) istringstream& _stream) {}
	template<typename Head, typename... Tails> void d_f(istringstream& _stream, Head H, Tails... T) { string _name; _stream >> _name; if(_name.back() == ',') _name.pop_back(); cerr << "\t" << _name << " <=> [" << H << "]\n"; d_f(_stream, T...); }
#else
	#define trace(args...)
#endif


// CODE STARTS HERE

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

	vector<int> arr(n);
	for(auto& i: arr) cin >> i;

	int su = accumulate(arr.begin(), arr.end(), 0);

	const int INF = 1e9;

	if(su % 10 == 0){
		int mi = INF;
		for(auto i: arr) if(i % 10) mi = min(mi, i);
		if(mi != INF) su -= mi;
	}

	cout << (su % 10 == 0 ? 0 : su) << "\n";
}

signed main (void){
	// Fast_IO
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// Set Fixed Notation (default sucks), High Precision for Floating-Point Output
	cout << fixed << setprecision(20);

	// Multiple TCs
	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898

//------------------------------------------------------

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];

    if (n == 1) {
        cout << a[0] << endl;
        return 0;
    }


    if (n % 2 == 0) {
        int i = n - 1;
        while (i >= 1) {
            cout << a[i] << " ";
            i -= 2;
        }
        i = 0;
        while (i != n - 2) {
            cout << a[i] << " ";
            i += 2;
        }
        cout << a[n - 2] << endl;
    } else {
        int i = n - 1;
        while (i >= 0) {
            cout << a[i] << " ";
            i -= 2;
        }
        i = 1;
        while (i != n - 2) {
            cout << a[i] << " ";
            i += 2;
        }
        cout << a[n - 2] << endl;
    }

    return 0;
}



Measured memory_bytes: 2944
N = int(input())
B = list(map(int, input().split()))

A = 0
b = 10**5+10
for i in range(N-1):
    a = b if B[i] > b else B[i]
    #print(b, B[i], a)
    b = B[i]
    A += a
A += B[-1]
print(A)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
using P = pair<int,int>;
using ivec = vector<int>;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const int MOD=1000000007;
int INF=100100100100100;
int add(int a,int b){
  return (a+b)%MOD;
}
int prod(int a,int b){
  return (a*b)%MOD;
}

int beki(int a,int b)
{
	if(b==0)return 1;
	int x=beki(a,b/2);
	if(b%2==0)return (x*x)%MOD;
	else return (((a*x)%MOD)*x)%MOD;
}

int inv(int a)
{
	return beki(a,MOD-2);
}

int kaijou(int a)
{
	int ans=1;
	for(int i=1;i<=a;i++)
	{
		ans=(ans*i)%MOD;
	}			
	return ans;
}

/*int combi(int a,int b)
{
	int ret=1;
	for(int i=1;i<=b;i++)
	{
		ret=(((ret*(a+1-i))%MOD)*inv(i))%MOD;
	}
	return ret;
}*/
/*
const int MAX_a=200010;
int cb[MAX_a+1]
void combi(int a,int b)
{
    int ret=1;
    cb[0]=1;
    for(int i=1;i<=b;i++)
    {
	ret=(((ret*(a+1-i))%MOD)*inv(i))%MOD;
        cb[i]=ret;
    }
	
}*/

vector<P> prime_factorize(int N)
{
	vector<P> res;
	for(int a=2;a*a<=N;a++)
	{
		if(N%a!=0)continue;
		int ex=0;
		while(N%a==0)
		{
			ex++;N/=a;
		}
		res.push_back(P(a,ex));
	}
	if(N!=1)res.push_back(P(N,1));
	return res;
}

//ここから書く
signed main(){
  int a,b;cin>>a>>b;
  cout<<max(a+b,max(a-b,a*b))<<endl;
  return 0;
}

Measured memory_bytes: 3552
#include <iostream>
#include <string>

using namespace std;

int main(){

  string str;
  int cnt[27] = {0};

  cin >> str;

  for(int i = 0; i < 4; i++){
    cnt[(char)str[i] - 'A']++;
  }
  
  for(int i = 0; i < 27; i++){
    if(cnt[i] != 0 && cnt[i] != 2){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d %d %d %d %d", $N, $x_num, $x_money, $y_num, $y_money);

$x_total = 0;
$y_total = 0;
if ($N % $x_num != 0) {
    $x_total = ceil($N/$x_num) * $x_money;
} else {
    $x_total = $N/$x_num * $x_money;
}
if ($N % $x_num != 0) {
    $y_total = ceil($N/$y_num) * $y_money;
} else {
    $y_total = $N/$y_num * $y_money;
}

echo min($x_total, $y_total), "\n";


Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
template<typename T>
inline void read(T &x)
{
	x=0;
	int f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') f=-1;
		ch=getchar();
}
	while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
	x*=f;
	return;
}	
template<typename T>
void write(T x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
	return;
}
int n,m;
int a[10];
int main()
{
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        int x,y;
        cin>>x>>y;
        if(a[x]&&a[x]!=y)
        {
            cout<<-1<<endl;
            return 0;
        }
        if(x==1&&y==0&&n!=1)
        {
            cout<<-1<<endl;
            return 0;
        }
        a[x]=y;
    }
    if(a[1]==0&&n!=1) a[1]=1;
    for(int i=1;i<=n;i++) cout<<a[i];cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int n, m;
    cin >> n;
    map < string, int > mp;
    string s;
    vector < string > v1;
    vector < string > v2;
    for(int i = 0; i < n; i++) {
        cin >> s;
        v1.push_back(s);
        mp[s]++;
    }
    cin >> m;
    for(int i = 0; i < m; i++) {
        cin >> s;
        v2.push_back(s);
        mp[s]--;
    }
    int mx = -100000;
    for(int i = 0; i < n; i++) {
        if(mp[v1[i]] > mx) {
            mx = mp[v1[i]];
        }
    }
    for(int i = 0; i < m; i++) {
        if(mp[v2[i]] > mx) {
            mx = mp[v2[i]];
        }
    }
    if(mx < 0) cout << "0" << endl;
    else cout << mx << endl;
}

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

int main(){
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    long double d,t,s;
    cin>>d>>t>>s;
    long double ans= d/s;
    
    
    if(ans <= t){
        cout<<"Yes";
    }
        else{
            cout<<"No";
        }
    
    return 0;
}


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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'
#define INF (1ll<<60)

int n, k;
VI h(100010);

signed main()
{
    cin >> n >> k;
    REP(i, n){
        cin >> h[i];
    }

    VI dp(n, INF);

    dp[0] = 0;
    FOR(i, 1, n){
        FOR(j, 1, min(i,k)+1){
            dp[i] = min(dp[i-j] + abs(h[i] - h[i-j]), dp[i]);
        }
        DEBUG(i);
        DEBUG(dp[i]);
    }

    cout << dp[n-1] << endl;

    return 0;
}

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

int main()
{
    long int a,b,c;
    cin >> a>>b>>c;
    
    
    for (long int i=1;i<b+2;i++){
        if ((a*i)%b == c){
            cout << "YES"; break;}
        if (i == b+1)
            cout << "NO";}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>                                                                               
using namespace std;
#define FOR(v1, v2) for (v1 = 0; v1 < v2; ++v1)
#define FORO(v1, v2) for (v1 = 1; v1 < v2; ++v1)
const int MAX_N = 200000;
int P[MAX_N];

int main () {
  int N;
  int i;
  cin >> N;
  FOR(i, N) {
    cin >> P[i];
  }

  int ans = 1;
  int m = P[0];
  FORO(i, N) {
    if (m >= P[i]) {
      ++ans; 
      cerr << i << "...";
    }   

    if(P[i] < m) {
      m = P[i];
    }   
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
	int h, w, H, W;

	while (1) {
		scanf("%d %d", &H, &W);
		for (h = 1; h <= H; h++)
		{
			if (h % 2 != 0) {
				for (w = 1; w <= (W); w++) {
					if (w % 2 != 0) {
						printf("#");
					}
					else
					{
						printf(".");
					}
				}
			}
			else {
				for (w = 1; w <= (W); w++) {
					if (w % 2 != 0) {
						printf(".");
					}
					else
					{
						printf("#");
					}
				}
			}
			printf("\n");
		}
		if (H == 0 && W == 0) break;
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2108
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author dyominov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ARotation solver = new ARotation();
        solver.solve(1, in, out);
        out.close();
    }

    static class ARotation {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            String t = in.next();
            StringBuilder sb = new StringBuilder(t);
            out.print(s.equals(sb.reverse().toString()) ? "YES" : "NO");
        }

    }

    static class InputReader implements AutoCloseable {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public void close() {
        }

    }
}



Measured memory_bytes: 23380
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int a, b, c; cin>>a>>b>>c;
    cout << max(0, c - (a - b)) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
signed main() {
	int m, n, mod = 1000000007;
	cin >> m >> n;
	int k = 1;
	while (n) {
		if (n % 2 == 1) {
			k *= m;
			n--;
		}
		m *= m; n /= 2;
		k %= mod; m %= mod;
	}
	cout << k << endl;
}


Measured memory_bytes: 3120
#include <iostream>

using namespace std;

int N, Min, sign, num;
long long ans;

int main(){
    while( cin >> N ){
        Min = 100000001;
        ans = sign = 0;
        while( N-- ){
            cin >> num;
            if( num < 0 ){
                num *= -1;
                ++sign;
            }
            if( num < Min )
                Min = num;
            ans += num;
        }
        if( sign % 2 ) ans -= Min*2;
        cout << ans << endl;
    }
    return 0;
}
/*
3
-10 5 -4
5
10 -4 -8 -11 3
11
-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000

*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int n;
    cin >> n;
    bool ok = false;
    int cnt = 0;
    ll ans = 0;
    rep(i,n){
        int a;cin >> a;
        if(a==i+1 && ok){
            cnt++;
        }else if(a!=i+1 && ok){
            ans += (cnt + 1)/2;
            cnt = 0;
            ok = false;
        }else if(a==i+1 && !ok){
            cnt++;
            ok = true;
        }
    }
    if(ok){
        ans += (cnt + 1)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int n,k,a[N],dx[N],dy[N];
const LL mod=1e9+7;
LL px[N],py[N];
long double lg[N],gl[N];
int main() {
  ios::sync_with_stdio(false);
  cin>>n>>k;int x=0,y=0,z=0;
  for(int i=1;i<=n;i++)cin>>a[i];
  for(int i=1;i<=n;i++){
    if(a[i]>0){
      dx[++y]=a[i];
    }else if(a[i]<0){
      dy[++z]=a[i];
    }else{
      x++;
    }
  }
  if(z+y<k)cout<<0<<'\n';
  else{
    sort(dx+1,dx+1+y,[](int x,int y){return x>y;});//++
    sort(dy+1,dy+1+z);//--
    int st=0;
    for(int i=0;i<=min(z,k);i+=2){
      if(k-i<=y)st=1;
    }
    if(!st){//必是负数
      if(x)return cout<<0,0;
      sort(dx+1,dx+1+y);
      sort(dy+1,dy+1+z,greater<int>());
      int dl=1,dr=1;
      LL temp=1;
      while(k){
        if(dl<=y && dr<=z){
          if(dx[dl]<abs(dy[dr])){
            temp*=dx[dl];
            temp%=mod;
            dl++;
          }else{
            temp*=dy[dr];
            temp%=mod;
            dr++;
          }
        }else if(dl<=y){
          temp*=dx[dl];
          temp%=mod;
          dl++;
        }else{
          temp*=dy[dr];
          temp%=mod;
          dr++;
        }
        k--;
      }
      cout<<(temp+mod)%mod;
    }else{
      sort(dx+1,dx+1+y,greater<int>());
      sort(dy+1,dy+1+z);
      LL temp=1;
      int l=1,r=1;
      if(k&1)temp*=dx[l++],temp%=mod,k--;
      while(k){
        if(y-l>=1 && z-r>=1){
          if(1ll*dx[l]*dx[l+1]>=1ll*dy[r]*dy[r+1]){
            temp*=dx[l];
            temp%=mod;
            temp*=dx[l+1];
            temp%=mod;
            l+=2;
            k-=2;
          }else{
            temp*=dy[r];
            temp%=mod;
            temp*=dy[r+1];
            temp%=mod;
            r+=2;
            k-=2;
          }
        }else if(y-l>=1){
          temp*=dx[l];
          temp%=mod;
          temp*=dx[l+1];
          temp%=mod;
          l+=2;
          k-=2;
        }else if(z-r>=1){
          temp*=dy[r];
          temp%=mod;
          temp*=dy[r+1];
          temp%=mod;
          r+=2;
          k-=2;
        }
      }
      cout<<(temp+mod)%mod<<'\n';
    }
  }
  return 0;
}

Measured memory_bytes: 5200
#include <stdio.h>
int main(void)
{
	int h,m,s;
	int S;
	scanf("%d",&S);
	h=S/3600;
	m=S%3600/60;
	s=S%60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}


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

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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b+c > 21) cout << "bust" << endl;
    else cout << "win" << endl;
}

Measured memory_bytes: 256
//#pragma GCC optimize(2)
//#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i, beg, end) for (int i = (beg); i < (end); i++)
#define rrep(i, beg, end) for (int i = (beg); i >= (end); i--)
#define sp(i) setprecision(i) << fixed
typedef long long ll;
typedef pair<ll, ll> P;
typedef unsigned long long ull;
const int INF = 2e9;
const int mod = 1e9 + 7;
const int N = 1000010;
ull p_hash(ull x, ull y) { return (x + y) * (x + y + 1) / 2 + y; } //NxN->N
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

bool notPirme[N + 1];
int primes[N + 1];
int cnt;
int a[N];
int num[N];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    for (int i = 2; i <= N; i++)
    {
        if (!notPirme[i])
            primes[cnt++] = i;

        for (int j = 0; primes[j] <= N / i; j++)
        {
            notPirme[primes[j] * i] = true;
            if (i % primes[j] == 0)
                break;
        }
    }

    int n;
    cin >> n;
    rep(i, 0, n)
    {
        cin >> a[i];
        num[a[i]]++;
    }
    bool pw = true;
    for (int i = 0; i < cnt; i++)
    {
        int cnt = 0;
        for (int j = primes[i]; j < N; j += primes[i])
        {
            cnt += num[j];
        }
        if (cnt > 1)
            pw = false;
    }

    if (pw)
    {
        cout << "pairwise coprime" << endl;
    }
    else
    {
        int g = 0;
        rep(i, 0, n)
            g = gcd(g, a[i]);

        if (g == 1)
            cout << "setwise coprime" << endl;
        else
            cout << "not coprime" << endl;
    }

    return 0;
}

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

int main(){
	
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if ( b <= a && c <= b && a - b <= d && b - c <= d ){
		cout << " Yes " << endl;
	} else if ( a <= b && b <= c && b - a <= d && c - b <= d ){
		cout << " Yes " << endl;
	} else if ( a <= b && c <= b && b - a <= d && b - c <= d ){
		cout << " Yes " << endl;
	} else if ( b <= a && b <= c && a - b <= d && c - b <= d ){
		cout << " Yes " << endl;
	} else if ( a <= c && c - a <= d ){
		cout << " Yes " << endl;
	} else if ( c <= a && a - c <= d ){
		cout << " Yes " << endl;
	} else {
		cout << " No " << endl;
	}
		
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Integer[] array = new Integer[m];
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int[] ary = new int[2];
        ary[0] = 1;
        ary[1] = n;
        for (int i = 0; i < m; i++) {
            int l = Integer.parseInt(sc.next());
            int r = Integer.parseInt(sc.next());
            if (ary[1] < l || ary[0] > r) {
                System.out.println(0);
                return;
            }
            if (ary[0] < l) {
                ary[0] = l;
            }
            if (ary[1] > r) {
                ary[1] = r;
            }
        }
        System.out.println(ary[1] - ary[0] + 1);
	}
}

Measured memory_bytes: 49108
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int T_tairyoku = sc.nextInt();
		int T_Attack = sc.nextInt();
		int A_tairyoku = sc.nextInt();
		int A_Attack = sc.nextInt();
		sc.close();


		while(true) {
			//青木に攻撃
			A_tairyoku -= T_Attack;
			if(A_tairyoku <= 0) {
				System.out.println("Yes");
				break;
			}
			T_tairyoku -= A_Attack;
			if(T_tairyoku <= 0) {
				System.out.println("No");
				break;
			}
		}
	}

}


Measured memory_bytes: 27008